From 2e9eef4f7b3939ac76b7c0790437b4a7bd6e1996 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Tue, 28 Jan 2020 14:43:52 -0500 Subject: [PATCH] Final review comments --- library/pkparse.c | 22 +++++++--------------- library/rsa.c | 2 +- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/library/pkparse.c b/library/pkparse.c index ac631d93d..7df30fea9 100644 --- a/library/pkparse.c +++ b/library/pkparse.c @@ -782,25 +782,17 @@ static int pk_parse_key_pkcs1_der( mbedtls_rsa_context *rsa, */ /* Import DP */ - if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, - MBEDTLS_ASN1_INTEGER ) ) != 0 || - ( ret = mbedtls_mpi_read_binary( &rsa->DP, p, len ) ) != 0 ) - goto cleanup; - p += len; + if( ( ret = mbedtls_asn1_get_mpi( &p, end, &rsa->DP ) ) != 0) + goto cleanup; /* Import DQ */ - if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, - MBEDTLS_ASN1_INTEGER ) ) != 0 || - ( ret = mbedtls_mpi_read_binary( &rsa->DQ, p, len ) ) != 0 ) - goto cleanup; - p += len; + if( ( ret = mbedtls_asn1_get_mpi( &p, end, &rsa->DQ ) ) != 0) + goto cleanup; /* Import QP */ - if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, - MBEDTLS_ASN1_INTEGER ) ) != 0 || - ( ret = mbedtls_mpi_read_binary( &rsa->QP, p, len ) ) != 0 ) - goto cleanup; - p += len; + if( ( ret = mbedtls_asn1_get_mpi( &p, end, &rsa->QP ) ) != 0) + goto cleanup; + #else /* Verify existance of the CRT params */ if( ( ret = mbedtls_asn1_get_mpi( &p, end, &T ) ) != 0 || diff --git a/library/rsa.c b/library/rsa.c index dc34e38b4..6c457468e 100644 --- a/library/rsa.c +++ b/library/rsa.c @@ -334,7 +334,7 @@ int mbedtls_rsa_complete( mbedtls_rsa_context *ctx ) */ #if !defined(MBEDTLS_RSA_NO_CRT) - if( is_priv && !(have_DP && have_DQ && have_QP)) + if( is_priv && ! ( have_DP && have_DQ && have_QP ) ) { ret = mbedtls_rsa_deduce_crt( &ctx->P, &ctx->Q, &ctx->D, &ctx->DP, &ctx->DQ, &ctx->QP );