1BN_CTX_NEW(3) OpenSSL BN_CTX_NEW(3)
2
3
4
6 BN_CTX_new, BN_CTX_secure_new, BN_CTX_free - allocate and free BN_CTX
7 structures
8
10 #include <openssl/bn.h>
11
12 BN_CTX *BN_CTX_new(void);
13
14 BN_CTX *BN_CTX_secure_new(void);
15
16 void BN_CTX_free(BN_CTX *c);
17
19 A BN_CTX is a structure that holds BIGNUM temporary variables used by
20 library functions. Since dynamic memory allocation to create BIGNUMs is
21 rather expensive when used in conjunction with repeated subroutine
22 calls, the BN_CTX structure is used.
23
24 BN_CTX_new() allocates and initializes a BN_CTX structure.
25 BN_CTX_secure_new() allocates and initializes a BN_CTX structure but
26 uses the secure heap (see CRYPTO_secure_malloc(3)) to hold the BIGNUMs.
27
28 BN_CTX_free() frees the components of the BN_CTX and the structure
29 itself. Since BN_CTX_start() is required in order to obtain BIGNUMs
30 from the BN_CTX, in most cases BN_CTX_end() must be called before the
31 BN_CTX may be freed by BN_CTX_free(). If c is NULL, nothing is done.
32
33 A given BN_CTX must only be used by a single thread of execution. No
34 locking is performed, and the internal pool allocator will not properly
35 handle multiple threads of execution.
36
38 BN_CTX_new() and BN_CTX_secure_new() return a pointer to the BN_CTX.
39 If the allocation fails, they return NULL and sets an error code that
40 can be obtained by ERR_get_error(3).
41
42 BN_CTX_free() has no return values.
43
45 void BN_CTX_init(BN_CTX *c);
46
47 BN_CTX_init() is no longer available as of OpenSSL 1.1.0. Applications
48 should replace use of BN_CTX_init with BN_CTX_new instead:
49
50 BN_CTX *ctx;
51 ctx = BN_CTX_new();
52 if (!ctx)
53 /* error */
54 ...
55 BN_CTX_free(ctx);
56
58 ERR_get_error(3), BN_add(3), BN_CTX_start(3)
59
61 BN_CTX_init() was removed in OpenSSL 1.1.0.
62
64 Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved.
65
66 Licensed under the OpenSSL license (the "License"). You may not use
67 this file except in compliance with the License. You can obtain a copy
68 in the file LICENSE in the source distribution or at
69 <https://www.openssl.org/source/license.html>.
70
71
72
731.1.1d 2019-10-03 BN_CTX_NEW(3)