Rename M255 to Curve25519

This commit is contained in:
Manuel Pégourié-Gonnard 2015-06-23 00:18:41 +02:00
parent 7320eb46d4
commit 07894338a0
10 changed files with 52 additions and 52 deletions

View File

@ -159,8 +159,8 @@
#if defined MBEDTLS_ECP_DP_BP512R1_ENABLED
#define POLARSSL_ECP_DP_BP512R1_ENABLED MBEDTLS_ECP_DP_BP512R1_ENABLED
#endif
#if defined MBEDTLS_ECP_DP_M255_ENABLED
#define POLARSSL_ECP_DP_M255_ENABLED MBEDTLS_ECP_DP_M255_ENABLED
#if defined MBEDTLS_ECP_DP_CURVE25519_ENABLED
#define POLARSSL_ECP_DP_M255_ENABLED MBEDTLS_ECP_DP_CURVE25519_ENABLED
#endif
#if defined MBEDTLS_ECP_DP_SECP192K1_ENABLED
#define POLARSSL_ECP_DP_SECP192K1_ENABLED MBEDTLS_ECP_DP_SECP192K1_ENABLED
@ -1042,7 +1042,7 @@
#define POLARSSL_ECP_DP_BP256R1 MBEDTLS_ECP_DP_BP256R1
#define POLARSSL_ECP_DP_BP384R1 MBEDTLS_ECP_DP_BP384R1
#define POLARSSL_ECP_DP_BP512R1 MBEDTLS_ECP_DP_BP512R1
#define POLARSSL_ECP_DP_M255 MBEDTLS_ECP_DP_M255
#define POLARSSL_ECP_DP_M255 MBEDTLS_ECP_DP_CURVE25519
#define POLARSSL_ECP_DP_MAX MBEDTLS_ECP_DP_MAX
#define POLARSSL_ECP_DP_NONE MBEDTLS_ECP_DP_NONE
#define POLARSSL_ECP_DP_SECP192K1 MBEDTLS_ECP_DP_SECP192K1

View File

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

View File

@ -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.

View File

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

View File

@ -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) || \

View File

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

View File

@ -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 )

View File

@ -421,8 +421,8 @@ POLARSSL_ECP_DP_BP384R1 MBEDTLS_ECP_DP_BP384R1
POLARSSL_ECP_DP_BP384R1_ENABLED MBEDTLS_ECP_DP_BP384R1_ENABLED
POLARSSL_ECP_DP_BP512R1 MBEDTLS_ECP_DP_BP512R1
POLARSSL_ECP_DP_BP512R1_ENABLED MBEDTLS_ECP_DP_BP512R1_ENABLED
POLARSSL_ECP_DP_M255 MBEDTLS_ECP_DP_M255
POLARSSL_ECP_DP_M255_ENABLED MBEDTLS_ECP_DP_M255_ENABLED
POLARSSL_ECP_DP_M255 MBEDTLS_ECP_DP_CURVE25519
POLARSSL_ECP_DP_M255_ENABLED MBEDTLS_ECP_DP_CURVE25519_ENABLED
POLARSSL_ECP_DP_MAX MBEDTLS_ECP_DP_MAX
POLARSSL_ECP_DP_NONE MBEDTLS_ECP_DP_NONE
POLARSSL_ECP_DP_SECP192K1 MBEDTLS_ECP_DP_SECP192K1

View File

@ -49,7 +49,7 @@ cat << EOF >$CONFIG_H
#define MBEDTLS_ECP_DP_SECP256R1_ENABLED
#define MBEDTLS_ECP_DP_SECP384R1_ENABLED
#define MBEDTLS_ECP_DP_SECP521R1_ENABLED
#define MBEDTLS_ECP_DP_M255_ENABLED
#define MBEDTLS_ECP_DP_CURVE25519_ENABLED
#include "check_config.h"

View File

