]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix SCA vulnerability when using PVK and MSBLOB key formats
authorCesar Pereida Garcia <cesar.pereidagarcia@tut.fi>
Mon, 19 Aug 2019 07:33:14 +0000 (10:33 +0300)
committerMatt Caswell <matt@openssl.org>
Tue, 27 Aug 2019 08:25:51 +0000 (09:25 +0100)
This commit addresses a side-channel vulnerability present when
PVK and MSBLOB key formats are loaded into OpenSSL.
The public key was not computed using a constant-time exponentiation
function.

This issue was discovered and reported by the NISEC group at TAU Finland.

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9638)

crypto/pem/pvkfmt.c

index f376f594b12dc514699cdfcb27fe01dcf0c4d01e..ff5674a99f865ba001dbdc2e832bf2c680deb81a 100644 (file)
@@ -327,6 +327,8 @@ static EVP_PKEY *b2i_dss(const unsigned char **in, unsigned int length,
     } else {
         if (!read_lebn(&p, 20, &dsa->priv_key))
             goto memerr;
+        /* Set constant time flag before public key calculation */
+        BN_set_flags(dsa->priv_key, BN_FLG_CONSTTIME);
         /* Calculate public key */
         if (!(dsa->pub_key = BN_new()))
             goto memerr;