]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/lib/libcrypto/man/bn.3
Regen amd64 assembly files for OpenSSL 1.1.1.
[FreeBSD/FreeBSD.git] / secure / lib / libcrypto / man / bn.3
1 .\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35)
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sp \" Vertical space (when we can't use .PP)
6 .if t .sp .5v
7 .if n .sp
8 ..
9 .de Vb \" Begin verbatim text
10 .ft CW
11 .nf
12 .ne \\$1
13 ..
14 .de Ve \" End verbatim text
15 .ft R
16 .fi
17 ..
18 .\" Set up some character translations and predefined strings.  \*(-- will
19 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
20 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
21 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
22 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
23 .\" nothing in troff, for use with C<>.
24 .tr \(*W-
25 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
26 .ie n \{\
27 .    ds -- \(*W-
28 .    ds PI pi
29 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
31 .    ds L" ""
32 .    ds R" ""
33 .    ds C` ""
34 .    ds C' ""
35 'br\}
36 .el\{\
37 .    ds -- \|\(em\|
38 .    ds PI \(*p
39 .    ds L" ``
40 .    ds R" ''
41 .    ds C`
42 .    ds C'
43 'br\}
44 .\"
45 .\" Escape single quotes in literal strings from groff's Unicode transform.
46 .ie \n(.g .ds Aq \(aq
47 .el       .ds Aq '
48 .\"
49 .\" If the F register is >0, we'll generate index entries on stderr for
50 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
51 .\" entries marked with X<> in POD.  Of course, you'll have to process the
52 .\" output yourself in some meaningful fashion.
53 .\"
54 .\" Avoid warning from groff about undefined register 'F'.
55 .de IX
56 ..
57 .if !\nF .nr F 0
58 .if \nF>0 \{\
59 .    de IX
60 .    tm Index:\\$1\t\\n%\t"\\$2"
61 ..
62 .    if !\nF==2 \{\
63 .        nr % 0
64 .        nr F 2
65 .    \}
66 .\}
67 .\"
68 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
70 .    \" fudge factors for nroff and troff
71 .if n \{\
72 .    ds #H 0
73 .    ds #V .8m
74 .    ds #F .3m
75 .    ds #[ \f1
76 .    ds #] \fP
77 .\}
78 .if t \{\
79 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80 .    ds #V .6m
81 .    ds #F 0
82 .    ds #[ \&
83 .    ds #] \&
84 .\}
85 .    \" simple accents for nroff and troff
86 .if n \{\
87 .    ds ' \&
88 .    ds ` \&
89 .    ds ^ \&
90 .    ds , \&
91 .    ds ~ ~
92 .    ds /
93 .\}
94 .if t \{\
95 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101 .\}
102 .    \" troff and (daisy-wheel) nroff accents
103 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110 .ds ae a\h'-(\w'a'u*4/10)'e
111 .ds Ae A\h'-(\w'A'u*4/10)'E
112 .    \" corrections for vroff
113 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115 .    \" for low resolution devices (crt and lpr)
116 .if \n(.H>23 .if \n(.V>19 \
117 \{\
118 .    ds : e
119 .    ds 8 ss
120 .    ds o a
121 .    ds d- d\h'-1'\(ga
122 .    ds D- D\h'-1'\(hy
123 .    ds th \o'bp'
124 .    ds Th \o'LP'
125 .    ds ae ae
126 .    ds Ae AE
127 .\}
128 .rm #[ #] #H #V #F C
129 .\" ========================================================================
130 .\"
131 .IX Title "bn 3"
132 .TH bn 3 "2018-08-14" "1.0.2p" "OpenSSL"
133 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
134 .\" way too many mistakes in technical documents.
135 .if n .ad l
136 .nh
137 .SH "NAME"
138 bn \- multiprecision integer arithmetics
139 .SH "SYNOPSIS"
140 .IX Header "SYNOPSIS"
141 .Vb 1
142 \& #include <openssl/bn.h>
143 \&
144 \& BIGNUM *BN_new(void);
145 \& void BN_free(BIGNUM *a);
146 \& void BN_init(BIGNUM *);
147 \& void BN_clear(BIGNUM *a);
148 \& void BN_clear_free(BIGNUM *a);
149 \&
150 \& BN_CTX *BN_CTX_new(void);
151 \& void BN_CTX_init(BN_CTX *c);
152 \& void BN_CTX_free(BN_CTX *c);
153 \&
154 \& BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
155 \& BIGNUM *BN_dup(const BIGNUM *a);
156 \&
157 \& BIGNUM *BN_swap(BIGNUM *a, BIGNUM *b);
158 \&
159 \& int BN_num_bytes(const BIGNUM *a);
160 \& int BN_num_bits(const BIGNUM *a);
161 \& int BN_num_bits_word(BN_ULONG w);
162 \&
163 \& void BN_set_negative(BIGNUM *a, int n);
164 \& int  BN_is_negative(const BIGNUM *a);
165 \&
166 \& int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
167 \& int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
168 \& int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
169 \& int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx);
170 \& int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *a, const BIGNUM *d,
171 \&         BN_CTX *ctx);
172 \& int BN_mod(BIGNUM *rem, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
173 \& int BN_nnmod(BIGNUM *rem, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
174 \& int BN_mod_add(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
175 \&         BN_CTX *ctx);
176 \& int BN_mod_sub(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
177 \&         BN_CTX *ctx);
178 \& int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
179 \&         BN_CTX *ctx);
180 \& int BN_mod_sqr(BIGNUM *ret, BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
181 \& int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx);
182 \& int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
183 \&         const BIGNUM *m, BN_CTX *ctx);
184 \& int BN_gcd(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
185 \&
186 \& int BN_add_word(BIGNUM *a, BN_ULONG w);
187 \& int BN_sub_word(BIGNUM *a, BN_ULONG w);
188 \& int BN_mul_word(BIGNUM *a, BN_ULONG w);
189 \& BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
190 \& BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
191 \&
192 \& int BN_cmp(BIGNUM *a, BIGNUM *b);
193 \& int BN_ucmp(BIGNUM *a, BIGNUM *b);
194 \& int BN_is_zero(BIGNUM *a);
195 \& int BN_is_one(BIGNUM *a);
196 \& int BN_is_word(BIGNUM *a, BN_ULONG w);
197 \& int BN_is_odd(BIGNUM *a);
198 \&
199 \& int BN_zero(BIGNUM *a);
200 \& int BN_one(BIGNUM *a);
201 \& const BIGNUM *BN_value_one(void);
202 \& int BN_set_word(BIGNUM *a, unsigned long w);
203 \& unsigned long BN_get_word(BIGNUM *a);
204 \&
205 \& int BN_rand(BIGNUM *rnd, int bits, int top, int bottom);
206 \& int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom);
207 \& int BN_rand_range(BIGNUM *rnd, BIGNUM *range);
208 \& int BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range);
209 \&
210 \& BIGNUM *BN_generate_prime(BIGNUM *ret, int bits,int safe, BIGNUM *add,
211 \&         BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg);
212 \& int BN_is_prime(const BIGNUM *p, int nchecks,
213 \&         void (*callback)(int, int, void *), BN_CTX *ctx, void *cb_arg);
214 \&
215 \& int BN_set_bit(BIGNUM *a, int n);
216 \& int BN_clear_bit(BIGNUM *a, int n);
217 \& int BN_is_bit_set(const BIGNUM *a, int n);
218 \& int BN_mask_bits(BIGNUM *a, int n);
219 \& int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
220 \& int BN_lshift1(BIGNUM *r, BIGNUM *a);
221 \& int BN_rshift(BIGNUM *r, BIGNUM *a, int n);
222 \& int BN_rshift1(BIGNUM *r, BIGNUM *a);
223 \&
224 \& int BN_bn2bin(const BIGNUM *a, unsigned char *to);
225 \& BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
226 \& char *BN_bn2hex(const BIGNUM *a);
227 \& char *BN_bn2dec(const BIGNUM *a);
228 \& int BN_hex2bn(BIGNUM **a, const char *str);
229 \& int BN_dec2bn(BIGNUM **a, const char *str);
230 \& int BN_print(BIO *fp, const BIGNUM *a);
231 \& int BN_print_fp(FILE *fp, const BIGNUM *a);
232 \& int BN_bn2mpi(const BIGNUM *a, unsigned char *to);
233 \& BIGNUM *BN_mpi2bn(unsigned char *s, int len, BIGNUM *ret);
234 \&
235 \& BIGNUM *BN_mod_inverse(BIGNUM *r, BIGNUM *a, const BIGNUM *n,
236 \&     BN_CTX *ctx);
237 \&
238 \& BN_RECP_CTX *BN_RECP_CTX_new(void);
239 \& void BN_RECP_CTX_init(BN_RECP_CTX *recp);
240 \& void BN_RECP_CTX_free(BN_RECP_CTX *recp);
241 \& int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *m, BN_CTX *ctx);
242 \& int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *a, BIGNUM *b,
243 \&        BN_RECP_CTX *recp, BN_CTX *ctx);
244 \&
245 \& BN_MONT_CTX *BN_MONT_CTX_new(void);
246 \& void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
247 \& void BN_MONT_CTX_free(BN_MONT_CTX *mont);
248 \& int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *m, BN_CTX *ctx);
249 \& BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from);
250 \& int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b,
251 \&         BN_MONT_CTX *mont, BN_CTX *ctx);
252 \& int BN_from_montgomery(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mont,
253 \&         BN_CTX *ctx);
254 \& int BN_to_montgomery(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mont,
255 \&         BN_CTX *ctx);
256 \&
257 \& BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai,
258 \&        BIGNUM *mod);
259 \& void BN_BLINDING_free(BN_BLINDING *b);
260 \& int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx);
261 \& int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
262 \& int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
263 \& int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b,
264 \&        BN_CTX *ctx);
265 \& int BN_BLINDING_invert_ex(BIGNUM *n,const BIGNUM *r,BN_BLINDING *b,
266 \&        BN_CTX *ctx);
267 \& unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *);
268 \& void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long);
269 \& unsigned long BN_BLINDING_get_flags(const BN_BLINDING *);
270 \& void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long);
271 \& BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,
272 \&        const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,
273 \&        int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
274 \&                          const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx),
275 \&        BN_MONT_CTX *m_ctx);
276 .Ve
277 .SH "DESCRIPTION"
278 .IX Header "DESCRIPTION"
279 This library performs arithmetic operations on integers of arbitrary
280 size. It was written for use in public key cryptography, such as \s-1RSA\s0
281 and Diffie-Hellman.
282 .PP
283 It uses dynamic memory allocation for storing its data structures.
284 That means that there is no limit on the size of the numbers
285 manipulated by these functions, but return values must always be
286 checked in case a memory allocation error has occurred.
287 .PP
288 The basic object in this library is a \fB\s-1BIGNUM\s0\fR. It is used to hold a
289 single large integer. This type should be considered opaque and fields
290 should not be modified or accessed directly.
291 .PP
292 The creation of \fB\s-1BIGNUM\s0\fR objects is described in \fIBN_new\fR\|(3);
293 \&\fIBN_add\fR\|(3) describes most of the arithmetic operations.
294 Comparison is described in \fIBN_cmp\fR\|(3); \fIBN_zero\fR\|(3)
295 describes certain assignments, \fIBN_rand\fR\|(3) the generation of
296 random numbers, \fIBN_generate_prime\fR\|(3) deals with prime
297 numbers and \fIBN_set_bit\fR\|(3) with bit operations. The conversion
298 of \fB\s-1BIGNUM\s0\fRs to external formats is described in \fIBN_bn2bin\fR\|(3).
299 .SH "SEE ALSO"
300 .IX Header "SEE ALSO"
301 \&\fIbn_internal\fR\|(3),
302 \&\fIdh\fR\|(3), \fIerr\fR\|(3), \fIrand\fR\|(3), \fIrsa\fR\|(3),
303 \&\fIBN_new\fR\|(3), \fIBN_CTX_new\fR\|(3),
304 \&\fIBN_copy\fR\|(3), \fIBN_swap\fR\|(3), \fIBN_num_bytes\fR\|(3),
305 \&\fIBN_add\fR\|(3), \fIBN_add_word\fR\|(3),
306 \&\fIBN_cmp\fR\|(3), \fIBN_zero\fR\|(3), \fIBN_rand\fR\|(3),
307 \&\fIBN_generate_prime\fR\|(3), \fIBN_set_bit\fR\|(3),
308 \&\fIBN_bn2bin\fR\|(3), \fIBN_mod_inverse\fR\|(3),
309 \&\fIBN_mod_mul_reciprocal\fR\|(3),
310 \&\fIBN_mod_mul_montgomery\fR\|(3),
311 \&\fIBN_BLINDING_new\fR\|(3)