diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/pubkey/ec_group/ec_group.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lib/pubkey/ec_group/ec_group.cpp b/src/lib/pubkey/ec_group/ec_group.cpp index 942e7401a..6064f869c 100644 --- a/src/lib/pubkey/ec_group/ec_group.cpp +++ b/src/lib/pubkey/ec_group/ec_group.cpp @@ -329,10 +329,16 @@ EC_Group::EC_Group(const std::string& str) if(m_data == nullptr) { - // OK try it as PEM ... - secure_vector<uint8_t> ber = PEM_Code::decode_check_label(str, "EC PARAMETERS"); - this->m_data = BER_decode_EC_group(ber.data(), ber.size()); + if(str.size() > 30 && str.substr(0, 29) == "-----BEGIN EC PARAMETERS-----") + { + // OK try it as PEM ... + secure_vector<uint8_t> ber = PEM_Code::decode_check_label(str, "EC PARAMETERS"); + this->m_data = BER_decode_EC_group(ber.data(), ber.size()); + } } + + if(m_data == nullptr) + throw Invalid_Argument("Unknown ECC group '" + str + "'"); } //static |