diff --git a/library/ecp_curves.c b/library/ecp_curves.c index 685a664ee..ca1991522 100644 --- a/library/ecp_curves.c +++ b/library/ecp_curves.c @@ -37,6 +37,10 @@ #endif /* __ARMCC_VERSION */ #endif /*_MSC_VER */ +/* + * Conversion macros for embedded constants: + * build lists of t_uint's from lists of unsigned char's grouped by 8 + */ #if defined(POLARSSL_HAVE_INT8) #define BYTES_TO_T_UINT( a, b, c, d, e, f, g, h ) \ @@ -81,6 +85,7 @@ /* * Domain parameters for secp192r1 */ +#if defined(POLARSSL_ECP_DP_SECP192R1_ENABLED) static t_uint secp192r1_p[] = { BYTES_TO_T_UINT( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), BYTES_TO_T_UINT( 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), @@ -106,10 +111,12 @@ static t_uint secp192r1_n[] = { BYTES_TO_T_UINT( 0x36, 0xF8, 0xDE, 0x99, 0xFF, 0xFF, 0xFF, 0xFF ), BYTES_TO_T_UINT( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), }; +#endif /* POLARSSL_ECP_DP_SECP192R1_ENABLED */ /* * Domain parameters for secp224r1 */ +#if defined(POLARSSL_ECP_DP_SECP224R1_ENABLED) static t_uint secp224r1_p[] = { BYTES_TO_T_UINT( 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ), BYTES_TO_T_UINT( 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), @@ -140,10 +147,12 @@ static t_uint secp224r1_n[] = { BYTES_TO_T_UINT( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), BYTES_TO_T_UINT( 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00 ), }; +#endif /* POLARSSL_ECP_DP_SECP224R1_ENABLED */ /* * Domain parameters for secp256r1 */ +#if defined(POLARSSL_ECP_DP_SECP256R1_ENABLED) static t_uint secp256r1_p[] = { BYTES_TO_T_UINT( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), BYTES_TO_T_UINT( 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00 ), @@ -174,10 +183,12 @@ static t_uint secp256r1_n[] = { BYTES_TO_T_UINT( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), BYTES_TO_T_UINT( 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), }; +#endif /* POLARSSL_ECP_DP_SECP256R1_ENABLED */ /* * Domain parameters for secp384r1 */ +#if defined(POLARSSL_ECP_DP_SECP384R1_ENABLED) static t_uint secp384r1_p[] = { BYTES_TO_T_UINT( 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00 ), BYTES_TO_T_UINT( 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), @@ -218,10 +229,12 @@ static t_uint secp384r1_n[] = { BYTES_TO_T_UINT( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), BYTES_TO_T_UINT( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), }; +#endif /* POLARSSL_ECP_DP_SECP384R1_ENABLED */ /* * Domain parameters for secp521r1 */ +#if defined(POLARSSL_ECP_DP_SECP521R1_ENABLED) static t_uint secp521r1_p[] = { BYTES_TO_T_UINT( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), BYTES_TO_T_UINT( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), @@ -277,10 +290,12 @@ static t_uint secp521r1_n[] = { BYTES_TO_T_UINT( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), BYTES_TO_T_UINT( 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ), }; +#endif /* POLARSSL_ECP_DP_SECP521R1_ENABLED */ /* * Domain parameters for brainpoolP256r1 (RFC 5639 3.4) */ +#if defined(POLARSSL_ECP_DP_BP256R1_ENABLED) static t_uint brainpoolP256r1_p[] = { BYTES_TO_T_UINT( 0x77, 0x53, 0x6E, 0x1F, 0x1D, 0x48, 0x13, 0x20 ), BYTES_TO_T_UINT( 0x28, 0x20, 0x26, 0xD5, 0x23, 0xF6, 0x3B, 0x6E ), @@ -317,10 +332,12 @@ static t_uint brainpoolP256r1_n[] = { BYTES_TO_T_UINT( 0x71, 0x8D, 0x83, 0x9D, 0x90, 0x0A, 0x66, 0x3E ), BYTES_TO_T_UINT( 0xBC, 0xA9, 0xEE, 0xA1, 0xDB, 0x57, 0xFB, 0xA9 ), }; +#endif /* POLARSSL_ECP_DP_BP256R1_ENABLED */ /* * Domain parameters for brainpoolP384r1 (RFC 5639 3.6) */ +#if defined(POLARSSL_ECP_DP_BP384R1_ENABLED) static t_uint brainpoolP384r1_p[] = { BYTES_TO_T_UINT( 0x53, 0xEC, 0x07, 0x31, 0x13, 0x00, 0x47, 0x87 ), BYTES_TO_T_UINT( 0x71, 0x1A, 0x1D, 0x90, 0x29, 0xA7, 0xD3, 0xAC ), @@ -369,10 +386,12 @@ static t_uint brainpoolP384r1_n[] = { BYTES_TO_T_UINT( 0xDF, 0x41, 0xE6, 0x50, 0x7E, 0x6F, 0x5D, 0x0F ), BYTES_TO_T_UINT( 0x28, 0x6D, 0x38, 0xA3, 0x82, 0x1E, 0xB9, 0x8C ), }; +#endif /* POLARSSL_ECP_DP_BP384R1_ENABLED */ /* * Domain parameters for brainpoolP512r1 (RFC 5639 3.7) */ +#if defined(POLARSSL_ECP_DP_BP512R1_ENABLED) static t_uint brainpoolP512r1_p[] = { BYTES_TO_T_UINT( 0xF3, 0x48, 0x3A, 0x58, 0x56, 0x60, 0xAA, 0x28 ), BYTES_TO_T_UINT( 0x85, 0xC6, 0x82, 0x2D, 0x2F, 0xFF, 0x81, 0x28 ), @@ -433,6 +452,7 @@ static t_uint brainpoolP512r1_n[] = { BYTES_TO_T_UINT( 0x07, 0xFC, 0xC9, 0x33, 0xAE, 0xE6, 0xD4, 0x3F ), BYTES_TO_T_UINT( 0x8B, 0xC4, 0xE9, 0xDB, 0xB8, 0x9D, 0xDD, 0xAA ), }; +#endif /* POLARSSL_ECP_DP_BP512R1_ENABLED */ /* * Create an MPI from embedded constants