Skip to content

Commit

Permalink
Make admin-app optional
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey committed Nov 17, 2023
1 parent 977729b commit ee932c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ trussed-staging = { version = "0.1.0", features = ["wrap-key-to-file", "chunked"
serde_repr = "0.1"
hex-literal = "0.4.1"
trussed-auth = "0.2.1"
admin-app = "0.1.0"
admin-app = { version = "0.1.0", optional = true }

# optional dependencies
apdu-dispatch = { version = "0.1", optional = true }
Expand Down
7 changes: 7 additions & 0 deletions src/card.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (C) 2022 Nitrokey GmbH
// SPDX-License-Identifier: LGPL-3.0-only

#[cfg(feature = "admin-app")]
use admin_app::{ResetSignal, ResetSignalAllocation};
use hex_literal::hex;
use iso7816::Status;
Expand Down Expand Up @@ -52,6 +53,7 @@ impl<T: Client> Card<T> {
command: &iso7816::Command<C>,
reply: &mut heapless::Vec<u8, R>,
) -> Result<(), Status> {
#[cfg(feature = "admin-app")]
if let Some(reset_signal) = self.options.reset_signal {
match reset_signal.load() {
ResetSignal::None => {}
Expand Down Expand Up @@ -82,6 +84,7 @@ impl<T: Client> Card<T> {

/// Resets the state of the card.
pub fn reset(&mut self) {
#[cfg(feature = "admin-app")]
if let Some(reset_signal) = self.options.reset_signal {
match reset_signal.load() {
ResetSignal::None => {}
Expand Down Expand Up @@ -167,6 +170,9 @@ pub struct Options {
pub storage: Location,

/// Flag to signal that the application has had its configuration changed or was factory-resetted by the admin application
///
/// Requires the feature-flag admin-app
#[cfg(feature = "admin-app")]
pub reset_signal: Option<&'static ResetSignalAllocation>,
}

Expand Down Expand Up @@ -206,6 +212,7 @@ impl Default for Options {
historical_bytes: heapless::Vec::from_slice(&hex!("0031F573C00160009000")).unwrap(),
button_available: true,
storage: Location::External,
#[cfg(feature = "admin-app")]
reset_signal: None,
}
}
Expand Down

0 comments on commit ee932c0

Please sign in to comment.