Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
59fd8fd
Rebasing branch 1
helkoulak Jul 21, 2025
076c541
Rebasing branch 2
helkoulak Jul 24, 2025
fab8217
Rebasing branch 3
helkoulak Sep 23, 2025
f772b22
rebasing branch 4
helkoulak Sep 26, 2025
4dddf97
Adjust workflow to build features code
helkoulak Sep 26, 2025
12e1d5f
Rebasing branch 5
helkoulak Sep 29, 2025
ce33f5e
Add missing algorithm identifier
helkoulak Nov 4, 2025
8ce1aa8
Decrypt function should not panic in case of decrypt error to handle …
helkoulak Nov 4, 2025
4a3b32e
See commit cd879e183305c7793c12e11fbca475f43e9d8025
helkoulak Nov 24, 2025
d23d75e
In case peer misbehaves and sends plain text after it is not anymore …
helkoulak Nov 24, 2025
29b7cec
Rebasing 6
helkoulak Nov 24, 2025
2b4e59e
Make the order of supported cipher suites compatible with other provi…
helkoulak Nov 24, 2025
48449dd
Consider the case where nither the SET OF attributes nor the public k…
helkoulak Nov 24, 2025
a20c590
Rebasing 7
helkoulak Nov 25, 2025
7274348
Minor code changes to make wolfcrypt-provider more compatible with ru…
helkoulak Nov 25, 2025
2071799
The implementation of this function is required by some tests in suit…
helkoulak Nov 27, 2025
2dde8ed
Adjust ubuntu and macos work flows to run tests against rustlsv0.23.35
helkoulak Nov 27, 2025
6c4cf26
Install go as it is required for installing aws-lc-fips-sys v0.13.10
helkoulak Dec 2, 2025
47ccedb
Key must be set before encrypting with aes object to get correct tag
helkoulak Dec 16, 2025
a4b5302
For correct tag calculation in AES GCM mode in macOS the function wc_…
helkoulak Dec 16, 2025
66e9b0c
Replace unwrap() with constructs such as ? and map_err to avoid panic…
helkoulak Jan 8, 2026
e57eb64
Rebasing 8
helkoulak Jan 8, 2026
26a9e6d
Store raw key bytes of ChaCha object when setKey
helkoulak Jan 8, 2026
15b1c0e
Remove unnecessary import
helkoulak Jan 9, 2026
8c86949
Remove allow(clippy::type_complexity) and fix readability issue
helkoulak Jan 9, 2026
c747bd5
Rebasing 9
helkoulak Jan 12, 2026
a125038
Run rustls tests in a separate yml file
helkoulak Jan 13, 2026
56be78c
Fix script title
helkoulak Jan 13, 2026
85a47b1
Fix formatting error resulting from wrongly ordered imports
helkoulak Jan 22, 2026
8708554
Fix tag names from v0.23.35 to v/0.23.35
helkoulak Jan 22, 2026
fc1b3b6
Fix path of provider in building step
helkoulak Jan 22, 2026
25b7ad6
Use zeroize::Zeroizing instead of der::zeroize
helkoulak Mar 23, 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
3 changes: 2 additions & 1 deletion .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 @@ -58,4 +59,4 @@ jobs:
cd wolfcrypt-rs
cargo clippy -- -D warnings -A unnecessary-transmutes
cd ../rustls-wolfcrypt-provider
cargo clippy -- -D warnings
cargo clippy --all-features -- -D warnings
82 changes: 82 additions & 0 deletions .github/workflows/macos-rustls-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
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: v/0.23.35
fetch-depth: 0
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/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

82 changes: 82 additions & 0 deletions .github/workflows/ubuntu-rustls-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
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: v/0.23.35
fetch-depth: 0
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/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 @@ -45,6 +45,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
10 changes: 8 additions & 2 deletions rustls-wolfcrypt-provider/src/aead/aes128gcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,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 @@ -226,7 +229,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 @@ -354,6 +357,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 @@ -391,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
11 changes: 9 additions & 2 deletions rustls-wolfcrypt-provider/src/aead/aes256gcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,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 @@ -226,7 +229,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 @@ -354,6 +357,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 @@ -391,7 +398,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 @@ -134,6 +134,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 @@ -161,7 +164,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 @@ -277,6 +280,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 @@ -303,7 +309,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