Path: blob/master/dep/ffmpeg/include/libavutil/hmac.h
4216 views
/*1* Copyright (C) 2012 Martin Storsjo2*3* This file is part of FFmpeg.4*5* FFmpeg is free software; you can redistribute it and/or6* modify it under the terms of the GNU Lesser General Public7* License as published by the Free Software Foundation; either8* version 2.1 of the License, or (at your option) any later version.9*10* FFmpeg is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU13* Lesser General Public License for more details.14*15* You should have received a copy of the GNU Lesser General Public16* License along with FFmpeg; if not, write to the Free Software17* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA18*/1920#ifndef AVUTIL_HMAC_H21#define AVUTIL_HMAC_H2223#include <stdint.h>2425/**26* @defgroup lavu_hmac HMAC27* @ingroup lavu_crypto28* @{29*/3031enum AVHMACType {32AV_HMAC_MD5,33AV_HMAC_SHA1,34AV_HMAC_SHA224,35AV_HMAC_SHA256,36AV_HMAC_SHA384,37AV_HMAC_SHA512,38};3940typedef struct AVHMAC AVHMAC;4142/**43* Allocate an AVHMAC context.44* @param type The hash function used for the HMAC.45*/46AVHMAC *av_hmac_alloc(enum AVHMACType type);4748/**49* Free an AVHMAC context.50* @param ctx The context to free, may be NULL51*/52void av_hmac_free(AVHMAC *ctx);5354/**55* Initialize an AVHMAC context with an authentication key.56* @param ctx The HMAC context57* @param key The authentication key58* @param keylen The length of the key, in bytes59*/60void av_hmac_init(AVHMAC *ctx, const uint8_t *key, unsigned int keylen);6162/**63* Hash data with the HMAC.64* @param ctx The HMAC context65* @param data The data to hash66* @param len The length of the data, in bytes67*/68void av_hmac_update(AVHMAC *ctx, const uint8_t *data, unsigned int len);6970/**71* Finish hashing and output the HMAC digest.72* @param ctx The HMAC context73* @param out The output buffer to write the digest into74* @param outlen The length of the out buffer, in bytes75* @return The number of bytes written to out, or a negative error code.76*/77int av_hmac_final(AVHMAC *ctx, uint8_t *out, unsigned int outlen);7879/**80* Hash an array of data with a key.81* @param ctx The HMAC context82* @param data The data to hash83* @param len The length of the data, in bytes84* @param key The authentication key85* @param keylen The length of the key, in bytes86* @param out The output buffer to write the digest into87* @param outlen The length of the out buffer, in bytes88* @return The number of bytes written to out, or a negative error code.89*/90int av_hmac_calc(AVHMAC *ctx, const uint8_t *data, unsigned int len,91const uint8_t *key, unsigned int keylen,92uint8_t *out, unsigned int outlen);9394/**95* @}96*/9798#endif /* AVUTIL_HMAC_H */99100101