Skip to content

Conversation

m271828
Copy link
Contributor

@m271828 m271828 commented Aug 1, 2025

Issues:

Resolves P280855694
Addresses CryptoAlg-2964

Description of changes:

Move dynamic dispatching from assembly to C.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

@codecov-commenter
Copy link

codecov-commenter commented Aug 5, 2025

Codecov Report

❌ Patch coverage is 97.56098% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 78.74%. Comparing base (04875db) to head (980bcff).
⚠️ Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
crypto/fipsmodule/bn/exponentiation.c 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2592      +/-   ##
==========================================
+ Coverage   78.72%   78.74%   +0.01%     
==========================================
  Files         645      646       +1     
  Lines      111086   111270     +184     
  Branches    15690    15708      +18     
==========================================
+ Hits        87453    87615     +162     
- Misses      22941    22960      +19     
- Partials      692      695       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@m271828 m271828 marked this pull request as ready for review August 9, 2025 08:25
@m271828 m271828 requested a review from a team as a code owner August 9, 2025 08:25
@m271828 m271828 requested review from skmcgrail and andrewhop August 9, 2025 08:25
@m271828 m271828 requested review from justsmth and dkostic August 9, 2025 08:25
@m271828
Copy link
Contributor Author

m271828 commented Aug 12, 2025

Need to add dispatch tests:

* purpose with or without fee is hereby granted, provided that the above

@m271828 m271828 requested a review from justsmth August 15, 2025 19:47
@m271828 m271828 requested a review from justsmth August 27, 2025 21:12
@@ -140,6 +140,11 @@ class ImplDispatchTest : public ::testing::Test {
bool is_assembler_too_old = false;
bool is_assembler_too_old_avx512 = false;
bool ifma_avx512 = false;
bool is_bn_mulx4x_mont_gather5 = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that we need these five values defined here, we only define capabilities here?


bn_mul_mont(r.data(), a.data(), b.data(), mont->N.d, mont->n0, words);

is_bn_mulx4x_mont_gather5 = bn_mulx4x_mont_gather5_capable(words);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you use the same function bn_mulx4x_mont_gather5_capable for the test and the actual implementation then this test doesn't make much sense, it will always pass. The idea of dispatch tests is to determine if a specific combination of CPU capabilities (like ADX, BMI, BMI2, etc.) triggers the expected code path.

BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *table, const BN_ULONG *np,
const BN_ULONG *n0, int num, int power) {
if (bn_mulx4x_mont_gather5_capable(num)) {
keccak_log_dispatch(15);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we please re-define keccak_log_dispatch to a generic log_dispatch function?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants