]>
Commit | Line | Data |
---|---|---|
dd8dec69 UM |
1 | =pod |
2 | ||
3 | =head1 NAME | |
4 | ||
7bc081dd MC |
5 | BN_CTX_new_ex, BN_CTX_new, BN_CTX_secure_new_ex, BN_CTX_secure_new, BN_CTX_free |
6 | - allocate and free BN_CTX structures | |
dd8dec69 UM |
7 | |
8 | =head1 SYNOPSIS | |
9 | ||
10 | #include <openssl/bn.h> | |
11 | ||
7bc081dd | 12 | BN_CTX *BN_CTX_new_ex(OPENSSL_CTX *ctx); |
dd8dec69 UM |
13 | BN_CTX *BN_CTX_new(void); |
14 | ||
7bc081dd | 15 | BN_CTX *BN_CTX_secure_new_ex(OPENSSL_CTX *ctx); |
74924dcb RS |
16 | BN_CTX *BN_CTX_secure_new(void); |
17 | ||
aafbe1cc MC |
18 | void BN_CTX_free(BN_CTX *c); |
19 | ||
dd8dec69 UM |
20 | =head1 DESCRIPTION |
21 | ||
15701211 DSH |
22 | A B<BN_CTX> is a structure that holds B<BIGNUM> temporary variables used by |
23 | library functions. Since dynamic memory allocation to create B<BIGNUM>s | |
24 | is rather expensive when used in conjunction with repeated subroutine | |
25 | calls, the B<BN_CTX> structure is used. | |
dd8dec69 | 26 | |
7bc081dd MC |
27 | BN_CTX_new_ex() allocates and initializes a B<BN_CTX> structure for the given |
28 | library context B<ctx>. The <ctx> value may be NULL in which case the default | |
29 | library context will be used. BN_CTX_new() is the same as BN_CTX_new_ex() except | |
30 | that the default library context is always used. | |
31 | ||
32 | BN_CTX_secure_new_ex() allocates and initializes a B<BN_CTX> structure | |
74924dcb | 33 | but uses the secure heap (see L<CRYPTO_secure_malloc(3)>) to hold the |
7bc081dd MC |
34 | B<BIGNUM>s for the given library context B<ctx>. The <ctx> value may be NULL in |
35 | which case the default library context will be used. BN_CTX_secure_new() is the | |
36 | same as BN_CTX_secure_new_ex() except that the default library context is always | |
37 | used. | |
dd8dec69 | 38 | |
7b5b2c46 BK |
39 | BN_CTX_free() frees the components of the B<BN_CTX> and the structure itself. |
40 | Since BN_CTX_start() is required in order to obtain B<BIGNUM>s from the | |
41 | B<BN_CTX>, in most cases BN_CTX_end() must be called before the B<BN_CTX> may | |
42 | be freed by BN_CTX_free(). If B<c> is NULL, nothing is done. | |
43 | ||
44 | A given B<BN_CTX> must only be used by a single thread of execution. No | |
45 | locking is performed, and the internal pool allocator will not properly handle | |
46 | multiple threads of execution. | |
37e48b88 | 47 | |
dd8dec69 UM |
48 | =head1 RETURN VALUES |
49 | ||
74924dcb RS |
50 | BN_CTX_new() and BN_CTX_secure_new() return a pointer to the B<BN_CTX>. |
51 | If the allocation fails, | |
52 | they return B<NULL> and sets an error code that can be obtained by | |
9b86974e | 53 | L<ERR_get_error(3)>. |
dd8dec69 | 54 | |
e35af275 MC |
55 | BN_CTX_free() has no return values. |
56 | ||
57 | =head1 REMOVED FUNCTIONALITY | |
58 | ||
59 | void BN_CTX_init(BN_CTX *c); | |
60 | ||
61 | BN_CTX_init() is no longer available as of OpenSSL 1.1.0. Applications should | |
62 | replace use of BN_CTX_init with BN_CTX_new instead: | |
63 | ||
64 | BN_CTX *ctx; | |
65 | ctx = BN_CTX_new(); | |
2947af32 BB |
66 | if (!ctx) |
67 | /* error */ | |
e35af275 MC |
68 | ... |
69 | BN_CTX_free(ctx); | |
dd8dec69 UM |
70 | |
71 | =head1 SEE ALSO | |
72 | ||
9e183d22 | 73 | L<ERR_get_error(3)>, L<BN_add(3)>, |
9b86974e | 74 | L<BN_CTX_start(3)> |
dd8dec69 UM |
75 | |
76 | =head1 HISTORY | |
77 | ||
a528d4f0 | 78 | BN_CTX_init() was removed in OpenSSL 1.1.0. |
dd8dec69 | 79 | |
e2f92610 RS |
80 | =head1 COPYRIGHT |
81 | ||
9e183d22 | 82 | Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved. |
e2f92610 | 83 | |
4746f25a | 84 | Licensed under the Apache License 2.0 (the "License"). You may not use |
e2f92610 RS |
85 | this file except in compliance with the License. You can obtain a copy |
86 | in the file LICENSE in the source distribution or at | |
87 | L<https://www.openssl.org/source/license.html>. | |
88 | ||
89 | =cut |