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