Fix build and clippy warnings (#433)

This commit is contained in:
Tony Arcieri (iqlusion)
2022-11-12 14:15:42 -07:00
committed by GitHub
parent 87ed7b2338
commit 4310cc0f9a
8 changed files with 19 additions and 21 deletions
+1 -1
View File
@@ -97,7 +97,7 @@ impl Serial {
}
/// Information about how a [`Certificate`] is stored within a YubiKey.
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum CertInfo {
/// The certificate is uncompressed.
Uncompressed,
+1 -1
View File
@@ -404,7 +404,7 @@ fn is_weak_key(key: &[u8; DES_LEN_3DES]) -> bool {
c = (c & 0x0F) + ((c >> 4) & 0x0F);
// if count is even, set low key bit to 1, otherwise 0
tmp[i] = (key[i] & 0xFE) | (if c & 0x01 == 0x01 { 0x00 } else { 0x01 });
tmp[i] = (key[i] & 0xFE) | u8::from(c & 0x01 != 0x01);
}
// check odd parity key against table by DES key block
+4 -4
View File
@@ -143,7 +143,7 @@ impl TryFrom<u8> for SlotId {
0xf9 => Ok(SlotId::Attestation),
_ => RetiredSlotId::try_from(value)
.map(SlotId::Retired)
.or(ManagementSlotId::try_from(value).map(SlotId::Management)),
.or_else(|_| ManagementSlotId::try_from(value).map(SlotId::Management)),
}
}
}
@@ -185,7 +185,7 @@ impl FromStr for SlotId {
_ => s
.parse()
.map(SlotId::Management)
.or(s.parse().map(SlotId::Retired)),
.or_else(|_| s.parse().map(SlotId::Retired)),
}
}
}
@@ -354,7 +354,7 @@ impl RetiredSlotId {
/// Management slot IDs.
#[allow(missing_docs)]
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Ord, PartialOrd)]
pub enum ManagementSlotId {
PIN,
PUK,
@@ -670,7 +670,7 @@ pub fn generate(
}
}
let value = &response.data()[..];
let value = response.data();
read_public_key(algorithm, value, true)
}
+2 -2
View File
@@ -6,7 +6,7 @@ use crate::{serialization::Tlv, Error, Result};
/// given slot.
///
/// This policy must be set when keys are generated or imported, and cannot be changed later.
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum PinPolicy {
/// Use the default PIN policy for the slot. See the slot's documentation for details.
Default,
@@ -64,7 +64,7 @@ impl PinPolicy {
/// addition to the [`PinPolicy`].
///
/// This policy must be set when keys are generated or imported, and cannot be changed later.
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum TouchPolicy {
/// Use the default touch policy for the slot.
Default,
+4 -4
View File
@@ -69,7 +69,7 @@ impl<'tx> Transaction<'tx> {
pub fn select_application(&self) -> Result<()> {
let response = Apdu::new(Ins::SelectApplication)
.p1(0x04)
.data(&PIV_AID)
.data(PIV_AID)
.transmit(self, 0xFF)
.map_err(|e| {
error!("failed communicating with card: '{}'", e);
@@ -109,7 +109,7 @@ impl<'tx> Transaction<'tx> {
// YK4 requires switching to the yk applet to retrieve the serial
let sw = Apdu::new(Ins::SelectApplication)
.p1(0x04)
.data(&YK_AID)
.data(YK_AID)
.transmit(self, 0xFF)?
.status_words();
@@ -131,7 +131,7 @@ impl<'tx> Transaction<'tx> {
// reselect the PIV applet
let sw = Apdu::new(Ins::SelectApplication)
.p1(0x04)
.data(&PIV_AID)
.data(PIV_AID)
.transmit(self, 0xFF)?
.status_words();
@@ -246,7 +246,7 @@ impl<'tx> Transaction<'tx> {
let status_words = Apdu::new(Ins::SetMgmKey)
.params(0xff, p2)
.data(&data)
.data(data)
.transmit(self, 261)?
.status_words();
+4 -4
View File
@@ -285,7 +285,7 @@ impl YubiKey {
// get a challenge from the card
let challenge = Apdu::new(Ins::Authenticate)
.params(ALGO_3DES, KEY_CARDMGM)
.data(&[TAG_DYN_AUTH, 0x02, 0x80, 0x00])
.data([TAG_DYN_AUTH, 0x02, 0x80, 0x00])
.transmit(&txn, 261)?;
if !challenge.is_success() || challenge.data().len() < 12 {
@@ -310,7 +310,7 @@ impl YubiKey {
let authentication = Apdu::new(Ins::Authenticate)
.params(ALGO_3DES, KEY_CARDMGM)
.data(&data)
.data(data)
.transmit(&txn, 261)?;
if !authentication.is_success() {
@@ -568,7 +568,7 @@ impl YubiKey {
let response = Apdu::new(Ins::Authenticate)
.params(ALGO_3DES, KEY_CARDMGM)
.data(&[0x7c, 0x02, 0x81, 0x00])
.data([0x7c, 0x02, 0x81, 0x00])
.transmit(&txn, 261)?;
if !response.is_success() {
@@ -594,7 +594,7 @@ impl YubiKey {
// send the response to the card and a challenge of our own.
let status_words = Apdu::new(Ins::Authenticate)
.params(ALGO_3DES, KEY_CARDMGM)
.data(&data)
.data(data)
.transmit(&txn, 261)?
.status_words();