summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/BN_mod_mul_reciprocal.3
diff options
context:
space:
mode:
authorcvs2svn <admin@example.com>2021-08-18 16:06:57 +0000
committercvs2svn <admin@example.com>2021-08-18 16:06:57 +0000
commitd56c8fa8260d226f98b26f017b45b9c2b135f38d (patch)
tree348178b41617813cc93787187984a734ef8379ca /src/lib/libcrypto/man/BN_mod_mul_reciprocal.3
parent18b9c1bcab7c37d8c5bd05b8e0d14d0c59d96650 (diff)
downloadopenbsd-tb_20210818.tar.gz
openbsd-tb_20210818.tar.bz2
openbsd-tb_20210818.zip
This commit was manufactured by cvs2git to create tag 'tb_20210818'.tb_20210818
Diffstat (limited to 'src/lib/libcrypto/man/BN_mod_mul_reciprocal.3')
-rw-r--r--src/lib/libcrypto/man/BN_mod_mul_reciprocal.3229
1 files changed, 0 insertions, 229 deletions
diff --git a/src/lib/libcrypto/man/BN_mod_mul_reciprocal.3 b/src/lib/libcrypto/man/BN_mod_mul_reciprocal.3
deleted file mode 100644
index 9ace357652..0000000000
--- a/src/lib/libcrypto/man/BN_mod_mul_reciprocal.3
+++ /dev/null
@@ -1,229 +0,0 @@
1.\" $OpenBSD: BN_mod_mul_reciprocal.3,v 1.10 2018/03/27 17:35:50 schwarze Exp $
2.\" OpenSSL 6859cf74 Sep 25 13:33:28 2002 +0000
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 27 2018 $
52.Dt BN_MOD_MUL_RECIPROCAL 3
53.Os
54.Sh NAME
55.Nm BN_mod_mul_reciprocal ,
56.Nm BN_RECP_CTX_new ,
57.Nm BN_RECP_CTX_init ,
58.Nm BN_RECP_CTX_free ,
59.Nm BN_RECP_CTX_set ,
60.Nm BN_div_recp
61.Nd modular multiplication using reciprocal
62.Sh SYNOPSIS
63.In openssl/bn.h
64.Ft int
65.Fo BN_mod_mul_reciprocal
66.Fa "BIGNUM *r"
67.Fa "BIGNUM *a"
68.Fa "BIGNUM *b"
69.Fa "BN_RECP_CTX *recp"
70.Fa "BN_CTX *ctx"
71.Fc
72.Ft BN_RECP_CTX *
73.Fo BN_RECP_CTX_new
74.Fa void
75.Fc
76.Ft void
77.Fo BN_RECP_CTX_init
78.Fa "BN_RECP_CTX *recp"
79.Fc
80.Ft void
81.Fo BN_RECP_CTX_free
82.Fa "BN_RECP_CTX *recp"
83.Fc
84.Ft int
85.Fo BN_RECP_CTX_set
86.Fa "BN_RECP_CTX *recp"
87.Fa "const BIGNUM *m"
88.Fa "BN_CTX *ctx"
89.Fc
90.Ft int
91.Fo BN_div_recp
92.Fa "BIGNUM *dv"
93.Fa "BIGNUM *rem"
94.Fa "BIGNUM *a"
95.Fa "BN_RECP_CTX *recp"
96.Fa "BN_CTX *ctx"
97.Fc
98.Sh DESCRIPTION
99.Fn BN_mod_mul_reciprocal
100can be used to perform an efficient
101.Xr BN_mod_mul 3
102operation when the operation will be performed repeatedly with the same
103modulus.
104It computes
105.Fa r Ns =( Ns Fa a Ns * Ns Fa b Ns )% Ns Fa m
106using
107.Fa recp Ns =1/ Ns Fa m ,
108which is set as described below.
109.Fa ctx
110is a previously allocated
111.Vt BN_CTX
112used for temporary variables.
113.Pp
114.Fn BN_RECP_CTX_new
115allocates and initializes a
116.Vt BN_RECP_CTX
117structure.
118.Pp
119.Fn BN_RECP_CTX_init
120initializes an existing uninitialized
121.Vt BN_RECP_CTX .
122It is deprecated and dangerous: see
123.Sx CAVEATS .
124.Pp
125.Fn BN_RECP_CTX_free
126frees the components of the
127.Vt BN_RECP_CTX ,
128and, if it was created by
129.Fn BN_RECP_CTX_new ,
130also the structure itself.
131If
132.Fa recp
133is a
134.Dv NULL
135pointer, no action occurs.
136.Pp
137.Fn BN_RECP_CTX_set
138stores
139.Fa m
140in
141.Fa recp
142and sets it up for computing
143.Pf 1/ Fa m
144and shifting it left by
145.Fn BN_num_bits m Ns +1
146to make it an integer.
147The result and the number of bits it was shifted left will later be
148stored in
149.Fa recp .
150.Pp
151.Fn BN_div_recp
152divides
153.Fa a
154by
155.Fa m
156using
157.Fa recp .
158It places the quotient in
159.Fa dv
160and the remainder in
161.Fa rem .
162.Pp
163The
164.Vt BN_RECP_CTX
165structure is defined as follows:
166.Bd -literal
167typedef struct bn_recp_ctx_st {
168 BIGNUM N; /* the divisor */
169 BIGNUM Nr; /* the reciprocal */
170 int num_bits;
171 int shift;
172 int flags;
173} BN_RECP_CTX;
174.Ed
175.Pp
176It cannot be shared between threads.
177.Sh RETURN VALUES
178.Fn BN_RECP_CTX_new
179returns the newly allocated
180.Vt BN_RECP_CTX
181or
182.Dv NULL
183on error.
184.Pp
185For the other functions, 1 is returned for success or 0 on error.
186The error codes can be obtained by
187.Xr ERR_get_error 3 .
188.Sh SEE ALSO
189.Xr BN_add 3 ,
190.Xr BN_CTX_new 3 ,
191.Xr BN_new 3
192.Sh HISTORY
193.Fn BN_mod_mul_reciprocal
194first appeared in SSLeay 0.5.1 and has been available since
195.Ox 2.4 .
196.Pp
197.Vt BN_RECP_CTX
198was added in SSLeay 0.9.0.
199Before that, a function
200.Fn BN_reciprocal
201was used instead, and the
202.Fn BN_mod_mul_reciprocal
203arguments were different.
204.Pp
205.Fn BN_RECP_CTX_new ,
206.Fn BN_RECP_CTX_init ,
207.Fn BN_RECP_CTX_free ,
208.Fn BN_RECP_CTX_set ,
209and
210.Fn BN_div_recp
211first appeared in SSLeay 0.9.1 and have been available since
212.Ox 2.6 .
213.Sh CAVEATS
214.Fn BN_RECP_CTX_init
215must not be called on a context that was used previously, or
216memory used by the embedded
217.Vt BIGNUM
218structures is leaked immediately.
219Besides, it must not be called on a context created with
220.Fn BN_RECP_CTX_new ,
221or the context itself will likely be leaked later.
222It can only be used on a static
223.Vt BN_RECP_CTX
224structure, on one located on the stack, or on one
225.Xr malloc 3 Ap ed
226manually, but all these options are discouraged because they
227will no longer work once
228.Vt BN_RECP_CTX
229is made opaque.