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

Function hmac_init_pad

freebsd/opencrypto/crypto.c:412–441  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

410}
411
412static void
413hmac_init_pad(const struct auth_hash *axf, const char *key, int klen,
414 void *auth_ctx, uint8_t padval)
415{
416 uint8_t hmac_key[HMAC_MAX_BLOCK_LEN];
417 u_int i;
418
419 KASSERT(axf->blocksize <= sizeof(hmac_key),
420 ("Invalid HMAC block size %d", axf->blocksize));
421
422 /*
423 * If the key is larger than the block size, use the digest of
424 * the key as the key instead.
425 */
426 memset(hmac_key, 0, sizeof(hmac_key));
427 if (klen > axf->blocksize) {
428 axf->Init(auth_ctx);
429 axf->Update(auth_ctx, key, klen);
430 axf->Final(hmac_key, auth_ctx);
431 klen = axf->hashsize;
432 } else
433 memcpy(hmac_key, key, klen);
434
435 for (i = 0; i < axf->blocksize; i++)
436 hmac_key[i] ^= padval;
437
438 axf->Init(auth_ctx);
439 axf->Update(auth_ctx, hmac_key, axf->blocksize);
440 explicit_bzero(hmac_key, sizeof(hmac_key));
441}
442
443void
444hmac_init_ipad(const struct auth_hash *axf, const char *key, int klen,

Callers 2

hmac_init_ipadFunction · 0.85
hmac_init_opadFunction · 0.85

Calls 4

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

Tested by

no test coverage detected