ML-KEM: Add a branchless pre-path to `scalar_from_keccak_block_vartime`.

This mirrors https://go.dev/cl/818725.

On aarch64 Apple M1 Pro:

Did 33376 BM_SpeedMLKEM768KeyGenDecap/threads:1 operations (47765.6 ops/sec) [+19.4%]
Did 53730 BM_SpeedMLKEM768ParseEncap/threads:1 operations (76357.6 ops/sec) [+9.5%]
Did 24107 BM_SpeedMLKEM1024KeyGenDecap/threads:1 operations (34840.2 ops/sec) [+23.7%]
Did 39086 BM_SpeedMLKEM1024ParseEncap/threads:1 operations (55732.7 ops/sec) [+16.0%]

On x86-64 AMD EPYC 7B13:

Did 13426 BM_SpeedMLKEM768KeyGenDecap/threads:1 operations (19159.0 ops/sec) [+7.9%]
Did 22704 BM_SpeedMLKEM768ParseEncap/threads:1 operations (32587.3 ops/sec) [+3.4%]
Did 9885 BM_SpeedMLKEM1024KeyGenDecap/threads:1 operations (14088.9 ops/sec) [+11.0%]
Did 16832 BM_SpeedMLKEM1024ParseEncap/threads:1 operations (24070.4 ops/sec) [+6.2%]

Also tried 1x (about 2% worse), 4x (about 1% better), 8x (much worse),
where the factor refers to iterations of the branchful loop (each
writing zero to two output words from 3 input bytes). Staying away from
4x for now as running out of registers has awful performance
consequences, but leaving the option open if a confirmed speedup on all
relevant platforms.

Bug: 503700354
Change-Id: I29afe4aa283b686b9fc3877e059931f46a6a6964
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/101987
Reviewed-by: David Benjamin <davidben@google.com>
Auto-Submit: Rudolf Polzer <rpolzer@google.com>
Commit-Queue: Rudolf Polzer <rpolzer@google.com>
1 file changed
tree: d0ceff21f11dbd568d87514d4389ae1236cc60e4
  1. .agents/
  2. .bcr/
  3. .github/
  4. agents/
  5. bench/
  6. cmake/
  7. crypto/
  8. decrepit/
  9. docs/
  10. fuzz/
  11. gen/
  12. include/
  13. infra/
  14. pki/
  15. rust/
  16. ssl/
  17. third_party/
  18. tool/
  19. util/
  20. .bazelignore
  21. .bazelrc
  22. .bazelversion
  23. .clang-format
  24. .clang-format-ignore
  25. .clangd
  26. .gitattributes
  27. .gitignore
  28. API-CONVENTIONS.md
  29. AUTHORS
  30. BREAKING-CHANGES.md
  31. BUILD.bazel
  32. build.json
  33. BUILDING.md
  34. CMakeLists.txt
  35. codereview.settings
  36. CONTRIBUTING.md
  37. FUZZING.md
  38. go.mod
  39. go.sum
  40. INCORPORATING.md
  41. LICENSE
  42. MODULE.bazel
  43. MODULE.bazel.lock
  44. PORTING.md
  45. PRESUBMIT.py
  46. PrivacyInfo.xcprivacy
  47. README.md
  48. SANDBOXING.md
  49. SECURITY.md
  50. STYLE.md
README.md

BoringSSL

BoringSSL is a fork of OpenSSL that is designed to meet Google's needs.

Although BoringSSL is an open source project, it is not intended for general use, as OpenSSL is. We don't recommend that third parties depend upon it. Doing so is likely to be frustrating because there are no guarantees of API or ABI stability.

Programs ship their own copies of BoringSSL when they use it and we update everything as needed when deciding to make API changes. This allows us to mostly avoid compromises in the name of compatibility. It works for us, but it may not work for you.

BoringSSL arose because Google used OpenSSL for many years in various ways and, over time, built up a large number of patches that were maintained while tracking upstream OpenSSL. As Google's product portfolio became more complex, more copies of OpenSSL sprung up and the effort involved in maintaining all these patches in multiple places was growing steadily.

Currently BoringSSL is the SSL library in Chrome/Chromium, Android (but it's not part of the NDK) and a number of other apps/programs.

Project links:

To file a security issue, use the Chromium process and mention in the report this is for BoringSSL. You can ignore the parts of the process that are specific to Chromium/Chrome.

There are other files in this directory which might be helpful: