diff options
author | schwarze <> | 2015-02-23 17:43:24 +0000 |
---|---|---|
committer | schwarze <> | 2015-02-23 17:43:24 +0000 |
commit | 9cb1a51933a1847042ee88e16d560485f682bcad (patch) | |
tree | 5a76fb973ee649bdb33c7731bc1ca457abfcec1e /src/lib/libcrypto/man/BN_add.3 | |
parent | 2820d04ee847cb7bede0b25e49194c3ade7ebdbf (diff) | |
download | openbsd-9cb1a51933a1847042ee88e16d560485f682bcad.tar.gz openbsd-9cb1a51933a1847042ee88e16d560485f682bcad.tar.bz2 openbsd-9cb1a51933a1847042ee88e16d560485f682bcad.zip |
fourth batch of perlpod(1) to mdoc(7) conversion
Diffstat (limited to 'src/lib/libcrypto/man/BN_add.3')
-rw-r--r-- | src/lib/libcrypto/man/BN_add.3 | 352 |
1 files changed, 352 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/BN_add.3 b/src/lib/libcrypto/man/BN_add.3 new file mode 100644 index 0000000000..d41599d8b0 --- /dev/null +++ b/src/lib/libcrypto/man/BN_add.3 | |||
@@ -0,0 +1,352 @@ | |||
1 | .Dd $Mdocdate: February 23 2015 $ | ||
2 | .Dt BN_ADD 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BN_add , | ||
6 | .Nm BN_sub , | ||
7 | .Nm BN_mul , | ||
8 | .Nm BN_sqr , | ||
9 | .Nm BN_div , | ||
10 | .Nm BN_mod , | ||
11 | .Nm BN_nnmod , | ||
12 | .Nm BN_mod_add , | ||
13 | .Nm BN_mod_sub , | ||
14 | .Nm BN_mod_mul , | ||
15 | .Nm BN_mod_sqr , | ||
16 | .Nm BN_exp , | ||
17 | .Nm BN_mod_exp , | ||
18 | .Nm BN_gcd | ||
19 | .Nd arithmetic operations on BIGNUMs | ||
20 | .Sh SYNOPSIS | ||
21 | .In openssl/bn.h | ||
22 | .Ft int | ||
23 | .Fo BN_add | ||
24 | .Fa "BIGNUM *r" | ||
25 | .Fa "const BIGNUM *a" | ||
26 | .Fa "const BIGNUM *b" | ||
27 | .Fc | ||
28 | .Ft int | ||
29 | .Fo BN_sub | ||
30 | .Fa "BIGNUM *r" | ||
31 | .Fa "const BIGNUM *a" | ||
32 | .Fa "const BIGNUM *b" | ||
33 | .Fc | ||
34 | .Ft int | ||
35 | .Fo BN_mul | ||
36 | .Fa "BIGNUM *r" | ||
37 | .Fa "BIGNUM *a" | ||
38 | .Fa "BIGNUM *b" | ||
39 | .Fa "BN_CTX *ctx" | ||
40 | .Fc | ||
41 | .Ft int | ||
42 | .Fo BN_sqr | ||
43 | .Fa "BIGNUM *r" | ||
44 | .Fa "BIGNUM *a" | ||
45 | .Fa "BN_CTX *ctx" | ||
46 | .Fc | ||
47 | .Ft int | ||
48 | .Fo BN_div | ||
49 | .Fa "BIGNUM *dv" | ||
50 | .Fa "BIGNUM *rem" | ||
51 | .Fa "const BIGNUM *a" | ||
52 | .Fa "const BIGNUM *d" | ||
53 | .Fa "BN_CTX *ctx" | ||
54 | .Fc | ||
55 | .Ft int | ||
56 | .Fo BN_mod | ||
57 | .Fa "BIGNUM *rem" | ||
58 | .Fa "const BIGNUM *a" | ||
59 | .Fa "const BIGNUM *m" | ||
60 | .Fa "BN_CTX *ctx" | ||
61 | .Fc | ||
62 | .Ft int | ||
63 | .Fo BN_nnmod | ||
64 | .Fa "BIGNUM *r" | ||
65 | .Fa "const BIGNUM *a" | ||
66 | .Fa "const BIGNUM *m" | ||
67 | .Fa "BN_CTX *ctx" | ||
68 | .Fc | ||
69 | .Ft int | ||
70 | .Fo BN_mod_add | ||
71 | .Fa "BIGNUM *r" | ||
72 | .Fa "BIGNUM *a" | ||
73 | .Fa "BIGNUM *b" | ||
74 | .Fa "const BIGNUM *m" | ||
75 | .Fa "BN_CTX *ctx" | ||
76 | .Fc | ||
77 | .Ft int | ||
78 | .Fo BN_mod_sub | ||
79 | .Fa "BIGNUM *r" | ||
80 | .Fa "BIGNUM *a" | ||
81 | .Fa "BIGNUM *b" | ||
82 | .Fa "const BIGNUM *m" | ||
83 | .Fa "BN_CTX *ctx" | ||
84 | .Fc | ||
85 | .Ft int | ||
86 | .Fo BN_mod_mul | ||
87 | .Fa "BIGNUM *r" | ||
88 | .Fa "BIGNUM *a" | ||
89 | .Fa "BIGNUM *b" | ||
90 | .Fa "const BIGNUM *m" | ||
91 | .Fa "BN_CTX *ctx" | ||
92 | .Fc | ||
93 | .Ft int | ||
94 | .Fo BN_mod_sqr | ||
95 | .Fa "BIGNUM *r" | ||
96 | .Fa "BIGNUM *a" | ||
97 | .Fa "const BIGNUM *m" | ||
98 | .Fa "BN_CTX *ctx" | ||
99 | .Fc | ||
100 | .Ft int | ||
101 | .Fo BN_exp | ||
102 | .Fa "BIGNUM *r" | ||
103 | .Fa "BIGNUM *a" | ||
104 | .Fa "BIGNUM *p" | ||
105 | .Fa "BN_CTX *ctx" | ||
106 | .Fc | ||
107 | .Ft int | ||
108 | .Fo BN_mod_exp | ||
109 | .Fa "BIGNUM *r" | ||
110 | .Fa "BIGNUM *a" | ||
111 | .Fa "const BIGNUM *p" | ||
112 | .Fa "const BIGNUM *m" | ||
113 | .Fa "BN_CTX *ctx" | ||
114 | .Fc | ||
115 | .Ft int | ||
116 | .Fo BN_gcd | ||
117 | .Fa "BIGNUM *r" | ||
118 | .Fa "BIGNUM *a" | ||
119 | .Fa "BIGNUM *b" | ||
120 | .Fa "BN_CTX *ctx" | ||
121 | .Fc | ||
122 | .Sh DESCRIPTION | ||
123 | .Fn BN_add | ||
124 | adds | ||
125 | .Fa a | ||
126 | and | ||
127 | .Fa b | ||
128 | and places the result in | ||
129 | .Fa r | ||
130 | .Pq Li r=a+b . | ||
131 | .Fa r | ||
132 | may be the same | ||
133 | .Vt BIGNUM | ||
134 | as | ||
135 | .Fa a | ||
136 | or | ||
137 | .Fa b . | ||
138 | .Pp | ||
139 | .Fn BN_sub | ||
140 | subtracts | ||
141 | .Fa b | ||
142 | from | ||
143 | .Fa a | ||
144 | and places the result in | ||
145 | .Fa r | ||
146 | .Pq Li r=a-b . | ||
147 | .Pp | ||
148 | .Fn BN_mul | ||
149 | multiplies | ||
150 | .Fa a | ||
151 | and | ||
152 | .Fa b | ||
153 | and places the result in | ||
154 | .Fa r | ||
155 | .Pq Li r=a*b . | ||
156 | .Fa r | ||
157 | may be the same | ||
158 | .Vt BIGNUM | ||
159 | as | ||
160 | .Fa a | ||
161 | or | ||
162 | .Fa b . | ||
163 | For multiplication by powers of 2, use | ||
164 | .Xr BN_lshift 3 . | ||
165 | .Pp | ||
166 | .Fn BN_sqr | ||
167 | takes the square of | ||
168 | .Fa a | ||
169 | and places the result in | ||
170 | .Fa r | ||
171 | .Pq Li r=a^2 . | ||
172 | .Fa r | ||
173 | and | ||
174 | .Fa a | ||
175 | may be the same | ||
176 | .Vt BIGNUM . | ||
177 | This function is faster than | ||
178 | .Fn BN_mul r a a . | ||
179 | .Pp | ||
180 | .Fn BN_div | ||
181 | divides | ||
182 | .Fa a | ||
183 | by | ||
184 | .Fa d | ||
185 | and places the result in | ||
186 | .Fa dv | ||
187 | and the remainder in | ||
188 | .Fa rem | ||
189 | .Pq Li dv=a/d , rem=a%d . | ||
190 | Either of | ||
191 | .Fa dv | ||
192 | and | ||
193 | .Fa rem | ||
194 | may be | ||
195 | .Dv NULL , | ||
196 | in which case the respective value is not returned. | ||
197 | The result is rounded towards zero; thus if | ||
198 | .Fa a | ||
199 | is negative, the remainder will be zero or negative. | ||
200 | For division by powers of 2, use | ||
201 | .Fn BN_rshift 3 . | ||
202 | .Pp | ||
203 | .Fn BN_mod | ||
204 | corresponds to | ||
205 | .Fn BN_div | ||
206 | with | ||
207 | .Fa dv | ||
208 | set to | ||
209 | .Dv NULL . | ||
210 | .Pp | ||
211 | .Fn BN_nnmod | ||
212 | reduces | ||
213 | .Fa a | ||
214 | modulo | ||
215 | .Fa m | ||
216 | and places the non-negative remainder in | ||
217 | .Fa r . | ||
218 | .Pp | ||
219 | .Fn BN_mod_add | ||
220 | adds | ||
221 | .Fa a | ||
222 | to | ||
223 | .Fa b | ||
224 | modulo | ||
225 | .Fa m | ||
226 | and places the non-negative result in | ||
227 | .Fa r . | ||
228 | .Pp | ||
229 | .Fn BN_mod_sub | ||
230 | subtracts | ||
231 | .Fa b | ||
232 | from | ||
233 | .Fa a | ||
234 | modulo | ||
235 | .Fa m | ||
236 | and places the non-negative result in | ||
237 | .Fa r . | ||
238 | .Pp | ||
239 | .Fn BN_mod_mul | ||
240 | multiplies | ||
241 | .Fa a | ||
242 | by | ||
243 | .Fa b | ||
244 | and finds the non-negative remainder respective to modulus | ||
245 | .Fa m | ||
246 | .Pq Li r=(a*b)%m . | ||
247 | .Fa r | ||
248 | may be the same | ||
249 | .Vt BIGNUM | ||
250 | as | ||
251 | .Fa a | ||
252 | or | ||
253 | .Fa b . | ||
254 | For more efficient algorithms for repeated computations using the same | ||
255 | modulus, see | ||
256 | .Xr BN_mod_mul_montgomery 3 | ||
257 | and | ||
258 | .Xr BN_mod_mul_reciprocal 3 . | ||
259 | .Pp | ||
260 | .Fn BN_mod_sqr | ||
261 | takes the square of | ||
262 | .Fa a | ||
263 | modulo | ||
264 | .Fa m | ||
265 | and places the result in | ||
266 | .Fa r . | ||
267 | .Pp | ||
268 | .Fn BN_exp | ||
269 | raises | ||
270 | .Fa a | ||
271 | to the | ||
272 | .Fa p Ns -th | ||
273 | power and places the result in | ||
274 | .Fa r | ||
275 | .Pq Li r=a^p . | ||
276 | This function is faster than repeated applications of | ||
277 | .Fn BN_mul . | ||
278 | .Pp | ||
279 | .Fn BN_mod_exp | ||
280 | computes | ||
281 | .Fa a | ||
282 | to the | ||
283 | .Fa p Ns -th | ||
284 | power modulo | ||
285 | .Fa m | ||
286 | .Pq Li r=(a^p)%m . | ||
287 | This function uses less time and space than | ||
288 | .Fn BN_exp . | ||
289 | .Pp | ||
290 | .Fn BN_gcd | ||
291 | computes the greatest common divisor of | ||
292 | .Fa a | ||
293 | and | ||
294 | .Fa b | ||
295 | and places the result in | ||
296 | .Fa r . | ||
297 | .Fa r | ||
298 | may be the same | ||
299 | .Vt BIGNUM | ||
300 | as | ||
301 | .Fa a | ||
302 | or | ||
303 | .Fa b . | ||
304 | .Pp | ||
305 | For all functions, | ||
306 | .Fa ctx | ||
307 | is a previously allocated | ||
308 | .Vt BN_CTX | ||
309 | used for temporary variables; see | ||
310 | .Xr BN_CTX_new 3 . | ||
311 | .Pp | ||
312 | Unless noted otherwise, the result | ||
313 | .Vt BIGNUM | ||
314 | must be different from the arguments. | ||
315 | .Sh RETURN VALUES | ||
316 | For all functions, 1 is returned for success, 0 on error. | ||
317 | The return value should always be checked, for example: | ||
318 | .Pp | ||
319 | .Dl if (!BN_add(r,a,b)) goto err; | ||
320 | .Pp | ||
321 | The error codes can be obtained by | ||
322 | .Xr ERR_get_error 3 . | ||
323 | .Sh SEE ALSO | ||
324 | .Xr bn 3 , | ||
325 | .Xr BN_add_word 3 , | ||
326 | .Xr BN_CTX_new 3 , | ||
327 | .Xr BN_set_bit 3 , | ||
328 | .Xr ERR_get_error 3 | ||
329 | .Sh HISTORY | ||
330 | .Fn BN_add , | ||
331 | .Fn BN_sub , | ||
332 | .Fn BN_sqr , | ||
333 | .Fn BN_div , | ||
334 | .Fn BN_mod , | ||
335 | .Fn BN_mod_mul , | ||
336 | .Fn BN_mod_exp , | ||
337 | and | ||
338 | .Fn BN_gcd | ||
339 | are available in all versions of SSLeay and OpenSSL. | ||
340 | The | ||
341 | .Fa ctx | ||
342 | argument to | ||
343 | .Fn BN_mul | ||
344 | was added in SSLeay 0.9.1b. | ||
345 | .Fn BN_exp | ||
346 | appeared in SSLeay 0.9.0. | ||
347 | .Fn BN_nnmod , | ||
348 | .Fn BN_mod_add , | ||
349 | .Fn BN_mod_sub , | ||
350 | and | ||
351 | .Fn BN_mod_sqr | ||
352 | were added in OpenSSL 0.9.7. | ||