Skip to content

Commit

Permalink
Applets management
Browse files Browse the repository at this point in the history
  • Loading branch information
baloo committed Apr 9, 2024
1 parent 0a90dc3 commit 1515dac
Show file tree
Hide file tree
Showing 8 changed files with 567 additions and 54 deletions.
7 changes: 4 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ members = [".", "cli"]
x509-cert = { version = "0.2.5", features = [ "builder", "hazmat" ] }

[dependencies]
bitflags = "2.5.0"
der = "0.7.1"
des = "0.8"
elliptic-curve = "0.13"
Expand Down
20 changes: 20 additions & 0 deletions src/apdu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,15 @@ pub enum Ins {
/// Get slot metadata
GetMetadata,

/// Management // Read Config
ReadConfig,

/// Management // Write Config
WriteConfig,

/// Management // DeviceReset
DeviceReset,

/// Other/unrecognized instruction codes
Other(u8),
}
Expand All @@ -223,6 +232,12 @@ impl Ins {
Ins::Attest => 0xf9,
Ins::GetSerial => 0xf8,
Ins::GetMetadata => 0xf7,

// Management
Ins::ReadConfig => 0x1d,
Ins::WriteConfig => 0x1c,
Ins::DeviceReset => 0x1f,

Ins::Other(code) => code,
}
}
Expand All @@ -231,6 +246,11 @@ impl Ins {
impl From<u8> for Ins {
fn from(code: u8) -> Self {
match code {
// Management
0x1d => Ins::ReadConfig,
0x1c => Ins::WriteConfig,
0x1f => Ins::DeviceReset,

0x20 => Ins::Verify,
0x24 => Ins::ChangeReference,
0x2c => Ins::ResetRetry,
Expand Down
17 changes: 17 additions & 0 deletions src/consts.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(dead_code)]
//! Miscellaneous constant values

/// YubiKey max buffer size
Expand All @@ -18,3 +19,19 @@ pub(crate) const TAG_ADMIN_TIMESTAMP: u8 = 0x83;
// Protected tags
pub(crate) const TAG_PROTECTED_FLAGS_1: u8 = 0x81;
pub(crate) const TAG_PROTECTED_MGM: u8 = 0x89;

// Management
pub(crate) const TAG_USB_SUPPORTED: u8 = 0x01;
pub(crate) const TAG_SERIAL: u8 = 0x02;
pub(crate) const TAG_USB_ENABLED: u8 = 0x03;
pub(crate) const TAG_FORM_FACTOR: u8 = 0x04;
pub(crate) const TAG_VERSION: u8 = 0x05;
pub(crate) const TAG_AUTO_EJECT_TIMEOUT: u8 = 0x06;
pub(crate) const TAG_CHALRESP_TIMEOUT: u8 = 0x07;
pub(crate) const TAG_DEVICE_FLAGS: u8 = 0x08;
pub(crate) const TAG_APP_VERSIONS: u8 = 0x09;
pub(crate) const TAG_CONFIG_LOCK: u8 = 0x0A;
pub(crate) const TAG_UNLOCK: u8 = 0x0B;
pub(crate) const TAG_REBOOT: u8 = 0x0C;
pub(crate) const TAG_NFC_SUPPORTED: u8 = 0x0D;
pub(crate) const TAG_NFC_ENABLED: u8 = 0x0E;
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ mod config;
mod consts;
mod error;
mod metadata;
mod mgm;
pub mod mgm;
#[cfg(feature = "untested")]
mod mscmap;
#[cfg(feature = "untested")]
Expand Down
Loading

0 comments on commit 1515dac

Please sign in to comment.