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:
Tony Arcieri (iqlusion)
2023-01-07 14:35:52 -07:00
committed by GitHub
parent f49c617a9d
commit 0c2633ab31
3 changed files with 8 additions and 4 deletions
+1 -1
View File
@@ -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
as a derived work.
Copyright (c) 2014-2022 Yubico AB, Tony Arcieri
Copyright (c) 2014-2023 Yubico AB, Tony Arcieri
All rights reserved.
Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -43,7 +43,7 @@ For more information, please see [CODE_OF_CONDUCT.md][cc-md].
## License
Copyright (c) 2014-2022 Yubico AB, Tony Arcieri
Copyright (c) 2014-2023 Yubico AB, Tony Arcieri
All rights reserved.
Redistribution and use in source and binary forms, with or without
+6 -2
View File
@@ -106,8 +106,8 @@ impl<'tx> Transaction<'tx> {
/// Get YubiKey device serial number.
pub fn get_serial(&self, version: Version) -> Result<Serial> {
match version.major {
// YK4 requires switching to the YK applet to retrieve the serial
4 => {
// YK4 requires switching to the yk applet to retrieve the serial
let sw = Apdu::new(Ins::SelectApplication)
.p1(0x04)
.data(YK_AID)
@@ -122,6 +122,7 @@ impl<'tx> Transaction<'tx> {
let response = Apdu::new(0x01).p1(0x10).transmit(self, 0xFF)?;
if !response.is_success() {
// TODO(tarcieri): still reselect the PIV applet in this case?
error!(
"failed retrieving serial number: {:04x}",
response.status_words().code()
@@ -143,8 +144,9 @@ impl<'tx> Transaction<'tx> {
response.data().try_into()
}
// YK5 implements getting the serial as a PIV applet command (0xf8)
5 => {
// YK5 implements getting the serial as a PIV applet command (0xf8)
let response = Apdu::new(Ins::GetSerial).transmit(self, 0xFF)?;
if !response.is_success() {
@@ -157,6 +159,8 @@ impl<'tx> Transaction<'tx> {
response.data().try_into()
}
// Other versions unsupported
_ => Err(Error::NotSupported),
}
}