mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-25 16:55:37 +00:00
Check public part when parsing private RSA key
This commit is contained in:
parent
8cc0491966
commit
869e9668dd
|
@ -805,9 +805,20 @@ static int pk_parse_key_pkcs1_der( mbedtls_rsa_context *rsa,
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Complete the RSA private key */
|
/* rsa_complete() doesn't complete anything with the default
|
||||||
if( ( ret = mbedtls_rsa_complete( rsa ) ) != 0 )
|
* implementation but is still called:
|
||||||
|
* - for the benefit of alternative implementation that may want to
|
||||||
|
* pre-compute stuff beyond what's provided (eg Montgomery factors)
|
||||||
|
* - as is also sanity-checks the key
|
||||||
|
*
|
||||||
|
* Furthermore, we also check the public part for consistency with
|
||||||
|
* mbedtls_pk_parse_pubkey(), as it includes size minima for example.
|
||||||
|
*/
|
||||||
|
if( ( ret = mbedtls_rsa_complete( rsa ) ) != 0 ||
|
||||||
|
( ret = mbedtls_rsa_check_pubkey( rsa ) ) != 0 )
|
||||||
|
{
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if( p != end )
|
if( p != end )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue