-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move manage::ManageExtension into trussed-se050-manage crate
Similar to the changes in trussed-staging#19 [0], this patch moves the extension that was previously defined in the backend crate into a separate extension crate. [0] trussed-dev/trussed-staging#19
- Loading branch information
1 parent
d2b6931
commit 1414a89
Showing
6 changed files
with
176 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,32 @@ | ||
[workspace] | ||
members = ["extensions/se050-manage"] | ||
|
||
[workspace.package] | ||
authors = ["Nitrokey GmbH <[email protected]>"] | ||
edition = "2021" | ||
repository = "https://github.com/trussed-dev/trussed-staging" | ||
license = "Apache-2.0 OR MIT" | ||
|
||
[package] | ||
name = "trussed-se050-backend" | ||
version = "0.2.0" | ||
edition = "2021" | ||
authors.workspace = true | ||
edition.workspace = true | ||
repository.workspace = true | ||
license.workspace = true | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
[workspace.dependencies] | ||
serde = { version = "1.0.185", default-features = false, features = ["derive"] } | ||
trussed = { version = "0.1.0", features = ["serde-extensions"] } | ||
|
||
[dependencies] | ||
serde.workspace = true | ||
trussed.workspace = true | ||
|
||
se05x = { version = "0.1.1", features = ["serde", "builder"] } | ||
trussed = { version = "0.1.0", features = ["serde-extensions"] } | ||
trussed-auth = "0.2.2" | ||
trussed-manage = "0.1.0" | ||
trussed-se050-manage = "0.1.0" | ||
trussed-wrap-key-to-file = "0.1.0" | ||
delog = "0.1.6" | ||
embedded-hal = "0.2.7" | ||
|
@@ -19,7 +36,6 @@ hex-literal = "0.4.1" | |
serde-byte-array = "0.1.2" | ||
iso7816 = "0.1.1" | ||
hmac = "0.12.1" | ||
serde = { version = "1.0.185", default-features = false, features = ["derive"] } | ||
rand = { version = "0.8.5", default-features = false } | ||
littlefs2 = "0.4.0" | ||
cbor-smol = "0.4.0" | ||
|
@@ -39,6 +55,8 @@ trussed-manage = { git = "https://github.com/trussed-dev/trussed-staging.git", t | |
trussed-rsa-alloc = { git = "https://github.com/Nitrokey/trussed-rsa-backend.git", rev = "2088e2f8a8d706276c1559717b4c6b6d4f270253" } | ||
trussed-wrap-key-to-file = { git = "https://github.com/trussed-dev/trussed-staging.git", tag = "wrap-key-to-file-v0.1.0" } | ||
|
||
trussed-se050-manage = { path = "extensions/se050-manage" } | ||
|
||
[features] | ||
default = ["log-all"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "trussed-se050-manage" | ||
version = "0.1.0" | ||
authors.workspace = true | ||
edition.workspace = true | ||
repository.workspace = true | ||
license.workspace = true | ||
|
||
[dependencies] | ||
serde.workspace = true | ||
trussed.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use trussed::{ | ||
serde_extensions::{Extension, ExtensionClient, ExtensionResult}, | ||
types::Bytes, | ||
Error, | ||
}; | ||
|
||
#[derive(Debug, Default)] | ||
pub struct ManageExtension; | ||
|
||
/// Request information regarding the SE050 | ||
#[derive(Debug, Deserialize, Serialize, Copy, Clone)] | ||
pub struct InfoRequest; | ||
|
||
/// Test SE050 functionality | ||
/// | ||
/// This is now a placeholder for the previous test. It is kept to return available space on the SE050 | ||
#[derive(Debug, Deserialize, Serialize, Copy, Clone)] | ||
pub struct TestSe050Request; | ||
|
||
#[allow(clippy::large_enum_variant)] | ||
#[derive(Debug, Deserialize, Serialize)] | ||
pub enum ManageRequest { | ||
Info(InfoRequest), | ||
TestSe050(TestSe050Request), | ||
} | ||
|
||
impl TryFrom<ManageRequest> for InfoRequest { | ||
type Error = Error; | ||
fn try_from(request: ManageRequest) -> Result<Self, Self::Error> { | ||
match request { | ||
ManageRequest::Info(request) => Ok(request), | ||
_ => Err(Error::InternalError), | ||
} | ||
} | ||
} | ||
|
||
impl From<InfoRequest> for ManageRequest { | ||
fn from(request: InfoRequest) -> Self { | ||
Self::Info(request) | ||
} | ||
} | ||
|
||
impl TryFrom<ManageRequest> for TestSe050Request { | ||
type Error = Error; | ||
fn try_from(request: ManageRequest) -> Result<Self, Self::Error> { | ||
match request { | ||
ManageRequest::TestSe050(request) => Ok(request), | ||
_ => Err(Error::InternalError), | ||
} | ||
} | ||
} | ||
|
||
impl From<TestSe050Request> for ManageRequest { | ||
fn from(request: TestSe050Request) -> Self { | ||
Self::TestSe050(request) | ||
} | ||
} | ||
|
||
#[derive(Debug, Deserialize, Serialize, Copy, Clone)] | ||
pub struct InfoReply { | ||
pub major: u8, | ||
pub minor: u8, | ||
pub patch: u8, | ||
pub sb_major: u8, | ||
pub sb_minor: u8, | ||
pub persistent: u16, | ||
pub transient_deselect: u16, | ||
pub transient_reset: u16, | ||
} | ||
|
||
#[derive(Debug, Deserialize, Serialize)] | ||
pub enum ManageReply { | ||
Info(InfoReply), | ||
TestSe050(TestSe050Reply), | ||
} | ||
|
||
impl TryFrom<ManageReply> for InfoReply { | ||
type Error = Error; | ||
fn try_from(request: ManageReply) -> Result<Self, Self::Error> { | ||
match request { | ||
ManageReply::Info(request) => Ok(request), | ||
_ => Err(Error::InternalError), | ||
} | ||
} | ||
} | ||
|
||
impl From<InfoReply> for ManageReply { | ||
fn from(request: InfoReply) -> Self { | ||
Self::Info(request) | ||
} | ||
} | ||
|
||
#[derive(Debug, Deserialize, Serialize, Clone)] | ||
pub struct TestSe050Reply { | ||
pub reply: Bytes<1024>, | ||
} | ||
|
||
impl TryFrom<ManageReply> for TestSe050Reply { | ||
type Error = Error; | ||
fn try_from(request: ManageReply) -> Result<Self, Self::Error> { | ||
match request { | ||
ManageReply::TestSe050(request) => Ok(request), | ||
_ => Err(Error::InternalError), | ||
} | ||
} | ||
} | ||
|
||
impl From<TestSe050Reply> for ManageReply { | ||
fn from(request: TestSe050Reply) -> Self { | ||
Self::TestSe050(request) | ||
} | ||
} | ||
|
||
impl Extension for ManageExtension { | ||
type Request = ManageRequest; | ||
type Reply = ManageReply; | ||
} | ||
|
||
pub type ManageResult<'a, R, C> = ExtensionResult<'a, ManageExtension, R, C>; | ||
|
||
pub trait ManageClient: ExtensionClient<ManageExtension> { | ||
/// Get info on the SE050 | ||
fn get_info(&mut self) -> ManageResult<'_, InfoReply, Self> { | ||
self.extension(InfoRequest) | ||
} | ||
|
||
/// Test the se050 device and driver | ||
/// | ||
/// This will fake the results of the tests from v0.1.0-test-driver for compatibility but | ||
/// return correct metadata header to be shown in the test result | ||
fn test_se050(&mut self) -> ManageResult<'_, TestSe050Reply, Self> { | ||
self.extension(TestSe050Request) | ||
} | ||
} | ||
|
||
impl<C: ExtensionClient<ManageExtension>> ManageClient for C {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters