Skip to content

Commit

Permalink
harden checks in kem
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav-thales committed Oct 9, 2024
1 parent a7b589c commit b370829
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions tests/test_kem.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ static OQS_STATUS kem_test_correctness(const char *method_name) {
OQS_MEM_insecure_free(ciphertext - sizeof(magic_t));
}
OQS_KEM_free(kem);

return ret;
}

Expand Down
8 changes: 4 additions & 4 deletions tests/vectors_kem.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static void MLKEM_randombytes_free(void) {
}

static OQS_STATUS kem_kg_vector(const char *method_name,
uint8_t *prng_output_stream,
const uint8_t *prng_output_stream,
const uint8_t *kg_pk, const uint8_t *kg_sk) {

uint8_t *entropy_input;
Expand Down Expand Up @@ -162,7 +162,7 @@ static OQS_STATUS kem_kg_vector(const char *method_name,
}

static OQS_STATUS kem_vector_encdec_aft(const char *method_name,
uint8_t *prng_output_stream,
const uint8_t *prng_output_stream,
const uint8_t *encdec_pk,
const uint8_t *encdec_k, const uint8_t *encdec_c) {

Expand Down Expand Up @@ -362,7 +362,7 @@ int main(int argc, char **argv) {
kg_pk = argv[4];
kg_sk = argv[5];

if (strlen(prng_output_stream) % 2 != 0 ||
if (strlen(prng_output_stream) != 128 ||
strlen(kg_pk) != 2 * kem->length_public_key ||
strlen(kg_sk) != 2 * kem->length_secret_key) {
rc = OQS_ERROR;
Expand Down Expand Up @@ -391,7 +391,7 @@ int main(int argc, char **argv) {
encdec_aft_k = argv[5];
encdec_aft_c = argv[6];

if (strlen(prng_output_stream) % 2 != 0 ||
if (strlen(prng_output_stream) != 64 ||
strlen(encdec_aft_c) != 2 * kem->length_ciphertext ||
strlen(encdec_aft_k) != 2 * kem->length_shared_secret ||
strlen(encdec_aft_pk) != 2 * kem->length_public_key) {
Expand Down

0 comments on commit b370829

Please sign in to comment.