Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
run: |
# trussed-core + trussed
for mechanism in \
aes256-cbc chacha8-poly1305 ed255 hmac-blake2s hmac-sha1 hmac-sha256 hmac-sha512 \
aes256-cbc aes256-gcm chacha8-poly1305 ed255 hmac-blake2s hmac-sha1 hmac-sha256 hmac-sha512 \
p256 p384 p521 sha256 shared-secret tdes totp trng x255
do
for package in trussed-core trussed
Expand All @@ -68,7 +68,7 @@ jobs:
done
# trussed-core only
for mechanism in \
brainpoolp256r1 brainpoolp384r1 brainpoolp512r1 rsa2048 rsa3072 rsa4096 secp256k1
brainpoolp256r1 brainpoolp384r1 brainpoolp512r1 mldsa44 rsa2048 rsa3072 rsa4096 secp256k1
do
echo "trussed-core: ${mechanism}"
cargo check --package trussed-core --all-targets --no-default-features --features crypto-client,${mechanism}
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
behind the `serde-extensions` feature.
- Added `types::Path` re-export of `littlefs2::path::Path`.
- Reduced stack usage of `Service::process`.
- Added the `Aes256Gcm` mechanism.

### Changed

Expand Down
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ license.workspace = true
repository.workspace = true

[dependencies]
trussed-core = "0.2"
trussed-core = "0.2.2"

# general
bitflags = { version = "2.1" }
Expand All @@ -45,8 +45,11 @@ zeroize = { version = "1.2", default-features = false, features = ["zeroize_deri
rand_chacha = { version = "0.3.1", default-features = false }

# RustCrypto
aead = { version = "0.5", default-features = false, optional = true }
aes = { version = "0.8", default-features = false }
aes-gcm = { version = "0.10", default-features = false, features = ["aes"], optional = true }
cbc = "0.1.2"
cipher = { version = "0.4", optional = true }
blake2 = { version = "0.10", default-features = false, optional = true }
chacha20 = { version = "0.9", default-features = false }
chacha20poly1305 = { version = "0.10", default-features = false, features = ["reduced-round"] }
Expand Down Expand Up @@ -116,7 +119,8 @@ default-mechanisms = [
"trng",
]
aes256-cbc = ["trussed-core/aes256-cbc"]
chacha8-poly1305 = ["trussed-core/chacha8-poly1305"]
aes256-gcm = ["trussed-core/aes256-gcm", "dep:aead", "dep:aes-gcm", "dep:cipher"]
chacha8-poly1305 = ["trussed-core/chacha8-poly1305", "dep:aead", "dep:cipher"]
ed255 = ["trussed-core/ed255"]
x255 = ["trussed-core/x255"]
hmac-blake2s = ["trussed-core/hmac-blake2s", "blake2"]
Expand Down
6 changes: 6 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

-

## [v0.2.2](https://github.com/trussed-dev/trussed/releases/tag/core-v0.2.2) (2026-05-30)

### Added

- Add `Mechanism::Aes256Gcm` and the `Aes256Gcm` trait behind the `aes256-gcm` feature flag.

## [v0.2.1](https://github.com/trussed-dev/trussed/releases/tag/core-v0.2.1) (2026-05-18)

### Added
Expand Down
3 changes: 2 additions & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "trussed-core"
version = "0.2.1"
version = "0.2.2"
description = "Core types for the trussed crate"

authors.workspace = true
Expand Down Expand Up @@ -31,6 +31,7 @@ ui-client = []

# mechanisms
aes256-cbc = []
aes256-gcm = []
brainpoolp256r1 = []
brainpoolp384r1 = []
brainpoolp512r1 = []
Expand Down
80 changes: 80 additions & 0 deletions core/src/mechanisms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,86 @@ pub trait Aes256Cbc: CryptoClient {
}
}

#[cfg(feature = "aes256-gcm")]
pub trait Aes256Gcm: CryptoClient {
fn decrypt_aes256gcm<'c>(
&'c mut self,
key: KeyId,
message: &[u8],
associated_data: &[u8],
nonce: &[u8],
tag: &[u8],
) -> ClientResult<'c, reply::Decrypt, Self> {
self.decrypt(
Mechanism::Aes256Gcm,
key,
message,
associated_data,
nonce,
tag,
)
}

