openssl: Add missing error checking when encoding ED private key
This applies the same logic found in other private key implementations like that for ECDSA. Closes strongswan/strongswan#2097
This commit is contained in:
committed by
Tobias Brunner
parent
e6176bf19c
commit
31f55ba6e9
@@ -19,6 +19,7 @@
|
|||||||
#if OPENSSL_VERSION_NUMBER >= 0x1010100fL && !defined(OPENSSL_NO_EC)
|
#if OPENSSL_VERSION_NUMBER >= 0x1010100fL && !defined(OPENSSL_NO_EC)
|
||||||
|
|
||||||
#include "openssl_ed_private_key.h"
|
#include "openssl_ed_private_key.h"
|
||||||
|
#include "openssl_util.h"
|
||||||
|
|
||||||
#include <utils/debug.h>
|
#include <utils/debug.h>
|
||||||
|
|
||||||
@@ -157,8 +158,6 @@ METHOD(private_key_t, get_fingerprint, bool,
|
|||||||
METHOD(private_key_t, get_encoding, bool,
|
METHOD(private_key_t, get_encoding, bool,
|
||||||
private_private_key_t *this, cred_encoding_type_t type, chunk_t *encoding)
|
private_private_key_t *this, cred_encoding_type_t type, chunk_t *encoding)
|
||||||
{
|
{
|
||||||
u_char *p;
|
|
||||||
|
|
||||||
if (this->engine)
|
if (this->engine)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -171,9 +170,7 @@ METHOD(private_key_t, get_encoding, bool,
|
|||||||
{
|
{
|
||||||
bool success = TRUE;
|
bool success = TRUE;
|
||||||
|
|
||||||
*encoding = chunk_alloc(i2d_PrivateKey(this->key, NULL));
|
*encoding = openssl_i2chunk(PrivateKey, this->key);
|
||||||
p = encoding->ptr;
|
|
||||||
i2d_PrivateKey(this->key, &p);
|
|
||||||
|
|
||||||
if (type == PRIVKEY_PEM)
|
if (type == PRIVKEY_PEM)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user