Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
49d2fce
Adding required code to support QUIC
helkoulak Jul 21, 2025
3b6baae
Code fixes and tests
helkoulak Jul 24, 2025
d8eb6c5
Code fixes and formatting
helkoulak Sep 23, 2025
c1bdc1a
Fix build errors in wolfcrypt-rs
helkoulak Sep 26, 2025
9143871
Adjust workflow to build features code
helkoulak Sep 26, 2025
ef849ed
Add features to building and testing for macos
helkoulak Sep 29, 2025
8b34946
Add missing algorithm identifier
helkoulak Nov 4, 2025
cd879e1
Decrypt function should not panic in case of decrypt error to handle …
helkoulak Nov 4, 2025
3bfcf11
See commit cd879e183305c7793c12e11fbca475f43e9d8025
helkoulak Nov 24, 2025
9ebcf7a
In case peer misbehaves and sends plain text after it is not anymore …
helkoulak Nov 24, 2025
b5e14d3
function copy_from_slice requires both source and destination to be o…
helkoulak Nov 24, 2025
afb2ffd
function extract_key_pair is a workaround for the faulty function wc_…
helkoulak Nov 24, 2025
8291d46
Make the order of supported cipher suites compatible with other provi…
helkoulak Nov 24, 2025
560944e
Consider the case where nither the SET OF attributes nor the public k…
helkoulak Nov 24, 2025
35686aa
Create key object only if needed and store pub key value if provided …
helkoulak Nov 25, 2025
bdd5acb
Minor code changes to make wolfcrypt-provider more compatible with ru…
helkoulak Nov 25, 2025
b0ed669
The implementation of this function is required by some tests in suit…
helkoulak Nov 27, 2025
ea2ec86
Adjust ubuntu and macos work flows to run tests against rustlsv0.23.35
helkoulak Nov 27, 2025
7d5a50b
Install go as it is required for installing aws-lc-fips-sys v0.13.10
helkoulak Dec 2, 2025
2d63a95
Key must be set before encrypting with aes object to get correct tag
helkoulak Dec 16, 2025
bdef49c
For correct tag calculation in AES GCM mode in macOS the function wc_…
helkoulak Dec 16, 2025
2b5f9db
Replace unwrap() with constructs such as ? and map_err to avoid panic…
helkoulak Jan 8, 2026
4cf5da9
Drop functions have been implemented for both ciphers to zero their k…
helkoulak Jan 8, 2026
8434956
Store raw key bytes of ChaCha object when setKey
helkoulak Jan 8, 2026
ae1d97e
Remove unnecessary import
helkoulak Jan 9, 2026
c0d2c73
Remove allow(clippy::type_complexity) and fix readability issue
helkoulak Jan 9, 2026
21122bf
Use der::zeroize::Zeroize instead of zeroize::Zeroize
helkoulak Jan 12, 2026
5d743b3
Run rustls tests in a separate yml file
helkoulak Jan 13, 2026
15aac2a
Fix script title
helkoulak Jan 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/macos-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- name: Install Build Prerequisites
run: |
brew install autoconf libtool automake
brew install go

- name: Install Rust
uses: dtolnay/rust-toolchain@master
Expand Down Expand Up @@ -56,6 +57,6 @@ jobs:
- name: Run clippy
run: |
cd wolfcrypt-rs
cargo clippy -- -D warnings
cargo clippy --all-features -- -D warnings
cd ../rustls-wolfcrypt-provider
cargo clippy -- -D warnings
cargo clippy --all-features -- -D warnings
81 changes: 81 additions & 0 deletions .github/workflows/macos-rustls-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: macOS rustls tests

on:
push:
branches: [ 'main' ]
pull_request:
branches: [ 'main' ]

jobs:
macos-build:
name: Build and Test (macOS)
runs-on: macos-latest
steps:
- uses: actions/checkout@v4

- name: Install Build Prerequisites
run: |
brew install autoconf libtool automake
brew install go

- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt, clippy

- name: Cache Rust dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: macos-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
macos-cargo-

- name: Checkout rustls v0.23.35
uses: actions/checkout@v4
with:
repository: rustls/rustls
ref: v0.23.35
path: rustlsv0.23.35-test-workspace/rustls

- name: Checkout rustls-wolfcrypt-provider (quic-support)
uses: actions/checkout@v4
with:
repository: helkoulak/rustls-wolfcrypt-provider
ref: quic-support
path: rustlsv0.23.35-test-workspace/rustls-wolfcrypt-provider

- name: Build wolfcrypt-rs
working-directory: rustlsv0.23.35-test-workspace/rustls-wolfcrypt-provider/wolfcrypt-rs
run: make build

