Skip to content

Commit 0c75880

Browse files
Move types into trussed-rsa-types crate and release v0.1.0
This means that applications no longer need to depend on the backend.
1 parent 053d3b5 commit 0c75880

File tree

10 files changed

+69
-16
lines changed

10 files changed

+69
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SPDX-License-Identifier: CC0-1.0
99

1010
[Unreleased]: https://github.com/trussed-dev/trussed-rsa-backend/compare/v0.3.0...HEAD
1111

12-
-
12+
- Move `RsaImportFormat` and `RsaPublicParts` to the `trussed-rsa-types` crate.
1313

1414
## [v0.3.0][] (2025-07-31)
1515

Cargo.toml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,39 @@
11
# Copyright (C) Nitrokey GmbH
22
# SPDX-License-Identifier: CC0-1.0
33

4+
[workspace]
5+
members = ["types"]
6+
7+
[workspace.package]
8+
authors = ["Nitrokey GmbH <[email protected]>"]
9+
edition = "2021"
10+
license = "Apache-2.0 OR MIT"
11+
repository = "https://github.com/trussed-dev/trussed-rsa-backend"
12+
13+
[workspace.dependencies]
14+
heapless-bytes = "0.3"
15+
trussed-core = "0.1"
16+
417
[package]
518
name = "trussed-rsa-alloc"
619
version = "0.3.0"
7-
edition = "2021"
820
description = "Trussed backend adding support for the RSA algorithm using an allocator"
9-
authors = ["Nitrokey GmbH <[email protected]>"]
10-
license = "Apache-2.0 OR MIT"
21+
edition.workspace = true
22+
authors.workspace = true
23+
license.workspace = true
24+
repository.workspace = true
1125
rust-version = "1.66"
1226
keywords = ["trussed", "rsa", "no-std"]
1327

1428
[dependencies]
29+
heapless-bytes.workspace = true
1530
delog = "0.1.6"
16-
heapless-bytes = "0.3.0"
1731
num-bigint-dig = { version = "0.8.2", default-features = false }
18-
postcard = { version = "0.7", default-features = false, features = ["heapless"] }
1932
rsa = { version = "0.9", default-features = false, features = ["sha2"]}
20-
serde = { version = "1.0.152", default-features = false, features = ["derive"] }
2133

2234
trussed = { version = "0.1", default-features = false }
23-
trussed-core = { version = "0.1.0-rc.1", features = ["crypto-client", "rsa2048", "rsa3072", "rsa4096"] }
35+
trussed-core = { workspace = true, features = ["crypto-client", "rsa2048", "rsa3072", "rsa4096"] }
36+
trussed-rsa-types = "0.1"
2437

2538
[dev-dependencies]
2639
hex-literal = "0.3.4"
@@ -49,6 +62,7 @@ log-error = []
4962

5063
[patch.crates-io]
5164
trussed = { git = "https://github.com/trussed-dev/trussed.git", rev = "6bba8fde36d05c0227769eb63345744e87d84b2b" }
65+
trussed-rsa-types.path = "types"
5266

5367
[profile.dev.package.rsa]
5468
opt-level = 2

src/crypto_traits.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ use trussed_core::{
1111
},
1212
ClientError, ClientResult, CryptoClient,
1313
};
14-
15-
use crate::{RsaImportFormat, RsaPublicParts};
14+
use trussed_rsa_types::{RsaImportFormat, RsaPublicParts};
1615

1716
impl<C: CryptoClient> Rsa2048Pkcs1v15 for C {}
1817

