bitcoin/src/crypto
fanquake 1e0198b6c1
Merge bitcoin/bitcoin#26153: Reduce wasted pseudorandom bytes in ChaCha20 + various improvements
511aa4f1c7 Add unit test for ChaCha20's new caching (Pieter Wuille)
fb243d25f7 Improve test vectors for ChaCha20 (Pieter Wuille)
93aee8bbda Inline ChaCha20 32-byte specific constants (Pieter Wuille)
62ec713961 Only support 32-byte keys in ChaCha20{,Aligned} (Pieter Wuille)
f21994a02e Use ChaCha20Aligned in MuHash3072 code (Pieter Wuille)
5d16f75763 Use ChaCha20 caching in FastRandomContext (Pieter Wuille)
38eaece67b Add fuzz test for testing that ChaCha20 works as a stream (Pieter Wuille)
5f05b27841 Add xoroshiro128++ PRNG (Martin Leitner-Ankerl)
12ff72476a Make unrestricted ChaCha20 cipher not waste keystream bytes (Pieter Wuille)
6babf40213 Rename ChaCha20::Seek -> Seek64 to clarify multiple of 64 (Pieter Wuille)
e37bcaa0a6 Split ChaCha20 into aligned/unaligned variants (Pieter Wuille)

Pull request description:

  This is an alternative to #25354 (by my benchmarking, somewhat faster), subsumes #25712, and adds additional test vectors.

  It separates the multiple-of-64-bytes-only "core" logic (which becomes simpler) from a layer around which performs caching/slicing to support arbitrary byte amounts. Both have their uses (in particular, the MuHash3072 code can benefit from multiple-of-64-bytes assumptions), plus the separation results in more readable code. Also, since FastRandomContext effectively had its own (more naive) caching on top of ChaCha20, that can be dropped in favor of ChaCha20's new built-in caching.

  I thought about rebasing #25712 on top of this, but the changes before are fairly extensive, so redid it instead.

ACKs for top commit:
  ajtowns:
    ut reACK 511aa4f1c7
  dhruv:
    tACK crACK 511aa4f1c7

Tree-SHA512: 3aa80971322a93e780c75a8d35bd39da3a9ea570fbae4491eaf0c45242f5f670a24a592c50ad870d5fd09b9f88ec06e274e8aa3cefd9561d623c63f7198cf2c7
2023-02-15 14:58:47 +00:00
..
ctaes Update ctaes 2016-12-08 17:09:07 -08:00
aes.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
aes.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
chacha20.cpp Inline ChaCha20 32-byte specific constants 2023-01-30 18:12:21 -05:00
chacha20.h Inline ChaCha20 32-byte specific constants 2023-01-30 18:12:21 -05:00
chacha_poly_aead.cpp Only support 32-byte keys in ChaCha20{,Aligned} 2023-01-30 18:12:21 -05:00
chacha_poly_aead.h scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
common.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
hkdf_sha256_32.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
hkdf_sha256_32.h scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
hmac_sha256.cpp Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
hmac_sha256.h scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
hmac_sha512.cpp Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
hmac_sha512.h scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
muhash.cpp Only support 32-byte keys in ChaCha20{,Aligned} 2023-01-30 18:12:21 -05:00
muhash.h scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
poly1305.cpp Add Poly1305 implementation 2019-03-26 18:12:29 +01:00
poly1305.h scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
ripemd160.cpp clang-tidy: Fix modernize-use-default-member-init in headers 2023-01-31 11:50:10 +00:00
ripemd160.h clang-tidy: Fix modernize-use-default-member-init in headers 2023-01-31 11:50:10 +00:00
sha1.cpp clang-tidy: Fix modernize-use-default-member-init in headers 2023-01-31 11:50:10 +00:00
sha1.h clang-tidy: Fix modernize-use-default-member-init in headers 2023-01-31 11:50:10 +00:00
sha3.cpp Unroll Keccak-f implementation 2020-09-06 18:35:23 -07:00
sha3.h scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
sha256.cpp clang-tidy: Fix modernize-use-default-member-init in headers 2023-01-31 11:50:10 +00:00
sha256.h clang-tidy: Fix modernize-use-default-member-init in headers 2023-01-31 11:50:10 +00:00
sha256_arm_shani.cpp doc: Fix typos 2022-02-17 03:42:08 +09:00
sha256_avx2.cpp scripted-diff: Add missed copyright headers 2020-01-04 20:18:28 +02:00
sha256_sse4.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
sha256_sse41.cpp scripted-diff: Add missed copyright headers 2020-01-04 20:18:28 +02:00
sha256_x86_shani.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
sha512.cpp clang-tidy: Fix modernize-use-default-member-init in headers 2023-01-31 11:50:10 +00:00
sha512.h clang-tidy: Fix modernize-use-default-member-init in headers 2023-01-31 11:50:10 +00:00
siphash.cpp refactor: use braced init for integer constants instead of c style casts 2023-01-03 19:31:29 -06:00
siphash.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00