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>
diff --git a/library/ecjpake.c b/library/ecjpake.c
index bd47169..b835ac1 100644
--- a/library/ecjpake.c
+++ b/library/ecjpake.c
@@ -286,6 +286,13 @@
* Verification
*/
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,
&VV, &h, X, &r, G ) );