mirror of
https://github.com/LordGrimmauld/yubi-oath-rs.git
synced 2025-03-03 21:34:40 +01:00
get rid of strum dependency
the enums are small enough, could find a better to rewrite the code later on as well
This commit is contained in:
parent
11533edc88
commit
26fc4f1aae
3 changed files with 25 additions and 50 deletions
35
Cargo.lock
generated
35
Cargo.lock
generated
|
@ -96,12 +96,6 @@ version = "0.4.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "hmac"
|
||||
version = "0.12.1"
|
||||
|
@ -134,8 +128,6 @@ dependencies = [
|
|||
"regex",
|
||||
"sha1",
|
||||
"sha2",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -167,7 +159,7 @@ version = "0.18.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c7028bdd3d43083f6d8d4d5187680d0d3560d54df4cc9d752005268b41e64d0"
|
||||
dependencies = [
|
||||
"heck 0.4.1",
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"proc-macro2-diagnostics",
|
||||
"quote",
|
||||
|
@ -270,12 +262,6 @@ version = "0.8.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4"
|
||||
|
||||
[[package]]
|
||||
name = "sha1"
|
||||
version = "0.10.6"
|
||||
|
@ -304,25 +290,6 @@ version = "1.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[package]]
|
||||
name = "strum"
|
||||
version = "0.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce1475c515a4f03a8a7129bb5228b81a781a86cb0b3fbbc19e1c556d491a401f"
|
||||
|
||||
[[package]]
|
||||
name = "strum_macros"
|
||||
version = "0.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9688894b43459159c82bfa5a5fa0435c19cbe3c9b427fa1dd7b1ce0c279b18a7"
|
||||
dependencies = [
|
||||
"heck 0.5.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rustversion",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "subtle"
|
||||
version = "2.6.1"
|
||||
|
|
|
@ -9,8 +9,6 @@ pcsc = "2.9.0"
|
|||
regex = "1.11.1"
|
||||
sha1 = "0.10.6"
|
||||
sha2 = "0.10.8"
|
||||
strum = { version = "0.27.0", features = [ ] }
|
||||
strum_macros = "0.27.0"
|
||||
|
||||
[package]
|
||||
name = "lib_ykoath2"
|
||||
|
|
|
@ -2,8 +2,6 @@ use std::fmt::Display;
|
|||
|
||||
use iso7816_tlv::simple::Tlv;
|
||||
use sha1::Digest;
|
||||
use strum::IntoEnumIterator; // 0.17.1
|
||||
use strum_macros::EnumIter; // 0.17.1
|
||||
pub const INS_SELECT: u8 = 0xa4;
|
||||
pub const OATH_AID: [u8; 7] = [0xa0, 0x00, 0x00, 0x05, 0x27, 0x21, 0x01];
|
||||
|
||||
|
@ -11,7 +9,7 @@ pub const DEFAULT_PERIOD: u32 = 30;
|
|||
pub const DEFAULT_DIGITS: OathDigits = OathDigits::Six;
|
||||
pub const DEFAULT_IMF: u32 = 0;
|
||||
|
||||
#[derive(Debug, EnumIter, Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u16)]
|
||||
pub enum ErrorResponse {
|
||||
NoSpace = 0x6a84,
|
||||
|
@ -25,12 +23,23 @@ pub enum ErrorResponse {
|
|||
|
||||
impl ErrorResponse {
|
||||
pub fn any_match(code: u16) -> Option<ErrorResponse> {
|
||||
for resp in ErrorResponse::iter() {
|
||||
if code == resp as u16 {
|
||||
return Some(resp);
|
||||
}
|
||||
if code == ErrorResponse::NoSpace as u16 {
|
||||
Some(ErrorResponse::NoSpace)
|
||||
} else if code == ErrorResponse::CommandAborted as u16 {
|
||||
Some(ErrorResponse::CommandAborted)
|
||||
} else if code == ErrorResponse::InvalidInstruction as u16 {
|
||||
Some(ErrorResponse::InvalidInstruction)
|
||||
} else if code == ErrorResponse::AuthRequired as u16 {
|
||||
Some(ErrorResponse::AuthRequired)
|
||||
} else if code == ErrorResponse::WrongSyntax as u16 {
|
||||
Some(ErrorResponse::WrongSyntax)
|
||||
} else if code == ErrorResponse::GenericError as u16 {
|
||||
Some(ErrorResponse::GenericError)
|
||||
} else if code == ErrorResponse::NoSuchObject as u16 {
|
||||
Some(ErrorResponse::NoSuchObject)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +59,7 @@ impl std::fmt::Display for ErrorResponse {
|
|||
|
||||
impl std::error::Error for ErrorResponse {}
|
||||
|
||||
#[derive(Debug, EnumIter, Clone, Copy)]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[repr(u16)]
|
||||
pub enum SuccessResponse {
|
||||
MoreData = 0x61,
|
||||
|
@ -59,12 +68,13 @@ pub enum SuccessResponse {
|
|||
|
||||
impl SuccessResponse {
|
||||
pub fn any_match(code: u16) -> Option<SuccessResponse> {
|
||||
for resp in SuccessResponse::iter() {
|
||||
if code == resp as u16 {
|
||||
return Some(resp);
|
||||
}
|
||||
if code == SuccessResponse::MoreData as u16 {
|
||||
Some(SuccessResponse::MoreData)
|
||||
} else if code == SuccessResponse::Okay as u16 {
|
||||
Some(SuccessResponse::Okay)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue