diff --git a/Cargo.lock b/Cargo.lock index 5bdee592..da37fb1d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,7 +5,7 @@ version = 3 [[package]] name = "admin-app" version = "0.1.0" -source = "git+https://github.com/Nitrokey/admin-app.git?rev=c257432dbe2efb53424d6847d82d90ddb527c53b#c257432dbe2efb53424d6847d82d90ddb527c53b" +source = "git+https://github.com/Nitrokey/admin-app.git?tag=v0.1.0-nitrokey.13#c24149193fb9bdcaa9ed4dd99fd2a503159a66ee" dependencies = [ "apdu-dispatch", "cbor-smol", diff --git a/Cargo.toml b/Cargo.toml index 7feb8117..f4131108 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ version = "1.7.2" memory-regions = { path = "components/memory-regions" } # forked -admin-app = { git = "https://github.com/Nitrokey/admin-app.git", rev = "c257432dbe2efb53424d6847d82d90ddb527c53b" } +admin-app = { git = "https://github.com/Nitrokey/admin-app.git", tag = "v0.1.0-nitrokey.13" } cbor-smol = { git = "https://github.com/Nitrokey/cbor-smol.git", tag = "v0.4.0-nitrokey.3"} fido-authenticator = { git = "https://github.com/Nitrokey/fido-authenticator.git", tag = "v0.1.1-nitrokey.16" } lpc55-hal = { git = "https://github.com/Nitrokey/lpc55-hal", tag = "v0.3.0-nitrokey.2" } diff --git a/components/apps/src/lib.rs b/components/apps/src/lib.rs index 4d7339ed..a60f9705 100644 --- a/components/apps/src/lib.rs +++ b/components/apps/src/lib.rs @@ -750,12 +750,13 @@ impl From for u8 { bitflags! { #[derive(Default, Clone, Copy)] pub struct InitStatus: u8 { - const NFC_ERROR = 0b00000001; + const NFC_ERROR = 0b00000001; const INTERNAL_FLASH_ERROR = 0b00000010; const EXTERNAL_FLASH_ERROR = 0b00000100; - const MIGRATION_ERROR = 0b00001000; - const SE050_ERROR = 0b00010000; - const CONFIG_ERROR = 0b00100000; + const MIGRATION_ERROR = 0b00001000; + const SE050_ERROR = 0b00010000; + const CONFIG_ERROR = 0b00100000; + const RNG_ERROR = 0b01000000; } } @@ -788,10 +789,23 @@ impl AdminData { } } -pub type AdminStatus = [u8; 5]; +pub struct AdminStatus { + init_status: InitStatus, + ifs_blocks: u8, + efs_blocks: u16, + variant: Variant, +} -impl AdminData { - fn status(&self) -> AdminStatus { +impl admin_app::StatusBytes for AdminStatus { + type Serialized = [u8; 5]; + fn set_random_error(&mut self, value: bool) { + self.init_status.set(InitStatus::RNG_ERROR, value); + } + fn get_random_error(&self) -> bool { + self.init_status.contains(InitStatus::RNG_ERROR) + } + + fn serialize(&self) -> [u8; 5] { let efs_blocks = self.efs_blocks.to_be_bytes(); [ self.init_status.bits(), @@ -803,6 +817,17 @@ impl AdminData { } } +impl AdminData { + fn status(&self) -> AdminStatus { + AdminStatus { + init_status: self.init_status, + ifs_blocks: self.ifs_blocks, + efs_blocks: self.efs_blocks, + variant: self.variant, + } + } +} + const ADMIN_APP_CLIENT_ID: &str = "admin"; impl App for AdminApp {