Commit 07894338 by Manuel Pégourié-Gonnard

### Rename M255 to Curve25519

parent 7320eb46
 ... ... @@ -421,7 +421,7 @@ #define MBEDTLS_ECP_DP_BP256R1_ENABLED #define MBEDTLS_ECP_DP_BP384R1_ENABLED #define MBEDTLS_ECP_DP_BP512R1_ENABLED #define MBEDTLS_ECP_DP_M255_ENABLED #define MBEDTLS_ECP_DP_CURVE25519_ENABLED /** * \def MBEDTLS_ECP_NIST_OPTIM ... ...
 ... ... @@ -62,7 +62,7 @@ typedef enum MBEDTLS_ECP_DP_BP256R1, /*!< 256-bits Brainpool curve */ MBEDTLS_ECP_DP_BP384R1, /*!< 384-bits Brainpool curve */ MBEDTLS_ECP_DP_BP512R1, /*!< 512-bits Brainpool curve */ MBEDTLS_ECP_DP_M255, /*!< Curve25519 */ MBEDTLS_ECP_DP_CURVE25519, /*!< Curve25519 */ MBEDTLS_ECP_DP_SECP192K1, /*!< 192-bits "Koblitz" curve */ MBEDTLS_ECP_DP_SECP224K1, /*!< 224-bits "Koblitz" curve */ MBEDTLS_ECP_DP_SECP256K1, /*!< 256-bits "Koblitz" curve */ ... ... @@ -108,7 +108,7 @@ mbedtls_ecp_point; * * We consider two types of curves equations: * 1. Short Weierstrass y^2 = x^3 + A x + B mod P (SEC1 + RFC 4492) * 2. Montgomery, y^2 = x^3 + A x^2 + x mod P (M255 + draft) * 2. Montgomery, y^2 = x^3 + A x^2 + x mod P (Curve25519 + draft) * In both cases, a generator G for a prime-order subgroup is fixed. In the * short weierstrass, this subgroup is actually the whole curve, and its * cardinal is denoted by N. ... ...
 ... ... @@ -28,7 +28,7 @@ * FIPS 186-3 http://csrc.nist.gov/publications/fips/fips186-3/fips_186-3.pdf * RFC 4492 for the related TLS structures and constants * * [M255] http://cr.yp.to/ecdh/curve25519-20060209.pdf * [Curve25519] http://cr.yp.to/ecdh/curve25519-20060209.pdf * * [2] CORON, Jean-S'ebastien. Resistance against differential power analysis * for elliptic curve cryptosystems. In : Cryptographic Hardware and ... ... @@ -98,7 +98,7 @@ static unsigned long add_count, dbl_count, mul_count; #define ECP_SHORTWEIERSTRASS #endif #if defined(MBEDTLS_ECP_DP_M255_ENABLED) #if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) #define ECP_MONTGOMERY #endif ... ... @@ -1704,7 +1704,7 @@ cleanup: */ static int ecp_check_pubkey_mx( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt ) { /* [M255 p. 5] Just check X is the correct number of bytes */ /* [Curve25519 p. 5] Just check X is the correct number of bytes */ if( mbedtls_mpi_size( &pt->X ) > ( grp->nbits + 7 ) / 8 ) return( MBEDTLS_ERR_ECP_INVALID_KEY ); ... ... @@ -1740,7 +1740,7 @@ int mbedtls_ecp_check_privkey( const mbedtls_ecp_group *grp, const mbedtls_mpi * #if defined(ECP_MONTGOMERY) if( ecp_get_type( grp ) == ECP_TYPE_MONTGOMERY ) { /* see [M255] page 5 */ /* see [Curve25519] page 5 */ if( mbedtls_mpi_get_bit( d, 0 ) != 0 || mbedtls_mpi_get_bit( d, 1 ) != 0 || mbedtls_mpi_get_bit( d, 2 ) != 0 || ... ...
 ... ... @@ -626,7 +626,7 @@ static int ecp_mod_p521( mbedtls_mpi * ); #endif /* MBEDTLS_ECP_NIST_OPTIM */ /* Additional forward declarations */ #if defined(MBEDTLS_ECP_DP_M255_ENABLED) #if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) static int ecp_mod_p255( mbedtls_mpi * ); #endif #if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) ... ... @@ -655,7 +655,7 @@ static int ecp_mod_p256k1( mbedtls_mpi * ); G ## _gy, sizeof( G ## _gy ), \ G ## _n, sizeof( G ## _n ) ) #if defined(MBEDTLS_ECP_DP_M255_ENABLED) #if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) /* * Specialized function for creating the Curve25519 group */ ... ... @@ -687,7 +687,7 @@ cleanup: return( ret ); } #endif /* MBEDTLS_ECP_DP_M255_ENABLED */ #endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ /* * Set a group using well-known domain parameters ... ... @@ -763,11 +763,11 @@ int mbedtls_ecp_group_load( mbedtls_ecp_group *grp, mbedtls_ecp_group_id id ) return( LOAD_GROUP_A( brainpoolP512r1 ) ); #endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */ #if defined(MBEDTLS_ECP_DP_M255_ENABLED) case MBEDTLS_ECP_DP_M255: #if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) case MBEDTLS_ECP_DP_CURVE25519: grp->modp = ecp_mod_p255; return( ecp_use_curve25519( grp ) ); #endif /* MBEDTLS_ECP_DP_M255_ENABLED */ #endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ default: mbedtls_ecp_group_free( grp ); ... ... @@ -1155,7 +1155,7 @@ cleanup: #endif /* MBEDTLS_ECP_NIST_OPTIM */ #if defined(MBEDTLS_ECP_DP_M255_ENABLED) #if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) /* Size of p255 in terms of mbedtls_mpi_uint */ #define P255_WIDTH ( 255 / 8 / sizeof( mbedtls_mpi_uint ) + 1 ) ... ... @@ -1197,7 +1197,7 @@ static int ecp_mod_p255( mbedtls_mpi *N ) cleanup: return( ret ); } #endif /* MBEDTLS_ECP_DP_M255_ENABLED */ #endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ #if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) || \ defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) || \ ... ...
 ... ... @@ -226,9 +226,9 @@ static const char *features[] = { #if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) "MBEDTLS_ECP_DP_BP512R1_ENABLED", #endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */ #if defined(MBEDTLS_ECP_DP_M255_ENABLED) "MBEDTLS_ECP_DP_M255_ENABLED", #endif /* MBEDTLS_ECP_DP_M255_ENABLED */ #if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) "MBEDTLS_ECP_DP_CURVE25519_ENABLED", #endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ #if defined(MBEDTLS_ECP_NIST_OPTIM) "MBEDTLS_ECP_NIST_OPTIM", #endif /* MBEDTLS_ECP_NIST_OPTIM */ ... ...
 ... ... @@ -716,7 +716,7 @@ int main( int argc, char *argv[] ) if( todo.ecdh ) { mbedtls_ecdh_context ecdh; #if defined(MBEDTLS_ECP_DP_M255_ENABLED) #if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) mbedtls_mpi z; #endif const mbedtls_ecp_curve_info *curve_info; ... ... @@ -748,11 +748,11 @@ int main( int argc, char *argv[] ) } /* Curve25519 needs to be handled separately */ #if defined(MBEDTLS_ECP_DP_M255_ENABLED) #if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) mbedtls_ecdh_init( &ecdh ); mbedtls_mpi_init( &z ); if( mbedtls_ecp_group_load( &ecdh.grp, MBEDTLS_ECP_DP_M255 ) != 0 || if( mbedtls_ecp_group_load( &ecdh.grp, MBEDTLS_ECP_DP_CURVE25519 ) != 0 || mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Qp, myrand, NULL ) != 0 ) { mbedtls_exit( 1 ); ... ... @@ -794,11 +794,11 @@ int main( int argc, char *argv[] ) } /* Curve25519 needs to be handled separately */ #if defined(MBEDTLS_ECP_DP_M255_ENABLED) #if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) mbedtls_ecdh_init( &ecdh ); mbedtls_mpi_init( &z ); if( mbedtls_ecp_group_load( &ecdh.grp, MBEDTLS_ECP_DP_M255 ) != 0 || if( mbedtls_ecp_group_load( &ecdh.grp, MBEDTLS_ECP_DP_CURVE25519 ) != 0 || mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Qp, myrand, NULL ) != 0 || mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Q, myrand, NULL ) != 0 ) ... ...