import libcrypto (LibreSSL 2.5.2)
[unleashed.git] / lib / libcrypto / man / BN_BLINDING_new.3
blob00b55f54eab014713b4b254b714811b80867cc7f
1 .\"     $OpenBSD: BN_BLINDING_new.3,v 1.6 2016/12/10 21:13:25 schwarze Exp $
2 .\"     OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400
3 .\"
4 .\" This file was written by Nils Larsch <nils@openssl.org>.
5 .\" Copyright (c) 2005, 2008, 2013, 2015 The OpenSSL Project.
6 .\" All rights reserved.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\"
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\"    notice, this list of conditions and the following disclaimer.
14 .\"
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\"    notice, this list of conditions and the following disclaimer in
17 .\"    the documentation and/or other materials provided with the
18 .\"    distribution.
19 .\"
20 .\" 3. All advertising materials mentioning features or use of this
21 .\"    software must display the following acknowledgment:
22 .\"    "This product includes software developed by the OpenSSL Project
23 .\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24 .\"
25 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 .\"    endorse or promote products derived from this software without
27 .\"    prior written permission. For written permission, please contact
28 .\"    openssl-core@openssl.org.
29 .\"
30 .\" 5. Products derived from this software may not be called "OpenSSL"
31 .\"    nor may "OpenSSL" appear in their names without prior written
32 .\"    permission of the OpenSSL Project.
33 .\"
34 .\" 6. Redistributions of any form whatsoever must retain the following
35 .\"    acknowledgment:
36 .\"    "This product includes software developed by the OpenSSL Project
37 .\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38 .\"
39 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
51 .\"
52 .Dd $Mdocdate: December 10 2016 $
53 .Dt BN_BLINDING_NEW 3
54 .Os
55 .Sh NAME
56 .Nm BN_BLINDING_new ,
57 .Nm BN_BLINDING_free ,
58 .Nm BN_BLINDING_update ,
59 .Nm BN_BLINDING_convert ,
60 .Nm BN_BLINDING_invert ,
61 .Nm BN_BLINDING_convert_ex ,
62 .Nm BN_BLINDING_invert_ex ,
63 .Nm BN_BLINDING_get_thread_id ,
64 .Nm BN_BLINDING_set_thread_id ,
65 .Nm BN_BLINDING_thread_id ,
66 .Nm BN_BLINDING_get_flags ,
67 .Nm BN_BLINDING_set_flags ,
68 .Nm BN_BLINDING_create_param
69 .Nd blinding related BIGNUM functions
70 .Sh SYNOPSIS
71 .In openssl/bn.h
72 .Ft BN_BLINDING *
73 .Fo BN_BLINDING_new
74 .Fa "const BIGNUM *A"
75 .Fa "const BIGNUM *Ai"
76 .Fa "BIGNUM *mod"
77 .Fc
78 .Ft void
79 .Fo BN_BLINDING_free
80 .Fa "BN_BLINDING *b"
81 .Fc
82 .Ft int
83 .Fo BN_BLINDING_update
84 .Fa "BN_BLINDING *b"
85 .Fa "BN_CTX *ctx"
86 .Fc
87 .Ft int
88 .Fo BN_BLINDING_convert
89 .Fa "BIGNUM *n"
90 .Fa "BN_BLINDING *b"
91 .Fa "BN_CTX *ctx"
92 .Fc
93 .Ft int
94 .Fo BN_BLINDING_invert
95 .Fa "BIGNUM *n"
96 .Fa "BN_BLINDING *b"
97 .Fa "BN_CTX *ctx"
98 .Fc
99 .Ft int
100 .Fo BN_BLINDING_convert_ex
101 .Fa "BIGNUM *n"
102 .Fa "BIGNUM *r"
103 .Fa "BN_BLINDING *b"
104 .Fa "BN_CTX *ctx"
106 .Ft int
107 .Fo BN_BLINDING_invert_ex
108 .Fa "BIGNUM *n"
109 .Fa "const BIGNUM *r"
110 .Fa "BN_BLINDING *b"
111 .Fa "BN_CTX *ctx"
113 .Fd #ifndef OPENSSL_NO_DEPRECATED
114 .Ft unsigned long
115 .Fo BN_BLINDING_get_thread_id
116 .Fa "const BN_BLINDING *"
118 .Ft void
119 .Fo BN_BLINDING_set_thread_id
120 .Fa "BN_BLINDING *"
121 .Fa "unsigned long"
123 .Fd #endif
124 .Ft CRYPTO_THREADID *
125 .Fo BN_BLINDING_thread_id
126 .Fa "BN_BLINDING *"
128 .Ft unsigned long
129 .Fo BN_BLINDING_get_flags
130 .Fa "const BN_BLINDING *"
132 .Ft void
133 .Fo BN_BLINDING_set_flags
134 .Fa "BN_BLINDING *"
135 .Fa "unsigned long"
137 .Ft BN_BLINDING *
138 .Fo BN_BLINDING_create_param
139 .Fa "BN_BLINDING *b"
140 .Fa "const BIGNUM *e"
141 .Fa "BIGNUM *m"
142 .Fa "BN_CTX *ctx"
143 .Fa "int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\
144  const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)"
145 .Fa "BN_MONT_CTX *m_ctx"
147 .Sh DESCRIPTION
148 .Fn BN_BLINDING_new
149 allocates a new
150 .Vt BN_BLINDING
151 structure and copies the
152 .Fa A
154 .Fa \&Ai
155 values into the newly created
156 .Vt BN_BLINDING
157 object.
159 .Fn BN_BLINDING_free
160 frees the
161 .Vt BN_BLINDING
162 structure.
164 .Fa b
165 is a
166 .Dv NULL
167 pointer, no action occurs.
169 .Fn BN_BLINDING_update
170 updates the
171 .Vt BN_BLINDING
172 parameters by squaring the
173 .Fa A
175 .Fa \&Ai
176 or, after a specific number of uses and if the necessary parameters are
177 set, by re-creating the blinding parameters.
179 .Fn BN_BLINDING_convert_ex
180 multiplies
181 .Fa n
182 with the blinding factor
183 .Fa A .
185 .Fa r
186 is not
187 .Dv NULL ,
188 a copy of the inverse blinding factor
189 .Fa \&Ai
190 will be returned in
191 .Fa r
192 (this is useful if an
193 .Vt RSA
194 object is shared among several threads).
195 .Fn BN_BLINDING_invert_ex
196 multiplies
197 .Fa n
198 with the inverse blinding factor
199 .Fa \&Ai .
201 .Fa r
202 is not
203 .Dv NULL ,
204 it will be used as the inverse blinding.
206 .Fn BN_BLINDING_convert
208 .Fn BN_BLINDING_invert
209 are wrapper functions for
210 .Fn BN_BLINDING_convert_ex
212 .Fn BN_BLINDING_invert_ex
213 with
214 .Fa r
215 set to
216 .Dv NULL .
218 .Fn BN_BLINDING_thread_id
219 provides access to the
220 .Vt CRYPTO_THREADID
221 object within the
222 .Vt BN_BLINDING
223 structure.
224 This is to help users provide proper locking if needed for
225 multi-threaded use.
226 The thread ID object of a newly allocated
227 .Vt BN_BLINDING
228 structure is initialised to the thread ID in which
229 .Fn BN_BLINDING_new
230 was called.
232 .Fn BN_BLINDING_get_flags
233 returns the
234 .Dv BN_BLINDING_*
235 flags.
236 Currently there are two supported flags:
237 .Dv BN_BLINDING_NO_UPDATE
239 .Dv BN_BLINDING_NO_RECREATE .
240 .Dv BN_BLINDING_NO_UPDATE
241 inhibits the automatic update of the
242 .Vt BN_BLINDING
243 parameters after each use and
244 .Dv BN_BLINDING_NO_RECREATE
245 inhibits the automatic re-creation of the
246 .Vt BN_BLINDING
247 parameters after a fixed number of uses (currently 32).
248 In newly allocated
249 .Vt BN_BLINDING
250 objects no flags are set.
251 .Fn BN_BLINDING_set_flags
252 sets the
253 .Dv BN_BLINDING_*
254 parameters flags.
256 .Fn BN_BLINDING_create_param
257 creates new
258 .Vt BN_BLINDING
259 parameters using the exponent
260 .Fa e
261 and the modulus
262 .Fa m .
263 .Fa bn_mod_exp
265 .Fa m_ctx
266 can be used to pass special functions for exponentiation (normally
267 .Xr BN_mod_exp 3
269 .Vt BN_MONT_CTX ) .
270 .Sh RETURN VALUES
271 .Fn BN_BLINDING_new
272 returns the newly allocated
273 .Vt BN_BLINDING
274 structure or
275 .Dv NULL
276 in case of an error.
278 .Fn BN_BLINDING_update ,
279 .Fn BN_BLINDING_convert ,
280 .Fn BN_BLINDING_invert ,
281 .Fn BN_BLINDING_convert_ex
283 .Fn BN_BLINDING_invert_ex
284 return 1 on success and 0 if an error occurred.
286 .Fn BN_BLINDING_thread_id
287 returns a pointer to the thread ID object within a
288 .Vt BN_BLINDING
289 object.
291 .Fn BN_BLINDING_get_flags
292 returns the currently set
293 .Dv BN_BLINDING_*
294 flags (an
295 .Vt unsigned long
296 value).
298 .Fn BN_BLINDING_create_param
299 returns the newly created
300 .Vt BN_BLINDING
301 parameters or
302 .Dv NULL
303 on error.
304 .Sh SEE ALSO
305 .Xr BN_new 3
306 .Sh HISTORY
307 .Fn BN_BLINDING_thread_id
308 was first introduced in OpenSSL 1.0.0, and it deprecates
309 .Fn BN_BLINDING_set_thread_id
311 .Fn BN_BLINDING_get_thread_id .
313 .Fn BN_BLINDING_convert_ex ,
314 .Fn BN_BLINDIND_invert_ex ,
315 .Fn BN_BLINDING_get_thread_id ,
316 .Fn BN_BLINDING_set_thread_id ,
317 .Fn BN_BLINDING_set_flags ,
318 .Fn BN_BLINDING_get_flags
320 .Fn BN_BLINDING_create_param
321 were first introduced in OpenSSL 0.9.8.
322 .Sh AUTHORS
323 .An Nils Larsch Aq Mt nils@openssl.org