aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-03-19 22:52:48 -0400
committerJack Lloyd <[email protected]>2016-03-20 09:38:22 -0400
commitb8966d0f89e520cecf3e822241aef38ed9a6d876 (patch)
tree9b5c0f6afa89e8e91ef230e3d7824b10e037802c /src/tests
parentada363473a9491a3b07e3bb6fa2b5fd9f12aec98 (diff)
Clean up PK decryption encoding.
Previously RSA and ElGamal stripped off leading zeros which were then assumed by the padding decoders. Instead have them produce ciphertexts with leading zeros. Changes EME_Raw to strip leading zeros to match existing behavior.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/test_pubkey.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/tests/test_pubkey.cpp b/src/tests/test_pubkey.cpp
index 025628636..4d795ae1d 100644
--- a/src/tests/test_pubkey.cpp
+++ b/src/tests/test_pubkey.cpp
@@ -37,7 +37,7 @@ void check_invalid_signatures(Test::Result& result,
std::vector<uint8_t> bad_sig = signature;
- for(size_t i = 0; i <= Test::soak_level(); ++i)
+ for(size_t i = 0; i < Test::soak_level(); ++i)
{
while(bad_sig == signature)
bad_sig = Test::mutate_vec(bad_sig, true);
@@ -59,7 +59,7 @@ void check_invalid_ciphertexts(Test::Result& result,
size_t ciphertext_accepted = 0, ciphertext_rejected = 0;
- for(size_t i = 0; i <= Test::soak_level(); ++i)
+ for(size_t i = 0; i < Test::soak_level(); ++i)
{
while(bad_ctext == ciphertext)
bad_ctext = Test::mutate_vec(bad_ctext, true);
@@ -222,7 +222,8 @@ PK_Encryption_Decryption_Test::run_one_test(const std::string&, const VarMap& va
if(enc_provider == "base")
{
- result.test_eq("generated ciphertext matches KAT", generated_ciphertext, ciphertext);
+ result.test_eq(enc_provider, "generated ciphertext matches KAT",
+ generated_ciphertext, ciphertext);
}
for(auto&& dec_provider : possible_pk_providers())
@@ -239,10 +240,14 @@ PK_Encryption_Decryption_Test::run_one_test(const std::string&, const VarMap& va
continue;
}
- result.test_eq("decryption of KAT", decryptor->decrypt(ciphertext), plaintext);
+ result.test_eq(dec_provider, "decryption of KAT", decryptor->decrypt(ciphertext), plaintext);
check_invalid_ciphertexts(result, *decryptor, plaintext, ciphertext);
- result.test_eq("decryption of generated ciphertext",
- decryptor->decrypt(generated_ciphertext), plaintext);
+
+ if(generated_ciphertext != ciphertext)
+ {
+ result.test_eq(dec_provider, "decryption of generated ciphertext",
+ decryptor->decrypt(generated_ciphertext), plaintext);
+ }
}
}