From 8195c1a5678867fcaf67500c71584b6d92ff46b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Mon, 7 Oct 2013 19:40:41 +0200 Subject: [PATCH] Add identifiers for Brainpool curves --- include/polarssl/config.h | 3 +++ include/polarssl/ecp.h | 5 ++++- library/ecp.c | 25 +++++++++++++++++-------- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/include/polarssl/config.h b/include/polarssl/config.h index bd1234396..6208c426d 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 0267cb07a..72e843c51 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 c8ee3a76f..b344c81a3 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 }, }; /*