From 2d9466f1db2527d63b815e70a5bdcb5b5ae7f882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 19 Sep 2019 10:45:14 +0200 Subject: [PATCH] Minor preparatory changes in mbedtls_pk_check_pair() 1. Mark an RSA-alt-specific code path as such. 2. Move NULL check for wrapper function closer to the use of that function. Those are in preparation of the next commit. --- library/pk.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/library/pk.c b/library/pk.c index 30ee27527..2519d8765 100644 --- a/library/pk.c +++ b/library/pk.c @@ -584,24 +584,25 @@ int mbedtls_pk_check_pair( const mbedtls_pk_context *pub, const mbedtls_pk_conte PK_VALIDATE_RET( pub != NULL ); PK_VALIDATE_RET( prv != NULL ); - if( pub->pk_info == NULL || - prv->pk_info == NULL || - prv->pk_info->check_pair_func == NULL ) - { + if( pub->pk_info == NULL || prv->pk_info == NULL ) return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); - } +#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) if( pk_info_type( prv->pk_info ) == MBEDTLS_PK_RSA_ALT ) { if( pk_info_type( pub->pk_info ) != MBEDTLS_PK_RSA ) return( MBEDTLS_ERR_PK_TYPE_MISMATCH ); } else +#endif /* MBEDTLS_PK_RSA_ALT_SUPPORT */ { if( pub->pk_info != prv->pk_info ) return( MBEDTLS_ERR_PK_TYPE_MISMATCH ); } + if( prv->pk_info->check_pair_func == NULL ) + return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + return( pk_info_check_pair_func( prv->pk_info, pub->pk_ctx, prv->pk_ctx ) ); }