]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/man3/BN_mod_mul_reciprocal.pod
OPENSSL_s390xcap.pod: list msa9 facility bit (155)
[thirdparty/openssl.git] / doc / man3 / BN_mod_mul_reciprocal.pod
CommitLineData
dd8dec69
UM
1=pod
2
3=head1 NAME
4
0517ffc4 5BN_mod_mul_reciprocal, BN_div_recp, BN_RECP_CTX_new,
4d524e10 6BN_RECP_CTX_free, BN_RECP_CTX_set - modular multiplication using
dd8dec69
UM
7reciprocal
8
9=head1 SYNOPSIS
10
11 #include <openssl/bn.h>
12
13 BN_RECP_CTX *BN_RECP_CTX_new(void);
dd8dec69
UM
14 void BN_RECP_CTX_free(BN_RECP_CTX *recp);
15
16 int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *m, BN_CTX *ctx);
17
cae55bfc 18 int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *a, BN_RECP_CTX *recp,
e9b77246 19 BN_CTX *ctx);
cae55bfc 20
dd8dec69 21 int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *a, BIGNUM *b,
e9b77246 22 BN_RECP_CTX *recp, BN_CTX *ctx);
dd8dec69
UM
23
24=head1 DESCRIPTION
25
26BN_mod_mul_reciprocal() can be used to perform an efficient
9b86974e 27L<BN_mod_mul(3)> operation when the operation will be performed
dd8dec69
UM
28repeatedly with the same modulus. It computes B<r>=(B<a>*B<b>)%B<m>
29using B<recp>=1/B<m>, which is set as described below. B<ctx> is a
30previously allocated B<BN_CTX> used for temporary variables.
31
32BN_RECP_CTX_new() allocates and initializes a B<BN_RECP> structure.
dd8dec69
UM
33
34BN_RECP_CTX_free() frees the components of the B<BN_RECP>, and, if it
35was created by BN_RECP_CTX_new(), also the structure itself.
23a1d5e9 36If B<recp> is NULL, nothing is done.
dd8dec69 37
cae55bfc
UM
38BN_RECP_CTX_set() stores B<m> in B<recp> and sets it up for computing
391/B<m> and shifting it left by BN_num_bits(B<m>)+1 to make it an
40integer. The result and the number of bits it was shifted left will
41later be stored in B<recp>.
42
43BN_div_recp() divides B<a> by B<m> using B<recp>. It places the quotient
44in B<dv> and the remainder in B<rem>.
dd8dec69 45
e35af275 46The B<BN_RECP_CTX> structure cannot be shared between threads.
dd8dec69
UM
47
48=head1 RETURN VALUES
49
50BN_RECP_CTX_new() returns the newly allocated B<BN_RECP_CTX>, and NULL
51on error.
52
c952780c 53BN_RECP_CTX_free() has no return value.
dd8dec69
UM
54
55For the other functions, 1 is returned for success, 0 on error.
9b86974e 56The error codes can be obtained by L<ERR_get_error(3)>.
dd8dec69
UM
57
58=head1 SEE ALSO
59
9e183d22 60L<ERR_get_error(3)>, L<BN_add(3)>,
9b86974e 61L<BN_CTX_new(3)>
dd8dec69
UM
62
63=head1 HISTORY
64
c952780c 65BN_RECP_CTX_init() was removed in OpenSSL 1.1.0
dd8dec69 66
e2f92610
RS
67=head1 COPYRIGHT
68
9e183d22 69Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved.
e2f92610 70
4746f25a 71Licensed under the Apache License 2.0 (the "License"). You may not use
e2f92610
RS
72this file except in compliance with the License. You can obtain a copy
73in the file LICENSE in the source distribution or at
74L<https://www.openssl.org/source/license.html>.
75
76=cut