Skip to content

ML-KEM keys seed storage #3140

@DarkaMaul

Description

@DarkaMaul

Problem:

AWS-LC can decode ML-KEM private keys from the compact 64-byte seed format but cannot encode to that format. After key generation the seed is discarded and kem_priv_encode always emits the expanded secret key.

In the encoding part, a comment acknowledges this:

!CBB_add_asn1(&private_key, &expanded_key, CBS_ASN1_OCTETSTRING) || // expandedKey CHOICE variant, AWS-LC uses expandedKey for the moment

Compare the two structs (MLDSA and MLKEM):

// PQDSA_KEY structure and helper functions.
struct pqdsa_key_st {
const PQDSA *pqdsa;
uint8_t *public_key;
uint8_t *private_key;
uint8_t *seed;
};

struct kem_key_st {
const KEM *kem;
uint8_t *public_key;
uint8_t *secret_key;
};

Solution:

  1. Add uint8_t *seed to kem_key_st, mirroring pqdsa_key_st:

    struct kem_key_st {
        const KEM *kem;
        uint8_t *public_key;
        uint8_t *secret_key;
        uint8_t *seed;
    };
  2. Populate the seed during keygen, the same way ML-DSA does in pkey_pqdsa_keygen.

  3. Update kem_priv_encode to serialize the seed, mirroring pqdsa_priv_encode which emits seed [0] OCTET STRING when the seed is available.

  • Does this change any public APIs? No
  • Which algorithm(s) will this impact? ML-KEM-512, ML-KEM-768, ML-KEM-1024.

Requirements / Acceptance Criteria:

What must a solution address in order to solve the problem? How do we know the solution is complete?

  • RFC links: FIPS 203
  • Related Issues: None
  • Will the Usage Guide or other documentation need to be updated? I'm unsure
  • Testing: Unit tests in the KEM test suite covering the cases listed above for all three ML-KEM variants.
    • Will this change trigger AWS LibCrypto Formal Verification changes? No
    • Should this change be fuzz tested? No

Out of scope:

Is there anything the solution will intentionally NOT address?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions