Merged support for Brainpool curves and ciphersuites

This commit is contained in:
Paul Bakker 2013-10-11 10:03:27 +02:00
commit b799dec4c0
30 changed files with 329 additions and 113 deletions

View file

@ -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
@ -1013,7 +1016,7 @@
* Caller: library/ecdh.c
* library/ecdsa.c
*
* Requires: POLARSSL_BIGNUM_C
* Requires: POLARSSL_BIGNUM_C and at least one POLARSSL_ECP_DP_XXX_ENABLED
*/
#define POLARSSL_ECP_C
@ -1707,7 +1710,15 @@
#error "POLARSSL_ECDSA_C defined, but not all prerequisites"
#endif
#if defined(POLARSSL_ECP_C) && !defined(POLARSSL_BIGNUM_C)
#if defined(POLARSSL_ECP_C) && !defined(POLARSSL_BIGNUM_C) || ( \
!defined(POLARSSL_ECP_DP_SECP192R1_ENABLED) && \
!defined(POLARSSL_ECP_DP_SECP224R1_ENABLED) && \
!defined(POLARSSL_ECP_DP_SECP256R1_ENABLED) && \
!defined(POLARSSL_ECP_DP_SECP384R1_ENABLED) && \
!defined(POLARSSL_ECP_DP_SECP521R1_ENABLED) && \
!defined(POLARSSL_ECP_DP_BP256R1_ENABLED) && \
!defined(POLARSSL_ECP_DP_BP384R1_ENABLED) && \
!defined(POLARSSL_ECP_DP_BP512R1_ENABLED) )
#error "POLARSSL_ECP_C defined, but not all prerequisites"
#endif

View file

@ -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
@ -113,21 +116,21 @@ ecp_point;
*/
typedef struct
{
ecp_group_id id; /*!< RFC 4492 group ID */
mpi P; /*!< prime modulus of the base field */
mpi A; /*!< currently unused (-3 assumed) */
mpi B; /*!< constant term in the equation */
ecp_point G; /*!< generator of the subgroup used */
mpi N; /*!< the order of G */
size_t pbits; /*!< number of bits in P */
size_t nbits; /*!< number of bits in N */
unsigned int h; /*!< cofactor (unused now: assume 1) */
int (*modp)(mpi *); /*!< function for fast reduction mod P */
int (*t_pre)(ecp_point *, void *); /*!< currently unused */
int (*t_post)(ecp_point *, void *); /*!< currently unused */
void *t_data; /*!< currently unused */
ecp_point *T; /*!< pre-computed points (unused now) */
size_t T_size; /*!< number for pre-computed points */
ecp_group_id id; /*!< internal group identifier */
mpi P; /*!< prime modulus of the base field */
mpi A; /*!< linear term in the equation */
mpi B; /*!< constant term in the equation */
ecp_point G; /*!< generator of the subgroup used */
mpi N; /*!< the order of G */
size_t pbits; /*!< number of bits in P */
size_t nbits; /*!< number of bits in N */
unsigned int h; /*!< cofactor (unused now: assume 1) */
int (*modp)(mpi *); /*!< function for fast reduction mod P */
int (*t_pre)(ecp_point *, void *); /*!< currently unused */
int (*t_post)(ecp_point *, void *); /*!< currently unused */
void *t_data; /*!< currently unused */
ecp_point *T; /*!< pre-computed points for ecp_mul() */
size_t T_size; /*!< number for pre-computed points */
}
ecp_group;

View file

@ -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
*/