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
a47e30a
Rebasing branch 1
helkoulak Jul 21, 2025
617cf00
Rebasing branch 2
helkoulak Jul 24, 2025
1825584
Rebasing branch 3
helkoulak Sep 23, 2025
9b41b7f
rebasing branch 4
helkoulak Sep 26, 2025
f02a8b6
Adjust workflow to build features code
helkoulak Sep 26, 2025
b2f1c44
Rebasing branch 5
helkoulak Sep 29, 2025
d774e27
Add missing algorithm identifier
helkoulak Nov 4, 2025
7cd2390
Decrypt function should not panic in case of decrypt error to handle …
helkoulak Nov 4, 2025
ab8008e
See commit cd879e183305c7793c12e11fbca475f43e9d8025
helkoulak Nov 24, 2025
0083cba
In case peer misbehaves and sends plain text after it is not anymore …
helkoulak Nov 24, 2025
3a474d2
Rebasing 7
helkoulak Nov 24, 2025
fcc37ea
Make the order of supported cipher suites compatible with other provi…
helkoulak Nov 24, 2025
0fecc29
Consider the case where nither the SET OF attributes nor the public k…
helkoulak Nov 24, 2025
e7cce19
Rebasing 7
helkoulak Nov 25, 2025
0e6b22d
Minor code changes to make wolfcrypt-provider more compatible with ru…
helkoulak Nov 25, 2025
20bda5c
The implementation of this function is required by some tests in suit…
helkoulak Nov 27, 2025
1220bbf
Adjust ubuntu and macos work flows to run tests against rustlsv0.23.35
helkoulak Nov 27, 2025
b54ebd8
Install go as it is required for installing aws-lc-fips-sys v0.13.10
helkoulak Dec 2, 2025
90f7342
Key must be set before encrypting with aes object to get correct tag
helkoulak Dec 16, 2025
972c19b
For correct tag calculation in AES GCM mode in macOS the function wc_…
helkoulak Dec 16, 2025
42bd60f
Replace unwrap() with constructs such as ? and map_err to avoid panic…
helkoulak Jan 8, 2026
1051f77
Rebasing 8
helkoulak Jan 8, 2026
11d4009
Store raw key bytes of ChaCha object when setKey
helkoulak Jan 8, 2026
a769d4d
Remove unnecessary import
helkoulak Jan 9, 2026
6d63f32
Remove allow(clippy::type_complexity) and fix readability issue
helkoulak Jan 9, 2026
6518c58
Rebasing 9
helkoulak Jan 12, 2026
e6f1e77
Run rustls tests in a separate yml file
helkoulak Jan 13, 2026
67a8540
Fix script title
helkoulak Jan 13, 2026
203387d
Fix formatting error resulting from wrongly ordered imports
helkoulak Jan 22, 2026
8c84d41
Fix tag names from v0.23.35 to v/0.23.35
helkoulak Jan 22, 2026
1d1dcf0
Fix path of provider in building step
helkoulak Jan 22, 2026
9e94096
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
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
Copy Markdown
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