xref: /freebsd/crypto/openssl/doc/man3/BN_CTX_new.pod (revision e71b70530d95c4f34d8bdbd78d1242df1ba4a945)
1*e71b7053SJung-uk Kim=pod
2*e71b7053SJung-uk Kim
3*e71b7053SJung-uk Kim=head1 NAME
4*e71b7053SJung-uk Kim
5*e71b7053SJung-uk KimBN_CTX_new, BN_CTX_secure_new, BN_CTX_free - allocate and free BN_CTX structures
6*e71b7053SJung-uk Kim
7*e71b7053SJung-uk Kim=head1 SYNOPSIS
8*e71b7053SJung-uk Kim
9*e71b7053SJung-uk Kim #include <openssl/bn.h>
10*e71b7053SJung-uk Kim
11*e71b7053SJung-uk Kim BN_CTX *BN_CTX_new(void);
12*e71b7053SJung-uk Kim
13*e71b7053SJung-uk Kim BN_CTX *BN_CTX_secure_new(void);
14*e71b7053SJung-uk Kim
15*e71b7053SJung-uk Kim void BN_CTX_free(BN_CTX *c);
16*e71b7053SJung-uk Kim
17*e71b7053SJung-uk Kim=head1 DESCRIPTION
18*e71b7053SJung-uk Kim
19*e71b7053SJung-uk KimA B<BN_CTX> is a structure that holds B<BIGNUM> temporary variables used by
20*e71b7053SJung-uk Kimlibrary functions. Since dynamic memory allocation to create B<BIGNUM>s
21*e71b7053SJung-uk Kimis rather expensive when used in conjunction with repeated subroutine
22*e71b7053SJung-uk Kimcalls, the B<BN_CTX> structure is used.
23*e71b7053SJung-uk Kim
24*e71b7053SJung-uk KimBN_CTX_new() allocates and initializes a B<BN_CTX> structure.
25*e71b7053SJung-uk KimBN_CTX_secure_new() allocates and initializes a B<BN_CTX> structure
26*e71b7053SJung-uk Kimbut uses the secure heap (see L<CRYPTO_secure_malloc(3)>) to hold the
27*e71b7053SJung-uk KimB<BIGNUM>s.
28*e71b7053SJung-uk Kim
29*e71b7053SJung-uk KimBN_CTX_free() frees the components of the B<BN_CTX> and the structure itself.
30*e71b7053SJung-uk KimSince BN_CTX_start() is required in order to obtain B<BIGNUM>s from the
31*e71b7053SJung-uk KimB<BN_CTX>, in most cases BN_CTX_end() must be called before the B<BN_CTX> may
32*e71b7053SJung-uk Kimbe freed by BN_CTX_free().  If B<c> is NULL, nothing is done.
33*e71b7053SJung-uk Kim
34*e71b7053SJung-uk KimA given B<BN_CTX> must only be used by a single thread of execution.  No
35*e71b7053SJung-uk Kimlocking is performed, and the internal pool allocator will not properly handle
36*e71b7053SJung-uk Kimmultiple threads of execution.
37*e71b7053SJung-uk Kim
38*e71b7053SJung-uk Kim=head1 RETURN VALUES
39*e71b7053SJung-uk Kim
40*e71b7053SJung-uk KimBN_CTX_new() and BN_CTX_secure_new() return a pointer to the B<BN_CTX>.
41*e71b7053SJung-uk KimIf the allocation fails,
42*e71b7053SJung-uk Kimthey return B<NULL> and sets an error code that can be obtained by
43*e71b7053SJung-uk KimL<ERR_get_error(3)>.
44*e71b7053SJung-uk Kim
45*e71b7053SJung-uk KimBN_CTX_free() has no return values.
46*e71b7053SJung-uk Kim
47*e71b7053SJung-uk Kim=head1 REMOVED FUNCTIONALITY
48*e71b7053SJung-uk Kim
49*e71b7053SJung-uk Kim void BN_CTX_init(BN_CTX *c);
50*e71b7053SJung-uk Kim
51*e71b7053SJung-uk KimBN_CTX_init() is no longer available as of OpenSSL 1.1.0. Applications should
52*e71b7053SJung-uk Kimreplace use of BN_CTX_init with BN_CTX_new instead:
53*e71b7053SJung-uk Kim
54*e71b7053SJung-uk Kim BN_CTX *ctx;
55*e71b7053SJung-uk Kim ctx = BN_CTX_new();
56*e71b7053SJung-uk Kim if (!ctx)
57*e71b7053SJung-uk Kim     /* error */
58*e71b7053SJung-uk Kim ...
59*e71b7053SJung-uk Kim BN_CTX_free(ctx);
60*e71b7053SJung-uk Kim
61*e71b7053SJung-uk Kim=head1 SEE ALSO
62*e71b7053SJung-uk Kim
63*e71b7053SJung-uk KimL<ERR_get_error(3)>, L<BN_add(3)>,
64*e71b7053SJung-uk KimL<BN_CTX_start(3)>
65*e71b7053SJung-uk Kim
66*e71b7053SJung-uk Kim=head1 HISTORY
67*e71b7053SJung-uk Kim
68*e71b7053SJung-uk KimBN_CTX_init() was removed in OpenSSL 1.1.0.
69*e71b7053SJung-uk Kim
70*e71b7053SJung-uk Kim=head1 COPYRIGHT
71*e71b7053SJung-uk Kim
72*e71b7053SJung-uk KimCopyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved.
73*e71b7053SJung-uk Kim
74*e71b7053SJung-uk KimLicensed under the OpenSSL license (the "License").  You may not use
75*e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
76*e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
77*e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
78*e71b7053SJung-uk Kim
79*e71b7053SJung-uk Kim=cut
80