mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-03 19:20:18 +00:00
Fix ECDSA signature verification edge-case
For R and S equal to 1, ensure the public key is checked for validity. Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
parent
1fdb8e8c17
commit
c947751a5f
@ -2666,14 +2666,17 @@ static int mbedtls_ecp_mul_shortcuts( mbedtls_ecp_group *grp,
|
|||||||
|
|
||||||
if( mbedtls_mpi_cmp_int( m, 0 ) == 0 )
|
if( mbedtls_mpi_cmp_int( m, 0 ) == 0 )
|
||||||
{
|
{
|
||||||
|
MBEDTLS_MPI_CHK( mbedtls_ecp_check_pubkey( grp, P ) );
|
||||||
MBEDTLS_MPI_CHK( mbedtls_ecp_set_zero( R ) );
|
MBEDTLS_MPI_CHK( mbedtls_ecp_set_zero( R ) );
|
||||||
}
|
}
|
||||||
else if( mbedtls_mpi_cmp_int( m, 1 ) == 0 )
|
else if( mbedtls_mpi_cmp_int( m, 1 ) == 0 )
|
||||||
{
|
{
|
||||||
|
MBEDTLS_MPI_CHK( mbedtls_ecp_check_pubkey( grp, P ) );
|
||||||
MBEDTLS_MPI_CHK( mbedtls_ecp_copy( R, P ) );
|
MBEDTLS_MPI_CHK( mbedtls_ecp_copy( R, P ) );
|
||||||
}
|
}
|
||||||
else if( mbedtls_mpi_cmp_int( m, -1 ) == 0 )
|
else if( mbedtls_mpi_cmp_int( m, -1 ) == 0 )
|
||||||
{
|
{
|
||||||
|
MBEDTLS_MPI_CHK( mbedtls_ecp_check_pubkey( grp, P ) );
|
||||||
MBEDTLS_MPI_CHK( mbedtls_ecp_copy( R, P ) );
|
MBEDTLS_MPI_CHK( mbedtls_ecp_copy( R, P ) );
|
||||||
MPI_ECP_NEG( &R->Y );
|
MPI_ECP_NEG( &R->Y );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user