mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-02-03 13:01:04 +00:00
Fix EC J-PAKE failing when the payload is all-bits-zero
Fix function mbedtls_ecp_mul_shortcuts() to skip multiplication when m is 0 and simply assignt 0 to R. Additionally fix ecjpake_zkp_read() to return MBEDTLS_ERR_ECP_INVALID_KEY when the above condintion is met. Fix #1792 Signed-off-by: TRodziewicz <rodziewicz@gmail.com>
This commit is contained in:
parent
2ac5f8c04b
commit
9edff740e1
4
ChangeLog.d/issue1792.txt
Normal file
4
ChangeLog.d/issue1792.txt
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
Bugfix
|
||||||
|
* Fix a bug in EC J-PAKE that would cause it fail when the payload is all-
|
||||||
|
bits-zero.
|
||||||
|
Found by Gilles Peskine, reported in #1792.
|
|
@ -286,6 +286,13 @@ static int ecjpake_zkp_read( const mbedtls_md_info_t *md_info,
|
||||||
* Verification
|
* Verification
|
||||||
*/
|
*/
|
||||||
MBEDTLS_MPI_CHK( ecjpake_hash( md_info, grp, pf, G, &V, X, id, &h ) );
|
MBEDTLS_MPI_CHK( ecjpake_hash( md_info, grp, pf, G, &V, X, id, &h ) );
|
||||||
|
|
||||||
|
if( mbedtls_mpi_cmp_int( &r,0 ) == 0 )
|
||||||
|
{
|
||||||
|
ret = MBEDTLS_ERR_ECP_INVALID_KEY;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
MBEDTLS_MPI_CHK( mbedtls_ecp_muladd( (mbedtls_ecp_group *) grp,
|
MBEDTLS_MPI_CHK( mbedtls_ecp_muladd( (mbedtls_ecp_group *) grp,
|
||||||
&VV, &h, X, &r, G ) );
|
&VV, &h, X, &r, G ) );
|
||||||
|
|
||||||
|
|
|
@ -2795,7 +2795,7 @@ cleanup:
|
||||||
|
|
||||||
#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED)
|
#if defined(MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED)
|
||||||
/*
|
/*
|
||||||
* R = m * P with shortcuts for m == 1 and m == -1
|
* R = m * P with shortcuts for m == 0, m == 1 and m == -1
|
||||||
* NOT constant-time - ONLY for short Weierstrass!
|
* NOT constant-time - ONLY for short Weierstrass!
|
||||||
*/
|
*/
|
||||||
static int mbedtls_ecp_mul_shortcuts( mbedtls_ecp_group *grp,
|
static int mbedtls_ecp_mul_shortcuts( mbedtls_ecp_group *grp,
|
||||||
|
@ -2806,7 +2806,11 @@ static int mbedtls_ecp_mul_shortcuts( mbedtls_ecp_group *grp,
|
||||||
{
|
{
|
||||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||||
|
|
||||||
if( mbedtls_mpi_cmp_int( m, 1 ) == 0 )
|
if ( mbedtls_mpi_cmp_int( m, 0 ) == 0 )
|
||||||
|
{
|
||||||
|
MBEDTLS_MPI_CHK( mbedtls_ecp_set_zero( R ) );
|
||||||
|
}
|
||||||
|
else if( mbedtls_mpi_cmp_int( m, 1 ) == 0 )
|
||||||
{
|
{
|
||||||
MBEDTLS_MPI_CHK( mbedtls_ecp_copy( R, P ) );
|
MBEDTLS_MPI_CHK( mbedtls_ecp_copy( R, P ) );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue