File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -820,9 +820,20 @@ static int pk_parse_key_pkcs1_der( mbedtls_rsa_context *rsa,
820
820
goto cleanup ;
821
821
#endif
822
822
823
- /* Complete the RSA private key */
824
- if ( ( ret = mbedtls_rsa_complete ( rsa ) ) != 0 )
823
+ /* rsa_complete() doesn't complete anything with the default
824
+ * implementation but is still called:
825
+ * - for the benefit of alternative implementation that may want to
826
+ * pre-compute stuff beyond what's provided (eg Montgomery factors)
827
+ * - as is also sanity-checks the key
828
+ *
829
+ * Furthermore, we also check the public part for consistency with
830
+ * mbedtls_pk_parse_pubkey(), as it includes size minima for example.
831
+ */
832
+ if ( ( ret = mbedtls_rsa_complete ( rsa ) ) != 0 ||
833
+ ( ret = mbedtls_rsa_check_pubkey ( rsa ) ) != 0 )
834
+ {
825
835
goto cleanup ;
836
+ }
826
837
827
838
if ( p != end )
828
839
{
You can’t perform that action at this time.
0 commit comments