Skip to content

Commit 743d9aa

Browse files
Use trussed-core and remove default features for trussed
1 parent a3b481d commit 743d9aa

File tree

4 files changed

+33
-16
lines changed

4 files changed

+33
-16
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ SPDX-License-Identifier: CC0-1.0
99

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

12+
- Use `trussed-core` and remove default features for `trussed`.
13+
- Add `MECHANISMS` constant with the implemented mechanisms.
14+
1215
## [v0.2.1][] (2024-06-21)
1316

1417
[v0.2.1]: https://github.com/trussed-dev/trussed-rsa-backend/compare/v0.2.0...v0.2.1

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ postcard = { version = "0.7", default-features = false, features = ["heapless"]
1919
rsa = { version = "0.9", default-features = false, features = ["sha2"]}
2020
serde = { version = "1.0.152", default-features = false, features = ["derive"] }
2121

22-
trussed = "0.1"
22+
trussed = { version = "0.1", default-features = false }
23+
trussed-core = { version = "0.1.0-rc.1", features = ["crypto-client", "rsa2048", "rsa3072", "rsa4096"] }
2324

2425
[dev-dependencies]
2526
hex-literal = "0.3.4"
@@ -28,6 +29,7 @@ delog = { version = "0.1.6", features = ["std-log"] }
2829
test-log = "0.2.11"
2930
env_logger = "0.10.0"
3031
rand = "0.8.5"
32+
trussed = { version = "0.1", default-features = false, features = ["certificate-client", "clients-1", "crypto-client"] }
3133

3234
[features]
3335

@@ -45,7 +47,7 @@ log-warn = []
4547
log-error = []
4648

4749
[patch.crates-io]
48-
trussed = { git = "https://github.com/Nitrokey/trussed", rev = "6b9a43fbaaf34fe8d69fac0021f8130dd9a436c9" }
50+
trussed = { git = "https://github.com/trussed-dev/trussed.git", rev = "6bba8fde36d05c0227769eb63345744e87d84b2b" }
4951

5052
[profile.dev.package.rsa]
5153
opt-level = 2

src/crypto_traits.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
// Copyright (C) Nitrokey GmbH
22
// SPDX-License-Identifier: Apache-2.0 or MIT
33

4-
use trussed::{
4+
use trussed_core::{
55
api::{
66
reply,
77
request::{DeserializeKey, UnsafeInjectKey},
88
},
9-
client::{ClientError, ClientResult, CryptoClient},
109
types::{
1110
KeyId, KeySerialization, Location, Mechanism, SignatureSerialization, StorageAttributes,
1211
},
12+
ClientError, ClientResult, CryptoClient,
1313
};
1414

1515
use crate::{RsaImportFormat, RsaPublicParts};
1616

1717
impl<C: CryptoClient> Rsa2048Pkcs1v15 for C {}
1818

19-
/// Helper trait to work with RSA 2048 bit keys through a [`Client`](trussed::Client)
19+
/// Helper trait to work with RSA 2048 bit keys through a [`CryptoClient`][]
2020
///
21-
/// This trait is implemented by all implementors of [`CryptoClient`](trussed::client::CryptoClient)
21+
/// This trait is implemented by all implementors of [`CryptoClient`][]
2222
pub trait Rsa2048Pkcs1v15: CryptoClient {
2323
fn generate_rsa2048pkcs_private_key(
2424
&mut self,
@@ -45,13 +45,13 @@ pub trait Rsa2048Pkcs1v15: CryptoClient {
4545

4646
/// Serializes an RSA 2048 bit key.
4747
///
48-
/// The resulting [`serialized_key`](trussed::api::reply::SerializeKey::serialized_key) contains a buffer of the parts of the key
48+
/// The resulting [`serialized_key`](trussed_core::api::reply::SerializeKey::serialized_key) contains a buffer of the parts of the key
4949
/// as a serialized [`RsaPublicParts`](crate::RsaPublicParts):
5050
/// ```
5151
///# #[cfg(feature = "virt")]
5252
///# {
5353
///# use trussed_rsa_alloc::*;
54-
///# use trussed::{syscall,types::Location::{Volatile,Internal}};
54+
///# 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;
5757
///# let pk = syscall!(client.derive_rsa2048pkcs_public_key(sk, Volatile)).key;
@@ -159,9 +159,9 @@ pub trait Rsa2048Pkcs1v15: CryptoClient {
159159

160160
impl<C: CryptoClient> Rsa3072Pkcs1v15 for C {}
161161

162-
/// Helper trait to work with RSA 3072 bit keys through a [`Client`](trussed::Client)
162+
/// Helper trait to work with RSA 3072 bit keys through a [`CryptoClient`][]
163163
///
164-
/// This trait is implemented by all implementors of [`CryptoClient`](trussed::client::CryptoClient)
164+
/// This trait is implemented by all implementors of [`CryptoClient`][]
165165
pub trait Rsa3072Pkcs1v15: CryptoClient {
166166
fn generate_rsa3072pkcs_private_key(
167167
&mut self,
@@ -188,13 +188,13 @@ pub trait Rsa3072Pkcs1v15: CryptoClient {
188188

189189
/// Serializes an RSA 3072 bit key.
190190
///
191-
/// The resulting [`serialized_key`](trussed::api::reply::SerializeKey::serialized_key) contains a buffer of the parts of the key
191+
/// The resulting [`serialized_key`](trussed_core::api::reply::SerializeKey::serialized_key) contains a buffer of the parts of the key
192192
/// as a serialized [`RsaPublicParts`](crate::RsaPublicParts):
193193
/// ```
194194
///# #[cfg(feature = "virt")]
195195
///# {
196196
///# use trussed_rsa_alloc::*;
197-
///# use trussed::{syscall,types::Location::{Volatile,Internal}};
197+
///# use trussed_core::{syscall,types::Location::{Volatile,Internal}};
198198
///# virt::with_ram_client("rsa tests", |mut client| {
199199
///# let sk = syscall!(client.generate_rsa3072pkcs_private_key(Internal)).key;
200200
///# let pk = syscall!(client.derive_rsa3072pkcs_public_key(sk, Volatile)).key;
@@ -302,9 +302,9 @@ pub trait Rsa3072Pkcs1v15: CryptoClient {
302302

303303
impl<C: CryptoClient> Rsa4096Pkcs1v15 for C {}
304304

305-
/// Helper trait to work with RSA 4096 bit keys through a [`Client`](trussed::Client)
305+
/// Helper trait to work with RSA 4096 bit keys through a [`CryptoClient`][]
306306
///
307-
/// This trait is implemented by all implementors of [`CryptoClient`](trussed::client::CryptoClient)
307+
/// This trait is implemented by all implementors of [`CryptoClient`][]
308308
pub trait Rsa4096Pkcs1v15: CryptoClient {
309309
fn generate_rsa4096pkcs_private_key(
310310
&mut self,
@@ -331,13 +331,13 @@ pub trait Rsa4096Pkcs1v15: CryptoClient {
331331

332332
/// Serializes an RSA 4096 bit key.
333333
///
334-
/// The resulting [`serialized_key`](trussed::api::reply::SerializeKey::serialized_key) contains a buffer of the parts of the key
334+
/// The resulting [`serialized_key`](trussed_core::api::reply::SerializeKey::serialized_key) contains a buffer of the parts of the key
335335
/// as a serialized [`RsaPublicParts`](crate::RsaPublicParts):
336336
/// ```
337337
///# #[cfg(feature = "virt")]
338338
///# {
339339
///# use trussed_rsa_alloc::*;
340-
///# use trussed::{syscall,types::Location::{Volatile,Internal}};
340+
///# use trussed_core::{syscall,types::Location::{Volatile,Internal}};
341341
///# virt::with_ram_client("rsa tests", |mut client| {
342342
///# let sk = syscall!(client.generate_rsa4096pkcs_private_key(Internal)).key;
343343
///# let pk = syscall!(client.derive_rsa4096pkcs_public_key(sk, Volatile)).key;

src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ pub use types::{RsaImportFormat, RsaPublicParts};
4343
mod crypto_traits;
4444
pub use crypto_traits::{Rsa2048Pkcs1v15, Rsa3072Pkcs1v15, Rsa4096Pkcs1v15};
4545

46+
pub const MECHANISMS: &[Mechanism] = &[
47+
Mechanism::Rsa2048Pkcs1v15,
48+
Mechanism::Rsa3072Pkcs1v15,
49+
Mechanism::Rsa4096Pkcs1v15,
50+
#[cfg(feature = "raw")]
51+
Mechanism::Rsa2048Raw,
52+
#[cfg(feature = "raw")]
53+
Mechanism::Rsa3072Raw,
54+
#[cfg(feature = "raw")]
55+
Mechanism::Rsa4096Raw,
56+
];
57+
4658
/// Trussed [`Backend`][] implementation adding support for RSA
4759
///
4860
/// This implementation is done in software and requieres an allocator

0 commit comments

Comments
 (0)