Skip to content

Conversation

@tarcieri
Copy link
Member

Adds a check that decoded EncryptionKeys successfully round-trip encode back to the bytes they were decoded from, in order to detect malformed keys.

Closes #172

cc @karalabe

@tarcieri
Copy link
Member Author

Here's the relevant section of FIPS 203:

Screenshot 2026-01-09 at 9 15 06 PM

I think this should accomplish that goal

Adds a check that decoded `EncryptionKey`s successfully round-trip
encode back to the bytes they were decoded from, in order to detect
malformed keys.

Closes #172
@tarcieri tarcieri force-pushed the ml-kem/encryption-key-validation branch from 4ef27cd to 15ab57a Compare January 10, 2026 18:59
@tarcieri tarcieri merged commit ad1ade9 into master Jan 10, 2026
23 checks passed
@tarcieri tarcieri deleted the ml-kem/encryption-key-validation branch January 10, 2026 19:02
@karalabe
Copy link

karalabe commented Jan 10, 2026 via email

@tarcieri
Copy link
Member Author

Yeah, per #172 I was looking into doing something like that, but then found FIPS 203 §7.2 which recommended this sort of round-trip serialization approach instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ml-kem: encapsulation keys are not validated

3 participants