Commit a2424a04 authored by Manuel Pégourié-Gonnard's avatar Manuel Pégourié-Gonnard
Browse files

PKCS8 encrypted key depend on PKCS5 or PKCS12

parent 92471fb3
......@@ -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 );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment