aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_pubkey.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-09-20 17:33:06 +0000
committerJack Lloyd <[email protected]>2017-09-20 17:33:06 +0000
commit98993f542727787dcdc8e549a748a94886643458 (patch)
tree1d369c60817b5ae0bd616f6b046322950cd65065 /src/tests/test_pubkey.cpp
parentbbbc4c59ec85ec912b482afab1eccc0fd3b1f87a (diff)
Update SM2 to use ASN.1 encoding for ciphertexts
There are in fact 3 different variations of SM2 standard, first C1||C2||C3, then C1||C3||C2, then (most recently) an ASN.1 encoding. This makes us compatible with GmSSL This work was sponsored by Ribose Inc (@riboseinc).
Diffstat (limited to 'src/tests/test_pubkey.cpp')
-rw-r--r--src/tests/test_pubkey.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/tests/test_pubkey.cpp b/src/tests/test_pubkey.cpp
index bbaa444f0..a7e58b10f 100644
--- a/src/tests/test_pubkey.cpp
+++ b/src/tests/test_pubkey.cpp
@@ -273,7 +273,17 @@ PK_Encryption_Decryption_Test::run_one_test(const std::string& pad_hdr, const Va
continue;
}
- result.test_eq(dec_provider, "decryption of KAT", decryptor->decrypt(ciphertext), plaintext);
+ Botan::secure_vector<uint8_t> decrypted;
+ try
+ {
+ decrypted = decryptor->decrypt(ciphertext);
+ }
+ catch(Botan::Exception& e)
+ {
+ result.test_failure("Failed to decrypt KAT ciphertext", e.what());
+ }
+
+ result.test_eq(dec_provider, "decryption of KAT", decrypted, plaintext);
check_invalid_ciphertexts(result, *decryptor, plaintext, ciphertext);
}