aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-08-04 15:37:07 -0400
committerJack Lloyd <[email protected]>2017-08-04 15:37:07 -0400
commit0f97d8b5cdabd0f57b5e936deff7be3d548abd9c (patch)
tree2f32564891c0dc378e20e583a066c6c9a8051865 /src
parent968c1e492708d4c9372063a3965dabd72fd79dcc (diff)
When creating an EC curve with default params, use algo-specific curve
Eg previously ./botan keygen --algo=GOST-34.10 would create a GOST-34.10 curve over P-256, probably not useful in most cases.
Diffstat (limited to 'src')
-rw-r--r--src/lib/pubkey/pk_algs.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/lib/pubkey/pk_algs.cpp b/src/lib/pubkey/pk_algs.cpp
index ab10f0ab9..e696b5e74 100644
--- a/src/lib/pubkey/pk_algs.cpp
+++ b/src/lib/pubkey/pk_algs.cpp
@@ -237,6 +237,22 @@ load_private_key(const AlgorithmIdentifier& alg_id,
throw Decoding_Error("Unhandled PK algorithm " + alg_name);
}
+namespace {
+
+std::string default_ec_group_for(const std::string& alg_name)
+ {
+ if(alg_name == "SM2_Enc" || alg_name == "SM2_Sig")
+ return "sm2p256v1";
+ if(alg_name == "GOST-34.10")
+ return "gost_256A";
+ if(alg_name == "ECGDSA")
+ return "brainpool256r1";
+ return "secp256r1";
+
+ }
+
+}
+
std::unique_ptr<Private_Key>
create_private_key(const std::string& alg_name,
RandomNumberGenerator& rng,
@@ -313,7 +329,7 @@ create_private_key(const std::string& alg_name,
alg_name == "SM2_Enc" ||
alg_name == "GOST-34.10")
{
- const EC_Group ec_group(params.empty() ? "secp256r1" : params);
+ const EC_Group ec_group(params.empty() ? default_ec_group_for(alg_name) : params);
#if defined(BOTAN_HAS_ECDSA)
if(alg_name == "ECDSA")