MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ccp_init_hmac_digest

Function ccp_init_hmac_digest

freebsd/crypto/ccp/ccp.c:230–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228}
229
230static void
231ccp_init_hmac_digest(struct ccp_session *s, const char *key, int klen)
232{
233 union authctx auth_ctx;
234 struct auth_hash *axf;
235 u_int i;
236
237 /*
238 * If the key is larger than the block size, use the digest of
239 * the key as the key instead.
240 */
241 axf = s->hmac.auth_hash;
242 if (klen > axf->blocksize) {
243 axf->Init(&auth_ctx);
244 axf->Update(&auth_ctx, key, klen);
245 axf->Final(s->hmac.ipad, &auth_ctx);
246 explicit_bzero(&auth_ctx, sizeof(auth_ctx));
247 klen = axf->hashsize;
248 } else
249 memcpy(s->hmac.ipad, key, klen);
250
251 memset(s->hmac.ipad + klen, 0, axf->blocksize - klen);
252 memcpy(s->hmac.opad, s->hmac.ipad, axf->blocksize);
253
254 for (i = 0; i < axf->blocksize; i++) {
255 s->hmac.ipad[i] ^= HMAC_IPAD_VAL;
256 s->hmac.opad[i] ^= HMAC_OPAD_VAL;
257 }
258}
259
260static bool
261ccp_aes_check_keylen(int alg, int klen)

Callers 2

ccp_newsessionFunction · 0.85
ccp_processFunction · 0.85

Calls 4

explicit_bzeroFunction · 0.85
memsetFunction · 0.85
InitMethod · 0.80
memcpyFunction · 0.50

Tested by

no test coverage detected