ml-kem: implement PKCS#8 serialization for pkcs8 0.10#123
Closed
meisterluk wants to merge 1 commit intoRustCrypto:masterfrom
Closed
ml-kem: implement PKCS#8 serialization for pkcs8 0.10#123meisterluk wants to merge 1 commit intoRustCrypto:masterfrom
meisterluk wants to merge 1 commit intoRustCrypto:masterfrom
Conversation
• add dependency to pkcs8 crate and define features pkcs8 & alloc
• implement AssociatedOid and AssociatedAlgorithmIdentifier
for ML-KEM parameter sets {MlKem512Params,MlKem768Params,MlKem1024Params}
• implement AssociatedAlgorithmIdentifier
for EncapsulationKey & DecapsulationKey
• serialization:
implement EncodePublicKey for EncapsulationKey
implement EncodePrivateKey for DecapsulationKey
• deserialization:
implement TryFrom<pkcs8::SubjectPublicKeyInfoRef> for EncapsulationKey
implement TryFrom<pkcs8::PrivateKeyInfo> for DecapsulationKey
• add testcase with DER serialization roundtrip
REMARK:
A dependency const-oid would be resolved to const-oid v0.9.6,
because der v0.7.10 includes const-oid v0.9.6. Recognize that
const-oid v0.9.6 does not yet support FIPS 203 which features
the ML-KEM OIDs. Recognize that an additional const-oid v0.10
dependency would be incompatible with the ObjectIdentifier of
const-oid v0.9.6.
In short, if the entire stack moves to const-oid v0.10,
we can use it in this crate too.
But as of now, we cannot use fips203 through const-oid
and thus the OIDs are contained explicitly.
REMARK:
The encapsulation key is serialized into a Subject Public Key Info
as defined in RFC 5280 § 4.1.2.7 or more specifically for ML-KEM,
draft-ietf-lamps-kyber-certificates-latest from 2025-05-27 § 4:
https://lamps-wg.github.io/kyber-certificates/draft-ietf-lamps-kyber-certificates.html#name-subject-public-key-fields
The decapsulation key is serialized into a Private Key Info
as defined in RFC 5958 § 2 or more specifically for ML-KEM,
draft-ietf-lamps-kyber-certificates-latest from 2025-05-27 § 6:
https://lamps-wg.github.io/kyber-certificates/draft-ietf-lamps-kyber-certificates.html#name-private-key-format
53829e8 to
788ac73
Compare
tarcieri
reviewed
Jul 2, 2025
Closed
Member
|
Closing in favor of #124 |
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
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.
Content:
implement EncodePublicKey for EncapsulationKey
implement EncodePrivateKey for DecapsulationKey
implement
TryFrom<pkcs8::SubjectPublicKeyInfoRef>for EncapsulationKeyimplement
TryFrom<pkcs8::PrivateKeyInfo>for DecapsulationKeyRemark:
A dependency const-oid would be resolved to const-oid v0.9.6, because der v0.7.10 includes const-oid v0.9.6. Recognize that const-oid v0.9.6 does not yet support FIPS 203 which features the ML-KEM OIDs. Recognize that an additional const-oid v0.10 dependency would be incompatible with the ObjectIdentifier of const-oid v0.9.6.
In short, if the entire stack moves to const-oid v0.10, we can use it in this crate too.
But as of now, we cannot use fips203 through const-oid and thus the OIDs are contained explicitly.
Remark:
The encapsulation key is serialized into a Subject Public Key Info as defined in RFC 5280 § 4.1.2.7 or more specifically for ML-KEM, draft-ietf-lamps-kyber-certificates-latest from 2025-05-27 § 4: https://lamps-wg.github.io/kyber-certificates/draft-ietf-lamps-kyber-certificates.html#name-subject-public-key-fields
The decapsulation key is serialized into a Private Key Info as defined in RFC 5958 § 2 or more specifically for ML-KEM, draft-ietf-lamps-kyber-certificates-latest from 2025-05-27 § 6: https://lamps-wg.github.io/kyber-certificates/draft-ietf-lamps-kyber-certificates.html#name-private-key-format
Implementation was paid for by our company fragmentiX, because we have the usecase internally as well. Many thanks! And also to my colleague for the helpful remarks.
Solves issue #54