FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 #include "version.h"
27 /**
28  * @defgroup lavu_hmac HMAC
29  * @ingroup lavu_crypto
30  * @{
31  */
32 
33 enum AVHMACType {
40 };
41 
42 typedef struct AVHMAC AVHMAC;
43 
44 /**
45  * Allocate an AVHMAC context.
46  * @param type The hash function used for the HMAC.
47  */
49 
50 /**
51  * Free an AVHMAC context.
52  * @param ctx The context to free, may be NULL
53  */
54 void av_hmac_free(AVHMAC *ctx);
55 
56 /**
57  * Initialize an AVHMAC context with an authentication key.
58  * @param ctx The HMAC context
59  * @param key The authentication key
60  * @param keylen The length of the key, in bytes
61  */
62 void av_hmac_init(AVHMAC *ctx, const uint8_t *key, unsigned int keylen);
63 
64 /**
65  * Hash data with the HMAC.
66  * @param ctx The HMAC context
67  * @param data The data to hash
68  * @param len The length of the data, in bytes
69  */
70 void av_hmac_update(AVHMAC *ctx, const uint8_t *data, unsigned int len);
71 
72 /**
73  * Finish hashing and output the HMAC digest.
74  * @param ctx The HMAC context
75  * @param out The output buffer to write the digest into
76  * @param outlen The length of the out buffer, in bytes
77  * @return The number of bytes written to out, or a negative error code.
78  */
79 int av_hmac_final(AVHMAC *ctx, uint8_t *out, unsigned int outlen);
80 
81 /**
82  * Hash an array of data with a key.
83  * @param ctx The HMAC context
84  * @param data The data to hash
85  * @param len The length of the data, in bytes
86  * @param key The authentication key
87  * @param keylen The length of the key, in bytes
88  * @param out The output buffer to write the digest into
89  * @param outlen The length of the out buffer, in bytes
90  * @return The number of bytes written to out, or a negative error code.
91  */
92 int av_hmac_calc(AVHMAC *ctx, const uint8_t *data, unsigned int len,
93  const uint8_t *key, unsigned int keylen,
94  uint8_t *out, unsigned int outlen);
95 
96 /**
97  * @}
98  */
99 
100 #endif /* AVUTIL_HMAC_H */
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:178
ptrdiff_t const GLvoid * data
Definition: opengl_enc.c:101
AVHMAC * av_hmac_alloc(enum AVHMACType type)
Allocate an AVHMAC context.
Definition: hmac.c:61
AVHMACType
Definition: hmac.h:33
uint8_t
void av_hmac_update(AVHMAC *ctx, const uint8_t *data, unsigned int len)
Hash data with the HMAC.
Definition: hmac.c:155
Libavutil version macros.
Definition: hmac.c:33
void av_hmac_init(AVHMAC *ctx, const uint8_t *key, unsigned int keylen)
Initialize an AVHMAC context with an authentication key.
Definition: hmac.c:134
AVFormatContext * ctx
Definition: movenc.c:48
uint8_t key[MAX_BLOCKLEN]
Definition: hmac.c:39
GLint GLenum type
Definition: opengl_enc.c:105
int av_hmac_final(AVHMAC *ctx, uint8_t *out, unsigned int outlen)
Finish hashing and output the HMAC digest.
Definition: hmac.c:160
int keylen
Definition: hmac.c:40
void av_hmac_free(AVHMAC *ctx)
Free an AVHMAC context.
Definition: hmac.c:126
int len
FILE * out
Definition: movenc.c:54