diff --git a/src/ssl_bn.c b/src/ssl_bn.c index e88ca03c2..0d947a8b5 100644 --- a/src/ssl_bn.c +++ b/src/ssl_bn.c @@ -2382,6 +2382,27 @@ WOLFSSL_BN_CTX* wolfSSL_BN_CTX_new(void) return ctx; } + +#ifndef NO_WOLFSSL_STUB +/* deprecated + * + * Initialize a BN context object. + * This function was removed in OpenSSL 1.1.0 and later. + * Keeping a stub function here for older applications that have BN_CTX_init() + * calls. + * + * @param [in] ctx Dummy BN context. + */ +void wolfSSL_BN_CTX_init(WOLFSSL_BN_CTX* ctx) +{ + (void)ctx; + WOLFSSL_ENTER("wolfSSL_BN_CTX_init"); + WOLFSSL_STUB("wolfSSL_BN_CTX_init"); + WOLFSSL_MSG("wolfSSL_BN_CTX_init is deprecated"); +} +#endif + + /* Free a BN context object. * * @param [in] ctx BN context object. diff --git a/tests/api.c b/tests/api.c index 88a6dfd6a..f49a5c52f 100644 --- a/tests/api.c +++ b/tests/api.c @@ -28725,6 +28725,9 @@ static int test_wolfSSL_BN_CTX(void) ExpectNotNull(bn_ctx = BN_CTX_new()); + /* No implementation. */ + BN_CTX_init(NULL); + ExpectNull(BN_CTX_get(NULL)); ExpectNotNull(BN_CTX_get(bn_ctx)); ExpectNotNull(BN_CTX_get(bn_ctx)); diff --git a/wolfssl/openssl/bn.h b/wolfssl/openssl/bn.h index c4768b286..8ffdb279d 100644 --- a/wolfssl/openssl/bn.h +++ b/wolfssl/openssl/bn.h @@ -88,6 +88,7 @@ typedef struct WOLFSSL_BN_MONT_CTX WOLFSSL_BN_MONT_CTX; typedef struct WOLFSSL_BN_GENCB WOLFSSL_BN_GENCB; WOLFSSL_API WOLFSSL_BN_CTX* wolfSSL_BN_CTX_new(void); +WOLFSSL_API void wolfSSL_BN_CTX_init(WOLFSSL_BN_CTX* ctx); WOLFSSL_API void wolfSSL_BN_CTX_free(WOLFSSL_BN_CTX* ctx); WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_BN_new(void);