BN_mod_mul_reciprocal.pod 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. =pod
  2. =head1 NAME
  3. BN_mod_mul_reciprocal, BN_div_recp, BN_RECP_CTX_new,
  4. BN_RECP_CTX_free, BN_RECP_CTX_set - modular multiplication using
  5. reciprocal
  6. =head1 SYNOPSIS
  7. #include <openssl/bn.h>
  8. BN_RECP_CTX *BN_RECP_CTX_new(void);
  9. void BN_RECP_CTX_free(BN_RECP_CTX *recp);
  10. int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *m, BN_CTX *ctx);
  11. int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *a, BN_RECP_CTX *recp,
  12. BN_CTX *ctx);
  13. int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *a, BIGNUM *b,
  14. BN_RECP_CTX *recp, BN_CTX *ctx);
  15. =head1 DESCRIPTION
  16. BN_mod_mul_reciprocal() can be used to perform an efficient
  17. L<BN_mod_mul(3)> operation when the operation will be performed
  18. repeatedly with the same modulus. It computes B<r>=(B<a>*B<b>)%B<m>
  19. using B<recp>=1/B<m>, which is set as described below. B<ctx> is a
  20. previously allocated B<BN_CTX> used for temporary variables.
  21. BN_RECP_CTX_new() allocates and initializes a B<BN_RECP> structure.
  22. BN_RECP_CTX_free() frees the components of the B<BN_RECP>, and, if it
  23. was created by BN_RECP_CTX_new(), also the structure itself.
  24. If B<recp> is NULL, nothing is done.
  25. BN_RECP_CTX_set() stores B<m> in B<recp> and sets it up for computing
  26. 1/B<m> and shifting it left by BN_num_bits(B<m>)+1 to make it an
  27. integer. The result and the number of bits it was shifted left will
  28. later be stored in B<recp>.
  29. BN_div_recp() divides B<a> by B<m> using B<recp>. It places the quotient
  30. in B<dv> and the remainder in B<rem>.
  31. The B<BN_RECP_CTX> structure cannot be shared between threads.
  32. =head1 RETURN VALUES
  33. BN_RECP_CTX_new() returns the newly allocated B<BN_RECP_CTX>, and NULL
  34. on error.
  35. BN_RECP_CTX_free() has no return value.
  36. For the other functions, 1 is returned for success, 0 on error.
  37. The error codes can be obtained by L<ERR_get_error(3)>.
  38. =head1 SEE ALSO
  39. L<ERR_get_error(3)>, L<BN_add(3)>,
  40. L<BN_CTX_new(3)>
  41. =head1 HISTORY
  42. BN_RECP_CTX_init() was removed in OpenSSL 1.1.0
  43. =head1 COPYRIGHT
  44. Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved.
  45. Licensed under the OpenSSL license (the "License"). You may not use
  46. this file except in compliance with the License. You can obtain a copy
  47. in the file LICENSE in the source distribution or at
  48. L<https://www.openssl.org/source/license.html>.
  49. =cut