diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 995db271..13532247 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -99,6 +99,24 @@ jobs: - name: Integration tests run: make PROFILE=debug CERT_COMPRESSION=true integration + # TODO(@cpu): MacOS and Windows FIPS test coverage + fips: + name: FIPS + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Install nightly rust toolchain + uses: dtolnay/rust-toolchain@nightly + - name: Unit tests + run: make FIPS=true test + - name: Integration tests + run: make FIPS=true integration + test-windows-cmake-debug: name: Windows CMake, Debug configuration runs-on: windows-latest diff --git a/CMakeLists.txt b/CMakeLists.txt index f460752e..79b12b90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,8 @@ endif () set(CERT_COMPRESSION "false" CACHE STRING "Whether to enable brotli and zlib certificate compression support") +set(FIPS "false" CACHE STRING "Whether to enable aws-lc-rs and FIPS support") + set(CARGO_FEATURES --no-default-features) if (CRYPTO_PROVIDER STREQUAL "aws-lc-rs") list(APPEND CARGO_FEATURES --features=aws-lc-rs) @@ -21,6 +23,11 @@ if (CERT_COMPRESSION STREQUAL "true") list(APPEND CARGO_FEATURES --features=cert_compression) endif () +# See https://docs.rs/rustls/latest/rustls/manual/_06_fips/index.html +if (FIPS STREQUAL "true") + list(APPEND CARGO_FEATURES --features=fips) +endif () + add_subdirectory(tests) include(ExternalProject) diff --git a/Cargo.lock b/Cargo.lock index cfe58966..8d707e28 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,12 +32,28 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +[[package]] +name = "aws-lc-fips-sys" +version = "0.12.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf12b67bc9c5168f68655aadb2a12081689a58f1d9b1484705e4d1810ed6e4ac" +dependencies = [ + "bindgen", + "cc", + "cmake", + "dunce", + "fs_extra", + "libc", + "paste", +] + [[package]] name = "aws-lc-rs" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f95446d919226d587817a7d21379e6eb099b97b45110a7f272a444ca5c54070" dependencies = [ + "aws-lc-fips-sys", "aws-lc-sys", "mirai-annotations", "paste", diff --git a/Cargo.toml b/Cargo.toml index 1d986774..edfccc51 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ capi = [] ring = ["rustls/ring", "webpki/ring"] aws-lc-rs = ["rustls/aws-lc-rs", "webpki/aws_lc_rs"] cert_compression = ["rustls/brotli", "rustls/zlib"] +fips = ["aws-lc-rs", "rustls/fips"] [dependencies] # Keep in sync with RUSTLS_CRATE_VERSION in build.rs diff --git a/Makefile b/Makefile index 0eacf1d7..87831554 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ CFLAGS := -Werror -Wall -Wextra -Wpedantic -g -I src/ PROFILE := release CRYPTO_PROVIDER := aws-lc-rs COMPRESSION := false +FIPS := false DESTDIR=/usr/local ifeq ($(PROFILE), debug) @@ -41,6 +42,11 @@ ifeq ($(COMPRESSION), true) LDFLAGS += -lm endif +# See https://docs.rs/rustls/latest/rustls/manual/_06_fips/index.html +ifeq ($(FIPS), true) + CARGOFLAGS += --features fips +endif + default: target/$(PROFILE)/librustls_ffi.a all: default test integration connect-test diff --git a/Makefile.pkg-config b/Makefile.pkg-config index 8baf7298..08720b88 100644 --- a/Makefile.pkg-config +++ b/Makefile.pkg-config @@ -15,6 +15,7 @@ CFLAGS := -Werror -Wall -Wextra -Wpedantic -g -I src/ PROFILE := release CRYPTO_PROVIDER := aws-lc-rs CERT_COMPRESSION := false +FIPS := false PREFIX=/usr/local ifeq ($(PROFILE), debug) @@ -39,6 +40,11 @@ ifeq ($(CERT_COMPRESSION), true) CARGOFLAGS += --features cert_compression endif +# See https://docs.rs/rustls/latest/rustls/manual/_06_fips/index.html +ifeq ($(FIPS), true) + CARGOFLAGS += --features fips +endif + all: target/client target/server integration: all diff --git a/tests/client_server.rs b/tests/client_server.rs index 1f3d2a30..9f5e03ca 100644 --- a/tests/client_server.rs +++ b/tests/client_server.rs @@ -110,11 +110,17 @@ fn client_server_integration() { ], }; + // CHACHA20 is not FIPS approved :) + #[cfg(not(feature = "fips"))] + let custom_ciphersuite = "TLS13_CHACHA20_POLY1305_SHA256"; + #[cfg(feature = "fips")] + let custom_ciphersuite = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"; + let custom_ciphersuites = TestCase { name: "client/server with limited ciphersuites", server_opts: ServerOptions { valgrind: valgrind.clone(), - env: vec![("RUSTLS_CIPHERSUITE", "TLS13_CHACHA20_POLY1305_SHA256")], + env: vec![("RUSTLS_CIPHERSUITE", custom_ciphersuite)], }, client_tests: vec![ ClientTest { @@ -122,7 +128,7 @@ fn client_server_integration() { valgrind: valgrind.clone(), env: vec![ ("NO_CHECK_CERTIFICATE", "1"), - ("RUSTLS_CIPHERSUITE", "TLS13_CHACHA20_POLY1305_SHA256"), + ("RUSTLS_CIPHERSUITE", custom_ciphersuite), ], expect_error: false, },