diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 0000000..6a75768 --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1,3 @@ +imports_granularity = "Crate" +format_code_in_doc_comments = true +group_imports = "StdExternalCrate" diff --git a/src/lib.rs b/src/lib.rs index 40258ed..aefd4d1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,15 +4,13 @@ mod transaction; use transaction::*; mod oath_credential; mod oath_credentialid; -use oath_credential::*; -use oath_credentialid::*; /// Utilities for interacting with YubiKey OATH/TOTP functionality -use std::{fmt::Display, time::Duration}; +use std::{fmt::Display, time::Duration, time::SystemTime}; use base64::{engine::general_purpose, Engine as _}; use hmac::{Hmac, Mac}; - -use std::time::SystemTime; +use oath_credential::*; +use oath_credentialid::*; fn _get_device_id(salt: Vec) -> String { let result = HashAlgo::Sha256.get_hash_fun()(salt.leak()); @@ -221,7 +219,8 @@ impl<'a> OathSession<'a> { )) } - /// Read the OATH codes from the device, calculate TOTP codes that don't need touch + /// Read the OATH codes from the device, calculate TOTP codes that don't + /// need touch pub fn calculate_oath_codes( &self, ) -> Result, FormattableErrorResponse> { @@ -242,8 +241,8 @@ impl<'a> OathSession<'a> { let id_data = CredentialIDData::from_tlv(cred_id.value(), meta.tag()); let code = OathCodeDisplay::from_tlv(meta); - /* println!("id bytes: {:?}", cred_id.value()); - println!("id recon: {:?}", id_data.format_cred_id()); */ + // println!("id bytes: {:?}", cred_id.value()); + // println!("id recon: {:?}", id_data.format_cred_id()); let cred = OathCredential { device_id: self.name.clone(), diff --git a/src/oath_credential.rs b/src/oath_credential.rs index 6344520..1712ef6 100644 --- a/src/oath_credential.rs +++ b/src/oath_credential.rs @@ -1,5 +1,7 @@ -use std::cmp::Ordering; -use std::hash::{Hash, Hasher}; +use std::{ + cmp::Ordering, + hash::{Hash, Hasher}, +}; use crate::CredentialIDData; diff --git a/src/oath_credentialid.rs b/src/oath_credentialid.rs index 63a7e56..ce98f48 100644 --- a/src/oath_credentialid.rs +++ b/src/oath_credentialid.rs @@ -1,7 +1,7 @@ -use regex::Regex; - use std::fmt::Display; +use regex::Regex; + use crate::{OathType, Tag, DEFAULT_PERIOD}; #[derive(Debug, Eq, PartialEq, Clone)] diff --git a/src/transaction.rs b/src/transaction.rs index 002b07f..41dffe4 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -1,14 +1,10 @@ -use iso7816_tlv::simple::{Tag as TlvTag, Tlv}; -use ouroboros::self_referencing; -use std::collections::HashMap; -use std::fmt::Display; +use std::{collections::HashMap, ffi::CString, fmt::Display}; use apdu_core::{Command, Response}; - +use iso7816_tlv::simple::{Tag as TlvTag, Tlv}; +use ouroboros::self_referencing; use pcsc::{Card, Transaction}; -use std::ffi::CString; - use crate::{ErrorResponse, Instruction, SuccessResponse, Tag}; #[derive(PartialEq, Eq, Debug)]