generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 151
Add ASN.1 decoding for ML-KEM private keys as seeds #2707
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jakemas
commented
Sep 23, 2025
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2707 +/- ##
==========================================
+ Coverage 78.96% 79.14% +0.18%
==========================================
Files 669 669
Lines 114582 114634 +52
Branches 16119 16128 +9
==========================================
+ Hits 90475 90731 +256
+ Misses 23326 23121 -205
- Partials 781 782 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
justsmth
reviewed
Sep 24, 2025
justsmth
reviewed
Sep 24, 2025
justsmth
previously approved these changes
Oct 1, 2025
justsmth
previously approved these changes
Oct 1, 2025
dkostic
reviewed
Oct 2, 2025
justsmth
previously approved these changes
Oct 3, 2025
justsmth
previously approved these changes
Oct 6, 2025
justsmth
previously approved these changes
Oct 6, 2025
This reverts commit 8924c73.
justsmth
approved these changes
Oct 6, 2025
dkostic
approved these changes
Oct 6, 2025
Merged
justsmth
added a commit
that referenced
this pull request
Oct 13, 2025
### Description of changes: Prepare v1.62.0 release #### What's Changed * nginx now supports AWS-LC by @samuel40791765 in #2714 * Fix tests that assume X25519 will be negotiated by @alexw91 in #2682 * Fixing a bug in ML-DSA poly_uniform function by @dkostic in #2721 * Migrate integration omnibus by @skmcgrail in #2715 * Delete util/bot directory by @justsmth in #2723 * Don't ignore CMAKE_C_FLAGS w/ MSVC by @justsmth in #2722 * Bump urllib3 from 2.2.3 to 2.5.0 in /tests/ci by @dependabot[bot] in #2551 * Type fix in mldsa by @manastasova in #2308 * Centralize password handling tool-openssl by @kingstjo in #2555 * crypto/pem: replace strncmp with CRYPTO_memcmp to fix -Wstring-compare error by @R3hankhan123 in #2724 * Implement dgst CLI command by @nhatnghiho in #2638 * Add ASN.1 decoding for ML-KEM private keys as seeds by @jakemas in #2707 * Implement genrsa command by @kingstjo in #2535 * Move udiv and sencond tweak calculations to when needed by @nebeid in #2726 * Add null check on RSA key checks by @samuel40791765 in #2727 * Implement workaround for FORTIFY_SOURCE warning with jitterentropy by @skmcgrail in #2728 * Implement coverity suggestions by @skmcgrail in #2730 * Add minimal EC CLI tool implementation by @kingstjo in #2640 * Adding pkeyutl tool to the CLI by @smittals2 in #2575 * Add CI dimensions for legacy AVX512 flags by @smittals2 in #2732 * Fix Libwebsockets CI by @smittals2 in #2737 * Add option ENABLE_SOURCE_MODIFICATION by @justsmth in #2739 * Simple script to build/run tests by @justsmth in #2736 * Add build-time option to opt-out of CPU Jitter Entropy by @torben-hansen in #2733 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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issues:
Resolves #N/A
Addresses #aws/aws-lc-rs#799
Description of changes:
This PR adds support for the parsing of ML-KEM private keys encoded in the ASN.1 seed format, as described in https://datatracker.ietf.org/doc/draft-ietf-lamps-kyber-certificates/.
As such, 64 byte ASN.1 encoded private keys, such as this example ml-kem-512 private key from the IETF draft can now be parsed in aws-lc using
EVP_parse_private_key:The
EVP_PKEYproduced will have both the full private and public ML-KEM key expanded material within.This very much follows a similar PR for ML-DSA #2157.
While there are a few ways to tackle the issue of getting the public key when the private is provided, for example making use of the
OneAsymmetricKeystructure as in https://datatracker.ietf.org/doc/html/draft-ietf-lamps-kyber-certificates-11#section-6. However as PKCS8 v2 isn't well supported, I feel encodingOneAsymmetricKeywon't be easy for those wanting to bring key material into aws-lc/-rs. Python Cryptography doesn't support it today, for example. OpenSSL encodes keys by default using theBOTHapproach (seed and expanded material), so importing from OpenSSL produced private seeds will now be possible, and populate both pub and priv keys.Background
The IETF draft standard defines three private key formats for ML-KEM certificates:
Previously, AWS-LC only supported the expandedKey format. This PR adds support for the more compact seed format, which uses deterministic key generation from a 64-byte seed.
How does this help aws/aws-lc-rs#799?
When the private key is provided as a seed, both the expanded private and secret key are populated within the EVP_PKEY structure, allowing, for the first time, a fully populated key on import.
Call-outs:
Core Implementation:
crypto/evp_extra/p_kem_asn1.c: Enhancedkem_priv_decode()to detect and parse seed format using ASN.1 context-specific tag[0](stubbed out BOTH format)crypto/fipsmodule/kem/kem.c: AddedKEM_KEY_set_raw_keypair_from_seed()function to generate keypairs from seeds using deterministic ML-KEM functionscrypto/fipsmodule/kem/internal.h: Added function declaration for seed-based key generationFIPS Questions:
Are we allowed to expose this functionality as part of the FIPS module? Yes, see https://csrc.nist.gov/projects/post-quantum-cryptography/faqs Question 1:
Testing:
crypto/evp_extra/p_kem_test.cc: Added comprehensiveParsePrivateKeySeedtest using IETF standard test vectorsBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.