aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/pubkey/ec_dompar/ec_dompar.cpp15
-rw-r--r--src/pubkey/ec_dompar/ec_dompar.h7
2 files changed, 16 insertions, 6 deletions
diff --git a/src/pubkey/ec_dompar/ec_dompar.cpp b/src/pubkey/ec_dompar/ec_dompar.cpp
index b0aa7a87a..512d8d769 100644
--- a/src/pubkey/ec_dompar/ec_dompar.cpp
+++ b/src/pubkey/ec_dompar/ec_dompar.cpp
@@ -30,12 +30,21 @@ EC_Domain_Params::EC_Domain_Params(const OID& domain_oid)
EC_Domain_Params::EC_Domain_Params(const std::string& pem)
{
- if(pem != "")
+ if(pem == "")
+ return; // no initialization / uninitialized
+
+ try
{
DataSource_Memory input(pem);
- *this = EC_Domain_Params(
- PEM_Code::decode_check_label(input, "EC PARAMETERS"));
+ SecureVector<byte> ber =
+ PEM_Code::decode_check_label(input, "EC PARAMETERS");
+
+ *this = EC_Domain_Params(ber);
+ }
+ catch(Decoding_Error) // hmm, not PEM?
+ {
+ *this = EC_Domain_Params(OID(pem));
}
}
diff --git a/src/pubkey/ec_dompar/ec_dompar.h b/src/pubkey/ec_dompar/ec_dompar.h
index 7da2120cc..15143373a 100644
--- a/src/pubkey/ec_dompar/ec_dompar.h
+++ b/src/pubkey/ec_dompar/ec_dompar.h
@@ -60,10 +60,11 @@ class BOTAN_DLL EC_Domain_Params
EC_Domain_Params(const OID& oid);
/**
- * Create an EC domain from PEM encoding (as from PEM_encode)
- * @param pem data
+ * Create an EC domain from PEM encoding (as from PEM_encode),
+ * or from an OID name (eg "secp16r1", or "1.3.132.0.8")
+ * @param pem_or_oid PEM-encoded data, or an OID
*/
- EC_Domain_Params(const std::string& pem = "");
+ EC_Domain_Params(const std::string& pem_or_oid = "");
/**
* Create the DER encoding of this domain