]> git.proxmox.com Git - mirror_zfs.git/blobdiff - tests/zfs-tests/tests/functional/hkdf/hkdf_test.c
Remove bcopy(), bzero(), bcmp()
[mirror_zfs.git] / tests / zfs-tests / tests / functional / hkdf / hkdf_test.c
index 5fff3e09ed04db402d3d9729169d440943f23253..e280af69b69ee1e28d899fa8584946c395296001 100644 (file)
@@ -174,12 +174,9 @@ static hkdf_tv_t test_vectors[] = {
 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");
 }
 
@@ -187,21 +184,21 @@ static int
 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);
        }