summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/bn.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/man/bn.3')
-rw-r--r--src/lib/libcrypto/man/bn.3576
1 files changed, 576 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/bn.3 b/src/lib/libcrypto/man/bn.3
new file mode 100644
index 0000000000..6406be1663
--- /dev/null
+++ b/src/lib/libcrypto/man/bn.3
@@ -0,0 +1,576 @@
1.Dd $Mdocdate: November 5 2016 $
2.Dt BN 3
3.Os
4.Sh NAME
5.Nm bn
6.Nd multiprecision integer arithmetics
7.Sh SYNOPSIS
8.In openssl/bn.h
9.Ft BIGNUM *
10.Fn BN_new void
11.Ft void
12.Fo BN_free
13.Fa "BIGNUM *a"
14.Fc
15.Ft void
16.Fo BN_init
17.Fa "BIGNUM *"
18.Fc
19.Ft void
20.Fo BN_clear
21.Fa "BIGNUM *a"
22.Fc
23.Ft void
24.Fo BN_clear_free
25.Fa "BIGNUM *a"
26.Fc
27.Ft BN_CTX *
28.Fn BN_CTX_new void
29.Ft void
30.Fo BN_CTX_init
31.Fa "BN_CTX *c"
32.Fc
33.Ft void
34.Fo BN_CTX_free
35.Fa "BN_CTX *c"
36.Fc
37.Ft BIGNUM *
38.Fo BN_copy
39.Fa "BIGNUM *a"
40.Fa "const BIGNUM *b"
41.Fc
42.Ft BIGNUM *
43.Fo BN_dup
44.Fa "const BIGNUM *a"
45.Fc
46.Ft BIGNUM *
47.Fo BN_swap
48.Fa "BIGNUM *a"
49.Fa "BIGNUM *b"
50.Fc
51.Ft int
52.Fo BN_num_bytes
53.Fa "const BIGNUM *a"
54.Fc
55.Ft int
56.Fo BN_num_bits
57.Fa "const BIGNUM *a"
58.Fc
59.Ft int
60.Fo BN_num_bits_word
61.Fa "BN_ULONG w"
62.Fc
63.Ft void
64.Fo BN_set_negative
65.Fa "BIGNUM *a"
66.Fa "int n"
67.Fc
68.Ft int
69.Fo BN_is_negative
70.Fa "const BIGNUM *a"
71.Fc
72.Ft int
73.Fo BN_add
74.Fa "BIGNUM *r"
75.Fa "const BIGNUM *a"
76.Fa "const BIGNUM *b"
77.Fc
78.Ft int
79.Fo BN_sub
80.Fa "BIGNUM *r"
81.Fa "const BIGNUM *a"
82.Fa "const BIGNUM *b"
83.Fc
84.Ft int
85.Fo BN_mul
86.Fa "BIGNUM *r"
87.Fa "BIGNUM *a"
88.Fa "BIGNUM *b"
89.Fa "BN_CTX *ctx"
90.Fc
91.Ft int
92.Fo BN_sqr
93.Fa "BIGNUM *r"
94.Fa "BIGNUM *a"
95.Fa "BN_CTX *ctx"
96.Fc
97.Ft int
98.Fo BN_div
99.Fa "BIGNUM *dv"
100.Fa "BIGNUM *rem"
101.Fa "const BIGNUM *a"
102.Fa "const BIGNUM *d"
103.Fa "BN_CTX *ctx"
104.Fc
105.Ft int
106.Fo BN_mod
107.Fa "BIGNUM *rem"
108.Fa "const BIGNUM *a"
109.Fa "const BIGNUM *m"
110.Fa "BN_CTX *ctx"
111.Fc
112.Ft int
113.Fo BN_nnmod
114.Fa "BIGNUM *rem"
115.Fa "const BIGNUM *a"
116.Fa "const BIGNUM *m"
117.Fa "BN_CTX *ctx"
118.Fc
119.Ft int
120.Fo BN_mod_add
121.Fa "BIGNUM *ret"
122.Fa "BIGNUM *a"
123.Fa "BIGNUM *b"
124.Fa "const BIGNUM *m"
125.Fa "BN_CTX *ctx"
126.Fc
127.Ft int
128.Fo BN_mod_sub
129.Fa "BIGNUM *ret"
130.Fa "BIGNUM *a"
131.Fa "BIGNUM *b"
132.Fa "const BIGNUM *m"
133.Fa "BN_CTX *ctx"
134.Fc
135.Ft int
136.Fo BN_mod_mul
137.Fa "BIGNUM *ret"
138.Fa "BIGNUM *a"
139.Fa "BIGNUM *b"
140.Fa "const BIGNUM *m"
141.Fa "BN_CTX *ctx"
142.Fc
143.Ft int
144.Fo BN_mod_sqr
145.Fa "BIGNUM *ret"
146.Fa "BIGNUM *a"
147.Fa "const BIGNUM *m"
148.Fa "BN_CTX *ctx"
149.Fc
150.Ft int
151.Fo BN_exp
152.Fa "BIGNUM *r"
153.Fa "BIGNUM *a"
154.Fa "BIGNUM *p"
155.Fa "BN_CTX *ctx"
156.Fc
157.Ft int
158.Fo BN_mod_exp
159.Fa "BIGNUM *r"
160.Fa "BIGNUM *a"
161.Fa "const BIGNUM *p"
162.Fa "const BIGNUM *m"
163.Fa "BN_CTX *ctx"
164.Fc
165.Ft int
166.Fo BN_gcd
167.Fa "BIGNUM *r"
168.Fa "BIGNUM *a"
169.Fa "BIGNUM *b"
170.Fa "BN_CTX *ctx"
171.Fc
172.Ft int
173.Fo BN_add_word
174.Fa "BIGNUM *a"
175.Fa "BN_ULONG w"
176.Fc
177.Ft int
178.Fo BN_sub_word
179.Fa "BIGNUM *a"
180.Fa "BN_ULONG w"
181.Fc
182.Ft int
183.Fo BN_mul_word
184.Fa "BIGNUM *a"
185.Fa "BN_ULONG w"
186.Fc
187.Ft BN_ULONG
188.Fo BN_div_word
189.Fa "BIGNUM *a"
190.Fa "BN_ULONG w"
191.Fc
192.Ft BN_ULONG
193.Fo BN_mod_word
194.Fa "const BIGNUM *a"
195.Fa "BN_ULONG w"
196.Fc
197.Ft int
198.Fo BN_cmp
199.Fa "BIGNUM *a"
200.Fa "BIGNUM *b"
201.Fc
202.Ft int
203.Fo BN_ucmp
204.Fa "BIGNUM *a"
205.Fa "BIGNUM *b"
206.Fc
207.Ft int
208.Fo BN_is_zero
209.Fa "BIGNUM *a"
210.Fc
211.Ft int
212.Fo BN_is_one
213.Fa "BIGNUM *a"
214.Fc
215.Ft int
216.Fo BN_is_word
217.Fa "BIGNUM *a"
218.Fa "BN_ULONG w"
219.Fc
220.Ft int
221.Fo BN_is_odd
222.Fa "BIGNUM *a"
223.Fc
224.Ft int
225.Fo BN_zero
226.Fa "BIGNUM *a"
227.Fc
228.Ft int
229.Fo BN_one
230.Fa "BIGNUM *a"
231.Fc
232.Ft const BIGNUM *
233.Fn BN_value_one void
234.Ft int
235.Fo BN_set_word
236.Fa "BIGNUM *a"
237.Fa "unsigned long w"
238.Fc
239.Ft unsigned long
240.Fo BN_get_word
241.Fa "BIGNUM *a"
242.Fc
243.Ft int
244.Fo BN_rand
245.Fa "BIGNUM *rnd"
246.Fa "int bits"
247.Fa "int top"
248.Fa "int bottom"
249.Fc
250.Ft int
251.Fo BN_pseudo_rand
252.Fa "BIGNUM *rnd"
253.Fa "int bits"
254.Fa "int top"
255.Fa "int bottom"
256.Fc
257.Ft int
258.Fo BN_rand_range
259.Fa "BIGNUM *rnd"
260.Fa "BIGNUM *range"
261.Fc
262.Ft int
263.Fo BN_pseudo_rand_range
264.Fa "BIGNUM *rnd"
265.Fa "BIGNUM *range"
266.Fc
267.Ft BIGNUM *
268.Fo BN_generate_prime
269.Fa "BIGNUM *ret"
270.Fa "int bits"
271.Fa "int safe"
272.Fa "BIGNUM *add"
273.Fa "BIGNUM *rem"
274.Fa "void (*callback)(int, int, void *)"
275.Fa "void *cb_arg"
276.Fc
277.Ft int
278.Fo BN_is_prime
279.Fa "const BIGNUM *p"
280.Fa "int nchecks"
281.Fa "void (*callback)(int, int, void *)"
282.Fa "BN_CTX *ctx"
283.Fa "void *cb_arg"
284.Fc
285.Ft int
286.Fo BN_set_bit
287.Fa "BIGNUM *a"
288.Fa "int n"
289.Fc
290.Ft int
291.Fo BN_clear_bit
292.Fa "BIGNUM *a"
293.Fa "int n"
294.Fc
295.Ft int
296.Fo BN_is_bit_set
297.Fa "const BIGNUM *a"
298.Fa "int n"
299.Fc
300.Ft int
301.Fo BN_mask_bits
302.Fa "BIGNUM *a"
303.Fa "int n"
304.Fc
305.Ft int
306.Fo BN_lshift
307.Fa "BIGNUM *r"
308.Fa "const BIGNUM *a"
309.Fa "int n"
310.Fc
311.Ft int
312.Fo BN_lshift1
313.Fa "BIGNUM *r"
314.Fa "BIGNUM *a"
315.Fc
316.Ft int
317.Fo BN_rshift
318.Fa "BIGNUM *r"
319.Fa "BIGNUM *a"
320.Fa "int n"
321.Fc
322.Ft int
323.Fo BN_rshift1
324.Fa "BIGNUM *r"
325.Fa "BIGNUM *a"
326.Fc
327.Ft int
328.Fo BN_bn2bin
329.Fa "const BIGNUM *a"
330.Fa "unsigned char *to"
331.Fc
332.Ft BIGNUM *
333.Fo BN_bin2bn
334.Fa "const unsigned char *s"
335.Fa "int len"
336.Fa "BIGNUM *ret"
337.Fc
338.Ft char *
339.Fo BN_bn2hex
340.Fa "const BIGNUM *a"
341.Fc
342.Ft char *
343.Fo BN_bn2dec
344.Fa "const BIGNUM *a"
345.Fc
346.Ft int
347.Fo BN_hex2bn
348.Fa "BIGNUM **a"
349.Fa "const char *str"
350.Fc
351.Ft int
352.Fo BN_dec2bn
353.Fa "BIGNUM **a"
354.Fa "const char *str"
355.Fc
356.Ft int
357.Fo BN_print
358.Fa "BIO *fp"
359.Fa "const BIGNUM *a"
360.Fc
361.Ft int
362.Fo BN_print_fp
363.Fa "FILE *fp"
364.Fa "const BIGNUM *a"
365.Fc
366.Ft int
367.Fo BN_bn2mpi
368.Fa "const BIGNUM *a"
369.Fa "unsigned char *to"
370.Fc
371.Ft BIGNUM *
372.Fo BN_mpi2bn
373.Fa "unsigned char *s"
374.Fa "int len"
375.Fa "BIGNUM *ret"
376.Fc
377.Ft BIGNUM *
378.Fo BN_mod_inverse
379.Fa "BIGNUM *r"
380.Fa "BIGNUM *a"
381.Fa "const BIGNUM *n"
382.Fa "BN_CTX *ctx"
383.Fc
384.Ft BN_RECP_CTX *
385.Fn BN_RECP_CTX_new void
386.Ft void
387.Fo BN_RECP_CTX_init
388.Fa "BN_RECP_CTX *recp"
389.Fc
390.Ft void
391.Fo BN_RECP_CTX_free
392.Fa "BN_RECP_CTX *recp"
393.Fc
394.Ft int
395.Fo BN_RECP_CTX_set
396.Fa "BN_RECP_CTX *recp"
397.Fa "const BIGNUM *m"
398.Fa "BN_CTX *ctx"
399.Fc
400.Ft int
401.Fo BN_mod_mul_reciprocal
402.Fa "BIGNUM *r"
403.Fa "BIGNUM *a"
404.Fa "BIGNUM *b"
405.Fa "BN_RECP_CTX *recp"
406.Fa "BN_CTX *ctx"
407.Fc
408.Ft BN_MONT_CTX *
409.Fn BN_MONT_CTX_new void
410.Ft void
411.Fo BN_MONT_CTX_init
412.Fa "BN_MONT_CTX *ctx"
413.Fc
414.Ft void
415.Fo BN_MONT_CTX_free
416.Fa "BN_MONT_CTX *mont"
417.Fc
418.Ft int
419.Fo BN_MONT_CTX_set
420.Fa "BN_MONT_CTX *mont"
421.Fa "const BIGNUM *m"
422.Fa "BN_CTX *ctx"
423.Fc
424.Ft BN_MONT_CTX *
425.Fo BN_MONT_CTX_copy
426.Fa "BN_MONT_CTX *to"
427.Fa "BN_MONT_CTX *from"
428.Fc
429.Ft int
430.Fo BN_mod_mul_montgomery
431.Fa "BIGNUM *r"
432.Fa "BIGNUM *a"
433.Fa "BIGNUM *b"
434.Fa "BN_MONT_CTX *mont"
435.Fa "BN_CTX *ctx"
436.Fc
437.Ft int
438.Fo BN_from_montgomery
439.Fa "BIGNUM *r"
440.Fa "BIGNUM *a"
441.Fa "BN_MONT_CTX *mont"
442.Fa "BN_CTX *ctx"
443.Fc
444.Ft int
445.Fo BN_to_montgomery
446.Fa "BIGNUM *r"
447.Fa "BIGNUM *a"
448.Fa "BN_MONT_CTX *mont"
449.Fa "BN_CTX *ctx"
450.Fc
451.Ft BN_BLINDING *
452.Fo BN_BLINDING_new
453.Fa "const BIGNUM *A"
454.Fa "const BIGNUM *Ai"
455.Fa "BIGNUM *mod"
456.Fc
457.Ft void
458.Fo BN_BLINDING_free
459.Fa "BN_BLINDING *b"
460.Fc
461.Ft int
462.Fo BN_BLINDING_update
463.Fa "BN_BLINDING *b"
464.Fa "BN_CTX *ctx"
465.Fc
466.Ft int
467.Fo BN_BLINDING_convert
468.Fa "BIGNUM *n"
469.Fa "BN_BLINDING *b"
470.Fa "BN_CTX *ctx"
471.Fc
472.Ft int
473.Fo BN_BLINDING_invert
474.Fa "BIGNUM *n"
475.Fa "BN_BLINDING *b"
476.Fa "BN_CTX *ctx"
477.Fc
478.Ft int
479.Fo BN_BLINDING_convert_ex
480.Fa "BIGNUM *n"
481.Fa "BIGNUM *r"
482.Fa "BN_BLINDING *b"
483.Fa "BN_CTX *ctx"
484.Fc
485.Ft int
486.Fo BN_BLINDING_invert_ex
487.Fa "BIGNUM *n"
488.Fa "const BIGNUM *r"
489.Fa "BN_BLINDING *b"
490.Fa "BN_CTX *ctx"
491.Fc
492.Ft unsigned long
493.Fo BN_BLINDING_get_thread_id
494.Fa "const BN_BLINDING *"
495.Fc
496.Ft void
497.Fo BN_BLINDING_set_thread_id
498.Fa "BN_BLINDING *"
499.Fa "unsigned long"
500.Fc
501.Ft unsigned long
502.Fo BN_BLINDING_get_flags
503.Fa "const BN_BLINDING *"
504.Fc
505.Ft void
506.Fo BN_BLINDING_set_flags
507.Fa "BN_BLINDING *"
508.Fa "unsigned long"
509.Fc
510.Ft BN_BLINDING *
511.Fo BN_BLINDING_create_param
512.Fa "BN_BLINDING *b"
513.Fa "const BIGNUM *e"
514.Fa "BIGNUM *m"
515.Fa "BN_CTX *ctx"
516.Fa "int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)"
517.Fa "BN_MONT_CTX *m_ctx"
518.Fc
519.Sh DESCRIPTION
520This library performs arithmetic operations on integers of arbitrary size.
521It was written for use in public key cryptography, such as RSA and
522Diffie-Hellman.
523.Pp
524It uses dynamic memory allocation for storing its data structures.
525That means that there is no limit on the size of the numbers manipulated
526by these functions, but return values must always be checked in case a
527memory allocation error has occurred.
528.Pp
529The basic object in this library is a
530.Vt BIGNUM .
531It is used to hold a single large integer.
532This type should be considered opaque and fields should not be modified
533or accessed directly.
534.Pp
535The creation of
536.Vt BIGNUM
537objects is described in
538.Xr BN_new 3 ;
539.Xr BN_add 3
540describes most of the arithmetic operations.
541Comparison is described in
542.Xr BN_cmp 3 ;
543.Xr BN_zero 3
544describes certain assignments,
545.Xr BN_rand 3
546the generation of random numbers,
547.Xr BN_generate_prime 3
548deals with prime numbers and
549.Xr BN_set_bit 3
550with bit operations.
551The conversion of
552.Vt BIGNUM Ns s
553to external formats is described in
554.Xr BN_bn2bin 3 .
555.Sh SEE ALSO
556.Xr BN_add 3 ,
557.Xr BN_add_word 3 ,
558.Xr BN_BLINDING_new 3 ,
559.Xr BN_bn2bin 3 ,
560.Xr BN_cmp 3 ,
561.Xr BN_copy 3 ,
562.Xr BN_CTX_new 3 ,
563.Xr bn_dump 3 ,
564.Xr BN_generate_prime 3 ,
565.Xr BN_mod_inverse 3 ,
566.Xr BN_mod_mul_montgomery 3 ,
567.Xr BN_mod_mul_reciprocal 3 ,
568.Xr BN_new 3 ,
569.Xr BN_num_bytes 3 ,
570.Xr BN_rand 3 ,
571.Xr BN_set_bit 3 ,
572.Xr BN_swap 3 ,
573.Xr BN_zero 3 ,
574.Xr dh 3 ,
575.Xr ERR 3 ,
576.Xr rsa 3