summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/BN_mod_mul_reciprocal.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/man/BN_mod_mul_reciprocal.3')
-rw-r--r--src/lib/libcrypto/man/BN_mod_mul_reciprocal.3147
1 files changed, 147 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/BN_mod_mul_reciprocal.3 b/src/lib/libcrypto/man/BN_mod_mul_reciprocal.3
new file mode 100644
index 0000000000..ceb1ffae5b
--- /dev/null
+++ b/src/lib/libcrypto/man/BN_mod_mul_reciprocal.3
@@ -0,0 +1,147 @@
1.Dd $Mdocdate: February 23 2015 $
2.Dt BN_MOD_MUL_RECIPROCAL 3
3.Os
4.Sh NAME
5.Nm BN_mod_mul_reciprocal ,
6.Nm BN_div_recp ,
7.Nm BN_RECP_CTX_new ,
8.Nm BN_RECP_CTX_init ,
9.Nm BN_RECP_CTX_free ,
10.Nm BN_RECP_CTX_set
11.Nd modular multiplication using reciprocal
12.Sh SYNOPSIS
13.In openssl/bn.h
14.Ft BN_RECP_CTX *
15.Fo BN_RECP_CTX_new
16.Fa void
17.Fc
18.Ft void
19.Fo BN_RECP_CTX_init
20.Fa "BN_RECP_CTX *recp"
21.Fc
22.Ft void
23.Fo BN_RECP_CTX_free
24.Fa "BN_RECP_CTX *recp"
25.Fc
26.Ft int
27.Fo BN_RECP_CTX_set
28.Fa "BN_RECP_CTX *recp"
29.Fa "const BIGNUM *m"
30.Fa "BN_CTX *ctx"
31.Fc
32.Ft int
33.Fo BN_div_recp
34.Fa "BIGNUM *dv"
35.Fa "BIGNUM *rem"
36.Fa "BIGNUM *a"
37.Fa "BN_RECP_CTX *recp"
38.Fa "BN_CTX *ctx"
39.Fc
40.Ft int
41.Fo BN_mod_mul_reciprocal
42.Fa "BIGNUM *r"
43.Fa "BIGNUM *a"
44.Fa "BIGNUM *b"
45.Fa "BN_RECP_CTX *recp"
46.Fa "BN_CTX *ctx"
47.Fc
48.Sh DESCRIPTION
49.Fn BN_mod_mul_reciprocal
50can be used to perform an efficient
51.Xr BN_mod_mul 3
52operation when the operation will be performed repeatedly with the same
53modulus.
54It computes
55.Fa r Ns =( Ns Fa a Ns * Ns Fa b Ns )% Ns Fa m
56using
57.Fa recp Ns =1/ Ns Fa m ,
58which is set as described below.
59.Fa ctx
60is a previously allocated
61.Vt BN_CTX
62used for temporary variables.
63.Pp
64.Fn BN_RECP_CTX_new
65allocates and initializes a
66.Vt BN_RECP_CTX
67structure.
68.Fn BN_RECP_CTX_init
69initializes an existing uninitialized
70.Vt BN_RECP_CTX .
71.Pp
72.Fn BN_RECP_CTX_free
73frees the components of the
74.Vt BN_RECP_CTX ,
75and, if it was created by
76.Fn BN_RECP_CTX_new ,
77also the structure itself.
78.Pp
79.Fn BN_RECP_CTX_set
80stores
81.Fa m
82in
83.Fa recp
84and sets it up for computing
85.Pf 1/ Fa m
86and shifting it left by
87.Fn BN_num_bits m Ns +1
88to make it an integer.
89The result and the number of bits it was shifted left will later be
90stored in
91.Fa recp .
92.Pp
93.Fn BN_div_recp
94divides
95.Fa a
96by
97.Fa m
98using
99.Fa recp .
100It places the quotient in
101.Fa dv
102and the remainder in
103.Fa rem .
104.Pp
105The
106.Vt BN_RECP_CTX
107structure is defined as follows:
108.Bd -literal
109typedef struct bn_recp_ctx_st {
110 BIGNUM N; /* the divisor */
111 BIGNUM Nr; /* the reciprocal */
112 int num_bits;
113 int shift;
114 int flags;
115} BN_RECP_CTX;
116.Ed
117.Pp
118It cannot be shared between threads.
119.Sh RETURN VALUES
120.Fn BN_RECP_CTX_new
121returns the newly allocated
122.Vt BN_RECP_CTX ,
123or
124.Dv NULL
125on error.
126.Pp
127.Fn BN_RECP_CTX_init
128and
129.Fn BN_RECP_CTX_free
130return no values.
131.Pp
132For the other functions, 1 is returned for success, 0 on error.
133The error codes can be obtained by
134.Xr ERR_get_error 3 .
135.Sh SEE ALSO
136.Xr bn 3 ,
137.Xr BN_add 3 ,
138.Xr BN_CTX_new 3 ,
139.Xr ERR_get_error 3
140.Sh HISTORY
141.Vt BN_RECP_CTX
142was added in SSLeay 0.9.0.
143Before that, a function
144.Fn BN_reciprocal
145was used instead, and the
146.Fn BN_mod_mul_reciprocal
147arguments were different.