diff --git a/src/cccid.rs b/src/cccid.rs index bea6e72..3a6e3e3 100644 --- a/src/cccid.rs +++ b/src/cccid.rs @@ -33,6 +33,7 @@ use crate::{Error, Result, YubiKey}; use rand_core::{OsRng, RngCore}; use std::{ + convert::TryInto, fmt::{self, Debug, Display}, str, }; @@ -99,13 +100,12 @@ impl Ccc { return Err(Error::GenericError); } - let mut ccc = [0u8; Self::BYTE_SIZE]; - ccc.copy_from_slice(&response[0..Self::BYTE_SIZE]); - Ok(Self(ccc)) + Ok(Self(response[..Self::BYTE_SIZE].try_into().unwrap())) } /// Set Cardholder Capability Container (CCC) ID #[cfg(feature = "untested")] + #[cfg_attr(docsrs, doc(cfg(feature = "untested")))] pub fn set(&self, yubikey: &mut YubiKey) -> Result<()> { let mut buf = CCC_TMPL.to_vec(); buf[0..self.0.len()].copy_from_slice(&self.0); @@ -117,6 +117,6 @@ impl Ccc { impl Display for Ccc { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", str::from_utf8(&hex::encode(&self.0[..])).unwrap()) + f.write_str(str::from_utf8(&hex::encode(&self.0[..])).unwrap()) } } diff --git a/src/certificate.rs b/src/certificate.rs index 31b228a..3dbfc88 100644 --- a/src/certificate.rs +++ b/src/certificate.rs @@ -472,6 +472,7 @@ impl Certificate { /// Delete a certificate located at the given slot of the given YubiKey #[cfg(feature = "untested")] + #[cfg_attr(docsrs, doc(cfg(feature = "untested")))] pub fn delete(yubikey: &mut YubiKey, slot: SlotId) -> Result<()> { let txn = yubikey.begin_transaction()?; write_certificate(&txn, slot, None, CertInfo::Uncompressed) diff --git a/src/chuid.rs b/src/chuid.rs index 22f65ff..9baf7cb 100644 --- a/src/chuid.rs +++ b/src/chuid.rs @@ -133,6 +133,6 @@ impl ChuId { impl Display for ChuId { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", str::from_utf8(&hex::encode(&self.0[..])).unwrap()) + f.write_str(str::from_utf8(&hex::encode(&self.0[..])).unwrap()) } } diff --git a/src/lib.rs b/src/lib.rs index 7797d20..4fa8b6c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,10 +33,12 @@ //! # Supported Algorithms //! //! - **Authentication**: `3DES` -//! - **Encryption**: `RSA1024`, `RSA2048`, `ECCP256`, `ECCP384` +//! - **Encryption**: +//! - RSA: `RSA1024`, `RSA2048` +//! - ECC: `ECCP256`, `ECCP384` (NIST curves: P-256, P-384) //! - **Signatures**: //! - RSASSA-PKCS#1v1.5: `RSA1024`, `RSA2048` -//! - ECDSA: `ECCP256`, `ECCP384` +//! - ECDSA: `ECCP256`, `ECCP384` (NIST curves: P-256, P-384) //! //! NOTE: RSASSA-PSS signatures and RSA-OAEP encryption may be supportable (TBD) //! @@ -47,7 +49,9 @@ //! Any functionality which is gated on the `untested` feature has not been //! properly tested and is not known to function correctly. //! -//! If +//! Please see the [`untested` functionality tracking issue] for current status. +//! We would appreciate any help testing this functionality and removing the +//! `untested` gating as well as writing more automated tests. //! //! # History //! @@ -91,6 +95,7 @@ //! [YubiKey NEO]: https://support.yubico.com/support/solutions/articles/15000006494-yubikey-neo //! [YubiKey 4]: https://support.yubico.com/support/solutions/articles/15000006486-yubikey-4 //! [YubiKey 5]: https://www.yubico.com/products/yubikey-5-overview/ +//! [`untested` functionality tracking issue]: https://github.com/iqlusioninc/yubikey.rs/issues/280 //! [yubico-piv-tool]: https://github.com/Yubico/yubico-piv-tool/ //! [Corrode]: https://github.com/jameysharp/corrode //! [piv-tool-guide]: https://www.yubico.com/wp-content/uploads/2016/05/Yubico_PIV_Tool_Command_Line_Guide_en.pdf @@ -158,6 +163,7 @@ mod yubikey; pub use crate::{ cccid::{CardId, Ccc}, + certificate::Certificate, chuid::ChuId, config::Config, error::{Error, Result}, diff --git a/src/metadata.rs b/src/metadata.rs index 9415cb6..07e3bcb 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -88,6 +88,7 @@ impl Metadata { /// Write metadata #[cfg(feature = "untested")] + #[cfg_attr(docsrs, doc(cfg(feature = "untested")))] pub(crate) fn write(&self, txn: &Transaction<'_>) -> Result<()> { if self.inner.len() > CB_OBJ_MAX - CB_OBJ_TAG_MAX { return Err(Error::GenericError); @@ -105,6 +106,7 @@ impl Metadata { /// Delete metadata #[cfg(feature = "untested")] + #[cfg_attr(docsrs, doc(cfg(feature = "untested")))] pub(crate) fn delete(txn: &Transaction<'_>) -> Result<()> { txn.save_object(T::obj_id(), &[]) } @@ -128,6 +130,7 @@ impl Metadata { /// Set metadata item #[cfg(feature = "untested")] + #[cfg_attr(docsrs, doc(cfg(feature = "untested")))] pub(crate) fn set_item(&mut self, tag: u8, item: &[u8]) -> Result<()> { let mut cb_temp: usize = 0; let mut tag_temp: u8 = 0; diff --git a/src/mgm.rs b/src/mgm.rs index 0c4aca6..6d1b404 100644 --- a/src/mgm.rs +++ b/src/mgm.rs @@ -325,7 +325,6 @@ impl MgmKey { } /// Encrypt with 3DES key - #[allow(clippy::trivially_copy_pass_by_ref)] pub(crate) fn encrypt(&self, input: &[u8; DES_LEN_DES]) -> [u8; DES_LEN_DES] { let mut output = input.to_owned(); TdesEde3::new(GenericArray::from_slice(&self.0)) @@ -334,7 +333,6 @@ impl MgmKey { } /// Decrypt with 3DES key - #[allow(clippy::trivially_copy_pass_by_ref)] pub(crate) fn decrypt(&self, input: &[u8; DES_LEN_DES]) -> [u8; DES_LEN_DES] { let mut output = input.to_owned(); TdesEde3::new(GenericArray::from_slice(&self.0)) diff --git a/src/piv.rs b/src/piv.rs index dcd226b..f074c2c 100644 --- a/src/piv.rs +++ b/src/piv.rs @@ -7,7 +7,7 @@ //! //! - **Encryption**: //! - RSA: `RSA1024`, `RSA2048` -//! - ECC: `ECCP256`, `ECCP384` (i.e. NIST curves: P-256, P-384) +//! - ECC: `ECCP256`, `ECCP384` (NIST curves: P-256, P-384) //! - **Signatures**: //! - RSASSA-PKCS#1v1.5: `RSA1024`, `RSA2048` //! - ECDSA: `ECCP256`, `ECCP384` (NIST curves: P-256, P-384) diff --git a/src/yubikey.rs b/src/yubikey.rs index 8231e2c..c257035 100644 --- a/src/yubikey.rs +++ b/src/yubikey.rs @@ -94,7 +94,7 @@ impl FromStr for Serial { type Err = Error; fn from_str(s: &str) -> Result { - u32::from_str(s).map(Serial).map_err(|_| Error::ParseError) + s.parse().map(Serial).map_err(|_| Error::ParseError) } }