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