static void
hexdump(char *str, uint8_t *src, uint_t len)
{
- int i;
-
printf("\t%s\t", str);
- for (i = 0; i < len; i++) {
- printf("%02x", src[i] & 0xff);
- }
+ for (int i = 0; i < len; i++)
+ printf("%02hhx", src[i]);
printf("\n");
}
run_test(int i, hkdf_tv_t *tv)
{
int ret;
- uint8_t okey[SHA512_DIGEST_LENGTH];
+ uint8_t good[SHA512_DIGEST_LENGTH];
printf("TEST %d:\t", i);
ret = hkdf_sha512((uint8_t *)tv->ikm, tv->ikm_len, (uint8_t *)tv->salt,
- tv->salt_len, (uint8_t *)tv->info, tv->info_len, okey, tv->okm_len);
+ tv->salt_len, (uint8_t *)tv->info, tv->info_len, good, tv->okm_len);
if (ret != 0) {
printf("HKDF failed with error code %d\n", ret);
return (ret);
}
- if (bcmp(okey, tv->okm, tv->okm_len) != 0) {
+ if (memcmp(good, tv->okm, tv->okm_len) != 0) {
printf("Output Mismatch\n");
hexdump("Expected:", (uint8_t *)tv->okm, tv->okm_len);
- hexdump("Actual: ", okey, tv->okm_len);
+ hexdump("Actual: ", good, tv->okm_len);
return (1);
}