| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 3 |
.\" |
| 4 |
.\" Standard preamble: |
| 5 |
.\" ======================================================================== |
| 6 |
.de Sp \" Vertical space (when we can't use .PP) |
| 7 |
.if t .sp .5v |
| 8 |
.if n .sp |
| 9 |
.. |
| 10 |
.de Vb \" Begin verbatim text |
| 11 |
.ft CW |
| 12 |
.nf |
| 13 |
.ne \\$1 |
| 14 |
.. |
| 15 |
.de Ve \" End verbatim text |
| 16 |
.ft R |
| 17 |
.fi |
| 18 |
.. |
| 19 |
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. |
| 20 |
.ie n \{\ |
| 21 |
. ds C` "" |
| 22 |
. ds C' "" |
| 23 |
'br\} |
| 24 |
.el\{\ |
| 25 |
. ds C` |
| 26 |
. ds C' |
| 27 |
'br\} |
| 28 |
.\" |
| 29 |
.\" Escape single quotes in literal strings from groff's Unicode transform. |
| 30 |
.ie \n(.g .ds Aq \(aq |
| 31 |
.el .ds Aq ' |
| 32 |
.\" |
| 33 |
.\" If the F register is >0, we'll generate index entries on stderr for |
| 34 |
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index |
| 35 |
.\" entries marked with X<> in POD. Of course, you'll have to process the |
| 36 |
.\" output yourself in some meaningful fashion. |
| 37 |
.\" |
| 38 |
.\" Avoid warning from groff about undefined register 'F'. |
| 39 |
.de IX |
| 40 |
.. |
| 41 |
.nr rF 0 |
| 42 |
.if \n(.g .if rF .nr rF 1 |
| 43 |
.if (\n(rF:(\n(.g==0)) \{\ |
| 44 |
. if \nF \{\ |
| 45 |
. de IX |
| 46 |
. tm Index:\\$1\t\\n%\t"\\$2" |
| 47 |
.. |
| 48 |
. if !\nF==2 \{\ |
| 49 |
. nr % 0 |
| 50 |
. nr F 2 |
| 51 |
. \} |
| 52 |
. \} |
| 53 |
.\} |
| 54 |
.rr rF |
| 55 |
.\" ======================================================================== |
| 56 |
.\" |
| 57 |
.IX Title "BN_CTX_NEW 3SSL" |
| 58 |
.TH BN_CTX_NEW 3SSL 2026-04-07 3.6.2 OpenSSL |
| 59 |
.\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 60 |
.\" way too many mistakes in technical documents. |
| 61 |
.if n .ad l |
| 62 |
.nh |
| 63 |
.SH NAME |
| 64 |
BN_CTX_new_ex, BN_CTX_new, BN_CTX_secure_new_ex, BN_CTX_secure_new, BN_CTX_free |
| 65 |
\&\- allocate and free BN_CTX structures |
| 66 |
.SH SYNOPSIS |
| 67 |
.IX Header "SYNOPSIS" |
| 68 |
.Vb 1 |
| 69 |
\& #include <openssl/bn.h> |
| 70 |
\& |
| 71 |
\& BN_CTX *BN_CTX_new_ex(OSSL_LIB_CTX *ctx); |
| 72 |
\& BN_CTX *BN_CTX_new(void); |
| 73 |
\& |
| 74 |
\& BN_CTX *BN_CTX_secure_new_ex(OSSL_LIB_CTX *ctx); |
| 75 |
\& BN_CTX *BN_CTX_secure_new(void); |
| 76 |
\& |
| 77 |
\& void BN_CTX_free(BN_CTX *c); |
| 78 |
.Ve |
| 79 |
.SH DESCRIPTION |
| 80 |
.IX Header "DESCRIPTION" |
| 81 |
A \fBBN_CTX\fR is a structure that holds \fBBIGNUM\fR temporary variables used by |
| 82 |
library functions. Since dynamic memory allocation to create \fBBIGNUM\fRs |
| 83 |
is rather expensive when used in conjunction with repeated subroutine |
| 84 |
calls, the \fBBN_CTX\fR structure is used. |
| 85 |
.PP |
| 86 |
\&\fBBN_CTX_new_ex()\fR allocates and initializes a \fBBN_CTX\fR structure for the given |
| 87 |
library context \fBctx\fR. The <ctx> value may be NULL in which case the default |
| 88 |
library context will be used. \fBBN_CTX_new()\fR is the same as \fBBN_CTX_new_ex()\fR except |
| 89 |
that the default library context is always used. |
| 90 |
.PP |
| 91 |
\&\fBBN_CTX_secure_new_ex()\fR allocates and initializes a \fBBN_CTX\fR structure |
| 92 |
but uses the secure heap (see \fBCRYPTO_secure_malloc\fR\|(3)) to hold the |
| 93 |
\&\fBBIGNUM\fRs for the given library context \fBctx\fR. The <ctx> value may be NULL in |
| 94 |
which case the default library context will be used. \fBBN_CTX_secure_new()\fR is the |
| 95 |
same as \fBBN_CTX_secure_new_ex()\fR except that the default library context is always |
| 96 |
used. |
| 97 |
.PP |
| 98 |
\&\fBBN_CTX_free()\fR frees the components of the \fBBN_CTX\fR and the structure itself. |
| 99 |
Since \fBBN_CTX_start()\fR is required in order to obtain \fBBIGNUM\fRs from the |
| 100 |
\&\fBBN_CTX\fR, in most cases \fBBN_CTX_end()\fR must be called before the \fBBN_CTX\fR may |
| 101 |
be freed by \fBBN_CTX_free()\fR. If \fBc\fR is NULL, nothing is done. |
| 102 |
.PP |
| 103 |
A given \fBBN_CTX\fR must only be used by a single thread of execution. No |
| 104 |
locking is performed, and the internal pool allocator will not properly handle |
| 105 |
multiple threads of execution. |
| 106 |
.SH "RETURN VALUES" |
| 107 |
.IX Header "RETURN VALUES" |
| 108 |
\&\fBBN_CTX_new()\fR and \fBBN_CTX_secure_new()\fR return a pointer to the \fBBN_CTX\fR. |
| 109 |
If the allocation fails, |
| 110 |
they return \fBNULL\fR and sets an error code that can be obtained by |
| 111 |
\&\fBERR_get_error\fR\|(3). |
| 112 |
.PP |
| 113 |
\&\fBBN_CTX_free()\fR has no return values. |
| 114 |
.SH "REMOVED FUNCTIONALITY" |
| 115 |
.IX Header "REMOVED FUNCTIONALITY" |
| 116 |
.Vb 1 |
| 117 |
\& void BN_CTX_init(BN_CTX *c); |
| 118 |
.Ve |
| 119 |
.PP |
| 120 |
\&\fBBN_CTX_init()\fR is no longer available as of OpenSSL 1.1.0. Applications should |
| 121 |
replace use of BN_CTX_init with BN_CTX_new instead: |
| 122 |
.PP |
| 123 |
.Vb 6 |
| 124 |
\& BN_CTX *ctx; |
| 125 |
\& ctx = BN_CTX_new(); |
| 126 |
\& if (!ctx) |
| 127 |
\& /* error */ |
| 128 |
\& ... |
| 129 |
\& BN_CTX_free(ctx); |
| 130 |
.Ve |
| 131 |
.SH "SEE ALSO" |
| 132 |
.IX Header "SEE ALSO" |
| 133 |
\&\fBERR_get_error\fR\|(3), \fBBN_add\fR\|(3), |
| 134 |
\&\fBBN_CTX_start\fR\|(3) |
| 135 |
.SH HISTORY |
| 136 |
.IX Header "HISTORY" |
| 137 |
\&\fBBN_CTX_init()\fR was removed in OpenSSL 1.1.0. |
| 138 |
.SH COPYRIGHT |
| 139 |
.IX Header "COPYRIGHT" |
| 140 |
Copyright 2000\-2020 The OpenSSL Project Authors. All Rights Reserved. |
| 141 |
.PP |
| 142 |
Licensed under the Apache License 2.0 (the "License"). You may not use |
| 143 |
this file except in compliance with the License. You can obtain a copy |
| 144 |
in the file LICENSE in the source distribution or at |
| 145 |
<https://www.openssl.org/source/license.html>. |