diff --git a/include/polarssl/config.h b/include/polarssl/config.h index bd12343963..6208c426de 100644 --- a/include/polarssl/config.h +++ b/include/polarssl/config.h @@ -241,6 +241,9 @@ #define POLARSSL_ECP_DP_SECP256R1_ENABLED #define POLARSSL_ECP_DP_SECP384R1_ENABLED #define POLARSSL_ECP_DP_SECP521R1_ENABLED +#define POLARSSL_ECP_DP_BP256R1_ENABLED +#define POLARSSL_ECP_DP_BP384R1_ENABLED +#define POLARSSL_ECP_DP_BP512R1_ENABLED /** * \def POLARSSL_KEY_EXCHANGE_PSK_ENABLED diff --git a/include/polarssl/ecp.h b/include/polarssl/ecp.h index 0267cb07a0..72e843c517 100644 --- a/include/polarssl/ecp.h +++ b/include/polarssl/ecp.h @@ -61,12 +61,15 @@ typedef enum POLARSSL_ECP_DP_SECP256R1, /*!< 256-bits NIST curve */ POLARSSL_ECP_DP_SECP384R1, /*!< 384-bits NIST curve */ POLARSSL_ECP_DP_SECP521R1, /*!< 521-bits NIST curve */ + POLARSSL_ECP_DP_BP256R1, /*!< 256-bits Brainpool curve */ + POLARSSL_ECP_DP_BP384R1, /*!< 384-bits Brainpool curve */ + POLARSSL_ECP_DP_BP512R1, /*!< 512-bits Brainpool curve */ } ecp_group_id; /** * Number of supported curves (plus one for NONE) */ -#define POLARSSL_ECP_DP_MAX 6 +#define POLARSSL_ECP_DP_MAX 9 /** * Curve information for use by other modules diff --git a/library/ecp.c b/library/ecp.c index c8ee3a76ff..b344c81a37 100644 --- a/library/ecp.c +++ b/library/ecp.c @@ -70,28 +70,37 @@ unsigned long add_count, dbl_count; /* * List of supported curves: * - internal ID - * - TLS NamedCurve ID (RFC 4492 section 5.1.1) + * - TLS NamedCurve ID (RFC 4492 sec. 5.1.1, RFC 7071 sec. 2) * - size in bits - * - readeble name + * - readable name */ const ecp_curve_info ecp_supported_curves[] = { +#if defined(POLARSSL_ECP_DP_BP512R1_ENABLED) + { POLARSSL_ECP_DP_BP512R1, 28, 512, "brainpool512r1" }, +#endif +#if defined(POLARSSL_ECP_DP_BP384R1_ENABLED) + { POLARSSL_ECP_DP_BP384R1, 27, 384, "brainpool384r1" }, +#endif +#if defined(POLARSSL_ECP_DP_BP256R1_ENABLED) + { POLARSSL_ECP_DP_BP256R1, 26, 256, "brainpool256r1" }, +#endif #if defined(POLARSSL_ECP_DP_SECP521R1_ENABLED) - { POLARSSL_ECP_DP_SECP521R1, 25, 521, "secp521r1" }, + { POLARSSL_ECP_DP_SECP521R1, 25, 521, "secp521r1" }, #endif #if defined(POLARSSL_ECP_DP_SECP384R1_ENABLED) - { POLARSSL_ECP_DP_SECP384R1, 24, 384, "secp384r1" }, + { POLARSSL_ECP_DP_SECP384R1, 24, 384, "secp384r1" }, #endif #if defined(POLARSSL_ECP_DP_SECP256R1_ENABLED) - { POLARSSL_ECP_DP_SECP256R1, 23, 256, "secp256r1" }, + { POLARSSL_ECP_DP_SECP256R1, 23, 256, "secp256r1" }, #endif #if defined(POLARSSL_ECP_DP_SECP224R1_ENABLED) - { POLARSSL_ECP_DP_SECP224R1, 21, 224, "secp224r1" }, + { POLARSSL_ECP_DP_SECP224R1, 21, 224, "secp224r1" }, #endif #if defined(POLARSSL_ECP_DP_SECP192R1_ENABLED) - { POLARSSL_ECP_DP_SECP192R1, 19, 192, "secp192r1" }, + { POLARSSL_ECP_DP_SECP192R1, 19, 192, "secp192r1" }, #endif - { POLARSSL_ECP_DP_NONE, 0, 0, NULL }, + { POLARSSL_ECP_DP_NONE, 0, 0, NULL }, }; /*