Skip to content

Commit

Permalink
Add KBKDF counter HMAC KAT to self-test. (#1882)
Browse files Browse the repository at this point in the history
  • Loading branch information
nebeid authored Sep 26, 2024
1 parent ed6d6ca commit c2846eb
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions crypto/fipsmodule/self_check/self_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -2005,6 +2005,35 @@ static int boringssl_self_test_fast(void) {
goto err;
}

// KBKDF counter HMAC-SHA-256
const uint8_t kKBKDF_ctr_hmac_secret[] = {
0xdd, 0x1d, 0x91, 0xb7, 0xd9, 0x0b, 0x2b, 0xd3, 0x13, 0x85, 0x33, 0xce,
0x92, 0xb2, 0x72, 0xfb, 0xf8, 0xa3, 0x69, 0x31, 0x6a, 0xef, 0xe2, 0x42,
0xe6, 0x59, 0xcc, 0x0a, 0xe2, 0x38, 0xaf, 0xe0
};
const uint8_t kKBKDF_ctr_hmac_info[] = {
0x01, 0x32, 0x2b, 0x96, 0xb3, 0x0a, 0xcd, 0x19, 0x79, 0x79, 0x44, 0x4e,
0x46, 0x8e, 0x1c, 0x5c, 0x68, 0x59, 0xbf, 0x1b, 0x1c, 0xf9, 0x51, 0xb7,
0xe7, 0x25, 0x30, 0x3e, 0x23, 0x7e, 0x46, 0xb8, 0x64, 0xa1, 0x45, 0xfa,
0xb2, 0x5e, 0x51, 0x7b, 0x08, 0xf8, 0x68, 0x3d, 0x03, 0x15, 0xbb, 0x29,
0x11, 0xd8, 0x0a, 0x0e, 0x8a, 0xba, 0x17, 0xf3, 0xb4, 0x13, 0xfa, 0xac
};
const uint8_t kKBKDF_ctr_hmac_output[] = {
0x10, 0x62, 0x13, 0x42, 0xbf, 0xb0, 0xfd, 0x40, 0x04, 0x6c, 0x0e, 0x29,
0xf2, 0xcf, 0xdb, 0xf0
};

uint8_t kbkdf_ctr_hmac_output[sizeof(kKBKDF_ctr_hmac_output)];
if (!KBKDF_ctr_hmac(kbkdf_ctr_hmac_output, sizeof(kbkdf_ctr_hmac_output),
EVP_sha256(),
kKBKDF_ctr_hmac_secret, sizeof(kKBKDF_ctr_hmac_secret),
kKBKDF_ctr_hmac_info, sizeof(kKBKDF_ctr_hmac_info)) ||
!check_test(kKBKDF_ctr_hmac_output, kbkdf_ctr_hmac_output,
sizeof(kbkdf_ctr_hmac_output),
"KBKDF-CTR-HMAC-SHA-256 KAT")) {
fprintf(stderr, "KBKDF counter HMAC-SHA-256 failed.\n");
goto err;
}
ret = 1;

err:
Expand Down

0 comments on commit c2846eb

Please sign in to comment.