diff --git a/include/polarssl/oid.h b/include/polarssl/oid.h index 20bacae1b..85ab04c21 100644 --- a/include/polarssl/oid.h +++ b/include/polarssl/oid.h @@ -74,6 +74,8 @@ #define OID_OIW_SECSIG_SHA1 OID_OIW_SECSIG_ALG "\x1a" #define OID_ORG_CERTICOM "\x81\x04" /* certicom(132) */ #define OID_CERTICOM OID_ISO_IDENTIFIED_ORG OID_ORG_CERTICOM +#define OID_ORG_TELETRUST "\x24" /* teletrust(36) */ +#define OID_TELETRUST OID_ISO_IDENTIFIED_ORG OID_ORG_TELETRUST /* * ISO ITU OID parts @@ -258,7 +260,7 @@ #define OID_EC_ALG_ECDH OID_CERTICOM "\x01\x0c" /* - * ECParameters namedCurve identifiers, from RFC 5480 + * ECParameters namedCurve identifiers, from RFC 5480 and RFC 5639 */ /* secp192r1 OBJECT IDENTIFIER ::= { @@ -281,6 +283,23 @@ * iso(1) identified-organization(3) certicom(132) curve(0) 35 } */ #define OID_EC_GRP_SECP521R1 OID_CERTICOM "\x00\x23" +/* RFC 5639 4.1 + * ecStdCurvesAndGeneration OBJECT IDENTIFIER::= {iso(1) + * identified-organization(3) teletrust(36) algorithm(3) signature- + * algorithm(3) ecSign(2) 8} + * ellipticCurve OBJECT IDENTIFIER ::= {ecStdCurvesAndGeneration 1} + * versionOne OBJECT IDENTIFIER ::= {ellipticCurve 1} */ +#define OID_EC_BRAINPOOL_V1 OID_TELETRUST "\x03\x03\x02\x08\x01\x01" + +/* brainpoolP256r1 OBJECT IDENTIFIER ::= {versionOne 7} */ +#define OID_EC_GRP_BP256R1 OID_EC_BRAINPOOL_V1 "\x07" + +/* brainpoolP384r1 OBJECT IDENTIFIER ::= {versionOne 11} */ +#define OID_EC_GRP_BP384R1 OID_EC_BRAINPOOL_V1 "\x0B" + +/* brainpoolP512r1 OBJECT IDENTIFIER ::= {versionOne 13} */ +#define OID_EC_GRP_BP512R1 OID_EC_BRAINPOOL_V1 "\x0D" + /* * ECDSA signature identifers, from RFC 5480 */ diff --git a/library/oid.c b/library/oid.c index 485fd4cc1..c9cfe4842 100644 --- a/library/oid.c +++ b/library/oid.c @@ -405,6 +405,18 @@ static const oid_ecp_grp_t oid_ecp_grp[] = { ADD_LEN( OID_EC_GRP_SECP521R1 ), "secp521r1", "secp521r1" }, POLARSSL_ECP_DP_SECP521R1, }, + { + { ADD_LEN( OID_EC_GRP_BP256R1 ), "brainpoolP256r1","brainpool256r1" }, + POLARSSL_ECP_DP_BP256R1, + }, + { + { ADD_LEN( OID_EC_GRP_BP384R1 ), "brainpoolP384r1","brainpool384r1" }, + POLARSSL_ECP_DP_BP384R1, + }, + { + { ADD_LEN( OID_EC_GRP_BP512R1 ), "brainpoolP512r1","brainpool512r1" }, + POLARSSL_ECP_DP_BP512R1, + }, { { NULL, 0, NULL, NULL }, 0, diff --git a/tests/data_files/ec_bp256_prv.pem b/tests/data_files/ec_bp256_prv.pem new file mode 100644 index 000000000..9d6a867cc --- /dev/null +++ b/tests/data_files/ec_bp256_prv.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHgCAQEEICFh1vLbdlJvpiwW81aoDwHzL3dnhLNqqZeZqLdmIID/oAsGCSskAwMC +CAEBB6FEA0IABHaMjK5KvKYwbbDtgbDEpiFcN4Bm7G1hbBRuE/HH34CblqtpEcJ9 +igIznwkmhA5VI209HvviZp0JDkxMZg+tqR0= +-----END EC PRIVATE KEY----- diff --git a/tests/data_files/ec_bp256_pub.pem b/tests/data_files/ec_bp256_pub.pem new file mode 100644 index 000000000..f738623d8 --- /dev/null +++ b/tests/data_files/ec_bp256_pub.pem @@ -0,0 +1,4 @@ +-----BEGIN PUBLIC KEY----- +MFowFAYHKoZIzj0CAQYJKyQDAwIIAQEHA0IABHaMjK5KvKYwbbDtgbDEpiFcN4Bm +7G1hbBRuE/HH34CblqtpEcJ9igIznwkmhA5VI209HvviZp0JDkxMZg+tqR0= +-----END PUBLIC KEY----- diff --git a/tests/data_files/ec_bp384_prv.pem b/tests/data_files/ec_bp384_prv.pem new file mode 100644 index 000000000..34e82db7a --- /dev/null +++ b/tests/data_files/ec_bp384_prv.pem @@ -0,0 +1,6 @@ +-----BEGIN EC PRIVATE KEY----- +MIGoAgEBBDA92S51DZDX05/BiFzYrRLqlEHyK5M0tNllICrbFEjOJMWAioXdmvwi +mvCjEk91W8ugCwYJKyQDAwIIAQELoWQDYgAEcZ+dCTpifg01A4XGYc6/AMYZI1Zv +6QBqMQevHYcbxrtomF/XIuoyvjFvjng7fNGVd4X2bPwMsZXdXJmo56uqhIVTpYTf +0rSOdtRF/gDdi+WQlth31GltI7S8jbFHJOZq +-----END EC PRIVATE KEY----- diff --git a/tests/data_files/ec_bp384_pub.pem b/tests/data_files/ec_bp384_pub.pem new file mode 100644 index 000000000..eb202e214 --- /dev/null +++ b/tests/data_files/ec_bp384_pub.pem @@ -0,0 +1,5 @@ +-----BEGIN PUBLIC KEY----- +MHowFAYHKoZIzj0CAQYJKyQDAwIIAQELA2IABHGfnQk6Yn4NNQOFxmHOvwDGGSNW +b+kAajEHrx2HG8a7aJhf1yLqMr4xb454O3zRlXeF9mz8DLGV3VyZqOerqoSFU6WE +39K0jnbURf4A3YvlkJbYd9RpbSO0vI2xRyTmag== +-----END PUBLIC KEY----- diff --git a/tests/data_files/ec_bp512_prv.pem b/tests/data_files/ec_bp512_prv.pem new file mode 100644 index 000000000..a30c622db --- /dev/null +++ b/tests/data_files/ec_bp512_prv.pem @@ -0,0 +1,7 @@ +-----BEGIN EC PRIVATE KEY----- +MIHaAgEBBEA3LJd49p9ybLyj9KJo8WtNYX0QKA15pqApzVGHn+EBKTTf5TlUVTN9 +9pBtx9bS7qTbsgZcAij3Oz7XFkgOfXHSoAsGCSskAwMCCAEBDaGBhQOBggAEOLfs +krYcXGx/vCik7HWdSPzU4uN03v1cSWilTb73UQ5ReIb7/DjqOapSk1nXCnFWw108 +usfOd2vbJR3WS85xI0Qk7nBJ7tBy8NvE15mW4XXVV+JjdjrpcJXAgec+fbLjitw9 +TJoEh7Ht6HbcH8phyQLpodhyK4YSko8YokhFWRo= +-----END EC PRIVATE KEY----- diff --git a/tests/data_files/ec_bp512_pub.pem b/tests/data_files/ec_bp512_pub.pem new file mode 100644 index 000000000..ff5d07296 --- /dev/null +++ b/tests/data_files/ec_bp512_pub.pem @@ -0,0 +1,6 @@ +-----BEGIN PUBLIC KEY----- +MIGbMBQGByqGSM49AgEGCSskAwMCCAEBDQOBggAEOLfskrYcXGx/vCik7HWdSPzU +4uN03v1cSWilTb73UQ5ReIb7/DjqOapSk1nXCnFWw108usfOd2vbJR3WS85xI0Qk +7nBJ7tBy8NvE15mW4XXVV+JjdjrpcJXAgec+fbLjitw9TJoEh7Ht6HbcH8phyQLp +odhyK4YSko8YokhFWRo= +-----END PUBLIC KEY----- diff --git a/tests/suites/test_suite_pkparse.data b/tests/suites/test_suite_pkparse.data index 8434efb79..dc13fdbde 100644 --- a/tests/suites/test_suite_pkparse.data +++ b/tests/suites/test_suite_pkparse.data @@ -130,6 +130,18 @@ Parse Public EC Key #6 (RFC 5480, secp521r1) depends_on:POLARSSL_PEM_PARSE_C:POLARSSL_ECP_C:POLARSSL_ECP_DP_SECP521R1_ENABLED pk_parse_public_keyfile_ec:"data_files/ec_521_pub.pem":0 +Parse Public EC Key #7 (RFC 5480, brainpoolP256r1) +depends_on:POLARSSL_PEM_PARSE_C:POLARSSL_ECP_C:POLARSSL_ECP_DP_BP256R1_ENABLED +pk_parse_public_keyfile_ec:"data_files/ec_bp256_pub.pem":0 + +Parse Public EC Key #8 (RFC 5480, brainpoolP384r1) +depends_on:POLARSSL_PEM_PARSE_C:POLARSSL_ECP_C:POLARSSL_ECP_DP_BP384R1_ENABLED +pk_parse_public_keyfile_ec:"data_files/ec_bp384_pub.pem":0 + +Parse Public EC Key #9 (RFC 5480, brainpoolP512r1) +depends_on:POLARSSL_PEM_PARSE_C:POLARSSL_ECP_C:POLARSSL_ECP_DP_BP512R1_ENABLED +pk_parse_public_keyfile_ec:"data_files/ec_bp512_pub.pem":0 + Parse EC Key #1 (SEC1 DER) depends_on:POLARSSL_PEM_PARSE_C:POLARSSL_ECP_C:POLARSSL_ECP_DP_SECP192R1_ENABLED pk_parse_keyfile_ec:"data_files/ec_prv.sec1.der":"NULL":0 @@ -174,6 +186,18 @@ Parse EC Key #11 (SEC1 PEM, secp521r1) depends_on:POLARSSL_PEM_PARSE_C:POLARSSL_ECP_C:POLARSSL_ECP_DP_SECP521R1_ENABLED pk_parse_keyfile_ec:"data_files/ec_521_prv.pem":"NULL":0 +Parse EC Key #12 (SEC1 PEM, bp256r1) +depends_on:POLARSSL_PEM_PARSE_C:POLARSSL_ECP_C:POLARSSL_ECP_DP_BP256R1_ENABLED +pk_parse_keyfile_ec:"data_files/ec_bp256_prv.pem":"NULL":0 + +Parse EC Key #13 (SEC1 PEM, bp384r1) +depends_on:POLARSSL_PEM_PARSE_C:POLARSSL_ECP_C:POLARSSL_ECP_DP_BP384R1_ENABLED +pk_parse_keyfile_ec:"data_files/ec_bp384_prv.pem":"NULL":0 + +Parse EC Key #14 (SEC1 PEM, bp512r1) +depends_on:POLARSSL_PEM_PARSE_C:POLARSSL_ECP_C:POLARSSL_ECP_DP_BP512R1_ENABLED +pk_parse_keyfile_ec:"data_files/ec_bp512_prv.pem":"NULL":0 + Key ASN1 (Incorrect first tag) pk_parse_key_rsa:"":"":POLARSSL_ERR_PK_KEY_INVALID_FORMAT