OPENSSL_free(ctx);
}
+OPENSSL_CTX *openssl_ctx_get_concrete(OPENSSL_CTX *ctx)
+{
+#ifndef FIPS_MODE
+ if (ctx == NULL) {
+ if (!RUN_ONCE(&default_context_init, do_default_context_init))
+ return 0;
+ return default_context;
+ }
+#endif
+ return ctx;
+}
+
static void openssl_ctx_generic_new(void *parent_ign, void *ptr_ign,
CRYPTO_EX_DATA *ad, int index,
long argl_ign, void *argp)
{
int idx;
-#ifndef FIPS_MODE
- if (ctx == NULL) {
- if (!RUN_ONCE(&default_context_init, do_default_context_init))
- return 0;
- ctx = default_context;
- }
-#endif
+ ctx = openssl_ctx_get_concrete(ctx);
if (ctx == NULL)
return 0;
{
void *data = NULL;
-#ifndef FIPS_MODE
- if (ctx == NULL) {
- if (!RUN_ONCE(&default_context_init, do_default_context_init))
- return NULL;
- ctx = default_context;
- }
-#endif
+ ctx = openssl_ctx_get_concrete(ctx);
if (ctx == NULL)
return NULL;
OSSL_EX_DATA_GLOBAL *openssl_ctx_get_ex_data_global(OPENSSL_CTX *ctx)
{
- /*
- * The default context code is not needed in FIPS_MODE and ctx should never
- * be NULL in the FIPS provider. However we compile this code out to ensure
- * we fail immediately if ctx == NULL in FIPS_MODE
- */
-#ifndef FIPS_MODE
- if (ctx == NULL) {
- if (!RUN_ONCE(&default_context_init, do_default_context_init))
- return NULL;
- ctx = default_context;
- }
-#endif
+ ctx = openssl_ctx_get_concrete(ctx);
if (ctx == NULL)
return NULL;
return &ctx->global;
{
int done = 0, ret = 0;
-#ifndef FIPS_MODE
- if (ctx == NULL) {
- if (!RUN_ONCE(&default_context_init, do_default_context_init))
- return 0;
- ctx = default_context;
- }
-#endif
+ ctx = openssl_ctx_get_concrete(ctx);
if (ctx == NULL)
return 0;
void (*free_func)(void *);
} OPENSSL_CTX_METHOD;
+OPENSSL_CTX *openssl_ctx_get_concrete(OPENSSL_CTX *ctx);
+
/* Functions to retrieve pointers to data by index */
void *openssl_ctx_get_data(OPENSSL_CTX *, int /* index */,
const OPENSSL_CTX_METHOD * ctx);