From fdde2337a42465ceb83d55efc150ebab2f47676c Mon Sep 17 00:00:00 2001 From: Juliusz Sosinowicz Date: Fri, 6 Nov 2020 19:11:39 +0100 Subject: [PATCH] Add static buffer to wolfSSL_ERR_error_string Add ED448 and ED25519 to wolfssl_object_info Add more error messages --- src/ssl.c | 29 ++++++++++++++++++++++++++--- wolfssl/openssl/ec.h | 8 ++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/ssl.c b/src/ssl.c index fd95f80ca..c8bf9fcf7 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -3163,15 +3163,17 @@ int wolfSSL_want_write(WOLFSSL* ssl) char* wolfSSL_ERR_error_string(unsigned long errNumber, char* data) { - static wcchar msg = "Please supply a buffer for error string"; + static char tmp[WOLFSSL_MAX_ERROR_SZ] = {0}; WOLFSSL_ENTER("ERR_error_string"); if (data) { SetErrorString((int)errNumber, data); return data; } - - return (char*)msg; + else { + SetErrorString((int)errNumber, tmp); + return tmp; + } } @@ -7667,6 +7669,9 @@ WOLFSSL_EVP_PKEY* wolfSSL_d2i_PUBKEY(WOLFSSL_EVP_PKEY** out, return pkey; } + else { + WOLFSSL_MSG("RSA wolfSSL_EVP_PKEY_new error"); + } } wc_FreeRsaKey(&rsa); } @@ -7711,6 +7716,9 @@ WOLFSSL_EVP_PKEY* wolfSSL_d2i_PUBKEY(WOLFSSL_EVP_PKEY** out, return pkey; } + else { + WOLFSSL_MSG("ECC wolfSSL_EVP_PKEY_new error"); + } } wc_ecc_free(&ecc); } @@ -7758,6 +7766,9 @@ WOLFSSL_EVP_PKEY* wolfSSL_d2i_PUBKEY(WOLFSSL_EVP_PKEY** out, return pkey; } + else { + WOLFSSL_MSG("DSA wolfSSL_EVP_PKEY_new error"); + } } wc_FreeDsaKey(&dsa); } @@ -7806,12 +7817,18 @@ WOLFSSL_EVP_PKEY* wolfSSL_d2i_PUBKEY(WOLFSSL_EVP_PKEY** out, return pkey; } + else { + WOLFSSL_MSG("DH wolfSSL_EVP_PKEY_new error"); + } } wc_FreeDhKey(&dh); } #endif /* !HAVE_FIPS || HAVE_FIPS_VERSION > 2 */ #endif /* !NO_DH && (WOLFSSL_QT || OPENSSL_ALL) */ + if (pkey == NULL) + WOLFSSL_MSG("wolfSSL_d2i_PUBKEY couldn't determine key type"); + return pkey; } @@ -30434,6 +30451,12 @@ const WOLFSSL_ObjectInfo wolfssl_object_info[] = { #ifndef NO_DH { NID_dhKeyAgreement, DHk, oidKeyType, "dhKeyAgreement", "dhKeyAgreement"}, #endif + #ifdef HAVE_ED448 + { NID_ED448, ED448k, oidKeyType, "ED448", "ED448"}, + #endif + #ifdef HAVE_ED25519 + { NID_ED25519, ED25519k, oidKeyType, "ED25519", "ED25519"}, + #endif /* oidCurveType */ #ifdef HAVE_ECC diff --git a/wolfssl/openssl/ec.h b/wolfssl/openssl/ec.h index 83a413639..80cebb5fc 100644 --- a/wolfssl/openssl/ec.h +++ b/wolfssl/openssl/ec.h @@ -25,6 +25,7 @@ #define WOLFSSL_EC_H_ #include +#include #include #ifdef __cplusplus @@ -68,6 +69,13 @@ enum { NID_brainpoolP512r1 = 933, #endif +#ifdef HAVE_ED448 + NID_ED448 = ED448k, +#endif +#ifdef HAVE_ED25519 + NID_ED25519 = ED25519k, +#endif + OPENSSL_EC_NAMED_CURVE = 0x001 };