fn encrypt_aes256gcm<'c>(
&'c mut self,
key: KeyId,
message: &[u8],
associated_data: &[u8],
nonce: Option<&[u8; 12]>,
) -> ClientResult<'c, reply::Encrypt, Self> {
self.encrypt(
Mechanism::Aes256Gcm,
key,
message,
associated_data,
nonce.map(ShortData::from),
)
}

fn generate_aes256gcm_key(
&mut self,
persistence: Location,
) -> ClientResult<'_, reply::GenerateKey, Self> {
self.generate_key(
Mechanism::Aes256Gcm,
StorageAttributes::new().set_persistence(persistence),
)
}

fn unwrap_key_aes256gcm<'c>(
&'c mut self,
wrapping_key: KeyId,
wrapped_key: &[u8],
associated_data: &[u8],
location: Location,
) -> ClientResult<'c, reply::UnwrapKey, Self> {
self.unwrap_key(
Mechanism::Aes256Gcm,
wrapping_key,
Message::try_from(wrapped_key).map_err(|_| ClientError::DataTooLarge)?,
associated_data,
&[],
StorageAttributes::new().set_persistence(location),
)
}

fn wrap_key_aes256gcm<'c>(
&'c mut self,
wrapping_key: KeyId,
key: KeyId,
associated_data: &[u8],
nonce: Option<&[u8; 12]>,
) -> ClientResult<'c, reply::WrapKey, Self> {
self.wrap_key(
Mechanism::Aes256Gcm,
wrapping_key,
key,
associated_data,
nonce.map(ShortData::from),
)
}
}

#[cfg(feature = "chacha8-poly1305")]
pub trait Chacha8Poly1305: CryptoClient {
fn decrypt_chacha8poly1305<'c>(
Expand Down
2 changes: 2 additions & 0 deletions core/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,8 @@ generate_mechanism! {
pub enum Mechanism {
#[cfg(feature = "aes256-cbc")]
Aes256Cbc,
#[cfg(feature = "aes256-gcm")]
Aes256Gcm,
#[cfg(feature = "chacha8-poly1305")]
Chacha8Poly1305,
#[cfg(feature = "ed255")]
Expand Down
3 changes: 3 additions & 0 deletions src/client/mechanisms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ pub use trussed_core::mechanisms::*;
#[cfg(feature = "aes256-cbc")]
impl<S: Syscall, E> Aes256Cbc for ClientImplementation<'_, S, E> {}

#[cfg(feature = "aes256-gcm")]
impl<S: Syscall, E> Aes256Gcm for ClientImplementation<'_, S, E> {}

#[cfg(feature = "chacha8-poly1305")]
impl<S: Syscall, E> Chacha8Poly1305 for ClientImplementation<'_, S, E> {}

Expand Down
8 changes: 8 additions & 0 deletions src/mechanisms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@
// The question of breaking down `reply_to` into smaller, more globally understandable pieces,
// should be revisited.

#[cfg(any(feature = "aes256-gcm", feature = "chacha8-poly1305"))]
mod aead;

// TODO: rename to aes256-cbc-zero-iv
#[cfg(feature = "aes256-cbc")]
pub struct Aes256Cbc;
#[cfg(feature = "aes256-cbc")]
mod aes256cbc;

#[cfg(feature = "aes256-gcm")]
pub struct Aes256Gcm;
#[cfg(feature = "aes256-gcm")]
mod aes256gcm;

#[cfg(feature = "chacha8-poly1305")]
pub struct Chacha8Poly1305;
#[cfg(feature = "chacha8-poly1305")]
Expand Down
Loading
Loading