Implement get_firmware_version (probably YubiKey specific)

This commit is contained in:
Heiko Schaefer 2021-11-23 19:52:06 +01:00
parent 9930e7d420
commit 9de79477b9
No known key found for this signature in database
GPG key ID: 4A849A1904CCBD7D
4 changed files with 31 additions and 1 deletions

View file

@ -267,6 +267,11 @@ impl<'a> Open<'a> {
self.card_app.get_algo_info() self.card_app.get_algo_info()
} }
/// Firmware Version, YubiKey specific (?)
pub fn firmware_version(&mut self) -> Result<Vec<u8>> {
self.card_app.get_firmware_version()
}
// ---------- // ----------
pub fn get_pub_key( pub fn get_pub_key(

View file

@ -66,6 +66,11 @@ pub(crate) fn get_algo_list() -> Command {
get_data(&[0xFA]) get_data(&[0xFA])
} }
/// GET Firmware Version (yubikey specific?)
pub(crate) fn get_firmware_version() -> Command {
Command::new(0x00, 0xF1, 0x00, 0x00, vec![])
}
/// GET RESPONSE /// GET RESPONSE
pub(crate) fn get_response() -> Command { pub(crate) fn get_response() -> Command {
Command::new(0x00, 0xC0, 0x00, 0x00, vec![]) Command::new(0x00, 0xC0, 0x00, 0x00, vec![])

View file

@ -233,6 +233,17 @@ impl CardApp {
Ok(Some(ai)) Ok(Some(ai))
} }
/// Firmware Version (YubiKey specific (?))
pub fn get_firmware_version(&mut self) -> Result<Vec<u8>> {
let resp = apdu::send_command(
self.card_client(),
commands::get_firmware_version(),
true,
)?;
Ok(resp.data()?.into())
}
/// SELECT DATA "select a DO in the current template" /// SELECT DATA "select a DO in the current template"
/// (e.g. for cardholder certificate) /// (e.g. for cardholder certificate)
pub fn select_data( pub fn select_data(

View file

@ -283,11 +283,20 @@ fn print_status(ident: Option<String>, verbose: bool) -> Result<()> {
// FIXME: add General key info; login data; KDF setting // FIXME: add General key info; login data; KDF setting
if verbose { if verbose {
if let Some(ai) = open.algorithm_information()? { // Algorithm information (list of supported algorithms)
if let Ok(Some(ai)) = open.algorithm_information() {
println!(); println!();
println!("Supported algorithms:"); println!("Supported algorithms:");
println!("{}", ai); println!("{}", ai);
} }
// YubiKey specific (?) firmware version
if let Ok(ver) = open.firmware_version() {
let ver =
ver.iter().map(u8::to_string).collect::<Vec<_>>().join(".");
println!("Firmware Version: {}", ver);
}
} }
Ok(()) Ok(())