PEM encoding for OpenSSL RSA and EC public and private keys
This commit is contained in:
@@ -226,11 +226,24 @@ static bool get_encoding(private_openssl_rsa_private_key_t *this,
|
||||
switch (type)
|
||||
{
|
||||
case KEY_PRIV_ASN1_DER:
|
||||
case KEY_PRIV_PEM:
|
||||
{
|
||||
bool success = TRUE;
|
||||
|
||||
*encoding = chunk_alloc(i2d_RSAPrivateKey(this->rsa, NULL));
|
||||
p = encoding->ptr;
|
||||
i2d_RSAPrivateKey(this->rsa, &p);
|
||||
return TRUE;
|
||||
|
||||
if (type == KEY_PRIV_PEM)
|
||||
{
|
||||
chunk_t asn1_encoding = *encoding;
|
||||
|
||||
success = lib->encoding->encode(lib->encoding, KEY_PRIV_PEM,
|
||||
NULL, encoding, KEY_PART_RSA_PRIV_ASN1_DER,
|
||||
asn1_encoding, KEY_PART_END);
|
||||
chunk_clear(&asn1_encoding);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
default:
|
||||
return FALSE;
|
||||
|
||||
Reference in New Issue
Block a user