BN_CTX_new.pod 2.7 KB

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