boringssl/include/openssl
David Benjamin 7139f755b6 Fix some timing leaks in the DSA code.
The DSA code is deprecated and will, hopefully, be removed in the future.
Nonetheless, this is easy enough to fix. It's the analog of the work we'd
already done for ECDSA.

- Document more clearly that we don't care about the DSA code.

- Use the existing constant-time modular addition function rather than
  the ad-hoc code.

- Reduce the digest to satisfy modular operations' invariants. (The
  underlying algorithms could accept looser bounds, but we reduce for
  simplicity.) There's no particular reason to do this in constant time,
  but we have the code for it, so we may as well.

- This additionally adds a missing check that num_bits(q) is a multiple
  of 8. We otherwise don't compute the right answer. Verification
  already rejected all 160-, 224-, and 256-bit keys, and we only
  generate DSA parameters where the length of q matches some hash
  function's length, so this is unlikely to cause anyone trouble.

- Use Montgomery reduction to perform the modular multiplication. This
  could be optimized to save a couple Montgomery reductions as in ECDSA,
  but DSA is deprecated, so I haven't bothered optimizing this.

- The reduction from g^k (mod p) to r = g^k (mod p) (mod q) is left
  in variable time, but reversing it would require a discrete log
  anyway. (The corresponding ECDSA operation is much easier to make
  constant-time due to Hasse's theorem, though that's actually still a
  TODO. I need to finish lifting EC_FELEM up the stack.)

Thanks to Keegan Ryan from NCC Group for reporting the modular addition issue
(CVE-2018-0495). The remainder is stuff I noticed along the way.

Update-Note: See the num_bits(q) change.

