transaction: comment cleanup in get_serial (#467)
Moves comments about each YubiKey version number above the arms of the `match` expression
This commit is contained in:
committed by
GitHub
parent
f49c617a9d
commit
0c2633ab31
@@ -172,7 +172,7 @@ Yubico's [yubico-piv-tool], a C library/CLI program. The original library
|
|||||||
was licensed under a [2-Clause BSD License][BSDL], which this library inherits
|
was licensed under a [2-Clause BSD License][BSDL], which this library inherits
|
||||||
as a derived work.
|
as a derived work.
|
||||||
|
|
||||||
Copyright (c) 2014-2022 Yubico AB, Tony Arcieri
|
Copyright (c) 2014-2023 Yubico AB, Tony Arcieri
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|||||||
+1
-1
@@ -43,7 +43,7 @@ For more information, please see [CODE_OF_CONDUCT.md][cc-md].
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Copyright (c) 2014-2022 Yubico AB, Tony Arcieri
|
Copyright (c) 2014-2023 Yubico AB, Tony Arcieri
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|||||||
+6
-2
@@ -106,8 +106,8 @@ impl<'tx> Transaction<'tx> {
|
|||||||
/// Get YubiKey device serial number.
|
/// Get YubiKey device serial number.
|
||||||
pub fn get_serial(&self, version: Version) -> Result<Serial> {
|
pub fn get_serial(&self, version: Version) -> Result<Serial> {
|
||||||
match version.major {
|
match version.major {
|
||||||
|
// YK4 requires switching to the YK applet to retrieve the serial
|
||||||
4 => {
|
4 => {
|
||||||
// YK4 requires switching to the yk applet to retrieve the serial
|
|
||||||
let sw = Apdu::new(Ins::SelectApplication)
|
let sw = Apdu::new(Ins::SelectApplication)
|
||||||
.p1(0x04)
|
.p1(0x04)
|
||||||
.data(YK_AID)
|
.data(YK_AID)
|
||||||
@@ -122,6 +122,7 @@ impl<'tx> Transaction<'tx> {
|
|||||||
let response = Apdu::new(0x01).p1(0x10).transmit(self, 0xFF)?;
|
let response = Apdu::new(0x01).p1(0x10).transmit(self, 0xFF)?;
|
||||||
|
|
||||||
if !response.is_success() {
|
if !response.is_success() {
|
||||||
|
// TODO(tarcieri): still reselect the PIV applet in this case?
|
||||||
error!(
|
error!(
|
||||||
"failed retrieving serial number: {:04x}",
|
"failed retrieving serial number: {:04x}",
|
||||||
response.status_words().code()
|
response.status_words().code()
|
||||||
@@ -143,8 +144,9 @@ impl<'tx> Transaction<'tx> {
|
|||||||
|
|
||||||
response.data().try_into()
|
response.data().try_into()
|
||||||
}
|
}
|
||||||
5 => {
|
|
||||||
// YK5 implements getting the serial as a PIV applet command (0xf8)
|
// YK5 implements getting the serial as a PIV applet command (0xf8)
|
||||||
|
5 => {
|
||||||
let response = Apdu::new(Ins::GetSerial).transmit(self, 0xFF)?;
|
let response = Apdu::new(Ins::GetSerial).transmit(self, 0xFF)?;
|
||||||
|
|
||||||
if !response.is_success() {
|
if !response.is_success() {
|
||||||
@@ -157,6 +159,8 @@ impl<'tx> Transaction<'tx> {
|
|||||||
|
|
||||||
response.data().try_into()
|
response.data().try_into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Other versions unsupported
|
||||||
_ => Err(Error::NotSupported),
|
_ => Err(Error::NotSupported),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user