boringssl/crypto/cipher_extra
Adam Langley a6a049a6fb Add start of infrastructure for checking constant-time properties.
Valgrind's checking of uninitialised memory behaves very much like a
check for constant-time code: branches and memory indexes based on
uninitialised memory trigger warnings. Therefore, if we can tell
Valgrind that some secret is “uninitialised”, it'll give us a warning if
we do something non-constant-time with it.

This was the idea behind https://github.com/agl/ctgrind. But tricks like
that are no longer needed because Valgrind now comes with support for
marking regions of memory as defined or not. Therefore we can use that
API to check constant-time code.

This CL defines |CONSTTIME_SECRET| and |CONSTTIME_DECLASSIFY|, which are
no-ops unless the code is built with
|BORINGSSL_CONSTANT_TIME_VALIDATION| defined, which it isn't by default.
So this CL is a no-op itself so far. But it does show that a couple of
bits of constant-time time are, in fact, constant-time—seemingly even
when compiled with optimisations, which is nice.

The annotations in the RSA code are a) probably not marking all the
secrets as secret, and b) triggers warnings that are a little
interesting:

The anti-glitch check calls |BN_mod_exp_mont| which checks that the
input is less than the modulus. Of course, it is because the input is
the RSA plaintext that we just decrypted, but the plaintext is supposed
to be secret and so branching based on its contents isn't allows by
Valgrind. The answer isn't totally clear, but I've run out of time on
this for now.

Change-Id: I1608ed0b22d201e97595fafe46127159e02d5b1b
Reviewed-on: https://boringssl-review.googlesource.com/c/33504
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2018-12-18 22:43:02 +00:00
..
asm Enable extra_in with the ChaCha20-Poly1305 AEAD. 2017-07-14 22:13:25 +00:00
test Test CBC padding more aggressively. 2018-10-30 20:53:00 +00:00
aead_test.cc Add XChaCha20-Poly1305 AEAD. 2018-08-09 18:49:09 +00:00
cipher_extra.c Actually add AES-192-OFB. 2018-06-21 22:03:34 +00:00
cipher_test.cc Add EVP_CTRL_AEAD_* constants. 2018-08-09 17:08:15 +00:00
derive_key.c
e_aesccm.c Modernize OPENSSL_COMPILE_ASSERT, part 2. 2018-11-14 16:06:37 +00:00
e_aesctrhmac.c Modernize OPENSSL_COMPILE_ASSERT, part 2. 2018-11-14 16:06:37 +00:00
e_aesgcmsiv.c Disable AES-GCM-SIV assembly on Windows. 2018-12-17 17:54:07 +00:00
e_chacha20poly1305.c Modernize OPENSSL_COMPILE_ASSERT, part 2. 2018-11-14 16:06:37 +00:00
e_null.c
e_rc2.c Move OPENSSL_FALLTHROUGH to internal headers. 2018-01-29 18:17:57 +00:00
e_rc4.c
e_tls.c Add start of infrastructure for checking constant-time properties. 2018-12-18 22:43:02 +00:00
internal.h Run the comment converter on libcrypto. 2017-08-18 21:49:04 +00:00
tls_cbc.c Fix EVP_tls_cbc_digest_record is slow using SHA-384 and short messages 2018-10-29 18:26:27 +00:00