From 31f55ba6e9b2ef469e7ee367fda832c779bec9d7 Mon Sep 17 00:00:00 2001 From: Gerardo Ravago Date: Tue, 13 Feb 2024 10:24:33 -0500 Subject: [PATCH] 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 --- src/libstrongswan/plugins/openssl/openssl_ed_private_key.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/libstrongswan/plugins/openssl/openssl_ed_private_key.c b/src/libstrongswan/plugins/openssl/openssl_ed_private_key.c index 609e64080..e8d900d94 100644 --- a/src/libstrongswan/plugins/openssl/openssl_ed_private_key.c +++ b/src/libstrongswan/plugins/openssl/openssl_ed_private_key.c @@ -19,6 +19,7 @@ #if OPENSSL_VERSION_NUMBER >= 0x1010100fL && !defined(OPENSSL_NO_EC) #include "openssl_ed_private_key.h" +#include "openssl_util.h" #include @@ -157,8 +158,6 @@ METHOD(private_key_t, get_fingerprint, bool, METHOD(private_key_t, get_encoding, bool, private_private_key_t *this, cred_encoding_type_t type, chunk_t *encoding) { - u_char *p; - if (this->engine) { return FALSE; @@ -171,9 +170,7 @@ METHOD(private_key_t, get_encoding, bool, { bool success = TRUE; - *encoding = chunk_alloc(i2d_PrivateKey(this->key, NULL)); - p = encoding->ptr; - i2d_PrivateKey(this->key, &p); + *encoding = openssl_i2chunk(PrivateKey, this->key); if (type == PRIVKEY_PEM) {