-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CAST and PCT for ML-DSA #2148
CAST and PCT for ML-DSA #2148
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2148 +/- ##
==========================================
- Coverage 78.97% 78.96% -0.02%
==========================================
Files 611 611
Lines 105748 105812 +64
Branches 14973 14975 +2
==========================================
+ Hits 83511 83550 +39
- Misses 21583 21608 +25
Partials 654 654 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Andrew! Yup clocked my mistake there! Thank you! I'll add PCT elements tonight. |
What's the performance impact of this change for key generation? |
Sign is about 4x slower than keygen across |
This reverts commit a03ddc3.
Issues:
Resolves #CryptoAlg-2886
Related to #1846 and #1969
Description of changes:
As part of the Implementation Guidance for FIPS 140-3 and the Cryptographic Module Validation Program validation there is requirement that states:
Pairwise Consistency Tests (PCT)
Per the I.G guidance a PCT shall be conducted for every generated public and private key pair for the applicable approved algorithm.
As such, we implement
VE10.35.02
of ISO/IEC 24759:2017. A simple test that generates an ML-DSA keypair, signs a message, and verifies the signature.In which we:
params->bytes
has the exact size but we can't dynamically allocate and we want to spent as little time in this function as possible -- allocate max KEM size hereNULL
(quick and works)This is called within the internal key generation function if defined
AWSLC_FIPS
Cryptographic Algorithm Self Test CAST)
Per the I.G guidance a CAST using a KAT is required for ML-DSA key generation
This is implemented by the new addition to the
self_check.c
test suite with testboringssl_self_test_ml_dsa
which performs the following:ml_dsa_44_keypair_internal_no_self_test
with provided seedkMLDSAKeyGenSeed
which is from the NIST ACVP KAT Keygen SeedtgId = 1
tcId = 1
check_test
on the outputpublic_key
from that function, with public key matching that of the expected output at public keytgId = 1
tcId = 1
check_test
on the outputprivate_key
from that function, with private key matching that of the expected output at private keytgId = 1
tcId = 1
Per the I.G guidance a CAST using a KAT is required for ML-DSA signature generation
ml_dsa_44_sign_internal_no_self_test
. The I.G statesWe implement "hedged" in aws-lc, rather than deterministic signatures (hedged short for "hedging your bets" and using both an RNG and hashing input from the message).
kMLDSASigGenSeed
is all zeros.kMLDSASignSignature
for that message and private key. We are not able to use the same NIST ACVP vector for this, as NIST do not provide vectors for the same public private key pairs between keygen and sigGen. We could load an additional public/private key pair from a known NIST CAVP vector, then we would have a known signature, but would have to store 2 public/private key pairs in the file (which feels obtuse). FIPS 140-3 doesn't state that the KAT has to be from CAVP in the implementation guidance, but if this isn't critical to performance, I can happily add a seed/pub/sig vector from the NIST ACVP KATs.Per the I.G guidance a CAST using a KAT is required for ML-DSA signature verification
kMLDSASignSignature
successfully verifies the provided plaintextkMLDSASignPlaintext
andpublic_key
.Test Configuration
For the above tests, only one ML-DSA parameter set variant needs to be tested:
Also note that only one variant of pre-hash (ExternalMu-ML-DSA) and pure mode needs to be tested:
Call-outs:
For reviewers:
kMLDSA*
, and also by putting in the seed from the IETF standard and verifying the key pairTesting:
The ML-DSA self-tests have been added to
--gtest_filter=SelfTests.
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.