-
Notifications
You must be signed in to change notification settings - Fork 141
Add EVP_PKEY_check and EVP_PKEY_public_check for KEMs #2709
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: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2709 +/- ##
==========================================
- Coverage 78.82% 78.81% -0.02%
==========================================
Files 667 667
Lines 114077 114143 +66
Branches 16045 16052 +7
==========================================
+ Hits 89925 89960 +35
- Misses 23378 23409 +31
Partials 774 774 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
// Check that at least the public key exists | ||
if (key->public_key == NULL) { | ||
OPENSSL_PUT_ERROR(EVP, EVP_R_NO_KEY_SET); | ||
return 0; | ||
} |
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.
NP: It's currently possible (although I wish it weren't) for the secret_key to be set but not the public_key. For those, this would always return an error.
if (ml_kem_512_check_pk(key->public_key) != 0) { | ||
OPENSSL_PUT_ERROR(EVP, EVP_R_DECODE_ERROR); | ||
return 0; | ||
} | ||
// Check secret key validity if present | ||
if (key->secret_key != NULL && ml_kem_512_check_sk(key->secret_key) != 0) { | ||
OPENSSL_PUT_ERROR(EVP, EVP_R_DECODE_ERROR); | ||
return 0; | ||
} | ||
break; |
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.
We would also need a pair-consistency check, otherwise the secret and public keys might be unrelated. (?)
Issues:
N/A - ML-KEM support.
Description of changes:
mlkem-native provides
pk
andsk
check functions crypto_kem_check_pk and crypto_kem_check_sk that are namespaced toml_kem_{512/768/1024}_check_{pk/sk}
. This PR hooks them up toEVP_PKEY_check
andEVP_PKEY_public_check
so we can call them onPKEY
of typeKEM
.Call-outs:
Due to the way the MLKEM multi-level build is compiled, we can't call
mlkem{512/768/1024}_check_sk
directly, so have to have those little wrapper functions incrypto/fipsmodule/ml_kem/ml_kem.c
, as with other functions in that file.Testing:
KEM tests are modified to:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.