Handle reference data not found in metadata command (#558)
This commit is contained in:
@@ -421,6 +421,9 @@ pub(crate) enum StatusWords {
|
||||
/// Not enough memory
|
||||
NoSpaceError,
|
||||
|
||||
/// Referenced data or reference data not found
|
||||
ReferenceDataNotFoundError,
|
||||
|
||||
//
|
||||
// Custom Yubico Status Word extensions
|
||||
//
|
||||
@@ -454,6 +457,7 @@ impl StatusWords {
|
||||
StatusWords::IncorrectParamError => 0x6a80,
|
||||
StatusWords::NotFoundError => 0x6a82,
|
||||
StatusWords::NoSpaceError => 0x6a84,
|
||||
StatusWords::ReferenceDataNotFoundError => 0x6a88,
|
||||
StatusWords::IncorrectSlotError => 0x6b00,
|
||||
StatusWords::NotSupportedError => 0x6d00,
|
||||
StatusWords::CommandAbortedError => 0x6f00,
|
||||
@@ -488,6 +492,7 @@ impl From<u16> for StatusWords {
|
||||
0x6a80 => StatusWords::IncorrectParamError,
|
||||
0x6a82 => StatusWords::NotFoundError,
|
||||
0x6a84 => StatusWords::NoSpaceError,
|
||||
0x6a88 => StatusWords::ReferenceDataNotFoundError,
|
||||
0x6b00 => StatusWords::IncorrectSlotError,
|
||||
0x6d00 => StatusWords::NotSupportedError,
|
||||
0x6f00 => StatusWords::CommandAbortedError,
|
||||
|
||||
+8
-9
@@ -163,17 +163,16 @@ impl<'tx> Transaction<'tx> {
|
||||
.p2(slot.into())
|
||||
.transmit(self, CB_OBJ_MAX)?;
|
||||
|
||||
if !response.is_success() {
|
||||
if response.status_words() == StatusWords::NotSupportedError {
|
||||
return Err(Error::NotSupported); // Requires firmware 5.2.3
|
||||
} else {
|
||||
return Err(Error::GenericError);
|
||||
match response.status_words() {
|
||||
StatusWords::Success => {
|
||||
let buf = Buffer::new(response.data().into());
|
||||
piv::SlotMetadata::try_from(buf)
|
||||
}
|
||||
StatusWords::ReferenceDataNotFoundError => Err(Error::NotFound),
|
||||
// Requires firmware 5.2.3
|
||||
StatusWords::NotSupportedError => Err(Error::NotSupported),
|
||||
_ => Err(Error::GenericError),
|
||||
}
|
||||
|
||||
let buf = Buffer::new(response.data().into());
|
||||
|
||||
piv::SlotMetadata::try_from(buf)
|
||||
}
|
||||
|
||||
/// Verify device PIN.
|
||||
|
||||
Reference in New Issue
Block a user