PKCS8 encrypted key depend on PKCS5 or PKCS12
This commit is contained in:
parent
92471fb3e5
commit
a2424a045a
@ -924,6 +924,7 @@ static int pk_parse_key_pkcs8_unencrypted_der(
|
||||
/*
|
||||
* Parse an encrypted PKCS#8 encoded private key
|
||||
*/
|
||||
#if defined(POLARSSL_PKCS12_C) || defined(POLARSSL_PKCS5_C)
|
||||
static int pk_parse_key_pkcs8_encrypted_der(
|
||||
pk_context *pk,
|
||||
const unsigned char *key, size_t keylen,
|
||||
@ -1041,6 +1042,7 @@ static int pk_parse_key_pkcs8_encrypted_der(
|
||||
|
||||
return( pk_parse_key_pkcs8_unencrypted_der( pk, buf, len ) );
|
||||
}
|
||||
#endif /* POLARSSL_PKCS12_C || POLARSSL_PKCS5_C */
|
||||
|
||||
/*
|
||||
* Parse a private key
|
||||
@ -1132,6 +1134,7 @@ int pk_parse_key( pk_context *pk,
|
||||
else if( ret != POLARSSL_ERR_PEM_NO_HEADER_FOOTER_PRESENT )
|
||||
return( ret );
|
||||
|
||||
#if defined(POLARSSL_PKCS12_C) || defined(POLARSSL_PKCS5_C)
|
||||
ret = pem_read_buffer( &pem,
|
||||
"-----BEGIN ENCRYPTED PRIVATE KEY-----",
|
||||
"-----END ENCRYPTED PRIVATE KEY-----",
|
||||
@ -1150,6 +1153,7 @@ int pk_parse_key( pk_context *pk,
|
||||
}
|
||||
else if( ret != POLARSSL_ERR_PEM_NO_HEADER_FOOTER_PRESENT )
|
||||
return( ret );
|
||||
#endif /* POLARSSL_PKCS12_C || POLARSSL_PKCS5_C */
|
||||
#else
|
||||
((void) pwd);
|
||||
((void) pwdlen);
|
||||
@ -1162,6 +1166,7 @@ int pk_parse_key( pk_context *pk,
|
||||
* We try the different DER format parsers to see if one passes without
|
||||
* error
|
||||
*/
|
||||
#if defined(POLARSSL_PKCS12_C) || defined(POLARSSL_PKCS5_C)
|
||||
if( ( ret = pk_parse_key_pkcs8_encrypted_der( pk, key, keylen,
|
||||
pwd, pwdlen ) ) == 0 )
|
||||
{
|
||||
@ -1174,6 +1179,7 @@ int pk_parse_key( pk_context *pk,
|
||||
{
|
||||
return( ret );
|
||||
}
|
||||
#endif /* POLARSSL_PKCS12_C || POLARSSL_PKCS5_C */
|
||||
|
||||
if( ( ret = pk_parse_key_pkcs8_unencrypted_der( pk, key, keylen ) ) == 0 )
|
||||
return( 0 );
|
||||
|
Loading…
Reference in New Issue
Block a user