Skip to content

Conversation

@cjpatton
Copy link
Collaborator

Internal users often have two builds for boring, one using a precompiled build of boringSSL and another built from source with patches applied. However the features that enable these builds are mutually exclusive. For example, the "pq-experimental" feature is required to build the source with all of the necessary codepoints for PQ key exchange, but if this feature is enabled and a precompiled boringSSL is provided, then the build will fail. This means users will have to also control their builds with mutually exclusive features.

An alternative is to ignore features that enable patches whenever a precompiled boringSSL is provided. This is a little different from the "assume patched" environment variable, which applies whenever we're building from source.

Comment on lines +721 to 723
#[cfg(all(not(feature = "fips"), feature = "pq-experimental"))]
pub const X25519_KYBER768_DRAFT00_OLD: SslCurve =
SslCurve(ffi::SSL_CURVE_X25519_KYBER768_DRAFT00_OLD as _);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively we could just remove these non-standard APIs from the bindings.

@cjpatton cjpatton force-pushed the cjpatton/prebuilt-ignore-patches branch from 0b94828 to f587ae2 Compare March 14, 2025 15:56
SslCurve(ffi::SSL_CURVE_X25519_KYBER768_DRAFT00 as _);

#[cfg(feature = "pq-experimental")]
#[cfg(all(not(feature = "fips"), feature = "pq-experimental"))]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not(feature = "fips") prevents us from building this code whenever "fips" is enabled. This is necessary because this API is too new for older boringSSL builds.

We could weaken this constraint to not(feature = "fips-compat"), but this is somewhat of a broader change than what this PR is trying to do.

Note: this is not a breaking change because "fips" and "pq-experimental" were previously mutually exclusive.

@cjpatton cjpatton marked this pull request as ready for review March 14, 2025 21:14
@cjpatton cjpatton requested a review from rushilmehra March 14, 2025 21:16
Internal users often have two builds for `boring`, one using a
precompiled build of boringSSL and another built from source with
patches applied. However the features that enable these builds are
mutually exclusive. For example, the `"pq-experimental"` feature is
required to build the source with all of the necessary codepoints for PQ
key exchange, but if this feature is enabled and a precompiled boringSSL
is provided, then the build will fail. This means users will have to
also control their builds with mutually exclusive features.

An alternative is to *ignore* features that enable patches whenever a
precompiled boringSSL is provided. This is a little different from the
"assume patched" environment variable, which applies whenever we're
building from source.
The "fips" feature implies use of a prebuilt boringSSL. The boringSSL
API consumed by `SslCurve` in incompatible with older versions of
boringSSL.

In the `ffi` bindings, the following symbols don't exist in older
builds:

* NID_X25519MLKEM768
* SSL_CURVE_X25519_MLKEM768
* NID_X25519Kyber768Draft00Old

The following symbols have been renamed:
* SSL_CURVE_P256KYBER768DRAFT00 => SSL_CURVE_P256_KYBER768_DRAFT00
* SSL_CURVE_X25519KYBER512DRAFT00 => SSL_CURVE_X25519_KYBER512_DRAFT00
* SSL_CURVE_X25519KYBER768DRAFT00OLD => SSL_CURVE_X25519_KYBER768_DRAFT00_OLD
* SSL_CURVE_P256KYBER768DRAFT00 => SSL_CURVE_P256_KYBER768_DRAFT00

Meanwhile, the `ssl_set_curves_list()` API is stable across these
versions of boringSSL.

These codepoints are added to the `SslCurve` API whenever
"pq-experimental" is enabled. Since this feature is no longer mutually
exclusive with prebuilt boringSSL (`boring-sys` just ignores patches),
we also need to disable this API whenever "fips" is enabled.
@cjpatton cjpatton force-pushed the cjpatton/prebuilt-ignore-patches branch from f587ae2 to 90121f0 Compare March 14, 2025 22:50
@cjpatton
Copy link
Collaborator Author

Rebased, plus I modified the warning to make it visible during the build.

@kornelski kornelski merged commit d8975dc into master Mar 16, 2025
23 checks passed
@kornelski kornelski deleted the cjpatton/prebuilt-ignore-patches branch March 16, 2025 08:45
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.

2 participants