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