FFmpeg
hmac.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Martin Storsjo
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef AVUTIL_HMAC_H
22 #define AVUTIL_HMAC_H
23 
24 #include <stdint.h>
25 
26 /**
27  * @defgroup lavu_hmac HMAC
28  * @ingroup lavu_crypto
29  * @{
30  */
31 
32 enum AVHMACType {
39 };
40 
41 typedef struct AVHMAC AVHMAC;
42 
43 /**
44  * Allocate an AVHMAC context.
45  * @param type The hash function used for the HMAC.
46  */
48 
49 /**
50  * Free an AVHMAC context.
51  * @param ctx The context to free, may be NULL
52  */
53 void av_hmac_free(AVHMAC *ctx);
54 
55 /**
56  * Initialize an AVHMAC context with an authentication key.
57  * @param ctx The HMAC context
58  * @param key The authentication key
59  * @param keylen The length of the key, in bytes
60  */
61 void av_hmac_init(AVHMAC *ctx, const uint8_t *key, unsigned int keylen);
62 
63 /**
64  * Hash data with the HMAC.
65  * @param ctx The HMAC context
66  * @param data The data to hash
67  * @param len The length of the data, in bytes
68  */
69 void av_hmac_update(AVHMAC *ctx, const uint8_t *data, unsigned int len);
70 
71 /**
72  * Finish hashing and output the HMAC digest.
73  * @param ctx The HMAC context
74  * @param out The output buffer to write the digest into
75  * @param outlen The length of the out buffer, in bytes
76  * @return The number of bytes written to out, or a negative error code.
77  */
78 int av_hmac_final(AVHMAC *ctx, uint8_t *out, unsigned int outlen);
79 
80 /**
81  * Hash an array of data with a key.
82  * @param ctx The HMAC context
83  * @param data The data to hash
84  * @param len The length of the data, in bytes
85  * @param key The authentication key
86  * @param keylen The length of the key, in bytes
87  * @param out The output buffer to write the digest into
88  * @param outlen The length of the out buffer, in bytes
89  * @return The number of bytes written to out, or a negative error code.
90  */
91 int av_hmac_calc(AVHMAC *ctx, const uint8_t *data, unsigned int len,
92  const uint8_t *key, unsigned int keylen,
93  uint8_t *out, unsigned int outlen);
94 
95 /**
96  * @}
97  */
98 
99 #endif /* AVUTIL_HMAC_H */
AVHMAC
Definition: hmac.c:40
out
FILE * out
Definition: movenc.c:54
AV_HMAC_MD5
@ AV_HMAC_MD5
Definition: hmac.h:33
data
const char data[16]
Definition: mxf.c:148
av_hmac_calc
int av_hmac_calc(AVHMAC *ctx, const uint8_t *data, unsigned int len, const uint8_t *key, unsigned int keylen, uint8_t *out, unsigned int outlen)
Hash an array of data with a key.
Definition: hmac.c:185
av_hmac_final
int av_hmac_final(AVHMAC *ctx, uint8_t *out, unsigned int outlen)
Finish hashing and output the HMAC digest.
Definition: hmac.c:167
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
ctx
AVFormatContext * ctx
Definition: movenc.c:48
key
const char * key
Definition: hwcontext_opencl.c:174
AV_HMAC_SHA256
@ AV_HMAC_SHA256
Definition: hmac.h:36
av_hmac_update
void av_hmac_update(AVHMAC *ctx, const uint8_t *data, unsigned int len)
Hash data with the HMAC.
Definition: hmac.c:162
AVHMAC::keylen
int keylen
Definition: hmac.c:47
AV_HMAC_SHA1
@ AV_HMAC_SHA1
Definition: hmac.h:34
AV_HMAC_SHA384
@ AV_HMAC_SHA384
Definition: hmac.h:37
AV_HMAC_SHA512
@ AV_HMAC_SHA512
Definition: hmac.h:38
av_hmac_alloc
AVHMAC * av_hmac_alloc(enum AVHMACType type)
Allocate an AVHMAC context.
Definition: hmac.c:68
av_hmac_free
void av_hmac_free(AVHMAC *ctx)
Free an AVHMAC context.
Definition: hmac.c:133
av_hmac_init
void av_hmac_init(AVHMAC *ctx, const uint8_t *key, unsigned int keylen)
Initialize an AVHMAC context with an authentication key.
Definition: hmac.c:141
len
int len
Definition: vorbis_enc_data.h:426
AVHMACType
AVHMACType
Definition: hmac.h:32
AV_HMAC_SHA224
@ AV_HMAC_SHA224
Definition: hmac.h:35