Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f557fd5
Rebasing branch 1
helkoulak Jul 21, 2025
6e54c28
Rebasing branch, resolve conflict in types/mod.rs
helkoulak Jul 24, 2025
2b9e64b
Rebasing branch 3
helkoulak Sep 23, 2025
1ee3928
rebasing branch 4
helkoulak Sep 26, 2025
711191e
Adjust workflow to build features code
helkoulak Sep 26, 2025
f07f3fb
Rebasing branch 5
helkoulak Sep 29, 2025
97e0f1e
Add missing algorithm identifier
helkoulak Nov 4, 2025
67b7093
Rebasing branch, Decrypt function should not panic in case of decrypt…
helkoulak Nov 4, 2025
d4677b3
Rebasing branch, This type of error is required by rustls to handle t…
helkoulak Nov 24, 2025
c07d07f
In case peer misbehaves and sends plain text after it is not anymore …
helkoulak Nov 24, 2025
a05b9cb
Rebasing 7
helkoulak Nov 24, 2025
3c7982e
Make the order of supported cipher suites compatible with other provi…
helkoulak Nov 24, 2025
79e382e
Consider the case where nither the SET OF attributes nor the public k…
helkoulak Nov 24, 2025
ce58ae4
Rebasing 7
helkoulak Nov 25, 2025
c533b36
Minor code changes to make wolfcrypt-provider more compatible with ru…
helkoulak Nov 25, 2025
caf8765
The implementation of this function is required by some tests in suit…
helkoulak Nov 27, 2025
96b178b
Adjust ubuntu and macos work flows to run tests against rustlsv0.23.35
helkoulak Nov 27, 2025
d15d943
Install go as it is required for installing aws-lc-fips-sys v0.13.10
helkoulak Dec 2, 2025
91cdda5
Key must be set before encrypting with aes object to get correct tag
helkoulak Dec 16, 2025
eab2050
For correct tag calculation in AES GCM mode in macOS the function wc_…
helkoulak Dec 16, 2025
8936644
Replace unwrap() with constructs such as ? and map_err to avoid panic…
helkoulak Jan 8, 2026
1443774
Rebasing 8
helkoulak Jan 8, 2026
22f3082
Store raw key bytes of ChaCha object when setKey
helkoulak Jan 8, 2026
3f035e6
Remove unnecessary import
helkoulak Jan 9, 2026
7716c56
Remove allow(clippy::type_complexity) and fix readability issue
helkoulak Jan 9, 2026
c60701a
Rebasing 9
helkoulak Jan 12, 2026
5508ee2
Run rustls tests in a separate yml file
helkoulak Jan 13, 2026
89a1390
Fix script title
helkoulak Jan 13, 2026
bff7ee6
Fix formatting error resulting from wrongly ordered imports
helkoulak Jan 22, 2026
7688fbc
Fix tag names from v0.23.35 to v/0.23.35
helkoulak Jan 22, 2026
fe43afb
Fix path of provider in building step
helkoulak Jan 22, 2026
6bfeda5
Use zeroize::Zeroizing instead of der::zeroize
helkoulak Mar 23, 2026
666164e
Fix formatting errors
helkoulak Apr 8, 2026
c0995c6
Use wrapper Zeroizing instead of a drop function for key arrays
helkoulak Apr 8, 2026
b7bf008
Fixing formatting issues after resolving conflicts
helkoulak Apr 9, 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
12 changes: 10 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,8 @@ impl MessageDecrypter for WCTls12Decrypter {
aad.len() as word32,
)
};
check_if_zero(ret).map_err(|_| rustls::Error::General("wc_AesGcmDecrypt failed".into()))?;

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 +358,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 +398,8 @@ impl MessageDecrypter for WCTls13Cipher {
aad.len() as word32,
)
};
check_if_zero(ret).map_err(|_| rustls::Error::General("wc_AesGcmDecrypt failed".into()))?;

check_if_zero(ret).map_err(|_| rustls::Error::DecryptError)?;

payload.truncate(message_len);

Expand Down
13 changes: 11 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,8 @@ impl MessageDecrypter for WCTls12Decrypter {
aad.len() as word32,
)
};
check_if_zero(ret).map_err(|_| rustls::Error::General("wc_AesGcmDecrypt failed".into()))?;

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 +358,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 +399,8 @@ impl MessageDecrypter for WCTls13Cipher {
aad.len() as word32,
)
};
check_if_zero(ret).map_err(|_| rustls::Error::General("wc_AesGcmDecrypt failed".into()))?;

check_if_zero(ret).map_err(|_| rustls::Error::DecryptError)?;

payload.truncate(message_len);

Expand Down
14 changes: 10 additions & 4 deletions rustls-wolfcrypt-provider/src/aead/chacha20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,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 @@ -162,8 +165,8 @@ impl MessageDecrypter for WCTls12Cipher {
payload[..message_len].as_mut_ptr(),
)
};
check_if_zero(ret)
.map_err(|_| rustls::Error::General("wc_ChaCha20Poly1305_Decrypt failed".into()))?;

check_if_zero(ret).map_err(|_| rustls::Error::DecryptError)?;

// We extract the final result...
payload.truncate(message_len);
Expand Down Expand Up @@ -280,6 +283,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 @@ -306,8 +312,8 @@ impl MessageDecrypter for WCTls13Cipher {
payload[..message_len].as_mut_ptr(),
)
};
check_if_zero(ret)
.map_err(|_| rustls::Error::General("wc_ChaCha20Poly1305_Decrypt failed".into()))?;

check_if_zero(ret).map_err(|_| rustls::Error::DecryptError)?;

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