-
Notifications
You must be signed in to change notification settings - Fork 711
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
Migrate Kyber 512 to EVP KEM API #3853
Conversation
705f275
to
4cce492
Compare
I checked whether we needed to update the CI's AWS-LC version under test and confirmed that the changes adding Kyber 512 Round 3 as well as those adding new KEM API are in the current version (1.4.0). |
4cce492
to
5b4583e
Compare
do we currently have test coverage of AWS-LC-backed Kyber? the |
0a7ea42
to
5f11a79
Compare
75906ee
to
4be5511
Compare
e38ee8d
to
d3bdb16
Compare
The
I don't think I have permissions to rebuild the CI docker image and update AWS-LC, so until that's done this PR is blocked. |
adaa2f9
to
dbcfe56
Compare
If some versions of awslc fail that test, then the test is wrong. The unit test shouldn't fail if someone tries to compile s2n with an old version of awslc. You may need to specify a version for awslc in that test. |
65fbc0c
to
72a0d8f
Compare
tests/unit/s2n_pq_kem_test.c
Outdated
|
||
/* If using non-FIPS AWS-LC >= v1.4.0 (API vers. 20), expect Kyber512 KEM from AWS-LC*/ |
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.
You're very confident that this version is correct? Since this is just a sanity check and the feature probe actually turns on the feature, definitely err on the side of caution here: we never want this to fail, but it's fine / expected that it doesn't catch all environments where this is true.
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.
yeah, i'm pretty sure this statement is correct. here's the 1.4.0 release at commit cfbc38b
. you can see the KEM stuff here and the API version here.
2e576b6
to
0530044
Compare
c2ea814
to
037ed4a
Compare
if (s2n_libcrypto_is_awslc() && lc_vers >= 20 && !s2n_libcrypto_is_fips()) { | ||
EXPECT_TRUE(s2n_libcrypto_supports_kyber_512()); | ||
} else { | ||
EXPECT_FALSE(s2n_libcrypto_supports_kyber_512()); |
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.
Is this EXPECT_FALSE check needed? If kyber is enabled when it shouldn't be, the build should fail, which means this check may not be needed in a test. I'm just worried that this test will start failing if kyber is added to AWSLC-FIPS. But maybe this isn't a concern!
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.
it's not strictly needed, i suppose, but I like to use tests to tightly define expected behavior at a given point in time. AWS-LC runs a CI check building s2n and running its tests against AWS-LC PR changes, so we'll catch this on the AWS-LC side if/when Kyber is enabled in AWS-LC-FIPS. you shouldn't get any failing tests on the s2n-tls side of things.
New usage is based on [the KEM API design document][1] and [header][2]. Now that we're on a stable KEM API, we remove the S2N_AWSLC_KYBER_UNSTABLE build flag and always use the linked libcrypto's Kyber implementation if available. This flag wasn't previously specified in any of our CI scripts, meaning that AWS-LC-backed kyber was previously uncovered in s2n's CI. This commit ensures that coverage and updates the PQ KEM unit test to asserts that if (non-FIPS) AWS-LC is used as the backing libcrypto, it has the new Kyber 512 KEM API available. [1]: https://github.com/aws/aws-lc/blob/main/crypto/kem/README.md [2]: https://github.com/aws/aws-lc/blob/92c56fbc15f9bb43c4ff062c6c02f7991fd417f6/include/openssl/evp.h#L880 Check for other pre-processor symbol from AWS-LC
This reverts commit 10ec83a.
Resolved issues:
This commit resolves CryptoAlg-1495.
Description of changes:
This commit does not implement any behavioral changes. It simply migrates from usage of AWS-LC's old kyber API to its newer, more generic KEM API.
New usage is based on the KEM API design document and header.
Now that we're on a stable KEM API, we remove the
S2N_AWSLC_KYBER_UNSTABLE build flag and always use the linked
libcrypto's Kyber implementation if available. This flag wasn't
previously specified in any of our CI scripts, meaning that
AWS-LC-backed kyber was previously uncovered in s2n's CI. This commit
ensures that coverage, and adds a unit test which asserts that if AWS-LC
is used as the backing libcrypto, it has the new Kyber 512 KEM API
available.
Call-outs:
n/a
Testing:
I tested this locally (AL2) against AWS-LC at commit 161e747 (v1.5.0). See CI checks for full automated testing.
Yes, we rely on existing tests to assert behavioral consistency.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.