Lines Matching defs:hash
1 /* $OpenBSD: hash.c,v 1.25 2024/11/21 10:07:30 yasuoka Exp $ */
2 /* $EOM: hash.c,v 1.10 1999/04/17 23:20:34 niklas Exp $ */
39 #include "hash.h"
42 void hmac_init(struct hash *, unsigned char *, unsigned int);
43 void hmac_final(unsigned char *, struct hash *);
45 /* Temporary hash contexts. */
52 /* Temporary hash digest. */
55 /* Encapsulation of hash functions. */
57 static struct hash hashes[] = {
101 struct hash *
117 * Initial a hash for HMAC usage this requires a special init function.
118 * ctx, ctx2 hold the contexts, if you want to use the hash object for
123 hmac_init(struct hash *hash, unsigned char *okey, unsigned int len)
129 if (len > hash->blocklen) {
131 hash->Init(hash->ctx);
132 hash->Update(hash->ctx, okey, len);
133 hash->Final(key, hash->ctx);
139 for (i = 0; i < hash->blocklen; i++)
142 hash->Init(hash->ctx);
143 hash->Update(hash->ctx, key, hash->blocklen);
145 for (i = 0; i < hash->blocklen; i++)
148 hash->Init(hash->ctx2);
149 hash->Update(hash->ctx2, key, hash->blocklen);
159 hmac_final(unsigned char *dgst, struct hash *hash)
161 hash->Final(dgst, hash->ctx);
162 hash->Update(hash->ctx2, dgst, hash->hashsize);
163 hash->Final(dgst, hash->ctx2);