mirror of
https://github.com/open-quantum-safe/liboqs.git
synced 2025-12-08 00:02:59 -05:00
Added invalid ciphertext test in test_kem, and replaced invalid signature with random array vs modified first byte (code from PR787).
This commit is contained in:
parent
e5f33fea7a
commit
0cba778097
@ -113,6 +113,14 @@ static OQS_STATUS kem_test_correctness(const char *method_name) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
// test invalid encapsulation (call should either fail or result in invalid shared secret)
|
||||
OQS_randombytes(ciphertext, kem->length_ciphertext);
|
||||
rc = OQS_KEM_decaps(kem, shared_secret_d, ciphertext, secret_key);
|
||||
if (rc == OQS_SUCCESS && memcmp(shared_secret_e, shared_secret_d, kem->length_shared_secret) == 0) {
|
||||
fprintf(stderr, "ERROR: OQS_KEM_decaps succeeded on wrong input\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = OQS_SUCCESS;
|
||||
goto cleanup;
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ static OQS_STATUS sig_test_correctness(const char *method_name) {
|
||||
}
|
||||
|
||||
/* modify the signature to invalidate it */
|
||||
signature[0]++;
|
||||
OQS_randombytes(signature, signature_len);
|
||||
rc = OQS_SIG_verify(sig, message, message_len, signature, signature_len, public_key);
|
||||
if (rc != OQS_ERROR) {
|
||||
fprintf(stderr, "ERROR: OQS_SIG_verify should have failed!\n");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user