33 #define MAX_HASHLEN 64
34 #define MAX_BLOCKLEN 128
37 #if FF_API_CRYPTO_SIZE_T
54 #define DEFINE_SHA(bits) \
55 static av_cold void sha ## bits ##_init(void *ctx) \
57 av_sha_init(ctx, bits); \
60 #define DEFINE_SHA512(bits) \
61 static av_cold void sha ## bits ##_init(void *ctx) \
63 av_sha512_init(ctx, bits); \
89 c->init = sha160_init;
97 c->init = sha224_init;
105 c->init = sha256_init;
113 c->init = sha384_init;
121 c->init = sha512_init;
149 if (keylen >
c->blocklen) {
151 c->update(
c->hash,
key, keylen);
152 c->final(
c->hash,
c->key);
153 c->keylen =
c->hashlen;
155 memcpy(
c->key,
key, keylen);
159 for (
i = 0;
i <
c->keylen;
i++)
161 for (
i =
c->keylen; i < c->blocklen;
i++)
163 c->update(
c->hash,
block,
c->blocklen);
175 if (outlen < c->hashlen)
177 c->final(
c->hash,
out);
179 for (
i = 0;
i <
c->keylen;
i++)
181 for (
i =
c->keylen; i < c->blocklen;
i++)
183 c->update(
c->hash,
block,
c->blocklen);
184 c->update(
c->hash,
out,
c->hashlen);
185 c->final(
c->hash,
out);
Macro definitions for various function/variable attributes.
int av_hmac_final(AVHMAC *c, uint8_t *out, unsigned int outlen)
Finish hashing and output the HMAC digest.
int av_hmac_calc(AVHMAC *c, 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.
void av_hmac_update(AVHMAC *c, const uint8_t *data, unsigned int len)
Hash data with the HMAC.
void av_hmac_free(AVHMAC *c)
Free an AVHMAC context.
AVHMAC * av_hmac_alloc(enum AVHMACType type)
Allocate an AVHMAC context.
void av_hmac_init(AVHMAC *c, const uint8_t *key, unsigned int keylen)
Initialize an AVHMAC context with an authentication key.
void av_md5_init(AVMD5 *ctx)
Initialize MD5 hashing.
struct AVMD5 * av_md5_alloc(void)
Allocate an AVMD5 context.
void av_md5_final(AVMD5 *ctx, uint8_t *dst)
Finish hashing and output digest value.
void av_md5_update(AVMD5 *ctx, const uint8_t *src, int len)
Update hash value.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
void av_sha512_update(AVSHA512 *ctx, const uint8_t *data, unsigned int len)
Update hash value.
struct AVSHA512 * av_sha512_alloc(void)
Allocate an AVSHA512 context.
void av_sha512_final(AVSHA512 *ctx, uint8_t *digest)
Finish hashing and output digest value.
struct AVSHA * av_sha_alloc(void)
Allocate an AVSHA context.
void av_sha_update(struct AVSHA *ctx, const uint8_t *data, unsigned int len)
Update hash value.
void av_sha_final(AVSHA *ctx, uint8_t *digest)
Finish hashing and output digest value.
void(* hmac_update)(void *ctx, const uint8_t *src, int len)
void(* hmac_init)(void *ctx)
void(* hmac_final)(void *ctx, uint8_t *dst)
#define DEFINE_SHA512(bits)
Public header for MD5 hash function implementation.
Memory handling functions.
typedef void(RENAME(mix_any_func_type))
Public header for SHA-512 implementation.
Public header for SHA-1 & SHA-256 hash function implementations.
uint8_t key[MAX_BLOCKLEN]