diff --git a/library/ecp.c b/library/ecp.c index 7cfb44f2c1..d742e812bc 100644 --- a/library/ecp.c +++ b/library/ecp.c @@ -483,8 +483,13 @@ int ecp_point_read_binary( const ecp_group *grp, ecp_point *pt, int ret; size_t plen; - if( ilen == 1 && buf[0] == 0x00 ) - return( ecp_set_zero( pt ) ); + if( buf[0] == 0x00 ) + { + if( ilen == 1 ) + return( ecp_set_zero( pt ) ); + else + return( POLARSSL_ERR_ECP_BAD_INPUT_DATA ); + } plen = mpi_size( &grp->P ); diff --git a/tests/suites/test_suite_ecp.data b/tests/suites/test_suite_ecp.data index a1833d4e84..278fa88f9c 100644 --- a/tests/suites/test_suite_ecp.data +++ b/tests/suites/test_suite_ecp.data @@ -213,7 +213,7 @@ ecp_read_binary:POLARSSL_ECP_DP_SECP192R1:"0000":"01":"01":"00":POLARSSL_ERR_ECP ECP read binary #2 (zero, invalid first byte) depends_on:POLARSSL_ECP_DP_SECP192R1_ENABLED -ecp_read_binary:POLARSSL_ECP_DP_SECP192R1:"01":"01":"01":"00":POLARSSL_ERR_ECP_BAD_INPUT_DATA +ecp_read_binary:POLARSSL_ECP_DP_SECP192R1:"01":"01":"01":"00":POLARSSL_ERR_ECP_FEATURE_UNAVAILABLE ECP read binary #3 (zero, OK) depends_on:POLARSSL_ECP_DP_SECP192R1_ENABLED @@ -225,7 +225,7 @@ ecp_read_binary:POLARSSL_ECP_DP_SECP192R1:"04001122":"01":"01":"00":POLARSSL_ERR ECP read binary #5 (non-zero, invalid first byte) depends_on:POLARSSL_ECP_DP_SECP192R1_ENABLED -ecp_read_binary:POLARSSL_ECP_DP_SECP192R1:"0548d8082a3a1e3112bc03a8ef2f6d40d0a77a6f8e00cc99336ceed4d7cba482e288669ee1b6415626d6f34d28501e060c":"48d8082a3a1e3112bc03a8ef2f6d40d0a77a6f8e00cc9933":"6ceed4d7cba482e288669ee1b6415626d6f34d28501e060c":"01":POLARSSL_ERR_ECP_BAD_INPUT_DATA +ecp_read_binary:POLARSSL_ECP_DP_SECP192R1:"0548d8082a3a1e3112bc03a8ef2f6d40d0a77a6f8e00cc99336ceed4d7cba482e288669ee1b6415626d6f34d28501e060c":"48d8082a3a1e3112bc03a8ef2f6d40d0a77a6f8e00cc9933":"6ceed4d7cba482e288669ee1b6415626d6f34d28501e060c":"01":POLARSSL_ERR_ECP_FEATURE_UNAVAILABLE ECP read binary #6 (non-zero, OK) depends_on:POLARSSL_ECP_DP_SECP192R1_ENABLED diff --git a/tests/suites/test_suite_ecp.function b/tests/suites/test_suite_ecp.function index 1f04d678c1..50a95e1551 100644 --- a/tests/suites/test_suite_ecp.function +++ b/tests/suites/test_suite_ecp.function @@ -472,7 +472,7 @@ void ecp_tls_write_read_point( int id ) TEST_ASSERT( ecp_tls_write_point( &grp, &grp.G, POLARSSL_ECP_PF_COMPRESSED, &olen, buf, 256 ) == 0 ); TEST_ASSERT( ecp_tls_read_point( &grp, &pt, &vbuf, olen ) - == POLARSSL_ERR_ECP_BAD_INPUT_DATA ); + == POLARSSL_ERR_ECP_FEATURE_UNAVAILABLE ); TEST_ASSERT( vbuf == buf + olen ); memset( buf, 0x00, sizeof( buf ) ); vbuf = buf;