Skip to content

Commit

Permalink
Update test_kem exception logic
Browse files Browse the repository at this point in the history
  • Loading branch information
vsoftco committed Jan 15, 2025
1 parent eb55cbc commit d3abde1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions unit_tests/tests/test_kem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ void test_kem_wrong_ciphertext(const std::string& kem_name) {
oqs::bytes shared_secret_client;
try {
shared_secret_client = client.decap_secret(wrong_ciphertext);
bool is_valid = (shared_secret_client == shared_secret_server);
if (is_valid)
std::cerr << kem_name << ": shared secrets should not coincide"
<< std::endl;
EXPECT_FALSE(is_valid);
} catch (std::exception& e) {
if (e.what() == std::string{"Can not decapsulate secret"})
return;
else
throw; // this is another un-expected exception
}
bool is_valid = (shared_secret_client == shared_secret_server);
if (is_valid)
std::cerr << kem_name << ": shared secrets should not coincide"
<< std::endl;
EXPECT_FALSE(is_valid);
}

TEST(oqs_KeyEncapsulation, Correctness) {
Expand Down

0 comments on commit d3abde1

Please sign in to comment.