Skip to content

Commit

Permalink
Merge pull request #4441 from randombit/jack/fix-4440
Browse files Browse the repository at this point in the history
Improve parsing of HSS-LMS parameters
  • Loading branch information
randombit authored Nov 24, 2024
2 parents d62fc66 + 0f5aa0e commit e54502e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/lib/pubkey/hss_lms/hss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ HSS_LMS_Params::HSS_LMS_Params(std::vector<LMS_LMOTS_Params_Pair> lm_lmots_param
}

HSS_LMS_Params::HSS_LMS_Params(std::string_view algo_params) {
SCAN_Name scan(fmt("HSS-LMS({})", algo_params));
const auto wrap_in_hss_lms = [&]() {
if(algo_params.starts_with("HSS-LMS(")) {
return std::string(algo_params);
} else {
return fmt("HSS-LMS({})", algo_params);
}
}();
SCAN_Name scan(wrap_in_hss_lms);

BOTAN_ARG_CHECK(scan.arg_count() >= 2 && scan.arg_count() <= HSS_MAX_LEVELS + 1, "Invalid number of arguments");
std::string hash = scan.arg(0);
Expand Down
9 changes: 8 additions & 1 deletion src/lib/pubkey/pk_algs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,14 @@ std::unique_ptr<Private_Key> create_private_key(std::string_view alg_name,

#if defined(BOTAN_HAS_HSS_LMS)
if(alg_name == "HSS-LMS") {
return std::make_unique<HSS_LMS_PrivateKey>(rng, params);
const auto hss_params = [&]() -> std::string {
if(params.empty()) {
return "SHA-256,HW(10,1)";
} else {
return std::string(params);
}
}();
return std::make_unique<HSS_LMS_PrivateKey>(rng, hss_params);
}
#endif

Expand Down

0 comments on commit e54502e

Please sign in to comment.