BN_CTX_new.pod 2.1 KB

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