CCCID/CHUID refactoring
- Move generate methods to the appropriate static types - Remove redundant name prefixes (Rust [RFC#356]) [RFC#356]: https://github.com/rust-lang/rfcs/pull/356
This commit is contained in:
+10
-8
@@ -57,7 +57,16 @@ const CHUID_TMPL: &[u8] = &[
|
||||
|
||||
/// Cardholder Unique Identifier (CHUID) Card UUID/GUID value
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct ChuidUuid(pub [u8; YKPIV_CARDID_SIZE]);
|
||||
pub struct Uuid(pub [u8; YKPIV_CARDID_SIZE]);
|
||||
|
||||
impl Uuid {
|
||||
/// Generate a random Cardholder Unique Identifier (CHUID)
|
||||
pub fn generate() -> Result<Self, Error> {
|
||||
let mut id = [0u8; YKPIV_CARDID_SIZE];
|
||||
getrandom(&mut id).map_err(|_| Error::RandomnessError)?;
|
||||
Ok(Self(id))
|
||||
}
|
||||
}
|
||||
|
||||
/// Cardholder Unique Identifier (CHUID)
|
||||
#[derive(Copy, Clone)]
|
||||
@@ -87,13 +96,6 @@ impl CHUID {
|
||||
Ok(expiration)
|
||||
}
|
||||
|
||||
/// Generate a random Cardholder Unique Identifier (CHUID)
|
||||
pub fn generate() -> Result<ChuidUuid, Error> {
|
||||
let mut id = [0u8; YKPIV_CARDID_SIZE];
|
||||
getrandom(&mut id).map_err(|_| Error::RandomnessError)?;
|
||||
Ok(ChuidUuid(id))
|
||||
}
|
||||
|
||||
/// Get Cardholder Unique Identifier (CHUID)
|
||||
pub fn get(yubikey: &mut YubiKey) -> Result<CHUID, Error> {
|
||||
let txn = yubikey.begin_transaction()?;
|
||||
|
||||
Reference in New Issue
Block a user