mirror of
https://github.com/solokeys/admin-app.git
synced 2026-06-20 13:16:17 -07:00
Implement factory reset command
This commit is contained in:
@@ -25,6 +25,7 @@ embedded-hal = { version = "0.2.7", optional = true }
|
||||
hex-literal = "0.4.1"
|
||||
rand_chacha = { version = "0.3.1", optional = true, default-features = false }
|
||||
trussed-se050-backend = { version = "0.1.0", optional = true }
|
||||
trussed-staging = { version = "0.1.0", features = ["manage"] }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
@@ -44,3 +45,4 @@ apdu-dispatch = { git = "https://github.com/trussed-dev/apdu-dispatch.git", rev
|
||||
trussed-se050-backend = { git = "https://github.com/Nitrokey/trussed-se050-backend.git", rev = "3395a5b73241a0a9f14a0715952be6fe7f1e56b0" }
|
||||
iso7816 = { git = "https://github.com/sosthene-nitrokey/iso7816.git", rev = "160ca3bbd8e21ec4e4ee1e0748e1eaa53a45c97f"}
|
||||
se05x = { git = "https://github.com/Nitrokey/se05x.git", rev = "0b77eb6b152d214897696aadf87767fd84ffcb0e"}
|
||||
trussed-staging = { git = "https://github.com/trussed-dev/trussed-staging.git", rev = "10baac2608e98e25ea77ade974a4e26f778d6c8e" }
|
||||
|
||||
@@ -19,6 +19,7 @@ const STATUS: u8 = 0x80;
|
||||
const TEST_SE050: u8 = 0x81;
|
||||
const GET_CONFIG: u8 = 0x82;
|
||||
const SET_CONFIG: u8 = 0x83;
|
||||
const FACTORY_RESET: u8 = 0x84;
|
||||
|
||||
// For compatibility, old commands are also available directly as separate vendor commands.
|
||||
const UPDATE: VendorCommand = VendorCommand::H51;
|
||||
@@ -48,6 +49,7 @@ enum Command {
|
||||
TestSe05X,
|
||||
GetConfig,
|
||||
SetConfig,
|
||||
FactoryReset,
|
||||
}
|
||||
|
||||
impl TryFrom<u8> for Command {
|
||||
@@ -67,6 +69,7 @@ impl TryFrom<u8> for Command {
|
||||
TEST_SE050 => Ok(Command::TestSe05X),
|
||||
GET_CONFIG => Ok(Command::GetConfig),
|
||||
SET_CONFIG => Ok(Command::SetConfig),
|
||||
FACTORY_RESET => Ok(Command::FactoryReset),
|
||||
_ => Err(Error::UnsupportedCommand),
|
||||
}
|
||||
}
|
||||
@@ -295,6 +298,10 @@ where
|
||||
};
|
||||
response.push(status).ok();
|
||||
}
|
||||
Command::FactoryReset => {
|
||||
debug_now!("Factory resetting the device");
|
||||
syscall!(self.trussed.factory_reset_device());
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
+3
-2
@@ -15,11 +15,12 @@ mod config;
|
||||
|
||||
pub use admin::{App, Reboot};
|
||||
pub use config::{Config, ConfigError, ConfigValueMut};
|
||||
use trussed_staging::manage::ManageClient;
|
||||
|
||||
#[cfg(not(feature = "se050"))]
|
||||
pub trait Client: trussed::Client {}
|
||||
pub trait Client: trussed::Client + ManageClient {}
|
||||
#[cfg(not(feature = "se050"))]
|
||||
impl<C: trussed::Client> Client for C {}
|
||||
impl<C: trussed::Client + ManageClient> Client for C {}
|
||||
|
||||
#[cfg(feature = "se050")]
|
||||
pub trait Client: trussed::Client + trussed_se050_backend::manage::ManageClient {}
|
||||
|
||||
Reference in New Issue
Block a user