Change-Id: I4f032b041e2aeb09f9737a39f178c24e6a7fa1cb
Reviewed-on: https://boringssl-review.googlesource.com/29145
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-15 02:37:45 +00:00
..
aead.h Document the correct nonce length for AES-GCM. 2018-05-24 22:13:07 +00:00
aes.h Run comment conversion script on include/ 2017-08-18 23:38:51 +00:00
arm_arch.h Run comment conversion script on include/ 2017-08-18 23:38:51 +00:00
asn1_mac.h
asn1.h Use new encoding functions in ASN1_mbstring_ncopy. 2018-05-11 21:58:47 +00:00
asn1t.h Remove ASN1_template_(i2d,d2i). 2017-09-15 22:53:43 +00:00
base64.h Run comment conversion script on include/ 2017-08-18 23:38:51 +00:00
base.h Bump BORINGSSL_API_VERSION. 2018-05-08 17:40:55 +00:00
bio.h Fix reference to nonexistent function. 2018-01-16 16:23:36 +00:00
blowfish.h Run comment conversion script on include/ 2017-08-18 23:38:51 +00:00
bn.h Require BN_mod_exp_mont* inputs be reduced. 2018-04-24 18:29:29 +00:00
buf.h Always process handshake records in full. 2017-10-17 14:53:11 +00:00
buffer.h
bytestring.h bytestring: document that |CBS_get_optional_asn1| can have a NULL output. 2018-03-19 20:22:25 +00:00
cast.h Run comment conversion script on include/ 2017-08-18 23:38:51 +00:00
chacha.h Add chacha.h to the list of documented headers. 2017-10-12 15:27:34 +00:00
cipher.h Add a Wycheproof driver for AES-CBC. 2018-05-02 19:41:48 +00:00
cmac.h Add some more compatibility functions. 2018-05-08 20:51:15 +00:00
conf.h Add more compatibility symbols for Node. 2017-11-03 01:31:50 +00:00
cpu.h Change OPENSSL_cpuid_setup to reserve more extended feature space. 2018-04-19 20:48:58 +00:00
crypto.h Return more placeholder version strings. 2018-05-15 22:57:30 +00:00
curve25519.h Fix typo. 2018-05-30 15:42:35 +00:00
des.h Run comment conversion script on include/ 2017-08-18 23:38:51 +00:00
dh.h Switch OPENSSL_VERSION_NUMBER to 1.1.0. 2017-09-29 04:51:27 +00:00
digest.h Match OpenSSL's EVP_MD_CTX_reset return value. 2018-05-29 17:07:16 +00:00
dsa.h Fix some timing leaks in the DSA code. 2018-06-15 02:37:45 +00:00
dtls1.h
e_os2.h Add a stub e_os2.h header. 2018-05-08 01:32:14 +00:00
ec_key.h Fold EC_KEY_copy into EC_KEY_dup. 2018-03-07 21:17:02 +00:00
ec.h More compatibility stuff. 2018-05-15 23:57:53 +00:00
ecdh.h Run comment conversion script on include/ 2017-08-18 23:38:51 +00:00
ecdsa.h Remove ECDSA_sign_setup and friends. 2017-11-22 20:23:40 +00:00
engine.h Run comment conversion script on include/ 2017-08-18 23:38:51 +00:00
err.h Add some more compatibility functions. 2018-05-08 20:51:15 +00:00
evp.h More compatibility stuff. 2018-05-15 23:57:53 +00:00
ex_data.h Run comment conversion script on include/ 2017-08-18 23:38:51 +00:00
hkdf.h Run comment conversion script on include/ 2017-08-18 23:38:51 +00:00
hmac.h Switch OPENSSL_VERSION_NUMBER to 1.1.0. 2017-09-29 04:51:27 +00:00
is_boringssl.h Run comment conversion script on include/ 2017-08-18 23:38:51 +00:00
lhash_macros.h Run comment conversion script on include/ 2017-08-18 23:38:51 +00:00
lhash.h Unexport more of lhash. 2017-10-25 04:17:18 +00:00
md4.h Run comment conversion script on include/ 2017-08-18 23:38:51 +00:00
md5.h Run comment conversion script on include/ 2017-08-18 23:38:51 +00:00
mem.h Remove redundant calls to |OPENSSL_cleanse| and |OPENSSL_realloc_clean|. 2017-09-18 19:16:51 +00:00
nid.h Add OpenSSL 1.1.0's cipher property functions. 2017-08-11 02:08:58 +00:00
obj_mac.h
obj.h Add some more compatibility functions. 2018-05-08 20:51:15 +00:00
objects.h
opensslconf.h Switch OPENSSL_VERSION_NUMBER to 1.1.0. 2017-09-29 04:51:27 +00:00
opensslv.h
ossl_typ.h
pem.h Switch a number of files to C++. 2017-07-12 20:54:02 +00:00
pkcs7.h Run comment conversion script on include/ 2017-08-18 23:38:51 +00:00
pkcs8.h Add PKCS12_create. 2018-05-11 21:59:34 +00:00
pkcs12.h
poly1305.h Run comment conversion script on include/ 2017-08-18 23:38:51 +00:00
pool.h Run comment conversion script on include/ 2017-08-18 23:38:51 +00:00
rand.h Run comment conversion script on include/ 2017-08-18 23:38:51 +00:00
rc4.h Run comment conversion script on include/ 2017-08-18 23:38:51 +00:00
ripemd.h Run comment conversion script on include/ 2017-08-18 23:38:51 +00:00
rsa.h More compatibility stuff. 2018-05-15 23:57:53 +00:00
safestack.h
sha.h Add SHA256_TransformBlocks. 2018-04-25 17:51:50 +00:00
span.h Add runtime bounds checks to bssl::Span. 2018-04-16 16:26:33 +00:00
srtp.h
ssl3.h Preliminary support for compressed certificates. 2018-06-04 21:24:20 +00:00
ssl.h Add SSL_SESSION_get0_id_context. 2018-06-11 14:25:23 +00:00
stack.h Avoid modifying stack in sk_find. 2018-04-12 21:02:12 +00:00
thread.h Run comment conversion script on include/ 2017-08-18 23:38:51 +00:00
tls1.h Preliminary support for compressed certificates. 2018-06-04 21:24:20 +00:00
type_check.h Run comment conversion script on include/ 2017-08-18 23:38:51 +00:00
x509_vfy.h Add a bunch of X509_STORE getters and setters. 2018-05-11 21:59:58 +00:00
x509.h Add PKCS12_create. 2018-05-11 21:59:34 +00:00
x509v3.h Fix up AUTHORITY_INFO_ACCESS/ACCESS_DESCRIPTION's deleter. 2018-04-02 17:07:46 +00:00