diff options
author | Matt Caswell <matt@openssl.org> | 2021-04-27 19:56:39 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2021-05-04 12:00:21 +0100 |
commit | b0ee1de9ab4fb8586934f3a8126432f06abf7115 (patch) | |
tree | a835c73699f9c0b1235e5004b8af292c52fa030f /crypto/context.c | |
parent | e3188bae04769242e62ae2fba96a0aca5b7ce605 (diff) | |
download | openssl-new-b0ee1de9ab4fb8586934f3a8126432f06abf7115.tar.gz |
Create libcrypto support for BIO_new_from_core_bio()
Previously the concept of wrapping an OSSL_CORE_BIO in a real BIO was an
internal only concept for our own providers. Since this is likely to be
generally useful, we make it a part of the public API.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15072)
Diffstat (limited to 'crypto/context.c')
-rw-r--r-- | crypto/context.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/crypto/context.c b/crypto/context.c index 39f96366e2..4ea949970a 100644 --- a/crypto/context.c +++ b/crypto/context.c @@ -12,6 +12,7 @@ #include "internal/thread_once.h" #include "internal/property.h" #include "internal/core.h" +#include "internal/bio.h" struct ossl_lib_ctx_onfree_list_st { ossl_lib_ctx_onfree_fn *fn; @@ -184,6 +185,21 @@ OSSL_LIB_CTX *OSSL_LIB_CTX_new(void) } #ifndef FIPS_MODULE +OSSL_LIB_CTX *OSSL_LIB_CTX_new_from_dispatch(const OSSL_DISPATCH *in) +{ + OSSL_LIB_CTX *ctx = OSSL_LIB_CTX_new(); + + if (ctx == NULL) + return NULL; + + if (!ossl_bio_init_core(ctx, in)) { + OSSL_LIB_CTX_free(ctx); + return NULL; + } + + return ctx; +} + int OSSL_LIB_CTX_load_config(OSSL_LIB_CTX *ctx, const char *config_file) { return CONF_modules_load_file_ex(ctx, config_file, NULL, 0) > 0; |