annotate ffmpeg/libavutil/hmac.h @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents f445c3017523
children
rev   line source
yading@11 1 /*
yading@11 2 * Copyright (C) 2012 Martin Storsjo
yading@11 3 *
yading@11 4 * This file is part of FFmpeg.
yading@11 5 *
yading@11 6 * FFmpeg is free software; you can redistribute it and/or
yading@11 7 * modify it under the terms of the GNU Lesser General Public
yading@11 8 * License as published by the Free Software Foundation; either
yading@11 9 * version 2.1 of the License, or (at your option) any later version.
yading@11 10 *
yading@11 11 * FFmpeg is distributed in the hope that it will be useful,
yading@11 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@11 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@11 14 * Lesser General Public License for more details.
yading@11 15 *
yading@11 16 * You should have received a copy of the GNU Lesser General Public
yading@11 17 * License along with FFmpeg; if not, write to the Free Software
yading@11 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@11 19 */
yading@11 20
yading@11 21 #ifndef AVUTIL_HMAC_H
yading@11 22 #define AVUTIL_HMAC_H
yading@11 23
yading@11 24 #include <stdint.h>
yading@11 25
yading@11 26 /**
yading@11 27 * @defgroup lavu_hmac HMAC
yading@11 28 * @ingroup lavu_crypto
yading@11 29 * @{
yading@11 30 */
yading@11 31
yading@11 32 enum AVHMACType {
yading@11 33 AV_HMAC_MD5,
yading@11 34 AV_HMAC_SHA1,
yading@11 35 };
yading@11 36
yading@11 37 typedef struct AVHMAC AVHMAC;
yading@11 38
yading@11 39 /**
yading@11 40 * Allocate an AVHMAC context.
yading@11 41 * @param type The hash function used for the HMAC.
yading@11 42 */
yading@11 43 AVHMAC *av_hmac_alloc(enum AVHMACType type);
yading@11 44
yading@11 45 /**
yading@11 46 * Free an AVHMAC context.
yading@11 47 * @param ctx The context to free, may be NULL
yading@11 48 */
yading@11 49 void av_hmac_free(AVHMAC *ctx);
yading@11 50
yading@11 51 /**
yading@11 52 * Initialize an AVHMAC context with an authentication key.
yading@11 53 * @param ctx The HMAC context
yading@11 54 * @param key The authentication key
yading@11 55 * @param keylen The length of the key, in bytes
yading@11 56 */
yading@11 57 void av_hmac_init(AVHMAC *ctx, const uint8_t *key, unsigned int keylen);
yading@11 58
yading@11 59 /**
yading@11 60 * Hash data with the HMAC.
yading@11 61 * @param ctx The HMAC context
yading@11 62 * @param data The data to hash
yading@11 63 * @param len The length of the data, in bytes
yading@11 64 */
yading@11 65 void av_hmac_update(AVHMAC *ctx, const uint8_t *data, unsigned int len);
yading@11 66
yading@11 67 /**
yading@11 68 * Finish hashing and output the HMAC digest.
yading@11 69 * @param ctx The HMAC context
yading@11 70 * @param out The output buffer to write the digest into
yading@11 71 * @param outlen The length of the out buffer, in bytes
yading@11 72 * @return The number of bytes written to out, or a negative error code.
yading@11 73 */
yading@11 74 int av_hmac_final(AVHMAC *ctx, uint8_t *out, unsigned int outlen);
yading@11 75
yading@11 76 /**
yading@11 77 * Hash an array of data with a key.
yading@11 78 * @param ctx The HMAC context
yading@11 79 * @param data The data to hash
yading@11 80 * @param len The length of the data, in bytes
yading@11 81 * @param key The authentication key
yading@11 82 * @param keylen The length of the key, in bytes
yading@11 83 * @param out The output buffer to write the digest into
yading@11 84 * @param outlen The length of the out buffer, in bytes
yading@11 85 * @return The number of bytes written to out, or a negative error code.
yading@11 86 */
yading@11 87 int av_hmac_calc(AVHMAC *ctx, const uint8_t *data, unsigned int len,
yading@11 88 const uint8_t *key, unsigned int keylen,
yading@11 89 uint8_t *out, unsigned int outlen);
yading@11 90
yading@11 91 /**
yading@11 92 * @}
yading@11 93 */
yading@11 94
yading@11 95 #endif /* AVUTIL_HMAC_H */