mirror of
				https://github.com/cuberite/polarssl.git
				synced 2025-11-03 20:22:59 -05:00 
			
		
		
		
	Some operations are not supported with Curve25519
This commit is contained in:
		
							parent
							
								
									3d7053a2bb
								
							
						
					
					
						commit
						97871ef236
					
				@ -444,6 +444,9 @@ int ecp_tls_write_group( const ecp_group *grp, size_t *olen,
 | 
			
		||||
 *
 | 
			
		||||
 * \return          0 if successful,
 | 
			
		||||
 *                  POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed
 | 
			
		||||
 *
 | 
			
		||||
 * \note            This function does not support Montgomery curves, such as
 | 
			
		||||
 *                  Curve25519.
 | 
			
		||||
 */
 | 
			
		||||
int ecp_add( const ecp_group *grp, ecp_point *R,
 | 
			
		||||
             const ecp_point *P, const ecp_point *Q );
 | 
			
		||||
@ -458,6 +461,9 @@ int ecp_add( const ecp_group *grp, ecp_point *R,
 | 
			
		||||
 *
 | 
			
		||||
 * \return          0 if successful,
 | 
			
		||||
 *                  POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed
 | 
			
		||||
 *
 | 
			
		||||
 * \note            This function does not support Montgomery curves, such as
 | 
			
		||||
 *                  Curve25519.
 | 
			
		||||
 */
 | 
			
		||||
int ecp_sub( const ecp_group *grp, ecp_point *R,
 | 
			
		||||
             const ecp_point *P, const ecp_point *Q );
 | 
			
		||||
 | 
			
		||||
@ -59,6 +59,10 @@ int ecdsa_sign( ecp_group *grp, mpi *r, mpi *s,
 | 
			
		||||
    ecp_point R;
 | 
			
		||||
    mpi k, e;
 | 
			
		||||
 | 
			
		||||
    /* Fail cleanly on curves such as Curve25519 that can't be used for ECDSA */
 | 
			
		||||
    if( grp->N.p == NULL )
 | 
			
		||||
        return( POLARSSL_ERR_ECP_BAD_INPUT_DATA );
 | 
			
		||||
 | 
			
		||||
    ecp_point_init( &R );
 | 
			
		||||
    mpi_init( &k );
 | 
			
		||||
    mpi_init( &e );
 | 
			
		||||
@ -129,6 +133,10 @@ int ecdsa_verify( ecp_group *grp,
 | 
			
		||||
    ecp_point_init( &R ); ecp_point_init( &P );
 | 
			
		||||
    mpi_init( &e ); mpi_init( &s_inv ); mpi_init( &u1 ); mpi_init( &u2 );
 | 
			
		||||
 | 
			
		||||
    /* Fail cleanly on curves such as Curve25519 that can't be used for ECDSA */
 | 
			
		||||
    if( grp->N.p == NULL )
 | 
			
		||||
        return( POLARSSL_ERR_ECP_BAD_INPUT_DATA );
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * Step 1: make sure r and s are in range 1..n-1
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
@ -946,6 +946,9 @@ int ecp_add( const ecp_group *grp, ecp_point *R,
 | 
			
		||||
{
 | 
			
		||||
    int ret;
 | 
			
		||||
 | 
			
		||||
    if( ecp_is_montgomery( grp ) )
 | 
			
		||||
        return( POLARSSL_ERR_ECP_FEATURE_UNAVAILABLE );
 | 
			
		||||
 | 
			
		||||
    MPI_CHK( ecp_add_mixed( grp, R, P, Q ) );
 | 
			
		||||
    MPI_CHK( ecp_normalize_jac( grp, R ) );
 | 
			
		||||
 | 
			
		||||
@ -965,6 +968,9 @@ int ecp_sub( const ecp_group *grp, ecp_point *R,
 | 
			
		||||
 | 
			
		||||
    ecp_point_init( &mQ );
 | 
			
		||||
 | 
			
		||||
    if( ecp_is_montgomery( grp ) )
 | 
			
		||||
        return( POLARSSL_ERR_ECP_FEATURE_UNAVAILABLE );
 | 
			
		||||
 | 
			
		||||
    /* mQ = - Q */
 | 
			
		||||
    ecp_copy( &mQ, Q );
 | 
			
		||||
    if( mpi_cmp_int( &mQ.Y, 0 ) != 0 )
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user