-
Notifications
You must be signed in to change notification settings - Fork 121
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
Use features to set key exchange preferences #145
Conversation
I've updated the commit based on feedback on this PR and clarification of the semantics of "fips" and "fips-link-compiled". Please take another look! |
2300577
to
de3c36c
Compare
d70dbb9
to
b960339
Compare
3aa916a
to
f083a08
Compare
b3537a8
to
3c94f05
Compare
Cargo features are supposed to be strictly additive so I'm not sure that's the correct vehicle to use. That being said, I offer no alternative. |
Are you referring to the fact that "kx-safe-default" disables Hmm, I definitely we agree we should try to follow best practice if we can. (I was not aware of this convention.) I guess one option is to put the Stepping back, the intent of this PR is to make it easy as possible for our Cloudflare-internal users to enable PQ key exchange without having to manually call |
Yes, they're mutually exclusive. What would we want to check at compile time? That if "kx-safe-defaults" is set, then |
in let enabled_count = [
cfg!(feature = "kx-client-pq-supported"),
cfg!(feature = "kx-client-pq-preferred")
cfg!(feature = "kx-client-nist-required")
]
.iter()
.filter(|f| f)
.count();
if enabled_count > 1 {
panic!("...");
} we can do similar checks for feature dependencies. |
But where would we do this? If I understand correctly what you're after, the goal is something like: if Also, note that it suffices to check if "kx-safe-defaults" is set because this is implied by any of the "kx-*" features.
Got, will do after rebasing this PR. |
3c94f05
to
dc49ad0
Compare
Rebased. |
dc49ad0
to
42099ee
Compare
Squashed. |
42099ee
to
829e7a9
Compare
Rebased. |
829e7a9
to
3da1a5a
Compare
Changed "nist-required" to "fips-required". Eventually X25519 might be FIPS-validated. |
I think there was a misunderstanding here, I thought that @nox complained that features are mutually exclusive, i.e.
not sure how do I feel about that, this seems to be relatively distant future thing and might be confusing considering currently FIPS-validated revision |
3da1a5a
to
c59f805
Compare
Ah, OK! In fact, "kx-client-pq-preferred" and "kx-client-nist-required" can be used at the same time. The effect is that P256Kyber768Draft00 is the client's preferred key exchange algorithm.
No problem, reverted. |
c59f805
to
41ff939
Compare
Overwrite boringSSL's default key exchange preferences with safe defaults using feature flags: * "kx-pq-supported" enables support for PQ key exchange algorithms. Classical key exchange is still preferred, but will be upgraded to PQ if requested. * "kx-pq-preferred" enables preference for PQ key exchange, with fallback to classical key exchange if requested. * "kx-nist-required" disables non-NIST key exchange. Each feature implies "kx-safe-default". When this feature is enabled, don't compile bindings for `SSL_CTX_set1_curves()` and `SslCurve`. This is to prevent the feature flags from silently overriding curve preferences chosen by the user. Ideally we'd allow both: that is, use "kx-*" to set defaults, but still allow the user to manually override them. However, this doesn't work because by the time the `SSL_CTX` is constructed, we don't yet know whether we're the client or server. (The "kx-*" features set different preferences for each.) If "kx-sfe-default" is set, then the curve preferences are set just before initiating a TLS handshake (`SslStreamBuilder::connect()`) or waiting for a TLS handshake (`SslStreamBuilder::accept()`).
41ff939
to
1437299
Compare
Fixed up commit message. |
Overwrite boringSSL's default key exchange preferences with safe
defaults using feature flags:
"kx-client-pq-supported" enables support for PQ key exchange algorithms.
Classical key exchange is still preferred, but will be upgraded to PQ
if requested.
"kx-client-pq-preferred" enables preference for PQ key exchange,
with fallback to classical key exchange if requested.
"kx-client-nist-required" disables non-FIPS-compliant algorithms on the client side.
If any of these "kx-*" features are enabled, then don't compile bindings
for
SSL_CTX_set1_curves()
. This is to prevent the feature flags fromsilently overriding curve preferences chosen by the user.
Ideally we'd allow both: that is, use "kx-*" to set defaults, but still
allow the user to manually override them. However, this doesn't work
because by the time the
SSL_CTX
is constructed, we don't yet knowwhether we're the client or server. (The "kx-*" features set different
preferences for each.)