diff --git a/include/mbedtls/ecp.h b/include/mbedtls/ecp.h index badfe86cf..32c4528ec 100644 --- a/include/mbedtls/ecp.h +++ b/include/mbedtls/ecp.h @@ -504,8 +504,14 @@ int mbedtls_ecp_tls_write_group( const mbedtls_ecp_group *grp, size_t *olen, #if defined(MBEDTLS_ASN1_WRITE_C) && defined(MBEDTLS_OID_C) /** * \brief Maximum size of the output of mbedtls_ecp_ansi_write_group + * + * \note The maximum size of the OID of a supported group + 2 for + * tag and length. Maximum size 30 is based on the length of + * the OID for primeCurves 10-38 over GF(p) defined by the + * CDC Group, as they seem to have the longest OID out of + * curves in use. */ -#define MBEDTLS_OID_EC_GRP_MAX_SIZE 12 +#define MBEDTLS_ECP_GRP_OID_MAX_SIZE ( 30 + 2 ) /** * \brief Write the ANSI X9.62/RFC5480 OID ECParameters of a group diff --git a/include/mbedtls/oid.h b/include/mbedtls/oid.h index fcecdafdc..618c0eae5 100644 --- a/include/mbedtls/oid.h +++ b/include/mbedtls/oid.h @@ -282,6 +282,8 @@ /* * ECParameters namedCurve identifiers, from RFC 5480, RFC 5639, and SEC2 + * When adding new OID's, please update \c MBEDTLS_ECP_GRP_OID_MAX_SIZE + * in ecp.h */ /* secp192r1 OBJECT IDENTIFIER ::= { diff --git a/tests/suites/test_suite_ecp.function b/tests/suites/test_suite_ecp.function index a3cde43c6..f5d88ba44 100644 --- a/tests/suites/test_suite_ecp.function +++ b/tests/suites/test_suite_ecp.function @@ -417,8 +417,8 @@ exit: void ecp_ansi_write_group( int id, char *hex ) { mbedtls_ecp_group grp; - unsigned char good[MBEDTLS_OID_EC_GRP_MAX_SIZE]; - unsigned char tested[MBEDTLS_OID_EC_GRP_MAX_SIZE]; + unsigned char good[MBEDTLS_ECP_GRP_OID_MAX_SIZE]; + unsigned char tested[MBEDTLS_ECP_GRP_OID_MAX_SIZE]; size_t good_len = unhexify( good, hex ); size_t received_len = 0; int ret = 0;