summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschwarze <>2017-01-29 23:41:49 +0000
committerschwarze <>2017-01-29 23:41:49 +0000
commitcdcc8ff92546c28c6052f507ba6ff8b82340b5e3 (patch)
tree83b0e7ffbb25488021b344d6b87cca01b6781a0b
parent349c6add6442fbf91283c7ec35808acbec836f29 (diff)
downloadopenbsd-cdcc8ff92546c28c6052f507ba6ff8b82340b5e3.tar.gz
openbsd-cdcc8ff92546c28c6052f507ba6ff8b82340b5e3.tar.bz2
openbsd-cdcc8ff92546c28c6052f507ba6ff8b82340b5e3.zip
Seriously warn against calling BN_init(3), BN_MONT_CTX_init(3),
and BN_RECP_CTX_init(3). They are not only deprecated but so dangerous that they are almost unusable. I found these scary traps while reading the code in order to document BN_set_flags(3). While here, delete ERR_get_error(3) from SEE ALSO.
-rw-r--r--src/lib/libcrypto/man/BN_mod_mul_montgomery.327
-rw-r--r--src/lib/libcrypto/man/BN_mod_mul_reciprocal.327
-rw-r--r--src/lib/libcrypto/man/BN_new.333
3 files changed, 75 insertions, 12 deletions
diff --git a/src/lib/libcrypto/man/BN_mod_mul_montgomery.3 b/src/lib/libcrypto/man/BN_mod_mul_montgomery.3
index 8b06cb6217..87f09e3cb6 100644
--- a/src/lib/libcrypto/man/BN_mod_mul_montgomery.3
+++ b/src/lib/libcrypto/man/BN_mod_mul_montgomery.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_mod_mul_montgomery.3,v 1.5 2016/12/10 21:13:25 schwarze Exp $ 1.\" $OpenBSD: BN_mod_mul_montgomery.3,v 1.6 2017/01/29 23:41:49 schwarze Exp $
2.\" OpenSSL 6859cf74 Sep 25 13:33:28 2002 +0000 2.\" OpenSSL 6859cf74 Sep 25 13:33:28 2002 +0000
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: December 10 2016 $ 51.Dd $Mdocdate: January 29 2017 $
52.Dt BN_MOD_MUL_MONTGOMERY 3 52.Dt BN_MOD_MUL_MONTGOMERY 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -119,9 +119,12 @@ operations are to be performed using the same modulus.
119allocates and initializes a 119allocates and initializes a
120.Vt BN_MONT_CTX 120.Vt BN_MONT_CTX
121structure. 121structure.
122.Pp
122.Fn BN_MONT_CTX_init 123.Fn BN_MONT_CTX_init
123initializes an existing uninitialized 124initializes an existing uninitialized
124.Vt BN_MONT_CTX . 125.Vt BN_MONT_CTX .
126It is deprecated and dangerous, see
127.Sx CAVEATS .
125.Pp 128.Pp
126.Fn BN_MONT_CTX_set 129.Fn BN_MONT_CTX_set
127sets up the 130sets up the
@@ -213,8 +216,7 @@ The error codes can be obtained by
213.Sh SEE ALSO 216.Sh SEE ALSO
214.Xr BN_add 3 , 217.Xr BN_add 3 ,
215.Xr BN_CTX_new 3 , 218.Xr BN_CTX_new 3 ,
216.Xr BN_new 3 , 219.Xr BN_new 3
217.Xr ERR_get_error 3
218.Sh HISTORY 220.Sh HISTORY
219.Fn BN_MONT_CTX_new , 221.Fn BN_MONT_CTX_new ,
220.Fn BN_MONT_CTX_free , 222.Fn BN_MONT_CTX_free ,
@@ -229,3 +231,20 @@ are available in all versions of SSLeay and OpenSSL.
229and 231and
230.Fn BN_MONT_CTX_copy 232.Fn BN_MONT_CTX_copy
231were added in SSLeay 0.9.1b. 233were added in SSLeay 0.9.1b.
234.Sh CAVEATS
235.Fn BN_MONT_CTX_init
236must not be called on a context that was used previously, or
237memory used by the embedded
238.Vt BIGNUM
239structures is leaked immediately.
240Besides, it must not be called on a context created with
241.Fn BN_MONT_CTX_new ,
242or the context itself will likely be leaked later.
243It can only be used on a static
244.Vt BN_MONT_CTX
245structure, on one located on the stack, or on one
246.Xr malloc 3 Ap ed
247manually, but all these options are discouraged because they
248will no longer work once
249.Vt BN_MONT_CTX
250will be made opaque.
diff --git a/src/lib/libcrypto/man/BN_mod_mul_reciprocal.3 b/src/lib/libcrypto/man/BN_mod_mul_reciprocal.3
index 74783b2f55..a24917bef9 100644
--- a/src/lib/libcrypto/man/BN_mod_mul_reciprocal.3
+++ b/src/lib/libcrypto/man/BN_mod_mul_reciprocal.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_mod_mul_reciprocal.3,v 1.5 2016/12/10 21:13:25 schwarze Exp $ 1.\" $OpenBSD: BN_mod_mul_reciprocal.3,v 1.6 2017/01/29 23:41:49 schwarze Exp $
2.\" OpenSSL 6859cf74 Sep 25 13:33:28 2002 +0000 2.\" OpenSSL 6859cf74 Sep 25 13:33:28 2002 +0000
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: December 10 2016 $ 51.Dd $Mdocdate: January 29 2017 $
52.Dt BN_MOD_MUL_RECIPROCAL 3 52.Dt BN_MOD_MUL_RECIPROCAL 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -115,9 +115,12 @@ used for temporary variables.
115allocates and initializes a 115allocates and initializes a
116.Vt BN_RECP_CTX 116.Vt BN_RECP_CTX
117structure. 117structure.
118.Pp
118.Fn BN_RECP_CTX_init 119.Fn BN_RECP_CTX_init
119initializes an existing uninitialized 120initializes an existing uninitialized
120.Vt BN_RECP_CTX . 121.Vt BN_RECP_CTX .
122It is deprecated and dangerous, see
123.Sx CAVEATS .
121.Pp 124.Pp
122.Fn BN_RECP_CTX_free 125.Fn BN_RECP_CTX_free
123frees the components of the 126frees the components of the
@@ -185,8 +188,7 @@ The error codes can be obtained by
185.Sh SEE ALSO 188.Sh SEE ALSO
186.Xr BN_add 3 , 189.Xr BN_add 3 ,
187.Xr BN_CTX_new 3 , 190.Xr BN_CTX_new 3 ,
188.Xr BN_new 3 , 191.Xr BN_new 3
189.Xr ERR_get_error 3
190.Sh HISTORY 192.Sh HISTORY
191.Vt BN_RECP_CTX 193.Vt BN_RECP_CTX
192was added in SSLeay 0.9.0. 194was added in SSLeay 0.9.0.
@@ -195,3 +197,20 @@ Before that, a function
195was used instead, and the 197was used instead, and the
196.Fn BN_mod_mul_reciprocal 198.Fn BN_mod_mul_reciprocal
197arguments were different. 199arguments were different.
200.Sh CAVEATS
201.Fn BN_RECP_CTX_init
202must not be called on a context that was used previously, or
203memory used by the embedded
204.Vt BIGNUM
205structures is leaked immediately.
206Besides, it must not be called on a context created with
207.Fn BN_RECP_CTX_new ,
208or the context itself will likely be leaked later.
209It can only be used on a static
210.Vt BN_RECP_CTX
211structure, on one located on the stack, or on one
212.Xr malloc 3 Ap ed
213manually, but all these options are discouraged because they
214will no longer work once
215.Vt BN_RECP_CTX
216will be made opaque.
diff --git a/src/lib/libcrypto/man/BN_new.3 b/src/lib/libcrypto/man/BN_new.3
index 2b2166ce30..8294a4f4d1 100644
--- a/src/lib/libcrypto/man/BN_new.3
+++ b/src/lib/libcrypto/man/BN_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_new.3,v 1.6 2016/12/22 19:33:57 jmc Exp $ 1.\" $OpenBSD: BN_new.3,v 1.7 2017/01/29 23:41:49 schwarze Exp $
2.\" OpenSSL doc/man3/BN_new.pod 2457c19d Mar 6 08:43:36 2004 +0000 2.\" OpenSSL doc/man3/BN_new.pod 2457c19d Mar 6 08:43:36 2004 +0000
3.\" OpenSSL doc/man7/bn.pod 05ea606a May 20 20:52:46 2016 -0400 3.\" OpenSSL doc/man7/bn.pod 05ea606a May 20 20:52:46 2016 -0400
4.\" 4.\"
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: December 22 2016 $ 52.Dd $Mdocdate: January 29 2017 $
53.Dt BN_NEW 3 53.Dt BN_NEW 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -102,9 +102,12 @@ or accessed directly.
102allocates and initializes a 102allocates and initializes a
103.Vt BIGNUM 103.Vt BIGNUM
104structure. 104structure.
105.Pp
105.Fn BN_init 106.Fn BN_init
106initializes an existing uninitialized 107initializes an existing uninitialized
107.Vt BIGNUM . 108.Vt BIGNUM .
109It is deprecated and dangerous, see
110.Sx CAVEATS .
108.Pp 111.Pp
109.Fn BN_clear 112.Fn BN_clear
110is used to destroy sensitive data such as keys when they are no longer 113is used to destroy sensitive data such as keys when they are no longer
@@ -154,8 +157,7 @@ and sets an error code that can be obtained by
154.Xr BN_set_bit 3 , 157.Xr BN_set_bit 3 ,
155.Xr BN_set_negative 3 , 158.Xr BN_set_negative 3 ,
156.Xr BN_swap 3 , 159.Xr BN_swap 3 ,
157.Xr BN_zero 3 , 160.Xr BN_zero 3
158.Xr ERR_get_error 3
159.Sh HISTORY 161.Sh HISTORY
160.Fn BN_new , 162.Fn BN_new ,
161.Fn BN_clear , 163.Fn BN_clear ,
@@ -165,3 +167,26 @@ and
165are available in all versions of SSLeay and OpenSSL. 167are available in all versions of SSLeay and OpenSSL.
166.Fn BN_init 168.Fn BN_init
167was added in SSLeay 0.9.1b. 169was added in SSLeay 0.9.1b.
170.Sh CAVEATS
171.Fn BN_init
172must not be called on a
173.Vt BIGNUM
174that was used and contains an actual number, or the memory
175used for storing the number is leaked immediately.
176Besides, it must not be called on a number allocated with
177.Fn BN_new ,
178or the
179.Vt BIGNUM
180structure itself will likely be leaked later on.
181It can only be used on static
182.Vt BIGNUM
183structures, on
184.Vt BIGNUM
185structures on the stack, or on
186.Vt BIGNUM
187structures
188.Xr malloc 3 Ap ed
189manually, but all of these options are discouraged because they
190will no longer work once the
191.Vt BIGNUM
192data type will be made opaque.