diff options
Diffstat (limited to 'src/lib/libcrypto')
-rw-r--r-- | src/lib/libcrypto/man/BN_BLINDING_new.3 | 269 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BN_CTX_new.3 | 91 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BN_CTX_start.3 | 85 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BN_add.3 | 352 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BN_add_word.3 | 123 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BN_bn2bin.3 | 237 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BN_cmp.3 | 99 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BN_copy.3 | 52 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BN_generate_prime.3 | 289 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BN_mod_inverse.3 | 59 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BN_mod_mul_montgomery.3 | 181 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BN_mod_mul_reciprocal.3 | 147 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BN_new.3 | 84 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BN_num_bytes.3 | 76 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BN_rand.3 | 93 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BN_set_bit.3 | 157 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BN_swap.3 | 23 | ||||
-rw-r--r-- | src/lib/libcrypto/man/BN_zero.3 | 101 | ||||
-rw-r--r-- | src/lib/libcrypto/man/Makefile | 6 |
19 files changed, 2521 insertions, 3 deletions
diff --git a/src/lib/libcrypto/man/BN_BLINDING_new.3 b/src/lib/libcrypto/man/BN_BLINDING_new.3 new file mode 100644 index 0000000000..c65d79c3bc --- /dev/null +++ b/src/lib/libcrypto/man/BN_BLINDING_new.3 | |||
@@ -0,0 +1,269 @@ | |||
1 | .Dd $Mdocdate: February 23 2015 $ | ||
2 | .Dt BN_BLINDING_NEW 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BN_BLINDING_new , | ||
6 | .Nm BN_BLINDING_free , | ||
7 | .Nm BN_BLINDING_update , | ||
8 | .Nm BN_BLINDING_convert , | ||
9 | .Nm BN_BLINDING_invert , | ||
10 | .Nm BN_BLINDING_convert_ex , | ||
11 | .Nm BN_BLINDING_invert_ex , | ||
12 | .Nm BN_BLINDING_get_thread_id , | ||
13 | .Nm BN_BLINDING_set_thread_id , | ||
14 | .Nm BN_BLINDING_thread_id , | ||
15 | .Nm BN_BLINDING_get_flags , | ||
16 | .Nm BN_BLINDING_set_flags , | ||
17 | .Nm BN_BLINDING_create_param | ||
18 | .Nd blinding related BIGNUM functions | ||
19 | .Sh SYNOPSIS | ||
20 | .In openssl/bn.h | ||
21 | .Ft BN_BLINDING * | ||
22 | .Fo BN_BLINDING_new | ||
23 | .Fa "const BIGNUM *A" | ||
24 | .Fa "const BIGNUM *Ai" | ||
25 | .Fa "BIGNUM *mod" | ||
26 | .Fc | ||
27 | .Ft void | ||
28 | .Fo BN_BLINDING_free | ||
29 | .Fa "BN_BLINDING *b" | ||
30 | .Fc | ||
31 | .Ft int | ||
32 | .Fo BN_BLINDING_update | ||
33 | .Fa "BN_BLINDING *b" | ||
34 | .Fa "BN_CTX *ctx" | ||
35 | .Fc | ||
36 | .Ft int | ||
37 | .Fo BN_BLINDING_convert | ||
38 | .Fa "BIGNUM *n" | ||
39 | .Fa "BN_BLINDING *b" | ||
40 | .Fa "BN_CTX *ctx" | ||
41 | .Fc | ||
42 | .Ft int | ||
43 | .Fo BN_BLINDING_invert | ||
44 | .Fa "BIGNUM *n" | ||
45 | .Fa "BN_BLINDING *b" | ||
46 | .Fa "BN_CTX *ctx" | ||
47 | .Fc | ||
48 | .Ft int | ||
49 | .Fo BN_BLINDING_convert_ex | ||
50 | .Fa "BIGNUM *n" | ||
51 | .Fa "BIGNUM *r" | ||
52 | .Fa "BN_BLINDING *b" | ||
53 | .Fa "BN_CTX *ctx" | ||
54 | .Fc | ||
55 | .Ft int | ||
56 | .Fo BN_BLINDING_invert_ex | ||
57 | .Fa "BIGNUM *n" | ||
58 | .Fa "const BIGNUM *r" | ||
59 | .Fa "BN_BLINDING *b" | ||
60 | .Fa "BN_CTX *ctx" | ||
61 | .Fc | ||
62 | .Fd #ifndef OPENSSL_NO_DEPRECATED | ||
63 | .Ft unsigned long | ||
64 | .Fo BN_BLINDING_get_thread_id | ||
65 | .Fa "const BN_BLINDING *" | ||
66 | .Fc | ||
67 | .Ft void | ||
68 | .Fo BN_BLINDING_set_thread_id | ||
69 | .Fa "BN_BLINDING *" | ||
70 | .Fa "unsigned long" | ||
71 | .Fc | ||
72 | .Fd #endif | ||
73 | .Ft CRYPTO_THREADID * | ||
74 | .Fo BN_BLINDING_thread_id | ||
75 | .Fa "BN_BLINDING *" | ||
76 | .Fc | ||
77 | .Ft unsigned long | ||
78 | .Fo BN_BLINDING_get_flags | ||
79 | .Fa "const BN_BLINDING *" | ||
80 | .Fc | ||
81 | .Ft void | ||
82 | .Fo BN_BLINDING_set_flags | ||
83 | .Fa "BN_BLINDING *" | ||
84 | .Fa "unsigned long" | ||
85 | .Fc | ||
86 | .Ft BN_BLINDING * | ||
87 | .Fo BN_BLINDING_create_param | ||
88 | .Fa "BN_BLINDING *b" | ||
89 | .Fa "const BIGNUM *e" | ||
90 | .Fa "BIGNUM *m" | ||
91 | .Fa "BN_CTX *ctx" | ||
92 | .Fa "int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\ | ||
93 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)" | ||
94 | .Fa "BN_MONT_CTX *m_ctx" | ||
95 | .Fc | ||
96 | .Sh DESCRIPTION | ||
97 | .Fn BN_BLINDING_new | ||
98 | allocates a new | ||
99 | .Vt BN_BLINDING | ||
100 | structure and copies the | ||
101 | .Fa A | ||
102 | and | ||
103 | .Fa \&Ai | ||
104 | values into the newly created | ||
105 | .Vt BN_BLINDING | ||
106 | object. | ||
107 | .Pp | ||
108 | .Fn BN_BLINDING_free | ||
109 | frees the | ||
110 | .Vt BN_BLINDING | ||
111 | structure. | ||
112 | .Pp | ||
113 | .Fn BN_BLINDING_update | ||
114 | updates the | ||
115 | .Vt BN_BLINDING | ||
116 | parameters by squaring the | ||
117 | .Fa A | ||
118 | and | ||
119 | .Fa \&Ai | ||
120 | or, after specific number of uses and if the necessary parameters are | ||
121 | set, by re-creating the blinding parameters. | ||
122 | .Pp | ||
123 | .Fn BN_BLINDING_convert_ex | ||
124 | multiplies | ||
125 | .Fa n | ||
126 | with the blinding factor | ||
127 | .Fa A . | ||
128 | If | ||
129 | .Fa r | ||
130 | is not | ||
131 | .Dv NULL , | ||
132 | a copy of the inverse blinding factor | ||
133 | .Fa \&Ai | ||
134 | will be returned in | ||
135 | .Fa r | ||
136 | (this is useful if a | ||
137 | .Vt RSA | ||
138 | object is shared among several threads). | ||
139 | .Fn BN_BLINDING_invert_ex | ||
140 | multiplies | ||
141 | .Fa n | ||
142 | with the inverse blinding factor | ||
143 | .Fa \&Ai . | ||
144 | If | ||
145 | .Fa r | ||
146 | is not | ||
147 | .Dv NULL , | ||
148 | it will be used as the inverse blinding. | ||
149 | .Pp | ||
150 | .Fn BN_BLINDING_convert | ||
151 | and | ||
152 | .Fn BN_BLINDING_invert | ||
153 | are wrapper functions for | ||
154 | .Fn BN_BLINDING_convert_ex | ||
155 | and | ||
156 | .Fn BN_BLINDING_invert_ex | ||
157 | with | ||
158 | .Fa r | ||
159 | set to | ||
160 | .Dv NULL . | ||
161 | .Pp | ||
162 | .Fn BN_BLINDING_thread_id | ||
163 | provides access to the | ||
164 | .Vt CRYPTO_THREADID | ||
165 | object within the | ||
166 | .Vt BN_BLINDING | ||
167 | structure. | ||
168 | This is to help users provide proper locking if needed for | ||
169 | multi-threaded use. | ||
170 | The "thread id" object of a newly allocated | ||
171 | .Vt BN_BLINDING | ||
172 | structure is initialised to the thread id in which | ||
173 | .Fn BN_BLINDING_new | ||
174 | was called. | ||
175 | .Pp | ||
176 | .Fn BN_BLINDING_get_flags | ||
177 | returns the | ||
178 | .Dv BN_BLINDING_* | ||
179 | flags. | ||
180 | Currently there are two supported flags: | ||
181 | .Dv BN_BLINDING_NO_UPDATE | ||
182 | and | ||
183 | .Dv BN_BLINDING_NO_RECREATE . | ||
184 | .Dv BN_BLINDING_NO_UPDATE | ||
185 | inhibits the automatic update of the | ||
186 | .Vt BN_BLINDING | ||
187 | parameters after each use and | ||
188 | .Dv BN_BLINDING_NO_RECREATE | ||
189 | inhibits the automatic re-creation of the | ||
190 | .Vt BN_BLINDING | ||
191 | parameters after a fixed number of uses (currently 32). | ||
192 | In newly allocated | ||
193 | .Vt BN_BLINDING | ||
194 | objects no flags are set. | ||
195 | .Fn BN_BLINDING_set_flags | ||
196 | sets the | ||
197 | .Dv BN_BLINDING_* | ||
198 | parameters flags. | ||
199 | .Pp | ||
200 | .Fn BN_BLINDING_create_param | ||
201 | creates new | ||
202 | .Vt BN_BLINDING | ||
203 | parameters using the exponent | ||
204 | .Fa e | ||
205 | and the modulus | ||
206 | .Fa m . | ||
207 | .Fa bn_mod_exp | ||
208 | and | ||
209 | .Fa m_ctx | ||
210 | can be used to pass special functions for exponentiation (normally | ||
211 | .Xr BN_mod_exp_mont 3 | ||
212 | and | ||
213 | .Vt BN_MONT_CTX Ns ). | ||
214 | .Sh RETURN VALUES | ||
215 | .Fn BN_BLINDING_new | ||
216 | returns the newly allocated | ||
217 | .Vt BN_BLINDING | ||
218 | structure or | ||
219 | .Dv NULL | ||
220 | in case of an error. | ||
221 | .Pp | ||
222 | .Fn BN_BLINDING_update , | ||
223 | .Fn BN_BLINDING_convert , | ||
224 | .Fn BN_BLINDING_invert , | ||
225 | .Fn BN_BLINDING_convert_ex | ||
226 | and | ||
227 | .Fn BN_BLINDING_invert_ex | ||
228 | return 1 on success and 0 if an error occured. | ||
229 | .Pp | ||
230 | .Fn BN_BLINDING_thread_id | ||
231 | returns a pointer to the thread id object within a | ||
232 | .Vt BN_BLINDING | ||
233 | object. | ||
234 | .Pp | ||
235 | .Fn BN_BLINDING_get_flags | ||
236 | returns the currently set | ||
237 | .Dv BN_BLINDING_* | ||
238 | flags (an | ||
239 | .Vt unsigned long | ||
240 | value). | ||
241 | .Pp | ||
242 | .Fn BN_BLINDING_create_param | ||
243 | returns the newly created | ||
244 | .Vt BN_BLINDING | ||
245 | parameters or | ||
246 | .Dv NULL | ||
247 | on error. | ||
248 | .Sh SEE ALSO | ||
249 | .Xr bn 3 | ||
250 | .Sh HISTORY | ||
251 | .Fn BN_BLINDING_thread_id | ||
252 | was first introduced in OpenSSL 1.0.0, and it deprecates | ||
253 | .Fn BN_BLINDING_set_thread_id | ||
254 | and | ||
255 | .Fn BN_BLINDING_get_thread_id . | ||
256 | .Pp | ||
257 | .Fn BN_BLINDING_convert_ex , | ||
258 | .Fn BN_BLINDIND_invert_ex , | ||
259 | .Fn BN_BLINDING_get_thread_id , | ||
260 | .Fn BN_BLINDING_set_thread_id , | ||
261 | .Fn BN_BLINDING_set_flags , | ||
262 | .Fn BN_BLINDING_get_flags | ||
263 | and | ||
264 | .Fn BN_BLINDING_create_param | ||
265 | were first introduced in OpenSSL 0.9.8 | ||
266 | .Sh AUTHORS | ||
267 | .An Nils Larsch | ||
268 | for | ||
269 | .Lk http://www.openssl.org/ "the OpenSSL project" . | ||
diff --git a/src/lib/libcrypto/man/BN_CTX_new.3 b/src/lib/libcrypto/man/BN_CTX_new.3 new file mode 100644 index 0000000000..1a77314854 --- /dev/null +++ b/src/lib/libcrypto/man/BN_CTX_new.3 | |||
@@ -0,0 +1,91 @@ | |||
1 | .Dd $Mdocdate: February 23 2015 $ | ||
2 | .Dt BN_CTX_NEW 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BN_CTX_new , | ||
6 | .Nm BN_CTX_init , | ||
7 | .Nm BN_CTX_free | ||
8 | .Nd allocate and free BN_CTX structures | ||
9 | .Sh SYNOPSIS | ||
10 | .In openssl/bn.h | ||
11 | .Ft BN_CTX * | ||
12 | .Fo BN_CTX_new | ||
13 | .Fa void | ||
14 | .Fc | ||
15 | .Ft void | ||
16 | .Fo BN_CTX_free | ||
17 | .Fa "BN_CTX *c" | ||
18 | .Fc | ||
19 | .Pp | ||
20 | Deprecated: | ||
21 | .Pp | ||
22 | .Ft void | ||
23 | .Fo BN_CTX_init | ||
24 | .Fa "BN_CTX *c" | ||
25 | .Fc | ||
26 | .Sh DESCRIPTION | ||
27 | A | ||
28 | .Vt BN_CTX | ||
29 | is a structure that holds | ||
30 | .Vt BIGNUM | ||
31 | temporary variables used by library functions. | ||
32 | Since dynamic memory allocation to create | ||
33 | .Vt BIGNUM Ns s | ||
34 | is rather expensive when used in conjunction with repeated subroutine | ||
35 | calls, the | ||
36 | .Vt BN_CTX | ||
37 | structure is used. | ||
38 | .Pp | ||
39 | .Fn BN_CTX_new | ||
40 | allocates and initializes a | ||
41 | .Vt BN_CTX | ||
42 | structure. | ||
43 | .Pp | ||
44 | .Fn BN_CTX_free | ||
45 | frees the components of the | ||
46 | .Vt BN_CTX , | ||
47 | and if it was created by | ||
48 | .Fn BN_CTX_new , | ||
49 | also the structure itself. | ||
50 | If | ||
51 | .Xr BN_CTX_start 3 | ||
52 | has been used on the | ||
53 | .Vt BN_CTX , | ||
54 | .Xr BN_CTX_end 3 | ||
55 | must be called before the | ||
56 | .Vt BN_CTX | ||
57 | may be freed by | ||
58 | .Fn BN_CTX_free . | ||
59 | .Pp | ||
60 | .Fn BN_CTX_init | ||
61 | (deprecated) initializes an existing uninitialized | ||
62 | .Vt BN_CTX . | ||
63 | This should not be used for new programs. | ||
64 | Use | ||
65 | .Fn BN_CTX_new | ||
66 | instead. | ||
67 | .Sh RETURN VALUES | ||
68 | .Fn BN_CTX_new | ||
69 | returns a pointer to the | ||
70 | .Vt BN_CTX . | ||
71 | If the allocation fails, it returns | ||
72 | .Dv NULL | ||
73 | and sets an error code that can be obtained by | ||
74 | .Xr ERR_get_error 3 . | ||
75 | .Pp | ||
76 | .Fn BN_CTX_init | ||
77 | and | ||
78 | .Fn BN_CTX_free | ||
79 | return no value. | ||
80 | .Sh SEE ALSO | ||
81 | .Xr bn 3 , | ||
82 | .Xr BN_add 3 , | ||
83 | .Xr BN_CTX_start 3 , | ||
84 | .Xr ERR_get_error 3 | ||
85 | .Sh HISTORY | ||
86 | .Fn BN_CTX_new | ||
87 | and | ||
88 | .Fn BN_CTX_free | ||
89 | are available in all versions on SSLeay and OpenSSL. | ||
90 | .Fn BN_CTX_init | ||
91 | was added in SSLeay 0.9.1b. | ||
diff --git a/src/lib/libcrypto/man/BN_CTX_start.3 b/src/lib/libcrypto/man/BN_CTX_start.3 new file mode 100644 index 0000000000..986208ba1a --- /dev/null +++ b/src/lib/libcrypto/man/BN_CTX_start.3 | |||
@@ -0,0 +1,85 @@ | |||
1 | .Dd $Mdocdate: February 23 2015 $ | ||
2 | .Dt BN_CTX_START 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BN_CTX_start , | ||
6 | .Nm BN_CTX_get , | ||
7 | .Nm BN_CTX_end | ||
8 | .Nd use temporary BIGNUM variables | ||
9 | .Sh SYNOPSIS | ||
10 | .In openssl/bn.h | ||
11 | .Ft void | ||
12 | .Fo BN_CTX_start | ||
13 | .Fa "BN_CTX *ctx" | ||
14 | .Fc | ||
15 | .Ft BIGNUM * | ||
16 | .Fo BN_CTX_get | ||
17 | .Fa "BN_CTX *ctx" | ||
18 | .Fc | ||
19 | .Ft void | ||
20 | .Fo BN_CTX_end | ||
21 | .Fa "BN_CTX *ctx" | ||
22 | .Fc | ||
23 | .Sh DESCRIPTION | ||
24 | These functions are used to obtain temporary | ||
25 | .Vt BIGNUM | ||
26 | variables from a | ||
27 | .Vt BN_CTX | ||
28 | (which can been created by using | ||
29 | .Xr BN_CTX_new 3 ) | ||
30 | in order to save the overhead of repeatedly creating and freeing | ||
31 | .Vt BIGNUM Ns s | ||
32 | in functions that are called from inside a loop. | ||
33 | .Pp | ||
34 | A function must call | ||
35 | .Fn BN_CTX_start | ||
36 | first. | ||
37 | Then, | ||
38 | .Fn BN_CTX_get | ||
39 | may be called repeatedly to obtain temporary | ||
40 | .Vt BIGNUM Ns s. | ||
41 | All | ||
42 | .Fn BN_CTX_get | ||
43 | calls must be made before calling any other functions that use the | ||
44 | .Fa ctx | ||
45 | as an argument. | ||
46 | .Pp | ||
47 | Finally, | ||
48 | .Fn BN_CTX_end | ||
49 | must be called before returning from the function. | ||
50 | When | ||
51 | .Fn BN_CTX_end | ||
52 | is called, the | ||
53 | .Vt BIGNUM | ||
54 | pointers obtained from | ||
55 | .Fn BN_CTX_get | ||
56 | become invalid. | ||
57 | .Sh RETURN VALUES | ||
58 | .Fn BN_CTX_start | ||
59 | and | ||
60 | .Fn BN_CTX_end | ||
61 | return no values. | ||
62 | .Pp | ||
63 | .Fn BN_CTX_get | ||
64 | returns a pointer to the | ||
65 | .Vt BIGNUM , | ||
66 | or | ||
67 | .Dv NULL | ||
68 | on error. | ||
69 | Once | ||
70 | .Fn BN_CTX_get | ||
71 | has failed, the subsequent calls will return | ||
72 | .Dv NULL | ||
73 | as well, so it is sufficient to check the return value of the last | ||
74 | .Fn BN_CTX_get | ||
75 | call. | ||
76 | In case of an error, an error code is set, which can be obtained by | ||
77 | .Xr ERR_get_error 3 . | ||
78 | .Sh SEE ALSO | ||
79 | .Xr BN_CTX_new 3 | ||
80 | .Sh HISTORY | ||
81 | .Fn BN_CTX_start , | ||
82 | .Fn BN_CTX_get , | ||
83 | and | ||
84 | .Fn BN_CTX_end | ||
85 | were added in OpenSSL 0.9.5. | ||
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. | ||
diff --git a/src/lib/libcrypto/man/BN_add_word.3 b/src/lib/libcrypto/man/BN_add_word.3 new file mode 100644 index 0000000000..930aae4d32 --- /dev/null +++ b/src/lib/libcrypto/man/BN_add_word.3 | |||
@@ -0,0 +1,123 @@ | |||
1 | .Dd $Mdocdate: February 23 2015 $ | ||
2 | .Dt BN_ADD_WORD 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BN_add_word , | ||
6 | .Nm BN_sub_word , | ||
7 | .Nm BN_mul_word , | ||
8 | .Nm BN_div_word , | ||
9 | .Nm BN_mod_word | ||
10 | .Nd arithmetic functions on BIGNUMs with integers | ||
11 | .Sh SYNOPSIS | ||
12 | .In openssl/bn.h | ||
13 | .Ft int | ||
14 | .Fo BN_add_word | ||
15 | .Fa "BIGNUM *a" | ||
16 | .Fa "BN_ULONG w" | ||
17 | .Fc | ||
18 | .Ft int | ||
19 | .Fo BN_sub_word | ||
20 | .Fa "BIGNUM *a" | ||
21 | .Fa "BN_ULONG w" | ||
22 | .Fc | ||
23 | .Ft int | ||
24 | .Fo BN_mul_word | ||
25 | .Fa "BIGNUM *a" | ||
26 | .Fa "BN_ULONG w" | ||
27 | .Fc | ||
28 | .Ft BN_ULONG | ||
29 | .Fo BN_div_word | ||
30 | .Fa "BIGNUM *a" | ||
31 | .Fa "BN_ULONG w" | ||
32 | .Fc | ||
33 | .Ft BN_ULONG | ||
34 | .Fo BN_mod_word | ||
35 | .Fa "const BIGNUM *a" | ||
36 | .Fa "BN_ULONG w" | ||
37 | .Fc | ||
38 | .Sh DESCRIPTION | ||
39 | These functions perform arithmetic operations on BIGNUMs with unsigned | ||
40 | integers. | ||
41 | They are much more efficient than the normal BIGNUM arithmetic | ||
42 | operations. | ||
43 | .Pp | ||
44 | .Fn BN_add_word | ||
45 | adds | ||
46 | .Fa w | ||
47 | to | ||
48 | .Fa a | ||
49 | .Pq Li a+=w . | ||
50 | .Pp | ||
51 | .Fn BN_sub_word | ||
52 | subtracts | ||
53 | .Fa w | ||
54 | from | ||
55 | .Fa a | ||
56 | .Pq Li a-=w . | ||
57 | .Pp | ||
58 | .Fn BN_mul_word | ||
59 | multiplies | ||
60 | .Fa a | ||
61 | and | ||
62 | .Fa w | ||
63 | .Pq Li a*=w . | ||
64 | .Pp | ||
65 | .Fn BN_div_word | ||
66 | divides | ||
67 | .Fa a | ||
68 | by | ||
69 | .Fa w | ||
70 | .Pq Li a/=w | ||
71 | and returns the remainder. | ||
72 | .Pp | ||
73 | .Fn BN_mod_word | ||
74 | returns the remainder of | ||
75 | .Fa a | ||
76 | divided by | ||
77 | .Fa w | ||
78 | .Pq Li a%w . | ||
79 | .Pp | ||
80 | For | ||
81 | .Fn BN_div_word | ||
82 | and | ||
83 | .Fn BN_mod_word , | ||
84 | .Fa w | ||
85 | must not be 0. | ||
86 | .Sh RETURN VALUES | ||
87 | .Fn BN_add_word , | ||
88 | .Fn BN_sub_word , | ||
89 | and | ||
90 | .Fn BN_mul_word | ||
91 | return 1 for success, 0 on error. | ||
92 | The error codes can be obtained by | ||
93 | .Xr ERR_get_error 3 . | ||
94 | .Pp | ||
95 | .Fn BN_mod_word | ||
96 | and | ||
97 | .Fn BN_div_word | ||
98 | return | ||
99 | .Fa a Ns % Ns Fa w | ||
100 | on success and | ||
101 | .Pq Vt BN_ULONG Ns -1 | ||
102 | if an error occurred. | ||
103 | .Sh SEE ALSO | ||
104 | .Xr bn 3 , | ||
105 | .Xr BN_add 3 , | ||
106 | .Xr ERR_get_error 3 | ||
107 | .Sh HISTORY | ||
108 | .Fn BN_add_word | ||
109 | and | ||
110 | .Fn BN_mod_word | ||
111 | are available in all versions of SSLeay and OpenSSL. | ||
112 | .Fn BN_div_word | ||
113 | was added in SSLeay 0.8, and | ||
114 | .Fn BN_sub_word | ||
115 | and | ||
116 | .Fn BN_mul_word | ||
117 | in SSLeay 0.9.0. | ||
118 | .Pp | ||
119 | Before 0.9.8a, the return value for | ||
120 | .Fn BN_div_word | ||
121 | and | ||
122 | .Fn BN_mod_word | ||
123 | in case of an error was 0. | ||
diff --git a/src/lib/libcrypto/man/BN_bn2bin.3 b/src/lib/libcrypto/man/BN_bn2bin.3 new file mode 100644 index 0000000000..02d6b2c8b8 --- /dev/null +++ b/src/lib/libcrypto/man/BN_bn2bin.3 | |||
@@ -0,0 +1,237 @@ | |||
1 | .Dd $Mdocdate: February 23 2015 $ | ||
2 | .Dt BN_BN2BIN 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BN_bn2bin , | ||
6 | .Nm BN_bin2bn , | ||
7 | .Nm BN_bn2hex , | ||
8 | .Nm BN_bn2dec , | ||
9 | .Nm BN_hex2bn , | ||
10 | .Nm BN_dec2bn , | ||
11 | .Nm BN_print , | ||
12 | .Nm BN_print_fp , | ||
13 | .Nm BN_bn2mpi , | ||
14 | .Nm BN_mpi2bn | ||
15 | .Nd format conversions | ||
16 | .Sh SYNOPSIS | ||
17 | .In openssl/bn.h | ||
18 | .Ft int | ||
19 | .Fo BN_bn2bin | ||
20 | .Fa "const BIGNUM *a" | ||
21 | .Fa "unsigned char *to" | ||
22 | .Fc | ||
23 | .Ft BIGNUM * | ||
24 | .Fo BN_bin2bn | ||
25 | .Fa "const unsigned char *s" | ||
26 | .Fa "int len" | ||
27 | .Fa "BIGNUM *ret" | ||
28 | .Fc | ||
29 | .Ft char * | ||
30 | .Fo BN_bn2hex | ||
31 | .Fa "const BIGNUM *a" | ||
32 | .Fc | ||
33 | .Ft char * | ||
34 | .Fo BN_bn2dec | ||
35 | .Fa "const BIGNUM *a" | ||
36 | .Fc | ||
37 | .Ft int | ||
38 | .Fo BN_hex2bn | ||
39 | .Fa "BIGNUM **a" | ||
40 | .Fa "const char *str" | ||
41 | .Fc | ||
42 | .Ft int | ||
43 | .Fo BN_dec2bn | ||
44 | .Fa "BIGNUM **a" | ||
45 | .Fa "const char *str" | ||
46 | .Fc | ||
47 | .Ft int | ||
48 | .Fo BN_print | ||
49 | .Fa "BIO *fp" | ||
50 | .Fa "const BIGNUM *a" | ||
51 | .Fc | ||
52 | .Ft int | ||
53 | .Fo BN_print_fp | ||
54 | .Fa "FILE *fp" | ||
55 | .Fa "const BIGNUM *a" | ||
56 | .Fc | ||
57 | .Ft int | ||
58 | .Fo BN_bn2mpi | ||
59 | .Fa "const BIGNUM *a" | ||
60 | .Fa "unsigned char *to" | ||
61 | .Fc | ||
62 | .Ft BIGNUM * | ||
63 | .Fo BN_mpi2bn | ||
64 | .Fa "unsigned char *s" | ||
65 | .Fa "int len" | ||
66 | .Fa "BIGNUM *ret" | ||
67 | .Fc | ||
68 | .Sh DESCRIPTION | ||
69 | .Fn BN_bn2bin | ||
70 | converts the absolute value of | ||
71 | .Fa a | ||
72 | into big-endian form and stores it at | ||
73 | .Fa to . | ||
74 | .Fa to | ||
75 | must point to | ||
76 | .Fn BN_num_bytes a | ||
77 | bytes of memory. | ||
78 | .Pp | ||
79 | .Fn BN_bin2bn | ||
80 | converts the positive integer in big-endian form of length | ||
81 | .Fa len | ||
82 | at | ||
83 | .Fa s | ||
84 | into a | ||
85 | .Vt BIGNUM | ||
86 | and places it in | ||
87 | .Fa ret . | ||
88 | If | ||
89 | .Fa ret | ||
90 | is | ||
91 | .Dv NULL , | ||
92 | a new | ||
93 | .Vt BIGNUM | ||
94 | is created. | ||
95 | .Pp | ||
96 | .Fn BN_bn2hex | ||
97 | and | ||
98 | .Fn BN_bn2dec | ||
99 | return printable strings containing the hexadecimal and decimal encoding of | ||
100 | .Fa a | ||
101 | respectively. | ||
102 | For negative numbers, the string is prefaced with a leading minus sign. | ||
103 | The string must be freed later using | ||
104 | .Xr free 3 . | ||
105 | .Pp | ||
106 | .Fn BN_hex2bn | ||
107 | converts the string | ||
108 | .Fa str | ||
109 | containing a hexadecimal number to a | ||
110 | .Vt BIGNUM | ||
111 | and stores it in | ||
112 | .Pf * Fa a . | ||
113 | If | ||
114 | .Pf * Fa a | ||
115 | is | ||
116 | .Dv NULL , | ||
117 | a new | ||
118 | .Vt BIGNUM | ||
119 | is created. | ||
120 | If | ||
121 | .Fa a | ||
122 | is | ||
123 | .Dv NULL , | ||
124 | it only computes the number's length in hexadecimal digits. | ||
125 | If the string starts with a minus sign, the number is negative. | ||
126 | .Fn BN_dec2bn | ||
127 | is the same using the decimal system. | ||
128 | .Pp | ||
129 | .Fn BN_print | ||
130 | and | ||
131 | .Fn BN_print_fp | ||
132 | write the hexadecimal encoding of | ||
133 | .Fa a , | ||
134 | with a leading minus sign for negative numbers, to the | ||
135 | .Vt BIO | ||
136 | or | ||
137 | .Vt FILE | ||
138 | .Fa fp . | ||
139 | .Pp | ||
140 | .Fn BN_bn2mpi | ||
141 | and | ||
142 | .Fn BN_mpi2bn | ||
143 | convert | ||
144 | .Vt BIGNUM Ns s | ||
145 | from and to a format that consists of the number's length in bytes | ||
146 | represented as a 4-byte big-endian number, and the number itself in | ||
147 | big-endian format, where the most significant bit signals a negative | ||
148 | number (the representation of numbers with the MSB set is prefixed with | ||
149 | a NUL byte). | ||
150 | .Pp | ||
151 | .Fn BN_bn2mpi | ||
152 | stores the representation of | ||
153 | .Fa a | ||
154 | at | ||
155 | .Fa to , | ||
156 | where | ||
157 | .Fa to | ||
158 | must be large enough to hold the result. | ||
159 | The size can be determined by calling | ||
160 | .Fn BN_bn2mpi a , NULL . | ||
161 | .Pp | ||
162 | .Fn BN_mpi2bn | ||
163 | converts the | ||
164 | .Fa len | ||
165 | bytes long representation at | ||
166 | .Fa s | ||
167 | to a | ||
168 | .Vt BIGNUM | ||
169 | and stores it at | ||
170 | .Fa ret , | ||
171 | or in a newly allocated | ||
172 | .Vt BIGNUM | ||
173 | if | ||
174 | .Fa ret | ||
175 | is | ||
176 | .Dv NULL . | ||
177 | .Sh RETURN VALUES | ||
178 | .Fn BN_bn2bin | ||
179 | returns the length of the big-endian number placed at | ||
180 | .Fa to . | ||
181 | .Fn BN_bin2bn | ||
182 | returns the | ||
183 | .Vt BIGNUM , | ||
184 | or | ||
185 | .Dv NULL | ||
186 | on error. | ||
187 | .Pp | ||
188 | .Fn BN_bn2hex | ||
189 | and | ||
190 | .Fn BN_bn2dec | ||
191 | return a NUL-terminated string, or | ||
192 | .Dv NULL | ||
193 | on error. | ||
194 | .Fn BN_hex2bn | ||
195 | and | ||
196 | .Fn BN_dec2bn | ||
197 | return the number's length in hexadecimal or decimal digits, and 0 on | ||
198 | error. | ||
199 | .Pp | ||
200 | .Fn BN_print_fp | ||
201 | and | ||
202 | .Fn BN_print | ||
203 | return 1 on success, 0 on write errors. | ||
204 | .Pp | ||
205 | .Fn BN_bn2mpi | ||
206 | returns the length of the representation. | ||
207 | .Fn BN_mpi2bn | ||
208 | returns the | ||
209 | .Vt BIGNUM , | ||
210 | or | ||
211 | .Dv NULL | ||
212 | on error. | ||
213 | .Pp | ||
214 | The error codes can be obtained by | ||
215 | .Xr ERR_get_error 3 . | ||
216 | .Sh SEE ALSO | ||
217 | .Xr ASN1_INTEGER_to_BN 3 , | ||
218 | .Xr bn 3 , | ||
219 | .Xr BN_num_bytes 3 , | ||
220 | .Xr BN_zero 3 , | ||
221 | .Xr ERR_get_error 3 | ||
222 | .Sh HISTORY | ||
223 | .Fn BN_bn2bin , | ||
224 | .Fn BN_bin2bn , | ||
225 | .Fn BN_print_fp , | ||
226 | and | ||
227 | .Fn BN_print | ||
228 | are available in all versions of SSLeay and OpenSSL. | ||
229 | .Pp | ||
230 | .Fn BN_bn2hex , | ||
231 | .Fn BN_bn2dec , | ||
232 | .Fn BN_hex2bn , | ||
233 | .Fn BN_dec2bn , | ||
234 | .Fn BN_bn2mpi , | ||
235 | and | ||
236 | .Fn BN_mpi2bn | ||
237 | were added in SSLeay 0.9.0. | ||
diff --git a/src/lib/libcrypto/man/BN_cmp.3 b/src/lib/libcrypto/man/BN_cmp.3 new file mode 100644 index 0000000000..b0a03b25ce --- /dev/null +++ b/src/lib/libcrypto/man/BN_cmp.3 | |||
@@ -0,0 +1,99 @@ | |||
1 | .Dd $Mdocdate: February 23 2015 $ | ||
2 | .Dt BN_CMP 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BN_cmp , | ||
6 | .Nm BN_ucmp , | ||
7 | .Nm BN_is_zero , | ||
8 | .Nm BN_is_one , | ||
9 | .Nm BN_is_word , | ||
10 | .Nm BN_is_odd | ||
11 | .Nd BIGNUM comparison and test functions | ||
12 | .Sh SYNOPSIS | ||
13 | .In openssl/bn.h | ||
14 | .Ft int | ||
15 | .Fo BN_cmp | ||
16 | .Fa "BIGNUM *a" | ||
17 | .Fa "BIGNUM *b" | ||
18 | .Fc | ||
19 | .Ft int | ||
20 | .Fo BN_ucmp | ||
21 | .Fa "BIGNUM *a" | ||
22 | .Fa "BIGNUM *b" | ||
23 | .Fc | ||
24 | .Ft int | ||
25 | .Fo BN_is_zero | ||
26 | .Fa "BIGNUM *a" | ||
27 | .Fc | ||
28 | .Ft int | ||
29 | .Fo BN_is_one | ||
30 | .Fa "BIGNUM *a" | ||
31 | .Fc | ||
32 | .Ft int | ||
33 | .Fo BN_is_word | ||
34 | .Fa "BIGNUM *a" | ||
35 | .Fa "BN_ULONG w" | ||
36 | .Fc | ||
37 | .Ft int | ||
38 | .Fo BN_is_odd | ||
39 | .Fa "BIGNUM *a" | ||
40 | .Fc | ||
41 | .Sh DESCRIPTION | ||
42 | .Fn BN_cmp | ||
43 | compares the numbers | ||
44 | .Fa a | ||
45 | and | ||
46 | .Fa b . | ||
47 | .Fn BN_ucmp | ||
48 | compares their absolute values. | ||
49 | .Pp | ||
50 | .Fn BN_is_zero , | ||
51 | .Fn BN_is_one | ||
52 | and | ||
53 | .Fn BN_is_word | ||
54 | test if | ||
55 | .Fa a | ||
56 | equals 0, 1, or | ||
57 | .Fa w | ||
58 | respectively. | ||
59 | .Fn BN_is_odd | ||
60 | tests if a is odd. | ||
61 | .Pp | ||
62 | .Fn BN_is_zero , | ||
63 | .Fn BN_is_one , | ||
64 | .Fn BN_is_word , | ||
65 | and | ||
66 | .Fn BN_is_odd | ||
67 | are macros. | ||
68 | .Sh RETURN VALUES | ||
69 | .Fn BN_cmp | ||
70 | returns -1 if | ||
71 | .Fa a Ns < Ns Fa b , | ||
72 | 0 if | ||
73 | .Fa a Ns == Ns Fa b , | ||
74 | and 1 if | ||
75 | .Fa a Ns > Ns Fa b . | ||
76 | .Fn BN_ucmp | ||
77 | is the same using the absolute values of | ||
78 | .Fa a | ||
79 | and | ||
80 | .Fa b . | ||
81 | .Pp | ||
82 | .Fn BN_is_zero , | ||
83 | .Fn BN_is_one , | ||
84 | .Fn BN_is_word , | ||
85 | and | ||
86 | .Fn BN_is_odd | ||
87 | return 1 if the condition is true, 0 otherwise. | ||
88 | .Sh SEE ALSO | ||
89 | .Xr bn 3 | ||
90 | .Sh HISTORY | ||
91 | .Fn BN_cmp , | ||
92 | .Fn BN_ucmp , | ||
93 | .Fn BN_is_zero , | ||
94 | .Fn BN_is_one | ||
95 | and | ||
96 | .Fn BN_is_word | ||
97 | are available in all versions of SSLeay and OpenSSL. | ||
98 | .Fn BN_is_odd | ||
99 | was added in SSLeay 0.8. | ||
diff --git a/src/lib/libcrypto/man/BN_copy.3 b/src/lib/libcrypto/man/BN_copy.3 new file mode 100644 index 0000000000..765e46c01c --- /dev/null +++ b/src/lib/libcrypto/man/BN_copy.3 | |||
@@ -0,0 +1,52 @@ | |||
1 | .Dd $Mdocdate: February 23 2015 $ | ||
2 | .Dt BN_COPY 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BN_copy , | ||
6 | .Nm BN_dup | ||
7 | .Nd copy BIGNUMs | ||
8 | .Sh SYNOPSIS | ||
9 | .In openssl/bn.h | ||
10 | .Ft BIGNUM * | ||
11 | .Fo BN_copy | ||
12 | .Fa "BIGNUM *to" | ||
13 | .Fa "const BIGNUM *from" | ||
14 | .Fc | ||
15 | .Ft BIGNUM * | ||
16 | .Fo BN_dup | ||
17 | .Fa "const BIGNUM *from" | ||
18 | .Fc | ||
19 | .Sh DESCRIPTION | ||
20 | .Fn BN_copy | ||
21 | copies | ||
22 | .Fa from | ||
23 | to | ||
24 | .Fa to . | ||
25 | .Fn BN_dup | ||
26 | creates a new | ||
27 | .Vt BIGNUM | ||
28 | containing the value | ||
29 | .Fa from . | ||
30 | .Sh RETURN VALUES | ||
31 | .Fn BN_copy | ||
32 | returns | ||
33 | .Fa to | ||
34 | on success, | ||
35 | .Dv NULL | ||
36 | on error. | ||
37 | .Fn BN_dup | ||
38 | returns the new | ||
39 | .Vt BIGNUM , | ||
40 | or | ||
41 | .Dv NULL | ||
42 | on error. | ||
43 | The error codes can be obtained by | ||
44 | .Xr ERR_get_error 3 . | ||
45 | .Sh SEE ALSO | ||
46 | .Xr bn 3 , | ||
47 | .Xr ERR_get_error 3 | ||
48 | .Sh HISTORY | ||
49 | .Fn BN_copy | ||
50 | and | ||
51 | .Fn BN_dup | ||
52 | are available in all versions of SSLeay and OpenSSL. | ||
diff --git a/src/lib/libcrypto/man/BN_generate_prime.3 b/src/lib/libcrypto/man/BN_generate_prime.3 new file mode 100644 index 0000000000..e269571914 --- /dev/null +++ b/src/lib/libcrypto/man/BN_generate_prime.3 | |||
@@ -0,0 +1,289 @@ | |||
1 | .Dd $Mdocdate: February 23 2015 $ | ||
2 | .Dt BN_GENERATE_PRIME 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BN_generate_prime_ex , | ||
6 | .Nm BN_is_prime_ex , | ||
7 | .Nm BN_is_prime_fasttest_ex , | ||
8 | .Nm BN_GENCB_call , | ||
9 | .Nm BN_GENCB_set_old , | ||
10 | .Nm BN_GENCB_set , | ||
11 | .Nm BN_generate_prime , | ||
12 | .Nm BN_is_prime , | ||
13 | .Nm BN_is_prime_fasttest | ||
14 | .Nd generate primes and test for primality | ||
15 | .Sh SYNOPSIS | ||
16 | .In openssl/bn.h | ||
17 | .Ft int | ||
18 | .Fo BN_generate_prime_ex | ||
19 | .Fa "BIGNUM *ret" | ||
20 | .Fa "int bits" | ||
21 | .Fa "int safe" | ||
22 | .Fa "const BIGNUM *add" | ||
23 | .Fa "const BIGNUM *rem" | ||
24 | .Fa "BN_GENCB *cb" | ||
25 | .Fc | ||
26 | .Ft int | ||
27 | .Fo BN_is_prime_ex | ||
28 | .Fa "const BIGNUM *p" | ||
29 | .Fa "int nchecks" | ||
30 | .Fa "BN_CTX *ctx" | ||
31 | .Fa "BN_GENCB *cb" | ||
32 | .Fc | ||
33 | .Ft int | ||
34 | .Fo BN_is_prime_fasttest_ex | ||
35 | .Fa "const BIGNUM *p" | ||
36 | .Fa "int nchecks" | ||
37 | .Fa "BN_CTX *ctx" | ||
38 | .Fa "int do_trial_division" | ||
39 | .Fa "BN_GENCB *cb" | ||
40 | .Fc | ||
41 | .Ft int | ||
42 | .Fo BN_GENCB_call | ||
43 | .Fa "BN_GENCB *cb" | ||
44 | .Fa "int a" | ||
45 | .Fa "int b" | ||
46 | .Fc | ||
47 | .Fd #define BN_GENCB_set_old(gencb, callback, cb_arg) ... | ||
48 | .Fd #define BN_GENCB_set(gencb, callback, cb_arg) ... | ||
49 | .Pp | ||
50 | Deprecated: | ||
51 | .Pp | ||
52 | .Ft BIGNUM * | ||
53 | .Fo BN_generate_prime | ||
54 | .Fa "BIGNUM *ret" | ||
55 | .Fa "int num" | ||
56 | .Fa "int safe" | ||
57 | .Fa "BIGNUM *add" | ||
58 | .Fa "BIGNUM *rem" | ||
59 | .Fa "void (*callback)(int, int, void *)" | ||
60 | .Fa "void *cb_arg" | ||
61 | .Fc | ||
62 | .Ft int | ||
63 | .Fo BN_is_prime | ||
64 | .Fa "const BIGNUM *a" | ||
65 | .Fa "int checks" | ||
66 | .Fa "void (*callback)(int, int, void *)" | ||
67 | .Fa "BN_CTX *ctx" | ||
68 | .Fa "void *cb_arg" | ||
69 | .Fc | ||
70 | .Ft int | ||
71 | .Fo BN_is_prime_fasttest | ||
72 | .Fa "const BIGNUM *a" | ||
73 | .Fa "int checks" | ||
74 | .Fa "void (*callback)(int, int, void *)" | ||
75 | .Fa "BN_CTX *ctx" | ||
76 | .Fa "void *cb_arg" | ||
77 | .Fa "int do_trial_division" | ||
78 | .Fc | ||
79 | .Sh DESCRIPTION | ||
80 | .Fn BN_generate_prime_ex | ||
81 | generates a pseudo-random prime number of bit length | ||
82 | .Fa bits . | ||
83 | If | ||
84 | .Fa ret | ||
85 | is not | ||
86 | .Dv NULL , | ||
87 | it will be used to store the number. | ||
88 | .Pp | ||
89 | If | ||
90 | .Fa cb | ||
91 | is not | ||
92 | .Dv NULL , | ||
93 | it is used as follows: | ||
94 | .Bl -bullet | ||
95 | .It | ||
96 | .Fn BN_GENCB_call cb 0 i | ||
97 | is called after generating the i-th potential prime number. | ||
98 | .It | ||
99 | While the number is being tested for primality, | ||
100 | .Fn BN_GENCB_call cb 1 j | ||
101 | is called as described below. | ||
102 | .It | ||
103 | When a prime has been found, | ||
104 | .Fn BN_GENCB_call cb 2 i | ||
105 | is called. | ||
106 | .El | ||
107 | .Pp | ||
108 | The prime may have to fulfill additional requirements for use in | ||
109 | Diffie-Hellman key exchange: | ||
110 | .Pp | ||
111 | If | ||
112 | .Fa add | ||
113 | is not | ||
114 | .Dv NULL , | ||
115 | the prime will fulfill the condition p % | ||
116 | .Fa add | ||
117 | == | ||
118 | .Fa rem | ||
119 | (p % | ||
120 | .Fa add | ||
121 | == 1 if | ||
122 | .Fa rem | ||
123 | == | ||
124 | .Dv NULL ) | ||
125 | in order to suit a given generator. | ||
126 | .Pp | ||
127 | If | ||
128 | .Fa safe | ||
129 | is true, it will be a safe prime (i.e. a prime p so that (p-1)/2 | ||
130 | is also prime). | ||
131 | .Pp | ||
132 | The prime number generation has a negligible error probability. | ||
133 | .Pp | ||
134 | .Fn BN_is_prime_ex | ||
135 | and | ||
136 | .Fn BN_is_prime_fasttest_ex | ||
137 | test if the number | ||
138 | .Fa p | ||
139 | is prime. | ||
140 | The following tests are performed until one of them shows that | ||
141 | .Fa p | ||
142 | is composite; if | ||
143 | .Fa p | ||
144 | passes all these tests, it is considered prime. | ||
145 | .Pp | ||
146 | .Fn BN_is_prime_fasttest_ex , | ||
147 | when called with | ||
148 | .Fa do_trial_division | ||
149 | == 1, first attempts trial division by a number of small primes; | ||
150 | if no divisors are found by this test and | ||
151 | .Fa cb | ||
152 | is not | ||
153 | .Dv NULL , | ||
154 | .Sy BN_GENCB_call(cb, 1, -1) | ||
155 | is called. | ||
156 | If | ||
157 | .Fa do_trial_division | ||
158 | == 0, this test is skipped. | ||
159 | .Pp | ||
160 | Both | ||
161 | .Fn BN_is_prime_ex | ||
162 | and | ||
163 | .Fn BN_is_prime_fasttest_ex | ||
164 | perform a Miller-Rabin probabilistic primality test with | ||
165 | .Fa nchecks | ||
166 | iterations. | ||
167 | If | ||
168 | .Fa nchecks | ||
169 | == | ||
170 | .Dv BN_prime_checks , | ||
171 | a number of iterations is used that yields a false positive rate of at | ||
172 | most 2^-80 for random input. | ||
173 | .Pp | ||
174 | If | ||
175 | .Fa cb | ||
176 | is not | ||
177 | .Dv NULL , | ||
178 | .Fa BN_GENCB_call cb 1 j | ||
179 | is called after the j-th iteration (j = 0, 1, ...). | ||
180 | .Fa ctx | ||
181 | is a pre-allocated | ||
182 | .Vt BN_CTX | ||
183 | (to save the overhead of allocating and freeing the structure in a | ||
184 | loop), or | ||
185 | .Dv NULL . | ||
186 | .Pp | ||
187 | .Fn BN_GENCB_call | ||
188 | calls the callback function held in the | ||
189 | .Vt BN_GENCB | ||
190 | structure and passes the ints | ||
191 | .Fa a | ||
192 | and | ||
193 | .Fa b | ||
194 | as arguments. | ||
195 | There are two types of | ||
196 | .Vt BN_GENCB | ||
197 | structures that are supported: "new" style and "old" style. | ||
198 | New programs should prefer the "new" style, whilst the "old" style is | ||
199 | provided for backwards compatibility purposes. | ||
200 | .Pp | ||
201 | For "new" style callbacks a | ||
202 | .Vt BN_GENCB | ||
203 | structure should be initialised with a call to | ||
204 | .Fn BN_GENCB_set , | ||
205 | where | ||
206 | .Fa gencb | ||
207 | is a | ||
208 | .Vt BN_GENCB * , | ||
209 | .Fa callback | ||
210 | is of type | ||
211 | .Vt int (*callback)(int, int, BN_GENCB *) | ||
212 | and | ||
213 | .Fa cb_arg | ||
214 | is a | ||
215 | .Vt void * . | ||
216 | "Old" style callbacks are the same except they are initialised with a | ||
217 | call to | ||
218 | .Fn BN_GENCB_set_old | ||
219 | and | ||
220 | .Fa callback | ||
221 | is of type | ||
222 | .Vt void (*callback)(int, int, void *) . | ||
223 | .Pp | ||
224 | A callback is invoked through a call to | ||
225 | .Fn BN_GENCB_call . | ||
226 | This will check the type of the callback and will invoke | ||
227 | .Fn callback a b gencb | ||
228 | for new style callbacks or | ||
229 | .Fn callback a b cb_arg | ||
230 | for old style. | ||
231 | .Pp | ||
232 | .Fn BN_generate_prime | ||
233 | (deprecated) works in the same way as | ||
234 | .Fn BN_generate_prime_ex | ||
235 | but expects an old style callback function directly in the | ||
236 | .Fa callback | ||
237 | parameter, and an argument to pass to it in the | ||
238 | .Fa cb_arg . | ||
239 | Similarly | ||
240 | .Fn BN_is_prime | ||
241 | and | ||
242 | .Fn BN_is_prime_fasttest | ||
243 | are deprecated and can be compared to | ||
244 | .Fn BN_is_prime_ex | ||
245 | and | ||
246 | .Fn BN_is_prime_fasttest_ex | ||
247 | respectively. | ||
248 | .Sh RETURN VALUES | ||
249 | .Fn BN_generate_prime_ex | ||
250 | returns 1 on success or 0 on error. | ||
251 | .Pp | ||
252 | .Fn BN_is_prime_ex , | ||
253 | .Fn BN_is_prime_fasttest_ex , | ||
254 | .Fn BN_is_prime , | ||
255 | and | ||
256 | .Fn BN_is_prime_fasttest | ||
257 | return 0 if the number is composite, 1 if it is prime with an error | ||
258 | probability of less than | ||
259 | .Pf 0.25^ Fa nchecks , | ||
260 | and -1 on error. | ||
261 | .Pp | ||
262 | .Fn BN_generate_prime | ||
263 | returns the prime number on success, | ||
264 | .Dv NULL | ||
265 | otherwise. | ||
266 | .Pp | ||
267 | Callback functions should return 1 on success or 0 on error. | ||
268 | .Pp | ||
269 | The error codes can be obtained by | ||
270 | .Xr ERR_get_error 3 . | ||
271 | .Sh SEE ALSO | ||
272 | .Xr bn 3 , | ||
273 | .Xr ERR_get_error 3 , | ||
274 | .Xr rand 3 | ||
275 | .Sh HISTORY | ||
276 | The | ||
277 | .Fa cb_arg | ||
278 | arguments to | ||
279 | .Fn BN_generate_prime | ||
280 | and to | ||
281 | .Fn BN_is_prime | ||
282 | were added in SSLeay 0.9.0. | ||
283 | The | ||
284 | .Fa ret | ||
285 | argument to | ||
286 | .Fn BN_generate_prime | ||
287 | was added in SSLeay 0.9.1. | ||
288 | .Fn BN_is_prime_fasttest | ||
289 | was added in OpenSSL 0.9.5. | ||
diff --git a/src/lib/libcrypto/man/BN_mod_inverse.3 b/src/lib/libcrypto/man/BN_mod_inverse.3 new file mode 100644 index 0000000000..db63269fb8 --- /dev/null +++ b/src/lib/libcrypto/man/BN_mod_inverse.3 | |||
@@ -0,0 +1,59 @@ | |||
1 | .Dd $Mdocdate: February 23 2015 $ | ||
2 | .Dt BN_MOD_INVERSE 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BN_mod_inverse | ||
6 | .Nd compute inverse modulo n | ||
7 | .Sh SYNOPSIS | ||
8 | .In openssl/bn.h | ||
9 | .Ft BIGNUM * | ||
10 | .Fo BN_mod_inverse | ||
11 | .Fa "BIGNUM *r" | ||
12 | .Fa "BIGNUM *a" | ||
13 | .Fa "const BIGNUM *n" | ||
14 | .Fa "BN_CTX *ctx" | ||
15 | .Fc | ||
16 | .Sh DESCRIPTION | ||
17 | .Fn BN_mod_inverse | ||
18 | computes the inverse of | ||
19 | .Fa a | ||
20 | modulo | ||
21 | .Fa n | ||
22 | add places the result in | ||
23 | .Fa r | ||
24 | .Pq Li (a*r)%n==1 . | ||
25 | If | ||
26 | .Fa r | ||
27 | is | ||
28 | .Dv NULL , | ||
29 | a new | ||
30 | .Vt BIGNUM | ||
31 | is created. | ||
32 | .Pp | ||
33 | .Fa ctx | ||
34 | is a previously allocated | ||
35 | .Vt BN_CTX | ||
36 | used for temporary variables. | ||
37 | .Fa r | ||
38 | may be the same | ||
39 | .Vt BIGNUM | ||
40 | as | ||
41 | .Fa a | ||
42 | or | ||
43 | .Fa n . | ||
44 | .Sh RETURN VALUES | ||
45 | .Fn BN_mod_inverse | ||
46 | returns the | ||
47 | .Vt BIGNUM | ||
48 | containing the inverse, or | ||
49 | .Dv NULL | ||
50 | on error. | ||
51 | The error codes can be obtained by | ||
52 | .Xr ERR_get_error 3 . | ||
53 | .Sh SEE ALSO | ||
54 | .Xr bn 3 , | ||
55 | .Xr BN_add 3 , | ||
56 | .Xr ERR_get_error 3 | ||
57 | .Sh HISTORY | ||
58 | .Fn BN_mod_inverse | ||
59 | is available in all versions of SSLeay and OpenSSL. | ||
diff --git a/src/lib/libcrypto/man/BN_mod_mul_montgomery.3 b/src/lib/libcrypto/man/BN_mod_mul_montgomery.3 new file mode 100644 index 0000000000..ac120f3c02 --- /dev/null +++ b/src/lib/libcrypto/man/BN_mod_mul_montgomery.3 | |||
@@ -0,0 +1,181 @@ | |||
1 | .Dd $Mdocdate: February 23 2015 $ | ||
2 | .Dt BN_MOD_MUL_MONTGOMERY 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BN_mod_mul_montgomery , | ||
6 | .Nm BN_MONT_CTX_new , | ||
7 | .Nm BN_MONT_CTX_init , | ||
8 | .Nm BN_MONT_CTX_free , | ||
9 | .Nm BN_MONT_CTX_set , | ||
10 | .Nm BN_MONT_CTX_copy , | ||
11 | .Nm BN_from_montgomery , | ||
12 | .Nm BN_to_montgomery | ||
13 | .Nd Montgomery multiplication | ||
14 | .Sh SYNOPSIS | ||
15 | .In openssl/bn.h | ||
16 | .Ft BN_MONT_CTX * | ||
17 | .Fo BN_MONT_CTX_new | ||
18 | .Fa void | ||
19 | .Fc | ||
20 | .Ft void | ||
21 | .Fo BN_MONT_CTX_init | ||
22 | .Fa "BN_MONT_CTX *ctx" | ||
23 | .Fc | ||
24 | .Ft void | ||
25 | .Fo BN_MONT_CTX_free | ||
26 | .Fa "BN_MONT_CTX *mont" | ||
27 | .Fc | ||
28 | .Ft int | ||
29 | .Fo BN_MONT_CTX_set | ||
30 | .Fa "BN_MONT_CTX *mont" | ||
31 | .Fa "const BIGNUM *m" | ||
32 | .Fa "BN_CTX *ctx" | ||
33 | .Fc | ||
34 | .Ft BN_MONT_CTX * | ||
35 | .Fo BN_MONT_CTX_copy | ||
36 | .Fa "BN_MONT_CTX *to" | ||
37 | .Fa "BN_MONT_CTX *from" | ||
38 | .Fc | ||
39 | .Ft int | ||
40 | .Fo BN_mod_mul_montgomery | ||
41 | .Fa "BIGNUM *r" | ||
42 | .Fa "BIGNUM *a" | ||
43 | .Fa "BIGNUM *b" | ||
44 | .Fa "BN_MONT_CTX *mont" | ||
45 | .Fa "BN_CTX *ctx" | ||
46 | .Fc | ||
47 | .Ft int | ||
48 | .Fo BN_from_montgomery | ||
49 | .Fa "BIGNUM *r" | ||
50 | .Fa "BIGNUM *a" | ||
51 | .Fa "BN_MONT_CTX *mont" | ||
52 | .Fa "BN_CTX *ctx" | ||
53 | .Fc | ||
54 | .Ft int | ||
55 | .Fo BN_to_montgomery | ||
56 | .Fa "BIGNUM *r" | ||
57 | .Fa "BIGNUM *a" | ||
58 | .Fa "BN_MONT_CTX *mont" | ||
59 | .Fa "BN_CTX *ctx" | ||
60 | .Fc | ||
61 | .Sh DESCRIPTION | ||
62 | These functions implement Montgomery multiplication. | ||
63 | They are used automatically when | ||
64 | .Xr BN_mod_exp 3 | ||
65 | is called with suitable input, but they may be useful when several | ||
66 | operations are to be performed using the same modulus. | ||
67 | .Pp | ||
68 | .Fn BN_MONT_CTX_new | ||
69 | allocates and initializes a | ||
70 | .Vt BN_MONT_CTX | ||
71 | structure. | ||
72 | .Fn BN_MONT_CTX_init | ||
73 | initializes an existing uninitialized | ||
74 | .Vt BN_MONT_CTX . | ||
75 | .Pp | ||
76 | .Fn BN_MONT_CTX_set | ||
77 | sets up the | ||
78 | .Fa mont | ||
79 | structure from the modulus | ||
80 | .Fa m | ||
81 | by precomputing its inverse and a value R. | ||
82 | .Pp | ||
83 | .Fn BN_MONT_CTX_copy | ||
84 | copies the | ||
85 | .Vt BN_MONT_CTX | ||
86 | .Fa from | ||
87 | to | ||
88 | .Fa to . | ||
89 | .Pp | ||
90 | .Fn BN_MONT_CTX_free | ||
91 | frees the components of the | ||
92 | .Vt BN_MONT_CTX , | ||
93 | and, if it was created by | ||
94 | .Fn BN_MONT_CTX_new , | ||
95 | also the structure itself. | ||
96 | .Pp | ||
97 | .Fn BN_mod_mul_montgomery | ||
98 | computes | ||
99 | .Pp | ||
100 | .D1 Mont Ns Po Fa a , Fa b Pc := Fa a No * Fa b No * R^-1 | ||
101 | .Pp | ||
102 | and places the result in | ||
103 | .Fa r . | ||
104 | .Pp | ||
105 | .Fn BN_from_montgomery | ||
106 | performs the Montgomery reduction | ||
107 | .Pp | ||
108 | .D1 Fa r No = Fa a No * R^-1. | ||
109 | .Pp | ||
110 | .Fn BN_to_montgomery | ||
111 | computes | ||
112 | .Pp | ||
113 | .D1 Mont Ns Po Fa a , No R^2 Pc = Fa a No * R . | ||
114 | .Pp | ||
115 | Note that | ||
116 | .Fa a | ||
117 | must be non-negative and smaller than the modulus. | ||
118 | .Pp | ||
119 | For all functions, | ||
120 | .Fa ctx | ||
121 | is a previously allocated | ||
122 | .Vt BN_CTX | ||
123 | used for temporary variables. | ||
124 | .Pp | ||
125 | The | ||
126 | .Vt BN_MONT_CTX | ||
127 | structure is defined as follows: | ||
128 | .Bd -literal | ||
129 | typedef struct bn_mont_ctx_st { | ||
130 | int ri; /* number of bits in R */ | ||
131 | BIGNUM RR; /* R^2 (used to convert to Montgomery form) */ | ||
132 | BIGNUM N; /* The modulus */ | ||
133 | BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1 | ||
134 | * (Ni is only stored for bignum algorithm) */ | ||
135 | BN_ULONG n0; /* least significant word of Ni */ | ||
136 | int flags; | ||
137 | } BN_MONT_CTX; | ||
138 | .Ed | ||
139 | .Pp | ||
140 | .Fn BN_to_montgomery | ||
141 | is a macro. | ||
142 | .Pp | ||
143 | .Sy Warning: | ||
144 | The inputs must be reduced modulo | ||
145 | .Fa m , | ||
146 | otherwise the result will be outside the expected range. | ||
147 | .Sh RETURN VALUES | ||
148 | .Fn BN_MONT_CTX_new | ||
149 | returns the newly allocated | ||
150 | .Vt BN_MONT_CTX , | ||
151 | and | ||
152 | .Dv NULL | ||
153 | on error. | ||
154 | .Pp | ||
155 | .Fn BN_MONT_CTX_init | ||
156 | and | ||
157 | .Fn BN_MONT_CTX_free | ||
158 | return no values. | ||
159 | .Pp | ||
160 | For the other functions, 1 is returned for success, 0 on error. | ||
161 | The error codes can be obtained by | ||
162 | .Xr ERR_get_error 3 . | ||
163 | .Sh SEE ALSO | ||
164 | .Xr bn 3 , | ||
165 | .Xr BN_add 3 , | ||
166 | .Xr BN_CTX_new 3 , | ||
167 | .Xr ERR_get_error 3 | ||
168 | .Sh HISTORY | ||
169 | .Fn BN_MONT_CTX_new , | ||
170 | .Fn BN_MONT_CTX_free , | ||
171 | .Fn BN_MONT_CTX_set , | ||
172 | .Fn BN_mod_mul_montgomery , | ||
173 | .Fn BN_from_montgomery | ||
174 | and | ||
175 | .Fn BN_to_montgomery | ||
176 | are available in all versions of SSLeay and OpenSSL. | ||
177 | .Pp | ||
178 | .Fn BN_MONT_CTX_init | ||
179 | and | ||
180 | .Fn BN_MONT_CTX_copy | ||
181 | were added in SSLeay 0.9.1b. | ||
diff --git a/src/lib/libcrypto/man/BN_mod_mul_reciprocal.3 b/src/lib/libcrypto/man/BN_mod_mul_reciprocal.3 new file mode 100644 index 0000000000..ceb1ffae5b --- /dev/null +++ b/src/lib/libcrypto/man/BN_mod_mul_reciprocal.3 | |||
@@ -0,0 +1,147 @@ | |||
1 | .Dd $Mdocdate: February 23 2015 $ | ||
2 | .Dt BN_MOD_MUL_RECIPROCAL 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BN_mod_mul_reciprocal , | ||
6 | .Nm BN_div_recp , | ||
7 | .Nm BN_RECP_CTX_new , | ||
8 | .Nm BN_RECP_CTX_init , | ||
9 | .Nm BN_RECP_CTX_free , | ||
10 | .Nm BN_RECP_CTX_set | ||
11 | .Nd modular multiplication using reciprocal | ||
12 | .Sh SYNOPSIS | ||
13 | .In openssl/bn.h | ||
14 | .Ft BN_RECP_CTX * | ||
15 | .Fo BN_RECP_CTX_new | ||
16 | .Fa void | ||
17 | .Fc | ||
18 | .Ft void | ||
19 | .Fo BN_RECP_CTX_init | ||
20 | .Fa "BN_RECP_CTX *recp" | ||
21 | .Fc | ||
22 | .Ft void | ||
23 | .Fo BN_RECP_CTX_free | ||
24 | .Fa "BN_RECP_CTX *recp" | ||
25 | .Fc | ||
26 | .Ft int | ||
27 | .Fo BN_RECP_CTX_set | ||
28 | .Fa "BN_RECP_CTX *recp" | ||
29 | .Fa "const BIGNUM *m" | ||
30 | .Fa "BN_CTX *ctx" | ||
31 | .Fc | ||
32 | .Ft int | ||
33 | .Fo BN_div_recp | ||
34 | .Fa "BIGNUM *dv" | ||
35 | .Fa "BIGNUM *rem" | ||
36 | .Fa "BIGNUM *a" | ||
37 | .Fa "BN_RECP_CTX *recp" | ||
38 | .Fa "BN_CTX *ctx" | ||
39 | .Fc | ||
40 | .Ft int | ||
41 | .Fo BN_mod_mul_reciprocal | ||
42 | .Fa "BIGNUM *r" | ||
43 | .Fa "BIGNUM *a" | ||
44 | .Fa "BIGNUM *b" | ||
45 | .Fa "BN_RECP_CTX *recp" | ||
46 | .Fa "BN_CTX *ctx" | ||
47 | .Fc | ||
48 | .Sh DESCRIPTION | ||
49 | .Fn BN_mod_mul_reciprocal | ||
50 | can be used to perform an efficient | ||
51 | .Xr BN_mod_mul 3 | ||
52 | operation when the operation will be performed repeatedly with the same | ||
53 | modulus. | ||
54 | It computes | ||
55 | .Fa r Ns =( Ns Fa a Ns * Ns Fa b Ns )% Ns Fa m | ||
56 | using | ||
57 | .Fa recp Ns =1/ Ns Fa m , | ||
58 | which is set as described below. | ||
59 | .Fa ctx | ||
60 | is a previously allocated | ||
61 | .Vt BN_CTX | ||
62 | used for temporary variables. | ||
63 | .Pp | ||
64 | .Fn BN_RECP_CTX_new | ||
65 | allocates and initializes a | ||
66 | .Vt BN_RECP_CTX | ||
67 | structure. | ||
68 | .Fn BN_RECP_CTX_init | ||
69 | initializes an existing uninitialized | ||
70 | .Vt BN_RECP_CTX . | ||
71 | .Pp | ||
72 | .Fn BN_RECP_CTX_free | ||
73 | frees the components of the | ||
74 | .Vt BN_RECP_CTX , | ||
75 | and, if it was created by | ||
76 | .Fn BN_RECP_CTX_new , | ||
77 | also the structure itself. | ||
78 | .Pp | ||
79 | .Fn BN_RECP_CTX_set | ||
80 | stores | ||
81 | .Fa m | ||
82 | in | ||
83 | .Fa recp | ||
84 | and sets it up for computing | ||
85 | .Pf 1/ Fa m | ||
86 | and shifting it left by | ||
87 | .Fn BN_num_bits m Ns +1 | ||
88 | to make it an integer. | ||
89 | The result and the number of bits it was shifted left will later be | ||
90 | stored in | ||
91 | .Fa recp . | ||
92 | .Pp | ||
93 | .Fn BN_div_recp | ||
94 | divides | ||
95 | .Fa a | ||
96 | by | ||
97 | .Fa m | ||
98 | using | ||
99 | .Fa recp . | ||
100 | It places the quotient in | ||
101 | .Fa dv | ||
102 | and the remainder in | ||
103 | .Fa rem . | ||
104 | .Pp | ||
105 | The | ||
106 | .Vt BN_RECP_CTX | ||
107 | structure is defined as follows: | ||
108 | .Bd -literal | ||
109 | typedef struct bn_recp_ctx_st { | ||
110 | BIGNUM N; /* the divisor */ | ||
111 | BIGNUM Nr; /* the reciprocal */ | ||
112 | int num_bits; | ||
113 | int shift; | ||
114 | int flags; | ||
115 | } BN_RECP_CTX; | ||
116 | .Ed | ||
117 | .Pp | ||
118 | It cannot be shared between threads. | ||
119 | .Sh RETURN VALUES | ||
120 | .Fn BN_RECP_CTX_new | ||
121 | returns the newly allocated | ||
122 | .Vt BN_RECP_CTX , | ||
123 | or | ||
124 | .Dv NULL | ||
125 | on error. | ||
126 | .Pp | ||
127 | .Fn BN_RECP_CTX_init | ||
128 | and | ||
129 | .Fn BN_RECP_CTX_free | ||
130 | return no values. | ||
131 | .Pp | ||
132 | For the other functions, 1 is returned for success, 0 on error. | ||
133 | The error codes can be obtained by | ||
134 | .Xr ERR_get_error 3 . | ||
135 | .Sh SEE ALSO | ||
136 | .Xr bn 3 , | ||
137 | .Xr BN_add 3 , | ||
138 | .Xr BN_CTX_new 3 , | ||
139 | .Xr ERR_get_error 3 | ||
140 | .Sh HISTORY | ||
141 | .Vt BN_RECP_CTX | ||
142 | was added in SSLeay 0.9.0. | ||
143 | Before that, a function | ||
144 | .Fn BN_reciprocal | ||
145 | was used instead, and the | ||
146 | .Fn BN_mod_mul_reciprocal | ||
147 | arguments were different. | ||
diff --git a/src/lib/libcrypto/man/BN_new.3 b/src/lib/libcrypto/man/BN_new.3 new file mode 100644 index 0000000000..ad8ce886d9 --- /dev/null +++ b/src/lib/libcrypto/man/BN_new.3 | |||
@@ -0,0 +1,84 @@ | |||
1 | .Dd $Mdocdate: February 23 2015 $ | ||
2 | .Dt BN_NEW 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BN_new , | ||
6 | .Nm BN_init , | ||
7 | .Nm BN_clear , | ||
8 | .Nm BN_free , | ||
9 | .Nm BN_clear_free | ||
10 | .Nd allocate and free BIGNUMs | ||
11 | .Sh SYNOPSIS | ||
12 | .In openssl/bn.h | ||
13 | .Ft BIGNUM * | ||
14 | .Fo BN_new | ||
15 | .Fa void | ||
16 | .Fc | ||
17 | .Ft void | ||
18 | .Fo BN_init | ||
19 | .Fa "BIGNUM *" | ||
20 | .Fc | ||
21 | .Ft void | ||
22 | .Fo BN_clear | ||
23 | .Fa "BIGNUM *a" | ||
24 | .Fc | ||
25 | .Ft void | ||
26 | .Fo BN_free | ||
27 | .Fa "BIGNUM *a" | ||
28 | .Fc | ||
29 | .Ft void | ||
30 | .Fo BN_clear_free | ||
31 | .Fa "BIGNUM *a" | ||
32 | .Fc | ||
33 | .Sh DESCRIPTION | ||
34 | .Fn BN_new | ||
35 | allocates and initializes a | ||
36 | .Vt BIGNUM | ||
37 | structure. | ||
38 | .Fn BN_init | ||
39 | initializes an existing uninitialized | ||
40 | .Vt BIGNUM . | ||
41 | .Pp | ||
42 | .Fn BN_clear | ||
43 | is used to destroy sensitive data such as keys when they are no longer | ||
44 | needed. | ||
45 | It erases the memory used by | ||
46 | .Fa a | ||
47 | and sets it to the value 0. | ||
48 | .Pp | ||
49 | .Fn BN_free | ||
50 | frees the components of the | ||
51 | .Vt BIGNUM , | ||
52 | and if it was created by | ||
53 | .Fn BN_new , | ||
54 | also the structure itself. | ||
55 | .Fn BN_clear_free | ||
56 | additionally overwrites the data before the memory is returned to the | ||
57 | system. | ||
58 | .Sh RETURN VALUES | ||
59 | .Fn BN_new | ||
60 | returns a pointer to the | ||
61 | .Vt BIGNUM . | ||
62 | If the allocation fails, it returns | ||
63 | .Dv NULL | ||
64 | and sets an error code that can be obtained by | ||
65 | .Xr ERR_get_error 3 . | ||
66 | .Pp | ||
67 | .Fn BN_init , | ||
68 | .Fn BN_clear , | ||
69 | .Fn BN_free , | ||
70 | and | ||
71 | .Fn BN_clear_free | ||
72 | return no values. | ||
73 | .Sh SEE ALSO | ||
74 | .Xr bn 3 , | ||
75 | .Xr ERR_get_error 3 | ||
76 | .Sh HISTORY | ||
77 | .Fn BN_new , | ||
78 | .Fn BN_clear , | ||
79 | .Fn BN_free , | ||
80 | and | ||
81 | .Fn BN_clear_free | ||
82 | are available in all versions on SSLeay and OpenSSL. | ||
83 | .Fn BN_init | ||
84 | was added in SSLeay 0.9.1b. | ||
diff --git a/src/lib/libcrypto/man/BN_num_bytes.3 b/src/lib/libcrypto/man/BN_num_bytes.3 new file mode 100644 index 0000000000..2d7be7e443 --- /dev/null +++ b/src/lib/libcrypto/man/BN_num_bytes.3 | |||
@@ -0,0 +1,76 @@ | |||
1 | .Dd $Mdocdate: February 23 2015 $ | ||
2 | .Dt BN_NUM_BYTES 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BN_num_bits , | ||
6 | .Nm BN_num_bytes , | ||
7 | .Nm BN_num_bits_word | ||
8 | .Nd get BIGNUM size | ||
9 | .Sh SYNOPSIS | ||
10 | .In openssl/bn.h | ||
11 | .Ft int | ||
12 | .Fo BN_num_bytes | ||
13 | .Fa "const BIGNUM *a" | ||
14 | .Fc | ||
15 | .Ft int | ||
16 | .Fo BN_num_bits | ||
17 | .Fa "const BIGNUM *a" | ||
18 | .Fc | ||
19 | .Ft int | ||
20 | .Fo BN_num_bits_word | ||
21 | .Fa "BN_ULONG w" | ||
22 | .Fc | ||
23 | .Sh DESCRIPTION | ||
24 | .Fn BN_num_bytes | ||
25 | returns the size of a | ||
26 | .Sy BIGNUM | ||
27 | in bytes. | ||
28 | .Pp | ||
29 | .Fn BN_num_bits_word | ||
30 | returns the number of significant bits in a word. | ||
31 | If we take 0x00000432 as an example, it returns 11, not 16, not 32. | ||
32 | Basically, except for a zero, it returns | ||
33 | .Pp | ||
34 | .D1 floor(log2( Ns Fa w ) ) No + 1 . | ||
35 | .Pp | ||
36 | .Fn BN_num_bits | ||
37 | returns the number of significant bits in a | ||
38 | .Sy BIGNUM , | ||
39 | following the same principle as | ||
40 | .Fn BN_num_bits_word . | ||
41 | .Pp | ||
42 | .Fn BN_num_bytes | ||
43 | is a macro. | ||
44 | .Sh RETURN VALUES | ||
45 | The size. | ||
46 | .Sh NOTES | ||
47 | Some have tried using | ||
48 | .Fn BN_num_bits | ||
49 | on individual numbers in RSA keys, DH keys and DSA keys, and found that | ||
50 | they don't always come up with the number of bits they expected | ||
51 | (something like 512, 1024, 2048, ...). This is because generating a | ||
52 | number with some specific number of bits doesn't always set the highest | ||
53 | bits, thereby making the number of | ||
54 | .Em significant | ||
55 | bits a little lower. | ||
56 | If you want to know the "key size" of such a key, either use functions | ||
57 | like | ||
58 | .Xr RSA_size 3 , | ||
59 | .Xr DH_size 3 , | ||
60 | and | ||
61 | .Xr DSA_size 3 , | ||
62 | or use | ||
63 | .Fn BN_num_bytes | ||
64 | and multiply with 8 (although there's no real guarantee that will match | ||
65 | the "key size", just a lot more probability). | ||
66 | .Sh SEE ALSO | ||
67 | .Xr bn 3 , | ||
68 | .Xr DH_size 3 , | ||
69 | .Xr DSA_size 3 , | ||
70 | .Xr RSA_size 3 | ||
71 | .Sh HISTORY | ||
72 | .Fn BN_num_bytes , | ||
73 | .Fn BN_num_bits , | ||
74 | and | ||
75 | .Fn BN_num_bits_word | ||
76 | are available in all versions of SSLeay and OpenSSL. | ||
diff --git a/src/lib/libcrypto/man/BN_rand.3 b/src/lib/libcrypto/man/BN_rand.3 new file mode 100644 index 0000000000..5ae9e9d791 --- /dev/null +++ b/src/lib/libcrypto/man/BN_rand.3 | |||
@@ -0,0 +1,93 @@ | |||
1 | .Dd $Mdocdate: February 23 2015 $ | ||
2 | .Dt BN_RAND 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BN_rand , | ||
6 | .Nm BN_pseudo_rand , | ||
7 | .Nm BN_rand_range , | ||
8 | .Nm BN_pseudo_rand_range | ||
9 | .Nd generate pseudo-random number | ||
10 | .Sh SYNOPSIS | ||
11 | .In openssl/bn.h | ||
12 | .Ft int | ||
13 | .Fo BN_rand | ||
14 | .Fa "BIGNUM *rnd" | ||
15 | .Fa "int bits" | ||
16 | .Fa "int top" | ||
17 | .Fa "int bottom" | ||
18 | .Fc | ||
19 | .Ft int | ||
20 | .Fo BN_pseudo_rand | ||
21 | .Fa "BIGNUM *rnd" | ||
22 | .Fa "int bits" | ||
23 | .Fa "int top" | ||
24 | .Fa "int bottom" | ||
25 | .Fc | ||
26 | .Ft int | ||
27 | .Fo BN_rand_range | ||
28 | .Fa "BIGNUM *rnd" | ||
29 | .Fa "BIGNUM *range" | ||
30 | .Fc | ||
31 | .Ft int | ||
32 | .Fo BN_pseudo_rand_range | ||
33 | .Fa "BIGNUM *rnd" | ||
34 | .Fa "BIGNUM *range" | ||
35 | .Fc | ||
36 | .Sh DESCRIPTION | ||
37 | .Fn BN_rand | ||
38 | generates a cryptographically strong pseudo-random number of | ||
39 | .Fa bits | ||
40 | bits in length and stores it in | ||
41 | .Fa rnd . | ||
42 | If | ||
43 | .Fa top | ||
44 | is -1, the most significant bit of the random number can be zero. | ||
45 | If | ||
46 | .Fa top | ||
47 | is 0, it is set to 1, and if | ||
48 | .Fa top | ||
49 | is 1, the two most significant bits of the number will be set to 1, so | ||
50 | that the product of two such random numbers will always have | ||
51 | .Pf 2* Fa bits | ||
52 | length. | ||
53 | If | ||
54 | .Fa bottom | ||
55 | is true, the number will be odd. | ||
56 | .Pp | ||
57 | .Fn BN_pseudo_rand | ||
58 | does the same, but pseudo-random numbers generated by this function are | ||
59 | not necessarily unpredictable. | ||
60 | They can be used for non-cryptographic purposes and for certain purposes | ||
61 | in cryptographic protocols, but usually not for key generation etc. | ||
62 | .Pp | ||
63 | .Fn BN_rand_range | ||
64 | generates a cryptographically strong pseudo-random number | ||
65 | .Fa rnd | ||
66 | in the range 0 <= | ||
67 | .Fa rnd No < Fa range . | ||
68 | .Fn BN_pseudo_rand_range | ||
69 | does the same, but is based on | ||
70 | .Fn BN_pseudo_rand , | ||
71 | and hence numbers generated by it are not necessarily unpredictable. | ||
72 | .Sh RETURN VALUES | ||
73 | The functions return 1 on success, 0 on error. | ||
74 | The error codes can be obtained by | ||
75 | .Xr ERR_get_error 3 . | ||
76 | .Sh SEE ALSO | ||
77 | .Xr bn 3 , | ||
78 | .Xr ERR_get_error 3 , | ||
79 | .Xr rand 3 , | ||
80 | .Xr RAND_add 3 , | ||
81 | .Xr RAND_bytes 3 | ||
82 | .Sh HISTORY | ||
83 | .Fn BN_rand | ||
84 | is available in all versions of SSLeay and OpenSSL. | ||
85 | .Fn BN_pseudo_rand | ||
86 | was added in OpenSSL 0.9.5. | ||
87 | The | ||
88 | .Fa top | ||
89 | == -1 case and the function | ||
90 | .Fn BN_rand_range | ||
91 | were added in OpenSSL 0.9.6a. | ||
92 | .Fn BN_pseudo_rand_range | ||
93 | was added in OpenSSL 0.9.6c. | ||
diff --git a/src/lib/libcrypto/man/BN_set_bit.3 b/src/lib/libcrypto/man/BN_set_bit.3 new file mode 100644 index 0000000000..4a199cd0d0 --- /dev/null +++ b/src/lib/libcrypto/man/BN_set_bit.3 | |||
@@ -0,0 +1,157 @@ | |||
1 | .Dd $Mdocdate: February 23 2015 $ | ||
2 | .Dt BN_SET_BIT 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BN_set_bit , | ||
6 | .Nm BN_clear_bit , | ||
7 | .Nm BN_is_bit_set , | ||
8 | .Nm BN_mask_bits , | ||
9 | .Nm BN_lshift , | ||
10 | .Nm BN_lshift1 , | ||
11 | .Nm BN_rshift , | ||
12 | .Nm BN_rshift1 | ||
13 | .Nd bit operations on BIGNUMs | ||
14 | .Sh SYNOPSIS | ||
15 | .In openssl/bn.h | ||
16 | .Ft int | ||
17 | .Fo BN_set_bit | ||
18 | .Fa "BIGNUM *a" | ||
19 | .Fa "int n" | ||
20 | .Fc | ||
21 | .Ft int | ||
22 | .Fo BN_clear_bit | ||
23 | .Fa "BIGNUM *a" | ||
24 | .Fa "int n" | ||
25 | .Fc | ||
26 | .Ft int | ||
27 | .Fo BN_is_bit_set | ||
28 | .Fa "const BIGNUM *a" | ||
29 | .Fa "int n" | ||
30 | .Fc | ||
31 | .Ft int | ||
32 | .Fo BN_mask_bits | ||
33 | .Fa "BIGNUM *a" | ||
34 | .Fa "int n" | ||
35 | .Fc | ||
36 | .Ft int | ||
37 | .Fo BN_lshift | ||
38 | .Fa "BIGNUM *r" | ||
39 | .Fa "const BIGNUM *a" | ||
40 | .Fa "int n" | ||
41 | .Fc | ||
42 | .Ft int | ||
43 | .Fo BN_lshift1 | ||
44 | .Fa "BIGNUM *r" | ||
45 | .Fa "BIGNUM *a" | ||
46 | .Fc | ||
47 | .Ft int | ||
48 | .Fo BN_rshift | ||
49 | .Fa "BIGNUM *r" | ||
50 | .Fa "BIGNUM *a" | ||
51 | .Fa "int n" | ||
52 | .Fc | ||
53 | .Ft int | ||
54 | .Fo BN_rshift1 | ||
55 | .Fa "BIGNUM *r" | ||
56 | .Fa "BIGNUM *a" | ||
57 | .Fc | ||
58 | .Sh DESCRIPTION | ||
59 | .Fn BN_set_bit | ||
60 | sets bit | ||
61 | .Fa n | ||
62 | in | ||
63 | .Fa a | ||
64 | to 1 | ||
65 | .Pq Li a|=(1<<n) . | ||
66 | The number is expanded if necessary. | ||
67 | .Pp | ||
68 | .Fn BN_clear_bit | ||
69 | sets bit | ||
70 | .Fa n | ||
71 | in | ||
72 | .Fa a | ||
73 | to 0 | ||
74 | .Pq Li a&=~(1<<n) . | ||
75 | An error occurs if | ||
76 | .Fa a | ||
77 | is shorter than | ||
78 | .Fa n | ||
79 | bits. | ||
80 | .Pp | ||
81 | .Fn BN_is_bit_set | ||
82 | tests if bit | ||
83 | .Fa n | ||
84 | in | ||
85 | .Fa a | ||
86 | is set. | ||
87 | .Pp | ||
88 | .Fn BN_mask_bits | ||
89 | truncates | ||
90 | .Fa a | ||
91 | to an | ||
92 | .Fa n | ||
93 | bit number | ||
94 | .Pq Li a&=~((~0)>>n) . | ||
95 | An error occurs if | ||
96 | .Fa a | ||
97 | already is shorter than | ||
98 | .Fa n | ||
99 | bits. | ||
100 | .Pp | ||
101 | .Fn BN_lshift | ||
102 | shifts | ||
103 | .Fa a | ||
104 | left by | ||
105 | .Fa n | ||
106 | bits and places the result in | ||
107 | .Fa r | ||
108 | .Pq Li r=a*2^n . | ||
109 | .Fn BN_lshift1 | ||
110 | shifts | ||
111 | .Fa a | ||
112 | left by one and places the result in | ||
113 | .Fa r | ||
114 | .Pq Li r=2*a . | ||
115 | .Pp | ||
116 | .Fn BN_rshift | ||
117 | shifts | ||
118 | .Fa a | ||
119 | right by | ||
120 | .Fa n | ||
121 | bits and places the result in | ||
122 | .Fa r | ||
123 | .Pq Li r=a/2^n . | ||
124 | .Fn BN_rshift1 | ||
125 | shifts | ||
126 | .Fa a | ||
127 | right by one and places the result in | ||
128 | .Fa r | ||
129 | .Pq Li r=a/2 . | ||
130 | .Pp | ||
131 | For the shift functions, | ||
132 | .Fa r | ||
133 | and | ||
134 | .Fa a | ||
135 | may be the same variable. | ||
136 | .Sh RETURN VALUES | ||
137 | .Fn BN_is_bit_set | ||
138 | returns 1 if the bit is set, 0 otherwise. | ||
139 | .Pp | ||
140 | All other functions return 1 for success, 0 on error. | ||
141 | The error codes can be obtained by | ||
142 | .Xr ERR_get_error 3 . | ||
143 | .Sh SEE ALSO | ||
144 | .Xr bn 3 , | ||
145 | .Xr BN_add 3 , | ||
146 | .Xr BN_num_bytes 3 | ||
147 | .Sh HISTORY | ||
148 | .Fn BN_set_bit , | ||
149 | .Fn BN_clear_bit , | ||
150 | .Fn BN_is_bit_set , | ||
151 | .Fn BN_mask_bits , | ||
152 | .Fn BN_lshift , | ||
153 | .Fn BN_lshift1 , | ||
154 | .Fn BN_rshift , | ||
155 | and | ||
156 | .Fn BN_rshift1 | ||
157 | are available in all versions of SSLeay and OpenSSL. | ||
diff --git a/src/lib/libcrypto/man/BN_swap.3 b/src/lib/libcrypto/man/BN_swap.3 new file mode 100644 index 0000000000..b252261067 --- /dev/null +++ b/src/lib/libcrypto/man/BN_swap.3 | |||
@@ -0,0 +1,23 @@ | |||
1 | .Dd $Mdocdate: February 23 2015 $ | ||
2 | .Dt BN_SWAP 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BN_swap | ||
6 | .Nd exchange BIGNUMs | ||
7 | .Sh SYNOPSIS | ||
8 | .In openssl/bn.h | ||
9 | .Ft void | ||
10 | .Fo BN_swap | ||
11 | .Fa "BIGNUM *a" | ||
12 | .Fa "BIGNUM *b" | ||
13 | .Fc | ||
14 | .Sh DESCRIPTION | ||
15 | .Fn BN_swap | ||
16 | exchanges the values of | ||
17 | .Fa a | ||
18 | and | ||
19 | .Fa b . | ||
20 | .Sh SEE ALSO | ||
21 | .Xr bn 3 | ||
22 | .Sh HISTORY | ||
23 | BN_swap was added in OpenSSL 0.9.7. | ||
diff --git a/src/lib/libcrypto/man/BN_zero.3 b/src/lib/libcrypto/man/BN_zero.3 new file mode 100644 index 0000000000..adfd6a0c65 --- /dev/null +++ b/src/lib/libcrypto/man/BN_zero.3 | |||
@@ -0,0 +1,101 @@ | |||
1 | .Dd $Mdocdate: February 23 2015 $ | ||
2 | .Dt BN_ZERO 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm BN_zero , | ||
6 | .Nm BN_one , | ||
7 | .Nm BN_value_one , | ||
8 | .Nm BN_set_word , | ||
9 | .Nm BN_get_word | ||
10 | .Nd BIGNUM assignment operations | ||
11 | .Sh SYNOPSIS | ||
12 | .In openssl/bn.h | ||
13 | .Ft int | ||
14 | .Fo BN_zero | ||
15 | .Fa "BIGNUM *a" | ||
16 | .Fc | ||
17 | .Ft int | ||
18 | .Fo BN_one | ||
19 | .Fa "BIGNUM *a" | ||
20 | .Fc | ||
21 | .Ft const BIGNUM * | ||
22 | .Fo BN_value_one | ||
23 | .Fa void | ||
24 | .Fc | ||
25 | .Ft int | ||
26 | .Fo BN_set_word | ||
27 | .Fa "BIGNUM *a" | ||
28 | .Fa "unsigned long w" | ||
29 | .Fc | ||
30 | .Ft unsigned long | ||
31 | .Fo BN_get_word | ||
32 | .Fa "BIGNUM *a" | ||
33 | .Fc | ||
34 | .Sh DESCRIPTION | ||
35 | .Fn BN_zero , | ||
36 | .Fn BN_one , | ||
37 | and | ||
38 | .Fn BN_set_word | ||
39 | set | ||
40 | .Fa a | ||
41 | to the values 0, 1 and | ||
42 | .Fa w | ||
43 | respectively. | ||
44 | .Fn BN_zero | ||
45 | and | ||
46 | .Fn BN_one | ||
47 | are macros. | ||
48 | .Pp | ||
49 | .Fn BN_value_one | ||
50 | returns a | ||
51 | .Vt BIGNUM | ||
52 | constant of value 1. | ||
53 | This constant is useful for use in comparisons and assignment. | ||
54 | .Pp | ||
55 | .Fn BN_get_word | ||
56 | returns | ||
57 | .Fa a | ||
58 | if it can be represented as an | ||
59 | .Vt unsigned long . | ||
60 | .Sh RETURN VALUES | ||
61 | .Fn BN_get_word | ||
62 | returns the value | ||
63 | .Fa a , | ||
64 | or 0xffffffffL if | ||
65 | .Fa a | ||
66 | cannot be represented as an | ||
67 | .Vt unsigned long . | ||
68 | .Pp | ||
69 | .Fn BN_zero , | ||
70 | .Fn BN_one , | ||
71 | and | ||
72 | .Fn BN_set_word | ||
73 | return 1 on success, 0 otherwise. | ||
74 | .Fn BN_value_one | ||
75 | returns the constant. | ||
76 | .Sh SEE ALSO | ||
77 | .Xr bn 3 , | ||
78 | .Xr BN_bn2bin 3 | ||
79 | .Sh HISTORY | ||
80 | .Fn BN_zero , | ||
81 | .Fn BN_one , | ||
82 | and | ||
83 | .Fn BN_set_word | ||
84 | are available in all versions of SSLeay and OpenSSL. | ||
85 | .Fn BN_value_one | ||
86 | and | ||
87 | .Fn BN_get_word | ||
88 | were added in SSLeay 0.8. | ||
89 | .Pp | ||
90 | .Fn BN_value_one | ||
91 | was changed to return a true | ||
92 | .Vt const BIGNUM * | ||
93 | in OpenSSL 0.9.7. | ||
94 | .Sh BUGS | ||
95 | Someone might change the constant. | ||
96 | .Pp | ||
97 | If a | ||
98 | .Vt BIGNUM | ||
99 | is equal to 0xffffffffL it can be represented as an | ||
100 | .Vt unsigned long | ||
101 | but this value is also returned on error. | ||
diff --git a/src/lib/libcrypto/man/Makefile b/src/lib/libcrypto/man/Makefile index 2ac6e5b6f6..bce02f647f 100644 --- a/src/lib/libcrypto/man/Makefile +++ b/src/lib/libcrypto/man/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: Makefile,v 1.18 2015/02/16 16:42:14 schwarze Exp $ | 1 | # $OpenBSD: Makefile,v 1.19 2015/02/23 17:43:24 schwarze Exp $ |
2 | 2 | ||
3 | .include <bsd.own.mk> # for NOMAN | 3 | .include <bsd.own.mk> # for NOMAN |
4 | 4 | ||
@@ -33,8 +33,6 @@ MAN= \ | |||
33 | BIO_s_socket.3 \ | 33 | BIO_s_socket.3 \ |
34 | BIO_set_callback.3 \ | 34 | BIO_set_callback.3 \ |
35 | BIO_should_retry.3 \ | 35 | BIO_should_retry.3 \ |
36 | |||
37 | GENMAN= \ | ||
38 | BN_BLINDING_new.3 \ | 36 | BN_BLINDING_new.3 \ |
39 | BN_CTX_new.3 \ | 37 | BN_CTX_new.3 \ |
40 | BN_CTX_start.3 \ | 38 | BN_CTX_start.3 \ |
@@ -53,6 +51,8 @@ GENMAN= \ | |||
53 | BN_set_bit.3 \ | 51 | BN_set_bit.3 \ |
54 | BN_swap.3 \ | 52 | BN_swap.3 \ |
55 | BN_zero.3 \ | 53 | BN_zero.3 \ |
54 | |||
55 | GENMAN= \ | ||
56 | BUF_MEM_new.3 \ | 56 | BUF_MEM_new.3 \ |
57 | CONF_modules_free.3 \ | 57 | CONF_modules_free.3 \ |
58 | CONF_modules_load_file.3 \ | 58 | CONF_modules_load_file.3 \ |