- name: Build rustls-wolfcrypt-provider
working-directory: rustlsv0.23.35-test-workspace/rustls-wolfcrypt-provider
run: cargo build --all-features --release

- name: Checkout rustls v0.23.35 test files
uses: actions/checkout@v4
with:
repository: helkoulak/rustls_v0.23.35_test_files
path: rustlsv0.23.35-test-workspace/rustls_v0.23.35_test_files

- name: Prepare test workspace
working-directory: rustlsv0.23.35-test-workspace
run: |
cp -r rustls_v0.23.35_test_files/tests .
cp rustls_v0.23.35_test_files/Cargo.toml .
cp rustls_v0.23.35_test_files/provider_files/Cargo.toml \
rustls-wolfcrypt-provider/rustls-wolfcrypt-provider/

- name: Run test suite
working-directory: rustlsv0.23.35-test-workspace
run: |
cargo test -p tests --test all_suites \
--features wolfcrypt-provider,tls12,fips,zlib,prefer-post-quantum,logging \
--no-default-features


5 changes: 3 additions & 2 deletions .github/workflows/ubuntu-build.yml
Copy link
Member

Choose a reason for hiding this comment

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

The same comments apply to macos-build.yml.

Copy link
Member

Choose a reason for hiding this comment

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

I would consider moving the rustls tests into a separate workflow.

Copy link
Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

Choose a reason for hiding this comment

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

One thing that I noticed is that you compile and run the tests with --all-features. I understand that with wolfcrypt-provider feature only the wolfcrypt provider is going to be used against the rustls testsuite, which is great, but with --all-features awc-lc-rs and ring get compiled too even if they are not used.
Is it possible to remove them? Or are they hardcoded dependencies used in some way in the testsuite?

I think the command to run the testsuite with only the wolfcrypt provider (which is already compiled in) is:
cargo test -p tests --test all_suites --features wolfcrypt-provider,tls12 --no-default-features
or something similar.

Copy link
Author

Choose a reason for hiding this comment

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

You are right. No need to use --all-features option. The tests run successfully using your suggested command with a few features added and it should be like this
cargo test -p tests --test all_suites --features wolfcrypt-provider,tls12,fips,zlib,prefer-post-quantum,logging --no-default-features

Copy link
Contributor

Choose a reason for hiding this comment

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

Me and Juliusz were also thinking that it might be worth to add a feature to print the current provider being used via cargo, since you added the configuration option wolfcrypt-provider.
And add that step before running the testsuite, by grepping the output from stdout and confirming that we are running the full testsuite against the wolfcrypt-provider only.
That would be great.

Copy link
Author

Choose a reason for hiding this comment

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

If I understand correctly, this is already done. The command that runs the tests targets only the runner file all_test_suites.rs. And in this runner file you have macros that are annotated with #[cfg(feature = "wolfcrypt-provider")] and print the sentence tests_with_wolfcrypt_. So as per my understanding, there is no way the tests will run against other providers than wolfcrypt-provider. Or did I miss something here?

Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
- name: Run clippy
run: |
cd wolfcrypt-rs
cargo clippy -- -D warnings
cargo clippy --all-features -- -D warnings
cd ../rustls-wolfcrypt-provider
cargo clippy -- -D warnings
cargo clippy --all-features -- -D warnings

81 changes: 81 additions & 0 deletions .github/workflows/ubuntu-rustls-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Ubuntu rustls tests

on:
push:
branches: [ 'main' ]
pull_request:
branches: [ 'main' ]

jobs:
ubuntu-build:
name: Build and Test (Ubuntu)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Build Prerequisites
run: |
sudo apt-get update
sudo apt-get install -y build-essential autoconf libtool

- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt, clippy

- name: Cache Rust dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ubuntu-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
ubuntu-cargo-


- name: Checkout rustls v0.23.35
uses: actions/checkout@v4
with:
repository: rustls/rustls
ref: v0.23.35
path: rustlsv0.23.35-test-workspace/rustls

- name: Checkout rustls-wolfcrypt-provider (quic-support)
uses: actions/checkout@v4
with:
repository: helkoulak/rustls-wolfcrypt-provider
ref: quic-support
path: rustlsv0.23.35-test-workspace/rustls-wolfcrypt-provider

- name: Build wolfcrypt-rs
working-directory: rustlsv0.23.35-test-workspace/rustls-wolfcrypt-provider/wolfcrypt-rs
run: make build

- name: Build rustls-wolfcrypt-provider
working-directory: rustlsv0.23.35-test-workspace/rustls-wolfcrypt-provider
run: cargo build --all-features --release