@ -31,12 +31,12 @@ depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED
mbedtls_ecp_curve_info:MBEDTLS_ECP_DP_SECP192R1:19:192:"secp192r1"
ECP check pubkey Montgomery #1 (too big)
depends_on:MBEDTLS_ECP_DP_M255_ENABLED
ecp_check_pub_mx:MBEDTLS_ECP_DP_M255:"010000000000000000000000000000000000000000000000000000000000000000":MBEDTLS_ERR_ECP_INVALID_KEY
depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED
ecp_check_pub_mx:MBEDTLS_ECP_DP_CURVE25519:"010000000000000000000000000000000000000000000000000000000000000000":MBEDTLS_ERR_ECP_INVALID_KEY
ECP check pubkey Montgomery #2 (biggest)
depends_on:MBEDTLS_ECP_DP_M255_ENABLED
ecp_check_pub_mx:MBEDTLS_ECP_DP_M255:"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF":0
depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED
ecp_check_pub_mx:MBEDTLS_ECP_DP_CURVE25519:"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF":0
ECP write binary #0 (zero, bad format)
depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED
@ -168,32 +168,32 @@ depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED
mbedtls_ecp_check_privkey:MBEDTLS_ECP_DP_SECP192R1:"FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831":MBEDTLS_ERR_ECP_INVALID_KEY
ECP check privkey #5 (montgomery, too big)
depends_on:MBEDTLS_ECP_DP_M255_ENABLED
mbedtls_ecp_check_privkey:MBEDTLS_ECP_DP_M255:"C000000000000000000000000000000000000000000000000000000000000000":MBEDTLS_ERR_ECP_INVALID_KEY
depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED
mbedtls_ecp_check_privkey:MBEDTLS_ECP_DP_CURVE25519:"C000000000000000000000000000000000000000000000000000000000000000":MBEDTLS_ERR_ECP_INVALID_KEY
ECP check privkey #6 (montgomery, not big enough)
depends_on:MBEDTLS_ECP_DP_M255_ENABLED
mbedtls_ecp_check_privkey:MBEDTLS_ECP_DP_M255:"3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0":MBEDTLS_ERR_ECP_INVALID_KEY
depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED
mbedtls_ecp_check_privkey:MBEDTLS_ECP_DP_CURVE25519:"3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0":MBEDTLS_ERR_ECP_INVALID_KEY
ECP check privkey #7 (montgomery, msb OK)
depends_on:MBEDTLS_ECP_DP_M255_ENABLED
mbedtls_ecp_check_privkey:MBEDTLS_ECP_DP_M255:"4000000000000000000000000000000000000000000000000000000000000000":0
depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED
mbedtls_ecp_check_privkey:MBEDTLS_ECP_DP_CURVE25519:"4000000000000000000000000000000000000000000000000000000000000000":0
ECP check privkey #8 (montgomery, bit 0 set)
depends_on:MBEDTLS_ECP_DP_M255_ENABLED
mbedtls_ecp_check_privkey:MBEDTLS_ECP_DP_M255:"4000000000000000000000000000000000000000000000000000000000000001":MBEDTLS_ERR_ECP_INVALID_KEY
depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED
mbedtls_ecp_check_privkey:MBEDTLS_ECP_DP_CURVE25519:"4000000000000000000000000000000000000000000000000000000000000001":MBEDTLS_ERR_ECP_INVALID_KEY
ECP check privkey #9 (montgomery, bit 1 set)
depends_on:MBEDTLS_ECP_DP_M255_ENABLED
mbedtls_ecp_check_privkey:MBEDTLS_ECP_DP_M255:"4000000000000000000000000000000000000000000000000000000000000002":MBEDTLS_ERR_ECP_INVALID_KEY
depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED
mbedtls_ecp_check_privkey:MBEDTLS_ECP_DP_CURVE25519:"4000000000000000000000000000000000000000000000000000000000000002":MBEDTLS_ERR_ECP_INVALID_KEY
ECP check privkey #10 (montgomery, bit 2 set)
depends_on:MBEDTLS_ECP_DP_M255_ENABLED
mbedtls_ecp_check_privkey:MBEDTLS_ECP_DP_M255:"4000000000000000000000000000000000000000000000000000000000000004":MBEDTLS_ERR_ECP_INVALID_KEY
depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED
mbedtls_ecp_check_privkey:MBEDTLS_ECP_DP_CURVE25519:"4000000000000000000000000000000000000000000000000000000000000004":MBEDTLS_ERR_ECP_INVALID_KEY
ECP check privkey #11 (montgomery, OK)
depends_on:MBEDTLS_ECP_DP_M255_ENABLED
mbedtls_ecp_check_privkey:MBEDTLS_ECP_DP_M255:"7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8":0
depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED
mbedtls_ecp_check_privkey:MBEDTLS_ECP_DP_CURVE25519:"7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8":0
ECP check public-private #1 (OK)
depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED
@ -227,8 +227,8 @@ depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED
mbedtls_ecp_gen_keypair:MBEDTLS_ECP_DP_SECP192R1
ECP gen keypair
depends_on:MBEDTLS_ECP_DP_M255_ENABLED
mbedtls_ecp_gen_keypair:MBEDTLS_ECP_DP_M255
depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED
mbedtls_ecp_gen_keypair:MBEDTLS_ECP_DP_CURVE25519
ECP gen keypair wrapper
depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED
@ -318,9 +318,9 @@ ECP test vectors brainpoolP512r1 rfc 7027
depends_on:MBEDTLS_ECP_DP_BP512R1_ENABLED
ecp_test_vect:MBEDTLS_ECP_DP_BP512R1:"16302FF0DBBB5A8D733DAB7141C1B45ACBC8715939677F6A56850A38BD87BD59B09E80279609FF333EB9D4C061231FB26F92EEB04982A5F1D1764CAD57665422":"0A420517E406AAC0ACDCE90FCD71487718D3B953EFD7FBEC5F7F27E28C6149999397E91E029E06457DB2D3E640668B392C2A7E737A7F0BF04436D11640FD09FD":"72E6882E8DB28AAD36237CD25D580DB23783961C8DC52DFA2EC138AD472A0FCEF3887CF62B623B2A87DE5C588301EA3E5FC269B373B60724F5E82A6AD147FDE7":"230E18E1BCC88A362FA54E4EA3902009292F7F8033624FD471B5D8ACE49D12CFABBC19963DAB8E2F1EBA00BFFB29E4D72D13F2224562F405CB80503666B25429":"9D45F66DE5D67E2E6DB6E93A59CE0BB48106097FF78A081DE781CDB31FCE8CCBAAEA8DD4320C4119F1E9CD437A2EAB3731FA9668AB268D871DEDA55A5473199F":"2FDC313095BCDD5FB3A91636F07A959C8E86B5636A1E930E8396049CB481961D365CC11453A06C719835475B12CB52FC3C383BCE35E27EF194512B71876285FA":"A7927098655F1F9976FA50A9D566865DC530331846381C87256BAF3226244B76D36403C024D7BBF0AA0803EAFF405D3D24F11A9B5C0BEF679FE1454B21C4CD1F":"7DB71C3DEF63212841C463E881BDCF055523BD368240E6C3143BD8DEF8B3B3223B95E0F53082FF5E412F4222537A43DF1C6D25729DDB51620A832BE6A26680A2"
ECP test vectors M255 aka Curve25519
depends_on:MBEDTLS_ECP_DP_M255_ENABLED
ecp_test_vec_x:MBEDTLS_ECP_DP_M255:"5AC99F33632E5A768DE7E81BF854C27C46E3FBF2ABBACD29EC4AFF517369C660":"057E23EA9F1CBE8A27168F6E696A791DE61DD3AF7ACD4EEACC6E7BA514FDA863":"47DC3D214174820E1154B49BC6CDB2ABD45EE95817055D255AA35831B70D3260":"6EB89DA91989AE37C7EAC7618D9E5C4951DBA1D73C285AE1CD26A855020EEF04":"61450CD98E36016B58776A897A9F0AEF738B99F09468B8D6B8511184D53494AB"
ECP test vectors Curve25519
depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED
ecp_test_vec_x:MBEDTLS_ECP_DP_CURVE25519:"5AC99F33632E5A768DE7E81BF854C27C46E3FBF2ABBACD29EC4AFF517369C660":"057E23EA9F1CBE8A27168F6E696A791DE61DD3AF7ACD4EEACC6E7BA514FDA863":"47DC3D214174820E1154B49BC6CDB2ABD45EE95817055D255AA35831B70D3260":"6EB89DA91989AE37C7EAC7618D9E5C4951DBA1D73C285AE1CD26A855020EEF04":"61450CD98E36016B58776A897A9F0AEF738B99F09468B8D6B8511184D53494AB"
ECP test vectors secp192k1
depends_on:MBEDTLS_ECP_DP_SECP192K1_ENABLED