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