-
Notifications
You must be signed in to change notification settings - Fork 911
ML-KEM: Add check for Pubkey hash mismatch on decoding the dk #9470
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
base: master
Are you sure you want to change the base?
Conversation
|
🛟 Devin Lifeguard found 2 likely issues in this PR
@lealem47 |
|
Jenkins retest this please |
wolfcrypt/src/wc_mlkem.c
Outdated
| /* Decode the public key that is after the private key. */ | ||
| mlkemkey_decode_public(key->pub, key->pubSeed, p, k); | ||
| /* Compute the hash of the public key. */ | ||
| MLKEM_HASH_H(&key->hash, p, pubLen, computedHash); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MLKEM_HASH_H may fail.
wolfcrypt/src/wc_mlkem.c
Outdated
| } | ||
|
|
||
| if (ret == 0) { | ||
| byte computedHash[WC_ML_KEM_SYM_SZ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hash into key->h and compare with the data in the encoded private key.
Don't need computedHash then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point, fixed
Description
Fix to adhere to FIPS 203 – Algorithm 18 (Decaps_internal)
Testing
CAVP vectors with a private key whose embedded public key does not match the hash stored in the key.
Checklist