@@ -46,11 +45,12 @@ pub trait Rsa2048Pkcs1v15: CryptoClient {
4645
/// Serializes an RSA 2048 bit key.
4746
///
4847
/// The resulting [`serialized_key`](trussed_core::api::reply::SerializeKey::serialized_key) contains a buffer of the parts of the key
49-
/// as a serialized [`RsaPublicParts`](crate::RsaPublicParts):
48+
/// as a serialized [`RsaPublicParts`](trussed_rsa_types::RsaPublicParts):
5049
/// ```
5150
///# #[cfg(feature = "virt")]
5251
///# {
5352
///# use trussed_rsa_alloc::*;
53+
///# use trussed_rsa_types::*;
5454
///# use trussed_core::{syscall,types::Location::{Volatile,Internal}};
5555
///# virt::with_ram_client("rsa tests", |mut client| {
5656
///# let sk = syscall!(client.generate_rsa2048pkcs_private_key(Internal)).key;
@@ -189,11 +189,12 @@ pub trait Rsa3072Pkcs1v15: CryptoClient {
189189
/// Serializes an RSA 3072 bit key.
190190
///
191191
/// The resulting [`serialized_key`](trussed_core::api::reply::SerializeKey::serialized_key) contains a buffer of the parts of the key
192-
/// as a serialized [`RsaPublicParts`](crate::RsaPublicParts):
192+
/// as a serialized [`RsaPublicParts`](trussed_rsa_types::RsaPublicParts):
193193
/// ```
194194
///# #[cfg(feature = "virt")]
195195
///# {
196196
///# use trussed_rsa_alloc::*;
197+
///# use trussed_rsa_types::*;
197198
///# use trussed_core::{syscall,types::Location::{Volatile,Internal}};
198199
///# virt::with_ram_client("rsa tests", |mut client| {
199200
///# let sk = syscall!(client.generate_rsa3072pkcs_private_key(Internal)).key;
@@ -332,11 +333,12 @@ pub trait Rsa4096Pkcs1v15: CryptoClient {
332333
/// Serializes an RSA 4096 bit key.
333334
///
334335
/// The resulting [`serialized_key`](trussed_core::api::reply::SerializeKey::serialized_key) contains a buffer of the parts of the key
335-
/// as a serialized [`RsaPublicParts`](crate::RsaPublicParts):
336+
/// as a serialized [`RsaPublicParts`](trussed_rsa_types::RsaPublicParts):
336337
/// ```
337338
///# #[cfg(feature = "virt")]
338339
///# {
339340
///# use trussed_rsa_alloc::*;
341+
///# use trussed_rsa_types::*;
340342
///# use trussed_core::{syscall,types::Location::{Volatile,Internal}};
341343
///# virt::with_ram_client("rsa tests", |mut client| {
342344
///# let sk = syscall!(client.generate_rsa4096pkcs_private_key(Internal)).key;

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use trussed::{
2727
},
2828
Error,
2929
};
30+
use trussed_rsa_types::{RsaImportFormat, RsaPublicParts};
3031

3132
#[cfg(feature = "virt")]
3233
pub mod virt;
@@ -38,8 +39,6 @@ generate_macros!();
3839
#[macro_use]
3940
extern crate alloc;
4041

41-
mod types;
42-
pub use types::{RsaImportFormat, RsaPublicParts};
4342
mod crypto_traits;
4443
pub use crypto_traits::{Rsa2048Pkcs1v15, Rsa3072Pkcs1v15, Rsa4096Pkcs1v15};
4544

tests/rsa2048.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use trussed::types::Mechanism;
1414
use trussed::types::StorageAttributes;
1515

1616
use trussed_rsa_alloc::*;
17+
use trussed_rsa_types::*;
1718

1819
use hex_literal::hex;
1920
use num_bigint_dig::BigUint;

tests/rsa3072.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use trussed::types::Mechanism;
1414
use trussed::types::StorageAttributes;
1515

1616
use trussed_rsa_alloc::*;
17+
use trussed_rsa_types::*;
1718

1819
use hex_literal::hex;
1920
use num_bigint_dig::BigUint;

tests/rsa4096.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use trussed::types::Mechanism;
1414
use trussed::types::StorageAttributes;
1515

1616
use trussed_rsa_alloc::*;
17+
use trussed_rsa_types::*;
1718

1819
use hex_literal::hex;
1920
use num_bigint_dig::BigUint;

types/CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!--
2+
Copyright (C) Nitrokey GmbH
3+
SPDX-License-Identifier: CC0-1.0
4+
-->
5+
6+
# Changelog
7+
8+
## [Unreleased](https://github.com/trussed-dev/trussed-rsa-backend/compare/types-v0.1.0...HEAD)
9+
10+
-
11+
12+
## [v0.1.0](https://github.com/trussed-dev/trussed-rsa-backend/releases/tag/types-v0.1.0)
13+
14+
- Add `Error`, `ErrorKind`, `RsaImportFormat` and `RsaPublicParts` from `trussed-rsa-alloc` v0.3.0.
15+

types/Cargo.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (C) Nitrokey GmbH
2+
# SPDX-License-Identifier: CC0-1.0
3+
4+
[package]
5+
name = "trussed-rsa-types"
6+
version = "0.1.0"
7+
description = "Helper types for the trussed-rsa-alloc backend"
8+
edition.workspace = true
9+
authors.workspace = true
10+
license.workspace = true
11+
repository.workspace = true
12+
keywords = ["trussed", "rsa", "no-std"]
13+
14+
[dependencies]
15+
heapless-bytes.workspace = true
16+
postcard = { version = "0.7", default-features = false, features = ["heapless"] }
17+
serde = { version = "1.0.152", default-features = false, features = ["derive"] }
18+
trussed-core.workspace = true

src/types.rs renamed to types/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use heapless_bytes::Bytes;
55
use serde::{Deserialize, Serialize};
6-
use trussed::types::SerializedKey;
6+
use trussed_core::types::SerializedKey;
77

88
/// Error type
99
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
@@ -52,6 +52,7 @@ impl<'d> RsaPublicParts<'d> {
5252
})?;
5353
Ok(Bytes::from(vec))
5454
}
55+
5556
pub fn deserialize(data: &'d [u8]) -> Result<Self, Error> {
5657
postcard::from_bytes(data).map_err(|_err| Error {
5758
kind: ErrorKind::Deseralization,
@@ -88,6 +89,7 @@ impl<'d> RsaImportFormat<'d> {
8889
})?;
8990
Ok(Bytes::from(vec))
9091
}
92+
9193
pub fn deserialize(data: &'d [u8]) -> Result<Self, Error> {
9294
postcard::from_bytes(data).map_err(|_err| Error {
9395
kind: ErrorKind::Deseralization,

0 commit comments

Comments
 (0)