aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-03-04 22:17:38 -0500
committerJack Lloyd <[email protected]>2018-03-04 22:17:38 -0500
commita7d664192a7dce877225e6fbe35c3ad4a1d3cceb (patch)
treeb09c2db1d6dd1ffa6791c4120baea034607f0248
parent8fe96b9384017b6d0f496c02c367e66ae6617a17 (diff)
Support decoding of ECC groups with seed parameter
Closes GH #874
-rw-r--r--src/lib/pubkey/ec_group/ec_group.cpp2
-rw-r--r--src/tests/data/x509/ecc/secp384r1_seed.pem10
-rw-r--r--src/tests/unit_ecc.cpp17
3 files changed, 29 insertions, 0 deletions
diff --git a/src/lib/pubkey/ec_group/ec_group.cpp b/src/lib/pubkey/ec_group/ec_group.cpp
index 6064f869c..9da1cd81f 100644
--- a/src/lib/pubkey/ec_group/ec_group.cpp
+++ b/src/lib/pubkey/ec_group/ec_group.cpp
@@ -264,6 +264,7 @@ std::shared_ptr<EC_Group_Data> EC_Group::BER_decode_EC_group(const uint8_t bits[
{
BigInt p, a, b, order, cofactor;
std::vector<uint8_t> base_pt;
+ std::vector<uint8_t> seed;
BER_Decoder(bits, len)
.start_cons(SEQUENCE)
@@ -276,6 +277,7 @@ std::shared_ptr<EC_Group_Data> EC_Group::BER_decode_EC_group(const uint8_t bits[
.start_cons(SEQUENCE)
.decode_octet_string_bigint(a)
.decode_octet_string_bigint(b)
+ .decode_optional_string(seed, BIT_STRING, BIT_STRING)
.end_cons()
.decode(base_pt, OCTET_STRING)
.decode(order)
diff --git a/src/tests/data/x509/ecc/secp384r1_seed.pem b/src/tests/data/x509/ecc/secp384r1_seed.pem
new file mode 100644
index 000000000..8f5598ed0
--- /dev/null
+++ b/src/tests/data/x509/ecc/secp384r1_seed.pem
@@ -0,0 +1,10 @@
+-----BEGIN EC PARAMETERS-----
+MIIBVwIBATA8BgcqhkjOPQEBAjEA////////////////////////////////////
+//////7/////AAAAAAAAAAD/////MHsEMP//////////////////////////////
+///////////+/////wAAAAAAAAAA/////AQwszEvp+I+5+SYjgVr4/gtGRgdnG7+
+gUESAxQIj1ATh1rGVjmNii7RnSqFyO3T7CrvAxUAozWSaqMZonodAIlqZ3OkgnrN
+rHMEYQSqh8oivosFN46xxx7zIK10bh07Younm5hZ90HgglQqOFUC8l2/VSlsOlRe
+OHJ2Crc2F95KliYsb12emL+Sktwp+PQdvSiaFHzp2jETtfC4wApgsc4dfoGdekMd
+fJDqDl8CMQD////////////////////////////////HY02B9Dct31gaDbJIsKd6
+7OwZaszFKXMCAQE=
+-----END EC PARAMETERS-----
diff --git a/src/tests/unit_ecc.cpp b/src/tests/unit_ecc.cpp
index aecf6e5d4..6f0d1a243 100644
--- a/src/tests/unit_ecc.cpp
+++ b/src/tests/unit_ecc.cpp
@@ -293,6 +293,22 @@ Test::Result test_groups()
return result;
}
+Test::Result test_decoding_with_seed()
+ {
+ Test::Result result("ECC Unit");
+
+ Botan::EC_Group secp384r1_with_seed(
+ Test::read_data_file("x509/ecc/secp384r1_seed.pem"));
+
+ result.confirm("decoding worked", secp384r1_with_seed.initialized());
+
+ Botan::EC_Group secp384r1("secp384r1");
+
+ result.test_eq("P-384 prime", secp384r1_with_seed.get_p(), secp384r1.get_p());
+
+ return result;
+ }
+
Test::Result test_coordinates()
{
Test::Result result("ECC Unit");
@@ -765,6 +781,7 @@ class ECC_Unit_Tests final : public Test
results.push_back(test_groups());
results.push_back(test_coordinates());
+ results.push_back(test_decoding_with_seed());
results.push_back(test_point_transformation());
results.push_back(test_point_mult());
results.push_back(test_point_negative());