boringssl/crypto/cipher_extra
armfazh 144d924e0b Fix EVP_tls_cbc_digest_record is slow using SHA-384 and short messages
Symptom: When using larger hash functions and short messages,
these six blocks take too much time to be conditionally copied.

Observations:
 - SHA-384 consumes more data per iteration, unlike SHA-256.
 - The value of `kVarianceBlocks` must depend on the parameters
   of the selected hash algorithm.
 - Avoid magic constants.

Changes:
 - A new formula for the kVarianceBlocks value.
 - Stronger test vectors were created in change: 32724.
 - The new formula passes these tests.

Discussion:
 OpenSSL team: https://github.com/openssl/openssl/pull/7342
 Quoting mattcaswell:
> The "real" data that needs to be hashed has to be padded for the
> hashing algorithm. For SHA1 the smallest amount of padding that
> can be added is the "0x80" byte plus 8 bytes containing the message
> length, i.e. 9 bytes. If the data length is within 9 bytes of the
> end of the hash block boundary then the padding will push it into
> an extra block to be hashed.

Change-Id: Id1ad2389927014316eed2b453aac6e4c2a585c5c
Reviewed-on: https://boringssl-review.googlesource.com/c/32624
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-29 18:26:27 +00:00
..
asm Enable extra_in with the ChaCha20-Poly1305 AEAD. 2017-07-14 22:13:25 +00:00
test Add XChaCha20-Poly1305 AEAD. 2018-08-09 18:49:09 +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 Move cipher/ into crypto/fipsmodule/ 2017-05-05 22:39:40 +00:00
e_aesccm.c Flatten EVP_AEAD_CTX 2018-10-22 23:12:57 +00:00
e_aesctrhmac.c Flatten EVP_AEAD_CTX 2018-10-22 23:12:57 +00:00
e_aesgcmsiv.c Fix redefinition of AEAD asserts in e_aes.c. 2018-10-24 00:29:29 +00:00
e_chacha20poly1305.c Flatten EVP_AEAD_CTX 2018-10-22 23:12:57 +00:00
e_null.c Move cipher/ into crypto/fipsmodule/ 2017-05-05 22:39:40 +00:00
e_rc2.c Move OPENSSL_FALLTHROUGH to internal headers. 2018-01-29 18:17:57 +00:00
e_rc4.c Move cipher/ into crypto/fipsmodule/ 2017-05-05 22:39:40 +00:00
e_tls.c Flatten EVP_AEAD_CTX 2018-10-22 23:12:57 +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