Skip to content

Commit

Permalink
remove OQS_MEM_free
Browse files Browse the repository at this point in the history
Signed-off-by: Songling Han <[email protected]>
  • Loading branch information
songlingatpan committed Sep 23, 2024
1 parent b268445 commit c4b647e
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions tests/test_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static int do_sha256(void) {

if (memcmp(output, output_inc, 32) != 0) {
fprintf(stderr, "ERROR: Incremental API does not match main API\n");
OQS_MEM_free(msg);
OQS_MEM_insecure_free(msg);
return -2;
}
// hash with second state
Expand All @@ -91,7 +91,7 @@ static int do_sha256(void) {
}
if (memcmp(output, output_inc, 32) != 0) {
fprintf(stderr, "ERROR: Incremental API with cloned state does not match main API\n");
OQS_MEM_free(msg);
OQS_MEM_insecure_free(msg);
return -3;
}

Expand All @@ -103,7 +103,7 @@ static int do_sha256(void) {
OQS_SHA2_sha256_inc_finalize(output_inc_2, &state3, &msg[i], 0);
if (memcmp(output, output_inc_2, 32) != 0) {
fprintf(stderr, "ERROR: Non-block Incremental API with cloned state does not match main API\n");
OQS_MEM_free(msg);
OQS_MEM_insecure_free(msg);
return -4;
}

Expand All @@ -112,7 +112,7 @@ static int do_sha256(void) {
OQS_SHA2_sha256_inc_finalize(output_inc, &state6, NULL, 0);
if (memcmp(output, output_inc, 32) != 0) {
fprintf(stderr, "ERROR: Incremental API with the entire msg.\n");
OQS_MEM_free(msg);
OQS_MEM_insecure_free(msg);
return -3;
}

Expand All @@ -128,7 +128,7 @@ static int do_sha256(void) {
}
if (memcmp(output, output_inc_2, 32) != 0) {
fprintf(stderr, "ERROR: Combined block increments with non-block size failed to match main API\n");
OQS_MEM_free(msg);
OQS_MEM_insecure_free(msg);
return -5;
}

Expand All @@ -142,12 +142,12 @@ static int do_sha256(void) {
}
if (memcmp(output, output_inc_2, 32) != 0) {
fprintf(stderr, "ERROR: Combined non-block size and block increments failed to match main API\n");
OQS_MEM_free(msg);
OQS_MEM_insecure_free(msg);
return -5;
}
//Test inc API
print_hex(output, 32);
OQS_MEM_free(msg);
OQS_MEM_insecure_free(msg);
return 0;
}

Expand Down Expand Up @@ -178,7 +178,7 @@ static int do_sha384(void) {
}
if (memcmp(output, output_inc, 48) != 0) {
fprintf(stderr, "ERROR: Incremental API does not match main API\n");
OQS_MEM_free(msg);
OQS_MEM_insecure_free(msg);
return -2;
}
// hash with second state
Expand All @@ -190,11 +190,11 @@ static int do_sha384(void) {
}
if (memcmp(output, output_inc, 48) != 0) {
fprintf(stderr, "ERROR: Incremental API with cloned state does not match main API\n");
OQS_MEM_free(msg);
OQS_MEM_insecure_free(msg);
return -3;
}
print_hex(output, 48);
OQS_MEM_free(msg);
OQS_MEM_insecure_free(msg);
return 0;
}

Expand Down Expand Up @@ -225,7 +225,7 @@ static int do_sha512(void) {
}
if (memcmp(output, output_inc, 64) != 0) {
fprintf(stderr, "ERROR: Incremental API does not match main API\n");
OQS_MEM_free(msg);
OQS_MEM_insecure_free(msg);
return -2;
}
// hash with second state
Expand All @@ -237,11 +237,11 @@ static int do_sha512(void) {
}
if (memcmp(output, output_inc, 64) != 0) {
fprintf(stderr, "ERROR: Incremental API with cloned state does not match main API\n");
OQS_MEM_free(msg);
OQS_MEM_insecure_free(msg);
return -3;
}
print_hex(output, 64);
OQS_MEM_free(msg);
OQS_MEM_insecure_free(msg);
return 0;
}

Expand All @@ -257,8 +257,8 @@ static int do_arbitrary_hash(void (*hash)(uint8_t *, const uint8_t *, size_t), s
uint8_t *output = OQS_MEM_malloc(hash_len);
hash(output, msg, msg_len);
print_hex(output, hash_len);
OQS_MEM_free(output);
OQS_MEM_free(msg);
OQS_MEM_insecure_free(output);
OQS_MEM_insecure_free(msg);
return 0;
}

Expand Down

0 comments on commit c4b647e

Please sign in to comment.