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