projects
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Create BN_CTX_new_ex() and BN_CTX_secure_new_ex()
[openssl.git]
/
crypto
/
bn
/
bn_ctx.c
diff --git
a/crypto/bn/bn_ctx.c
b/crypto/bn/bn_ctx.c
index 62e29b5dcc2dff736c51cc21f8b9790d8955058e..4857661d2db32748ef9f6c84aa74b047e342c092 100644
(file)
--- a/
crypto/bn/bn_ctx.c
+++ b/
crypto/bn/bn_ctx.c
@@
-86,6
+86,8
@@
struct bignum_ctx {
int too_many;
/* Flags. */
int flags;
int too_many;
/* Flags. */
int flags;
+ /* The library context */
+ OPENSSL_CTX *libctx;
};
/* Debugging functionality */
};
/* Debugging functionality */
@@
-121,30
+123,40
@@
static void ctxdbg(BIO *channel, const char *text, BN_CTX *ctx)
ctxdbg(trc_out, str, ctx); \
} OSSL_TRACE_END(BN_CTX)
ctxdbg(trc_out, str, ctx); \
} OSSL_TRACE_END(BN_CTX)
-
-BN_CTX *BN_CTX_new(void)
+BN_CTX *BN_CTX_new_ex(OPENSSL_CTX *ctx)
{
BN_CTX *ret;
if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
{
BN_CTX *ret;
if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
- BNerr(BN_F_BN_CTX_NEW, ERR_R_MALLOC_FAILURE);
+ BNerr(BN_F_BN_CTX_NEW
_EX
, ERR_R_MALLOC_FAILURE);
return NULL;
}
/* Initialise the structure */
BN_POOL_init(&ret->pool);
BN_STACK_init(&ret->stack);
return NULL;
}
/* Initialise the structure */
BN_POOL_init(&ret->pool);
BN_STACK_init(&ret->stack);
+ ret->libctx = ctx;
return ret;
}
return ret;
}
-BN_CTX *BN_CTX_
secure_
new(void)
+BN_CTX *BN_CTX_new(void)
{
{
- BN_CTX *ret = BN_CTX_new();
+ return BN_CTX_new_ex(NULL);
+}
+
+BN_CTX *BN_CTX_secure_new_ex(OPENSSL_CTX *ctx)
+{
+ BN_CTX *ret = BN_CTX_new_ex(ctx);
if (ret != NULL)
ret->flags = BN_FLG_SECURE;
return ret;
}
if (ret != NULL)
ret->flags = BN_FLG_SECURE;
return ret;
}
+BN_CTX *BN_CTX_secure_new(void)
+{
+ return BN_CTX_secure_new_ex(NULL);
+}
+
void BN_CTX_free(BN_CTX *ctx)
{
if (ctx == NULL)
void BN_CTX_free(BN_CTX *ctx)
{
if (ctx == NULL)