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