Streamline code-path in rsa_rsassa_pkcs1_v15_encode

This commit is contained in:
Hanno Becker 2017-09-27 17:10:03 +01:00
parent c21a8db3fe
commit 2b2f898cbd

View file

@ -1229,15 +1229,14 @@ static int rsa_rsassa_pkcs1_v15_encode( mbedtls_md_type_t md_alg,
nb_pad -= hashlen; nb_pad -= hashlen;
} }
/* Signature header and padding delimiter */ /* Need space for signature header and padding delimiter (3 bytes),
if( nb_pad < 3 ) * and 8 bytes for the minimal padding */
if( nb_pad < 3 + 8 )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
nb_pad -= 3; nb_pad -= 3;
/* Now nb_pad is the amount of memory to be filled /* Now nb_pad is the amount of memory to be filled
* with padding; must be at least 8 bytes. */ * with padding, and at least 8 bytes long. */
if( nb_pad < 8 )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
/* Write signature header and padding */ /* Write signature header and padding */
*p++ = 0; *p++ = 0;