aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_sm2.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-08-01 20:19:38 -0400
committerJack Lloyd <[email protected]>2018-08-01 20:19:38 -0400
commitd17dbed547765739e1885bde33b0165795bcbd72 (patch)
tree4541ace57656daffcc1f17f04cd6656a9ded67e9 /src/tests/test_sm2.cpp
parent2504351f6df8ff07df131dcee3248f4b9595e2d7 (diff)
Combine SM2 key types for signatures and encryption
It seems in practice the same key may be end up used for both operations, so maintaining a distinction at the type level just complicates things.
Diffstat (limited to 'src/tests/test_sm2.cpp')
-rw-r--r--src/tests/test_sm2.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/tests/test_sm2.cpp b/src/tests/test_sm2.cpp
index 0c5a62c46..24e5c640d 100644
--- a/src/tests/test_sm2.cpp
+++ b/src/tests/test_sm2.cpp
@@ -9,7 +9,6 @@
#if defined(BOTAN_HAS_SM2)
#include <botan/sm2.h>
- #include <botan/sm2_enc.h>
#include "test_pubkey.h"
#endif
@@ -19,7 +18,6 @@ namespace Botan_Tests {
namespace {
-template<typename T>
std::unique_ptr<Botan::Private_Key> load_sm2_private_key(const VarMap& vars)
{
// group params
@@ -35,7 +33,7 @@ std::unique_ptr<Botan::Private_Key> load_sm2_private_key(const VarMap& vars)
Botan::EC_Group domain(p, a, b, xG, yG, order, cofactor);
Botan::Null_RNG null_rng;
- return std::unique_ptr<Botan::Private_Key>(new T(null_rng, domain, x));
+ return std::unique_ptr<Botan::Private_Key>(new Botan::SM2_PrivateKey(null_rng, domain, x));
}
class SM2_Signature_KAT_Tests final : public PK_Signature_Generation_Test
@@ -60,7 +58,7 @@ class SM2_Signature_KAT_Tests final : public PK_Signature_Generation_Test
std::unique_ptr<Botan::Private_Key> load_private_key(const VarMap& vars) override
{
- return load_sm2_private_key<Botan::SM2_Signature_PrivateKey>(vars);
+ return load_sm2_private_key(vars);
}
};
@@ -90,7 +88,7 @@ class SM2_Encryption_KAT_Tests final : public PK_Encryption_Decryption_Test
std::unique_ptr<Botan::Private_Key> load_private_key(const VarMap& vars) override
{
- return load_sm2_private_key<Botan::SM2_Encryption_PrivateKey>(vars);
+ return load_sm2_private_key(vars);
}
};
@@ -98,6 +96,22 @@ class SM2_Encryption_KAT_Tests final : public PK_Encryption_Decryption_Test
BOTAN_REGISTER_TEST("sm2_enc", SM2_Encryption_KAT_Tests);
+class SM2_Keygen_Tests final : public PK_Key_Generation_Test
+ {
+ public:
+ std::vector<std::string> keygen_params() const override
+ {
+ return { "secp256r1", "sm2p256v1" };
+ }
+
+ std::string algo_name() const override
+ {
+ return "SM2";
+ }
+ };
+
+BOTAN_REGISTER_TEST("sm2_keygen", SM2_Keygen_Tests);
+
#endif