- name: Checkout rustls v0.23.35 test files
uses: actions/checkout@v4
with:
repository: helkoulak/rustls_v0.23.35_test_files
path: rustlsv0.23.35-test-workspace/rustls_v0.23.35_test_files

- name: Prepare test workspace
working-directory: rustlsv0.23.35-test-workspace
run: |
cp -r rustls_v0.23.35_test_files/tests .
cp rustls_v0.23.35_test_files/Cargo.toml .
cp rustls_v0.23.35_test_files/provider_files/Cargo.toml \
rustls-wolfcrypt-provider/rustls-wolfcrypt-provider/

- name: Run test suite
working-directory: rustlsv0.23.35-test-workspace
run: |
cargo test -p tests --test all_suites \
--features wolfcrypt-provider,tls12,fips,zlib,prefer-post-quantum,logging \
--no-default-features

1 change: 1 addition & 0 deletions rustls-wolfcrypt-provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ rustls-pemfile = { version = "2.2.0", default-features = false, features = ["std
[features]
default = []
std = ["pkcs8/std", "rustls/std", "wolfcrypt-rs/std"]
quic = []

[profile.release]
strip = true
Expand Down
4 changes: 2 additions & 2 deletions rustls-wolfcrypt-provider/examples/client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rustls_wolfcrypt_provider::provider;
use rustls_wolfcrypt_provider::default_provider;
use std::io::{stdout, Read, Write};
use std::net::TcpStream;
use std::sync::Arc;
Expand All @@ -9,7 +9,7 @@ fn main() {
let root_store =
rustls::RootCertStore::from_iter(webpki_roots::TLS_SERVER_ROOTS.iter().cloned());

let config = rustls::ClientConfig::builder_with_provider(provider().into())
let config = rustls::ClientConfig::builder_with_provider(default_provider().into())
.with_safe_default_protocol_versions()
.unwrap()
.with_root_certificates(root_store)
Expand Down
4 changes: 2 additions & 2 deletions rustls-wolfcrypt-provider/examples/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::sync::Arc;
use rustls::pki_types::{CertificateDer, PrivateKeyDer, PrivatePkcs8KeyDer};
use rustls::server::Acceptor;
use rustls::ServerConfig;
use rustls_wolfcrypt_provider::provider;
use rustls_wolfcrypt_provider::default_provider;

fn main() {
env_logger::init();
Expand Down Expand Up @@ -90,7 +90,7 @@ impl TestPki {
}

fn server_config(self) -> Arc<ServerConfig> {
let mut server_config = ServerConfig::builder_with_provider(provider().into())
let mut server_config = ServerConfig::builder_with_provider(default_provider().into())
.with_safe_default_protocol_versions()
.unwrap()
.with_no_client_auth()
Expand Down
14 changes: 10 additions & 4 deletions rustls-wolfcrypt-provider/src/aead/aes128gcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ impl Tls12AeadAlgorithm for Aes128Gcm {
) -> Result<ConnectionTrafficSecrets, UnsupportedOperationError> {
let mut iv_as_vec = vec![0u8; GCM_NONCE_LENGTH];

iv_as_vec.copy_from_slice(iv);
iv_as_vec.copy_from_slice(explicit);
iv_as_vec[..iv.len()].copy_from_slice(iv);
iv_as_vec[iv.len()..].copy_from_slice(explicit);

Ok(ConnectionTrafficSecrets::Aes128Gcm {
key,
Expand Down Expand Up @@ -172,6 +172,9 @@ impl MessageDecrypter for WCTls12Decrypter {
seq: u64,
) -> Result<InboundPlainMessage<'a>, rustls::Error> {
let payload = &mut m.payload;
if payload.len() < GCM_TAG_LENGTH {
return Err(rustls::Error::DecryptError);
}
let payload_len = payload.len();

// First we copy the implicit nonce followed by copying
Expand Down Expand Up @@ -225,7 +228,7 @@ impl MessageDecrypter for WCTls12Decrypter {
aad.len() as word32,
)
};
check_if_zero(ret).unwrap();
check_if_zero(ret).map_err(|_| rustls::Error::DecryptError)?;

payload.copy_within(payload_start..(payload_len - GCM_TAG_LENGTH), 0);
payload.truncate(payload_len - ((payload_start) + GCM_TAG_LENGTH));
Expand Down Expand Up @@ -353,6 +356,9 @@ impl MessageDecrypter for WCTls13Cipher {
seq: u64,
) -> Result<InboundPlainMessage<'a>, rustls::Error> {
let payload = &mut m.payload;
if payload.len() < GCM_TAG_LENGTH {
return Err(rustls::Error::DecryptError);
}
let nonce = Nonce::new(&self.iv, seq);
let aad = make_tls13_aad(payload.len());
let mut auth_tag = [0u8; GCM_TAG_LENGTH];
Expand Down Expand Up @@ -390,7 +396,7 @@ impl MessageDecrypter for WCTls13Cipher {
aad.len() as word32,
)
};
check_if_zero(ret).unwrap();
check_if_zero(ret).map_err(|_| rustls::Error::DecryptError)?;

payload.truncate(message_len);

Expand Down
15 changes: 11 additions & 4 deletions rustls-wolfcrypt-provider/src/aead/aes256gcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ impl Tls12AeadAlgorithm for Aes256Gcm {
) -> Result<ConnectionTrafficSecrets, UnsupportedOperationError> {
let mut iv_as_vec = vec![0u8; GCM_NONCE_LENGTH];

iv_as_vec.copy_from_slice(iv);
iv_as_vec.copy_from_slice(explicit);
iv_as_vec[..iv.len()].copy_from_slice(iv);
iv_as_vec[iv.len()..].copy_from_slice(explicit);

Ok(ConnectionTrafficSecrets::Aes256Gcm {
key,
Expand Down Expand Up @@ -172,6 +172,9 @@ impl MessageDecrypter for WCTls12Decrypter {
seq: u64,
) -> Result<InboundPlainMessage<'a>, rustls::Error> {
let payload = &mut m.payload;
if payload.len() < GCM_TAG_LENGTH {
return Err(rustls::Error::DecryptError);
}
let payload_len = payload.len();

// First we copy the implicit nonce followed by copying
Expand Down Expand Up @@ -225,7 +228,7 @@ impl MessageDecrypter for WCTls12Decrypter {
aad.len() as word32,
)
};
check_if_zero(ret).unwrap();
check_if_zero(ret).map_err(|_| rustls::Error::DecryptError)?;

payload.copy_within(payload_start..(payload_len - GCM_TAG_LENGTH), 0);
payload.truncate(payload_len - ((payload_start) + GCM_TAG_LENGTH));
Expand Down Expand Up @@ -353,6 +356,10 @@ impl MessageDecrypter for WCTls13Cipher {
seq: u64,
) -> Result<InboundPlainMessage<'a>, rustls::Error> {
let payload = &mut m.payload;
// In case peer misbehaves and sends plain text after it is not anymore allowed
if payload.len() < GCM_TAG_LENGTH {
return Err(rustls::Error::DecryptError);
}
let nonce = Nonce::new(&self.iv, seq);
let aad = make_tls13_aad(payload.len());
let mut auth_tag = [0u8; GCM_TAG_LENGTH];
Expand Down Expand Up @@ -390,7 +397,7 @@ impl MessageDecrypter for WCTls13Cipher {
aad.len() as word32,
)
};
check_if_zero(ret).unwrap();
check_if_zero(ret).map_err(|_| rustls::Error::DecryptError)?;

payload.truncate(message_len);

Expand Down
10 changes: 8 additions & 2 deletions rustls-wolfcrypt-provider/src/aead/chacha20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ impl MessageDecrypter for WCTls12Cipher {
seq: u64,
) -> Result<InboundPlainMessage<'a>, rustls::Error> {
let payload = &mut m.payload;
if payload.len() < CHACHAPOLY1305_OVERHEAD {
return Err(rustls::Error::DecryptError);
}

// We substract the tag, so this len will only consider
// the message that we are trying to decrypt.
Expand Down Expand Up @@ -160,7 +163,7 @@ impl MessageDecrypter for WCTls12Cipher {
payload[..message_len].as_mut_ptr(),
)
};
check_if_zero(ret).unwrap();
check_if_zero(ret).map_err(|_| rustls::Error::DecryptError)?;

// We extract the final result...
payload.truncate(message_len);
Expand Down Expand Up @@ -276,6 +279,9 @@ impl MessageDecrypter for WCTls13Cipher {
seq: u64,
) -> Result<InboundPlainMessage<'a>, rustls::Error> {
let payload = &mut m.payload;
if payload.len() < CHACHAPOLY1305_OVERHEAD {
return Err(rustls::Error::DecryptError);
}
let nonce = Nonce::new(&self.iv, seq);
let aad = make_tls13_aad(payload.len());
let mut auth_tag = [0u8; CHACHAPOLY1305_OVERHEAD];
Expand All @@ -302,7 +308,7 @@ impl MessageDecrypter for WCTls13Cipher {
payload[..message_len].as_mut_ptr(),
)
};
check_if_zero(ret).unwrap();
check_if_zero(ret).map_err(|_| rustls::Error::DecryptError)?;

// We extract the final result...
payload.truncate(message_len);
Expand Down
Loading