mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-02-11 09:40:38 +00:00
Remove NULL pointer validation in ecjpake.c
Signed-off-by: Tuvshinzaya Erdenekhuu <tuvshinzaya.erdenekhuu@arm.com>
This commit is contained in:
parent
2392419c9d
commit
2b1ecdaf4e
@ -56,8 +56,6 @@ static const char * const ecjpake_id[] = {
|
|||||||
*/
|
*/
|
||||||
void mbedtls_ecjpake_init( mbedtls_ecjpake_context *ctx )
|
void mbedtls_ecjpake_init( mbedtls_ecjpake_context *ctx )
|
||||||
{
|
{
|
||||||
ECJPAKE_VALIDATE( ctx != NULL );
|
|
||||||
|
|
||||||
ctx->md_info = NULL;
|
ctx->md_info = NULL;
|
||||||
mbedtls_ecp_group_init( &ctx->grp );
|
mbedtls_ecp_group_init( &ctx->grp );
|
||||||
ctx->point_format = MBEDTLS_ECP_PF_UNCOMPRESSED;
|
ctx->point_format = MBEDTLS_ECP_PF_UNCOMPRESSED;
|
||||||
@ -107,10 +105,8 @@ int mbedtls_ecjpake_setup( mbedtls_ecjpake_context *ctx,
|
|||||||
{
|
{
|
||||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||||
|
|
||||||
ECJPAKE_VALIDATE_RET( ctx != NULL );
|
|
||||||
ECJPAKE_VALIDATE_RET( role == MBEDTLS_ECJPAKE_CLIENT ||
|
ECJPAKE_VALIDATE_RET( role == MBEDTLS_ECJPAKE_CLIENT ||
|
||||||
role == MBEDTLS_ECJPAKE_SERVER );
|
role == MBEDTLS_ECJPAKE_SERVER );
|
||||||
ECJPAKE_VALIDATE_RET( secret != NULL || len == 0 );
|
|
||||||
|
|
||||||
ctx->role = role;
|
ctx->role = role;
|
||||||
|
|
||||||
@ -147,8 +143,6 @@ int mbedtls_ecjpake_set_point_format( mbedtls_ecjpake_context *ctx,
|
|||||||
*/
|
*/
|
||||||
int mbedtls_ecjpake_check( const mbedtls_ecjpake_context *ctx )
|
int mbedtls_ecjpake_check( const mbedtls_ecjpake_context *ctx )
|
||||||
{
|
{
|
||||||
ECJPAKE_VALIDATE_RET( ctx != NULL );
|
|
||||||
|
|
||||||
if( ctx->md_info == NULL ||
|
if( ctx->md_info == NULL ||
|
||||||
ctx->grp.id == MBEDTLS_ECP_DP_NONE ||
|
ctx->grp.id == MBEDTLS_ECP_DP_NONE ||
|
||||||
ctx->s.p == NULL )
|
ctx->s.p == NULL )
|
||||||
@ -521,9 +515,6 @@ int mbedtls_ecjpake_read_round_one( mbedtls_ecjpake_context *ctx,
|
|||||||
const unsigned char *buf,
|
const unsigned char *buf,
|
||||||
size_t len )
|
size_t len )
|
||||||
{
|
{
|
||||||
ECJPAKE_VALIDATE_RET( ctx != NULL );
|
|
||||||
ECJPAKE_VALIDATE_RET( buf != NULL );
|
|
||||||
|
|
||||||
return( ecjpake_kkpp_read( ctx->md_info, &ctx->grp, ctx->point_format,
|
return( ecjpake_kkpp_read( ctx->md_info, &ctx->grp, ctx->point_format,
|
||||||
&ctx->grp.G,
|
&ctx->grp.G,
|
||||||
&ctx->Xp1, &ctx->Xp2, ID_PEER,
|
&ctx->Xp1, &ctx->Xp2, ID_PEER,
|
||||||
@ -538,11 +529,6 @@ int mbedtls_ecjpake_write_round_one( mbedtls_ecjpake_context *ctx,
|
|||||||
int (*f_rng)(void *, unsigned char *, size_t),
|
int (*f_rng)(void *, unsigned char *, size_t),
|
||||||
void *p_rng )
|
void *p_rng )
|
||||||
{
|
{
|
||||||
ECJPAKE_VALIDATE_RET( ctx != NULL );
|
|
||||||
ECJPAKE_VALIDATE_RET( buf != NULL );
|
|
||||||
ECJPAKE_VALIDATE_RET( olen != NULL );
|
|
||||||
ECJPAKE_VALIDATE_RET( f_rng != NULL );
|
|
||||||
|
|
||||||
return( ecjpake_kkpp_write( ctx->md_info, &ctx->grp, ctx->point_format,
|
return( ecjpake_kkpp_write( ctx->md_info, &ctx->grp, ctx->point_format,
|
||||||
&ctx->grp.G,
|
&ctx->grp.G,
|
||||||
&ctx->xm1, &ctx->Xm1, &ctx->xm2, &ctx->Xm2,
|
&ctx->xm1, &ctx->Xm1, &ctx->xm2, &ctx->Xm2,
|
||||||
@ -585,9 +571,6 @@ int mbedtls_ecjpake_read_round_two( mbedtls_ecjpake_context *ctx,
|
|||||||
mbedtls_ecp_group grp;
|
mbedtls_ecp_group grp;
|
||||||
mbedtls_ecp_point G; /* C: GB, S: GA */
|
mbedtls_ecp_point G; /* C: GB, S: GA */
|
||||||
|
|
||||||
ECJPAKE_VALIDATE_RET( ctx != NULL );
|
|
||||||
ECJPAKE_VALIDATE_RET( buf != NULL );
|
|
||||||
|
|
||||||
mbedtls_ecp_group_init( &grp );
|
mbedtls_ecp_group_init( &grp );
|
||||||
mbedtls_ecp_point_init( &G );
|
mbedtls_ecp_point_init( &G );
|
||||||
|
|
||||||
@ -680,11 +663,6 @@ int mbedtls_ecjpake_write_round_two( mbedtls_ecjpake_context *ctx,
|
|||||||
const unsigned char *end = buf + len;
|
const unsigned char *end = buf + len;
|
||||||
size_t ec_len;
|
size_t ec_len;
|
||||||
|
|
||||||
ECJPAKE_VALIDATE_RET( ctx != NULL );
|
|
||||||
ECJPAKE_VALIDATE_RET( buf != NULL );
|
|
||||||
ECJPAKE_VALIDATE_RET( olen != NULL );
|
|
||||||
ECJPAKE_VALIDATE_RET( f_rng != NULL );
|
|
||||||
|
|
||||||
mbedtls_ecp_point_init( &G );
|
mbedtls_ecp_point_init( &G );
|
||||||
mbedtls_ecp_point_init( &Xm );
|
mbedtls_ecp_point_init( &Xm );
|
||||||
mbedtls_mpi_init( &xm );
|
mbedtls_mpi_init( &xm );
|
||||||
@ -760,11 +738,6 @@ int mbedtls_ecjpake_derive_secret( mbedtls_ecjpake_context *ctx,
|
|||||||
unsigned char kx[MBEDTLS_ECP_MAX_BYTES];
|
unsigned char kx[MBEDTLS_ECP_MAX_BYTES];
|
||||||
size_t x_bytes;
|
size_t x_bytes;
|
||||||
|
|
||||||
ECJPAKE_VALIDATE_RET( ctx != NULL );
|
|
||||||
ECJPAKE_VALIDATE_RET( buf != NULL );
|
|
||||||
ECJPAKE_VALIDATE_RET( olen != NULL );
|
|
||||||
ECJPAKE_VALIDATE_RET( f_rng != NULL );
|
|
||||||
|
|
||||||
*olen = mbedtls_md_get_size( ctx->md_info );
|
*olen = mbedtls_md_get_size( ctx->md_info );
|
||||||
if( len < *olen )
|
if( len < *olen )
|
||||||
return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL );
|
return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user