diff options
author | Jack Lloyd <[email protected]> | 2018-02-20 11:01:03 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2020-11-28 08:03:14 -0500 |
commit | 0c76f906a3083b9f4662e89508325e1dd474c7c3 (patch) | |
tree | f4c846c132feaaa22c9f5ff5563429671bea0668 /src/tests/test_pubkey.cpp | |
parent | b00cd7cea9233b782697f645a5aa54fd59ecacd9 (diff) |
Add Private_Key::public_key
Diffstat (limited to 'src/tests/test_pubkey.cpp')
-rw-r--r-- | src/tests/test_pubkey.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/tests/test_pubkey.cpp b/src/tests/test_pubkey.cpp index 703f7360f..3e3001a86 100644 --- a/src/tests/test_pubkey.cpp +++ b/src/tests/test_pubkey.cpp @@ -667,6 +667,12 @@ std::vector<Test::Result> PK_Key_Generation_Test::run() std::unique_ptr<Botan::Private_Key> key_p = Botan::create_private_key(algo_name(), Test::rng(), param, prov); + if(key_p == nullptr) + { + result.test_failure("create_private_key returned null, should throw instead"); + continue; + } + const Botan::Private_Key& key = *key_p; try @@ -678,6 +684,14 @@ std::vector<Test::Result> PK_Key_Generation_Test::run() result.test_gte("Key has reasonable estimated strength (lower)", key.estimated_strength(), 64); result.test_lt("Key has reasonable estimated strength (upper)", key.estimated_strength(), 512); + std::unique_ptr<Botan::Public_Key> public_key = key.public_key(); + + result.test_eq("public_key has same name", public_key->algo_name(), key.algo_name()); + + result.test_eq("public_key has same encoding", + Botan::X509::PEM_encode(key), + Botan::X509::PEM_encode(*public_key)); + // Test PEM public key round trips OK try { |