BN_CTX_new.pod 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 if it was
  19. created by BN_CTX_new(), also the structure itself.
  20. If L<BN_CTX_start(3)> has been used on the B<BN_CTX>,
  21. L<BN_CTX_end(3)> must be called before the B<BN_CTX>
  22. may be freed by BN_CTX_free().
  23. If B<c> is NULL, nothing is done.
  24. =head1 RETURN VALUES
  25. BN_CTX_new() and BN_CTX_secure_new() return a pointer to the B<BN_CTX>.
  26. If the allocation fails,
  27. they return B<NULL> and sets an error code that can be obtained by
  28. L<ERR_get_error(3)>.
  29. BN_CTX_free() has no return values.
  30. =head1 REMOVED FUNCTIONALITY
  31. void BN_CTX_init(BN_CTX *c);
  32. BN_CTX_init() is no longer available as of OpenSSL 1.1.0. Applications should
  33. replace use of BN_CTX_init with BN_CTX_new instead:
  34. BN_CTX *ctx;
  35. ctx = BN_CTX_new();
  36. if(!ctx) /* Handle error */
  37. ...
  38. BN_CTX_free(ctx);
  39. =head1 SEE ALSO
  40. L<ERR_get_error(3)>, L<BN_add(3)>,
  41. L<BN_CTX_start(3)>
  42. =head1 HISTORY
  43. BN_CTX_init() was removed in OpenSSL 1.1.0.
  44. =head1 COPYRIGHT
  45. Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved.
  46. Licensed under the OpenSSL license (the "License"). You may not use
  47. this file except in compliance with the License. You can obtain a copy
  48. in the file LICENSE in the source distribution or at
  49. L<https://www.openssl.org/source/license.html>.
  50. =cut