aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/pk_algs.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-06-21 14:43:52 -0400
committerJack Lloyd <[email protected]>2017-06-29 12:38:37 -0400
commit6ac870e6d81d98420a102661a27ad9b521da86f5 (patch)
tree0341a30bbf1003614e81e54f98b0a08105b6d9d1 /src/lib/pubkey/pk_algs.cpp
parent8b0986310ae9fdf7fa93e28e2820d818cc954cdd (diff)
Add SM2 signature scheme
From https://tools.ietf.org/html/draft-shen-sm2-ecdsa-02 This is a contribution from Ribose Inc (@riboseinc).
Diffstat (limited to 'src/lib/pubkey/pk_algs.cpp')
-rw-r--r--src/lib/pubkey/pk_algs.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lib/pubkey/pk_algs.cpp b/src/lib/pubkey/pk_algs.cpp
index 45e88f2a3..34d659c8f 100644
--- a/src/lib/pubkey/pk_algs.cpp
+++ b/src/lib/pubkey/pk_algs.cpp
@@ -60,6 +60,10 @@
#include <botan/xmss.h>
#endif
+#if defined(BOTAN_HAS_SM2)
+ #include <botan/sm2.h>
+#endif
+
#if defined(BOTAN_HAS_OPENSSL)
#include <botan/internal/openssl.h>
#endif
@@ -134,6 +138,11 @@ load_public_key(const AlgorithmIdentifier& alg_id,
return std::unique_ptr<Public_Key>(new GOST_3410_PublicKey(alg_id, key_bits));
#endif
+#if defined(BOTAN_HAS_SM2)
+ if(alg_name == "SM2_Sig")
+ return std::unique_ptr<Public_Key>(new SM2_Signature_PublicKey(alg_id, key_bits));
+#endif
+
#if defined(BOTAN_HAS_XMSS)
if(alg_name == "XMSS")
return std::unique_ptr<Public_Key>(new XMSS_PublicKey(key_bits));
@@ -205,6 +214,11 @@ load_private_key(const AlgorithmIdentifier& alg_id,
return std::unique_ptr<Private_Key>(new GOST_3410_PrivateKey(alg_id, key_bits));
#endif
+#if defined(BOTAN_HAS_SM2)
+ if(alg_name == "SM2_Sig")
+ return std::unique_ptr<Private_Key>(new SM2_Signature_PrivateKey(alg_id, key_bits));
+#endif
+
#if defined(BOTAN_HAS_ELGAMAL)
if(alg_name == "ElGamal")
return std::unique_ptr<Private_Key>(new ElGamal_PrivateKey(alg_id, key_bits));
@@ -290,6 +304,7 @@ create_private_key(const std::string& alg_name,
alg_name == "ECDH" ||
alg_name == "ECKCDSA" ||
alg_name == "ECGDSA" ||
+ alg_name == "SM2_Sig" ||
alg_name == "GOST-34.10")
{
const EC_Group ec_group(params.empty() ? "secp256r1" : params);
@@ -314,6 +329,11 @@ create_private_key(const std::string& alg_name,
return std::unique_ptr<Private_Key>(new GOST_3410_PrivateKey(rng, ec_group));
#endif
+#if defined(BOTAN_HAS_SM2)
+ if(alg_name == "SM2_Sig")
+ return std::unique_ptr<Private_Key>(new SM2_Signature_PrivateKey(rng, ec_group));
+#endif
+
#if defined(BOTAN_HAS_ECGDSA)
if(alg_name == "ECGDSA")
return std::unique_ptr<Private_Key>(new ECGDSA_PrivateKey(rng, ec_group));