forked from wolfSSL/wolfssl
Added support for ECC private key with PKCS8 parsing. Fix is to attempt pkcs8 parse for -----BEGIN EC PRIVATE KEY-----
and if parse fails to treat as normal private key. ZD 4379.
This commit is contained in:
@@ -8512,12 +8512,20 @@ int PemToDer(const unsigned char* buff, long longSz, int type,
|
||||
der->buffer, &der->length) < 0)
|
||||
return BUFFER_E;
|
||||
|
||||
if (header == BEGIN_PRIV_KEY && !encrypted_key) {
|
||||
if ((header == BEGIN_PRIV_KEY
|
||||
#ifdef HAVE_ECC
|
||||
|| header == BEGIN_EC_PRIV
|
||||
#endif
|
||||
) && !encrypted_key)
|
||||
{
|
||||
/* pkcs8 key, convert and adjust length */
|
||||
if ((ret = ToTraditional(der->buffer, der->length)) < 0)
|
||||
return ret;
|
||||
if ((ret = ToTraditional(der->buffer, der->length)) > 0) {
|
||||
der->length = ret;
|
||||
}
|
||||
else {
|
||||
/* ignore failure here and assume key is not pkcs8 wrapped */
|
||||
}
|
||||
|
||||
der->length = ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user