aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cli/speed.cpp3
-rw-r--r--src/lib/pubkey/pk_algs.cpp2
-rw-r--r--src/lib/pubkey/xmss/xmss_parameters.cpp53
-rw-r--r--src/lib/pubkey/xmss/xmss_parameters.h4
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_parameters.cpp24
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_parameters.h2
-rw-r--r--src/tests/test_xmss.cpp17
7 files changed, 70 insertions, 35 deletions
diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp
index 6fac9411c..cd01f9180 100644
--- a/src/cli/speed.cpp
+++ b/src/cli/speed.cpp
@@ -1188,8 +1188,9 @@ class Speed final : public Command
std::chrono::milliseconds msec)
{
std::vector<std::string> xmss_params{
- "XMSS_SHA2-256_W16_H10",
"XMSS_SHA2-512_W16_H10",
+ "XMSS_SHA2-512_W16_H16",
+ "XMSS_SHA2-512_W16_H20",
};
for(std::string params : xmss_params)
diff --git a/src/lib/pubkey/pk_algs.cpp b/src/lib/pubkey/pk_algs.cpp
index 7cccd0168..178001316 100644
--- a/src/lib/pubkey/pk_algs.cpp
+++ b/src/lib/pubkey/pk_algs.cpp
@@ -242,7 +242,7 @@ create_private_key(const std::string& alg_name,
if(alg_name == "XMSS")
{
return std::unique_ptr<Private_Key>(
- new XMSS_PrivateKey(XMSS_Parameters(params).oid(), rng));
+ new XMSS_PrivateKey(XMSS_Parameters(params.empty() ? "XMSS_SHA2-512_W16_H10" : params).oid(), rng));
}
#endif
diff --git a/src/lib/pubkey/xmss/xmss_parameters.cpp b/src/lib/pubkey/xmss/xmss_parameters.cpp
index f1f3281cf..c55b25a27 100644
--- a/src/lib/pubkey/xmss/xmss_parameters.cpp
+++ b/src/lib/pubkey/xmss/xmss_parameters.cpp
@@ -16,26 +16,41 @@
namespace Botan {
-const std::map<std::string, XMSS_Parameters::xmss_algorithm_t>
- XMSS_Parameters::m_oid_name_lut =
- {
- { "XMSS_SHA2-256_W16_H10", XMSS_SHA2_256_W16_H10 },
- { "XMSS_SHA2-256_W16_H16", XMSS_SHA2_256_W16_H16 },
- { "XMSS_SHA2-256_W16_H20", XMSS_SHA2_256_W16_H20 },
- { "XMSS_SHA2-512_W16_H10", XMSS_SHA2_512_W16_H10 },
- { "XMSS_SHA2-512_W16_H16", XMSS_SHA2_512_W16_H16 },
- { "XMSS_SHA2-512_W16_H20", XMSS_SHA2_512_W16_H20 },
- { "XMSS_SHAKE128_W16_H10", XMSS_SHAKE128_W16_H10 },
- { "XMSS_SHAKE128_W16_H16", XMSS_SHAKE128_W16_H16 },
- { "XMSS_SHAKE128_W16_H20", XMSS_SHAKE128_W16_H20 },
- { "XMSS_SHAKE256_W16_H10", XMSS_SHAKE256_W16_H10 },
- { "XMSS_SHAKE256_W16_H16", XMSS_SHAKE256_W16_H16 },
- { "XMSS_SHAKE256_W16_H20", XMSS_SHAKE256_W16_H20 }
- };
+//static
+XMSS_Parameters::xmss_algorithm_t XMSS_Parameters::xmss_id_from_string(const std::string& param_set)
+ {
+ if(param_set == "XMSS_SHA2-256_W16_H10")
+ return XMSS_SHA2_256_W16_H10;
+ if(param_set == "XMSS_SHA2-256_W16_H16")
+ return XMSS_SHA2_256_W16_H16;
+ if(param_set == "XMSS_SHA2-256_W16_H20")
+ return XMSS_SHA2_256_W16_H20;
+ if(param_set == "XMSS_SHA2-512_W16_H10")
+ return XMSS_SHA2_512_W16_H10;
+ if(param_set == "XMSS_SHA2-512_W16_H16")
+ return XMSS_SHA2_512_W16_H16;
+ if(param_set == "XMSS_SHA2-512_W16_H20")
+ return XMSS_SHA2_512_W16_H20;
+ if(param_set == "XMSS_SHAKE128_W16_H10")
+ return XMSS_SHAKE128_W16_H10;
+ if(param_set == "XMSS_SHAKE128_W16_H16")
+ return XMSS_SHAKE128_W16_H16;
+ if(param_set == "XMSS_SHAKE128_W16_H20")
+ return XMSS_SHAKE128_W16_H20;
+ if(param_set == "XMSS_SHAKE256_W16_H10")
+ return XMSS_SHAKE256_W16_H10;
+ if(param_set == "XMSS_SHAKE256_W16_H16")
+ return XMSS_SHAKE256_W16_H16;
+ if(param_set == "XMSS_SHAKE256_W16_H20")
+ return XMSS_SHAKE256_W16_H20;
+ throw Invalid_Argument("Unknown XMSS algorithm param '" + param_set + "'");
+ }
+
+XMSS_Parameters::XMSS_Parameters(const std::string& param_set)
+ : XMSS_Parameters(XMSS_Parameters::xmss_id_from_string(param_set))
+ {
+ }
-XMSS_Parameters::XMSS_Parameters(const std::string& algo_name)
- : XMSS_Parameters(m_oid_name_lut.at(algo_name))
- {}
XMSS_Parameters::XMSS_Parameters(xmss_algorithm_t oid)
: m_oid(oid)
diff --git a/src/lib/pubkey/xmss/xmss_parameters.h b/src/lib/pubkey/xmss/xmss_parameters.h
index 7a83af381..1e8048217 100644
--- a/src/lib/pubkey/xmss/xmss_parameters.h
+++ b/src/lib/pubkey/xmss/xmss_parameters.h
@@ -44,6 +44,8 @@ class BOTAN_DLL XMSS_Parameters
XMSS_SHAKE256_W16_H20 = 0x0c00000c
};
+ static xmss_algorithm_t xmss_id_from_string(const std::string& algo_name);
+
XMSS_Parameters(const std::string& algo_name);
XMSS_Parameters(xmss_algorithm_t oid);
@@ -106,8 +108,6 @@ class BOTAN_DLL XMSS_Parameters
}
private:
- static const std::map<std::string, xmss_algorithm_t>
- m_oid_name_lut;
xmss_algorithm_t m_oid;
XMSS_WOTS_Parameters::ots_algorithm_t m_wots_oid;
std::string m_name;
diff --git a/src/lib/pubkey/xmss/xmss_wots_parameters.cpp b/src/lib/pubkey/xmss/xmss_wots_parameters.cpp
index 274da8d31..3a1c1902d 100644
--- a/src/lib/pubkey/xmss/xmss_wots_parameters.cpp
+++ b/src/lib/pubkey/xmss/xmss_wots_parameters.cpp
@@ -17,17 +17,23 @@
namespace Botan {
-const std::map<std::string, XMSS_WOTS_Parameters::ots_algorithm_t>
- XMSS_WOTS_Parameters::m_oid_name_lut =
+//static
+XMSS_WOTS_Parameters::ots_algorithm_t
+XMSS_WOTS_Parameters::xmss_wots_id_from_string(const std::string& param_set)
{
- { "WOTSP_SHA2-256_W16", WOTSP_SHA2_256_W16 },
- { "WOTSP_SHA2-512_W16", WOTSP_SHA2_512_W16 },
- { "WOTSP_SHAKE128_W16", WOTSP_SHAKE128_W16 },
- { "WOTSP_SHAKE256_W16", WOTSP_SHAKE256_W16 }
- };
+ if(param_set == "WOTSP_SHA2-256_W16")
+ return WOTSP_SHA2_256_W16;
+ if(param_set == "WOTSP_SHA2-512_W16")
+ return WOTSP_SHA2_512_W16;
+ if(param_set == "WOTSP_SHAKE128_W16")
+ return WOTSP_SHAKE128_W16;
+ if(param_set == "WOTSP_SHAKE256_W16")
+ return WOTSP_SHAKE256_W16;
+ throw Invalid_Argument("Unknown XMSS-WOTS algorithm param '" + param_set + "'");
+ }
-XMSS_WOTS_Parameters::XMSS_WOTS_Parameters(const std::string& algo_name)
- : XMSS_WOTS_Parameters(m_oid_name_lut.at(algo_name))
+XMSS_WOTS_Parameters::XMSS_WOTS_Parameters(const std::string& param_set)
+ : XMSS_WOTS_Parameters(xmss_wots_id_from_string(param_set))
{}
XMSS_WOTS_Parameters::XMSS_WOTS_Parameters(ots_algorithm_t oid)
diff --git a/src/lib/pubkey/xmss/xmss_wots_parameters.h b/src/lib/pubkey/xmss/xmss_wots_parameters.h
index 15644a257..cc89c3d4a 100644
--- a/src/lib/pubkey/xmss/xmss_wots_parameters.h
+++ b/src/lib/pubkey/xmss/xmss_wots_parameters.h
@@ -45,6 +45,8 @@ class XMSS_WOTS_Parameters
XMSS_WOTS_Parameters(const std::string& algo_name);
XMSS_WOTS_Parameters(ots_algorithm_t ots_spec);
+ static ots_algorithm_t xmss_wots_id_from_string(const std::string& param_set);
+
/**
* Algorithm 1: convert input string to base.
*
diff --git a/src/tests/test_xmss.cpp b/src/tests/test_xmss.cpp
index 534a8601e..eb75daa38 100644
--- a/src/tests/test_xmss.cpp
+++ b/src/tests/test_xmss.cpp
@@ -60,16 +60,27 @@ class XMSS_Signature_Verify_Tests : public PK_Signature_Verification_Test
std::unique_ptr<Botan::Public_Key> load_public_key(const VarMap& vars) override
{
- const std::vector<byte> raw_key = get_req_bin(vars, "PublicKey");
- const Botan::secure_vector<byte> sec_key(raw_key.begin(), raw_key.end());
+ const std::vector<byte> raw_key = get_req_bin(vars, "PublicKey");
+ const Botan::secure_vector<byte> sec_key(raw_key.begin(), raw_key.end());
- std::unique_ptr<Botan::Public_Key> key(new Botan::XMSS_PublicKey(sec_key));
+ std::unique_ptr<Botan::Public_Key> key(new Botan::XMSS_PublicKey(sec_key));
return key;
}
};
+class XMSS_Keygen_Tests : public PK_Key_Generation_Test
+ {
+ public:
+ std::vector<std::string> keygen_params() const override
+ {
+ return { "XMSS_SHA2-256_W16_H10" };
+ }
+ std::string algo_name() const override { return "XMSS"; }
+ };
+
BOTAN_REGISTER_TEST("xmss_sign", XMSS_Signature_Tests);
BOTAN_REGISTER_TEST("xmss_verify", XMSS_Signature_Verify_Tests);
+BOTAN_REGISTER_TEST("xmss_keygen", XMSS_Keygen_Tests);
#endif