ml-kem: implement PKCS#8 serialization for pkcs8 0.10 #123
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