summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/BN_set_flags.3
diff options
context:
space:
mode:
authorschwarze <>2018-04-29 15:58:21 +0000
committerschwarze <>2018-04-29 15:58:21 +0000
commita60c20fc32aa2f822c683424f5bd90611e4d452f (patch)
treef067081374e9045588229a0f9af9373361fb2cbe /src/lib/libcrypto/man/BN_set_flags.3
parent0a991f6de98776a2cd65f3529adb8948b51c275a (diff)
downloadopenbsd-a60c20fc32aa2f822c683424f5bd90611e4d452f.tar.gz
openbsd-a60c20fc32aa2f822c683424f5bd90611e4d452f.tar.bz2
openbsd-a60c20fc32aa2f822c683424f5bd90611e4d452f.zip
In view of the recent BN_FLG_CONSTTIME vulnerabilities in OpenSSL,
carefully document constant time vs. non-constant time operation of BN_div(3), BN_mod_exp(3), and BN_mod_inverse(3). Until the work that is required on the ill-designed BN_exp(3) and BN_gcd(3) interfaces can be undertaken, also document the imperfections in their behaviour, for now. Finally, mention BN_mod_exp(3) behaviour for even moduli. Delete the vague statement about some functions automatically setting BN_FLG_CONSTTIME. It created a false sense of security. Do not rely on it: not all relevant functions do that. Topic brought up by beck@, significant feedback and OK jsing@.
Diffstat (limited to 'src/lib/libcrypto/man/BN_set_flags.3')
-rw-r--r--src/lib/libcrypto/man/BN_set_flags.359
1 files changed, 38 insertions, 21 deletions
diff --git a/src/lib/libcrypto/man/BN_set_flags.3 b/src/lib/libcrypto/man/BN_set_flags.3
index a998037534..9b1647cd31 100644
--- a/src/lib/libcrypto/man/BN_set_flags.3
+++ b/src/lib/libcrypto/man/BN_set_flags.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: BN_set_flags.3,v 1.2 2018/03/21 09:03:49 schwarze Exp $ 1.\" $OpenBSD: BN_set_flags.3,v 1.3 2018/04/29 15:58:21 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: March 21 2018 $ 17.Dd $Mdocdate: April 29 2018 $
18.Dt BN_SET_FLAGS 3 18.Dt BN_SET_FLAGS 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -47,6 +47,8 @@ together:
47.It Dv BN_FLG_CONSTTIME 47.It Dv BN_FLG_CONSTTIME
48If this flag is set on the divident 48If this flag is set on the divident
49.Fa a 49.Fa a
50or the divisor
51.Fa d
50in 52in
51.Xr BN_div 3 , 53.Xr BN_div 3 ,
52on the exponent 54on the exponent
@@ -59,27 +61,14 @@ or the modulus
59.Fa n 61.Fa n
60in 62in
61.Xr BN_mod_inverse 3 , 63.Xr BN_mod_inverse 3 ,
62these functions prefer algorithms with an execution time independent 64these functions select algorithms with an execution time independent
63of the respective numbers, to avoid exposing sensitive information 65of the respective numbers, to avoid exposing sensitive information
64to timing attacks. 66to timing side-channel attacks.
65.Pp 67.Pp
66If this flag is set on the exponent 68This flag is off by default for
67.Fa p 69.Vt BIGNUM
68in 70objects created with
69.Xr BN_exp 3 71.Xr BN_new 3 .
70or if the modulus
71.Fa m
72is even for
73.Xr BN_mod_exp 3 ,
74an error occurs.
75.Pp
76Various functions automatically set this flag on sensitive data.
77For example, the default implementations of
78.Xr DH_generate_key 3 ,
79.Xr DSA_generate_key 3 ,
80and
81.Xr RSA_generate_key_ex 3
82set it on the generated private key.
83.It Dv BN_FLG_MALLOCED 72.It Dv BN_FLG_MALLOCED
84If this flag is set, 73If this flag is set,
85.Xr BN_free 3 74.Xr BN_free 3
@@ -148,3 +137,31 @@ first appeared in SSLeay 0.9.1 and have been available since
148No public interface exists to clear a flag once it is set. 137No public interface exists to clear a flag once it is set.
149So think twice before using 138So think twice before using
150.Fn BN_set_flags . 139.Fn BN_set_flags .
140.Sh BUGS
141Even if the
142.Dv BN_FLG_CONSTTIME
143flag is set on
144.Fa a
145or
146.Fa b ,
147.Fn BN_gcd
148neither fails nor operates in constant time, potentially allowing
149timing side-channel attacks.
150.Pp
151Even if the
152.Dv BN_FLG_CONSTTIME
153flag is set on
154.Fa p ,
155if the modulus
156.Fa m
157is even,
158.Xr BN_mod_exp 3
159does not operate in constant time, potentially allowing
160timing side-channel attacks.
161.Pp
162If
163.Dv BN_FLG_CONSTTIME
164is set on
165.Fa p ,
166.Fn BN_exp
167fails instead of operating in constant time.