From 4481f9b626f6f0694b218f08b4c14db7edf8a5f8 Mon Sep 17 00:00:00 2001 From: Kareem Date: Tue, 31 Oct 2023 14:35:36 -0700 Subject: [PATCH] Add stub for wolfSSL_set_ecdh_auto. --- src/ssl.c | 11 +++++++++++ tests/api.c | 14 ++++++++++++++ wolfssl/openssl/ssl.h | 1 + wolfssl/ssl.h | 1 + 4 files changed, 27 insertions(+) diff --git a/src/ssl.c b/src/ssl.c index 2c996310c5..993c727df5 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -23192,6 +23192,17 @@ unsigned long wolfSSL_THREADID_hash(const WOLFSSL_CRYPTO_THREADID* id) (void)id; return 0UL; } +/* wolfSSL_set_ecdh_auto is provided as compatible API with + * SSL_set_ecdh_auto to enable auto ecdh curve selection functionality. + * Since this functionality is enabled by default in wolfSSL, + * this API exists as a stub. + */ +int wolfSSL_set_ecdh_auto(WOLFSSL* ssl, int onoff) +{ + (void)ssl; + (void)onoff; + return WOLFSSL_SUCCESS; +} /* wolfSSL_CTX_set_ecdh_auto is provided as compatible API with * SSL_CTX_set_ecdh_auto to enable auto ecdh curve selection functionality. * Since this functionality is enabled by default in wolfSSL, diff --git a/tests/api.c b/tests/api.c index 4c1f8e8d77..82c8b40256 100644 --- a/tests/api.c +++ b/tests/api.c @@ -64442,6 +64442,19 @@ static int test_wolfSSL_THREADID_hash(void) #endif /* OPENSSL_EXTRA */ return EXPECT_RESULT(); } +static int test_wolfSSL_set_ecdh_auto(void) +{ + EXPECT_DECLS; +#if defined(OPENSSL_EXTRA) + WOLFSSL* ssl = NULL; + + ExpectIntEQ(SSL_set_ecdh_auto(NULL,0), 1); + ExpectIntEQ(SSL_set_ecdh_auto(NULL,1), 1); + ExpectIntEQ(SSL_set_ecdh_auto(ssl,0), 1); + ExpectIntEQ(SSL_set_ecdh_auto(ssl,1), 1); +#endif /* OPENSSL_EXTRA */ + return EXPECT_RESULT(); +} static int test_wolfSSL_CTX_set_ecdh_auto(void) { EXPECT_DECLS; @@ -73030,6 +73043,7 @@ TEST_CASE testCases[] = { /* Can't memory test as server hangs. */ TEST_DECL(test_wolfSSL_Tls13_Key_Logging_test), TEST_DECL(test_wolfSSL_Tls13_postauth), + TEST_DECL(test_wolfSSL_set_ecdh_auto), TEST_DECL(test_wolfSSL_CTX_set_ecdh_auto), TEST_DECL(test_wolfSSL_set_minmax_proto_version), TEST_DECL(test_wolfSSL_CTX_set_max_proto_version), diff --git a/wolfssl/openssl/ssl.h b/wolfssl/openssl/ssl.h index 5de9bb1611..39abccb260 100644 --- a/wolfssl/openssl/ssl.h +++ b/wolfssl/openssl/ssl.h @@ -210,6 +210,7 @@ typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS; #define i2d_PKCS8PrivateKey_bio wolfSSL_PEM_write_bio_PKCS8PrivateKey #define PKCS8_PRIV_KEY_INFO_free wolfSSL_EVP_PKEY_free #define d2i_PKCS12_fp wolfSSL_d2i_PKCS12_fp +#define SSL_set_ecdh_auto wolfSSL_set_ecdh_auto #define SSL_CTX_set_ecdh_auto wolfSSL_CTX_set_ecdh_auto #define i2d_PUBKEY wolfSSL_i2d_PUBKEY diff --git a/wolfssl/ssl.h b/wolfssl/ssl.h index d4fb17ca65..dbcb336ddd 100644 --- a/wolfssl/ssl.h +++ b/wolfssl/ssl.h @@ -1135,6 +1135,7 @@ WOLFSSL_API WOLFSSL_CTX* wolfSSL_CTX_new_ex(WOLFSSL_METHOD* method, void* heap); WOLFSSL_ABI WOLFSSL_API WOLFSSL_CTX* wolfSSL_CTX_new(WOLFSSL_METHOD* method); WOLFSSL_API int wolfSSL_CTX_up_ref(WOLFSSL_CTX* ctx); #ifdef OPENSSL_EXTRA +WOLFSSL_API int wolfSSL_set_ecdh_auto(WOLFSSL* ssl, int onoff); WOLFSSL_API int wolfSSL_CTX_set_ecdh_auto(WOLFSSL_CTX* ctx, int onoff); WOLFSSL_API int wolfSSL_get_signature_nid(WOLFSSL* ssl, int* nid); WOLFSSL_API int wolfSSL_get_signature_type_nid(const WOLFSSL* ssl, int* nid);