mirror of
https://github.com/trussed-dev/piv-authenticator.git
synced 2026-06-20 04:16:15 -07:00
Rework GENERAL AUTHENTICATE implementation
This commit is contained in:
+252
-458
File diff suppressed because it is too large
Load Diff
+6
-6
@@ -148,8 +148,8 @@ crate::container::enum_subset! {
|
||||
impl AsymmetricAlgorithms {
|
||||
pub fn key_mechanism(self) -> Mechanism {
|
||||
match self {
|
||||
Self::Rsa2048 => Mechanism::Rsa2048Pkcs1v15,
|
||||
Self::Rsa4096 => Mechanism::Rsa4096Pkcs1v15,
|
||||
Self::Rsa2048 => Mechanism::Rsa2048Raw,
|
||||
Self::Rsa4096 => Mechanism::Rsa4096Raw,
|
||||
Self::P256 => Mechanism::P256,
|
||||
}
|
||||
}
|
||||
@@ -165,8 +165,8 @@ impl AsymmetricAlgorithms {
|
||||
|
||||
pub fn sign_mechanism(self) -> Mechanism {
|
||||
match self {
|
||||
Self::Rsa2048 => Mechanism::Rsa2048Pkcs1v15,
|
||||
Self::Rsa4096 => Mechanism::Rsa4096Pkcs1v15,
|
||||
Self::Rsa2048 => Mechanism::Rsa2048Raw,
|
||||
Self::Rsa4096 => Mechanism::Rsa4096Raw,
|
||||
Self::P256 => Mechanism::P256Prehashed,
|
||||
}
|
||||
}
|
||||
@@ -202,8 +202,8 @@ crate::container::enum_subset! {
|
||||
impl RsaAlgorithms {
|
||||
pub fn mechanism(self) -> Mechanism {
|
||||
match self {
|
||||
Self::Rsa2048 => Mechanism::Rsa2048Pkcs1v15,
|
||||
Self::Rsa4096 => Mechanism::Rsa4096Pkcs1v15,
|
||||
Self::Rsa2048 => Mechanism::Rsa2048Raw,
|
||||
Self::Rsa4096 => Mechanism::Rsa4096Raw,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-10
@@ -269,17 +269,17 @@ impl Volatile {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn take_witness(&mut self) -> Option<Bytes<16>> {
|
||||
pub fn take_single_challenge(&mut self) -> Option<Bytes<16>> {
|
||||
match self.command_cache.take() {
|
||||
Some(CommandCache::WitnessChallenge(b)) => return Some(b),
|
||||
Some(CommandCache::SingleAuthChallenge(b)) => return Some(b),
|
||||
old => self.command_cache = old,
|
||||
};
|
||||
None
|
||||
}
|
||||
|
||||
pub fn take_challenge(&mut self) -> Option<Bytes<16>> {
|
||||
pub fn take_mutual_challenge(&mut self) -> Option<Bytes<16>> {
|
||||
match self.command_cache.take() {
|
||||
Some(CommandCache::AuthenticateChallenge(b)) => return Some(b),
|
||||
Some(CommandCache::MutualAuthChallenge(b)) => return Some(b),
|
||||
old => self.command_cache = old,
|
||||
};
|
||||
None
|
||||
@@ -301,14 +301,10 @@ pub struct AppSecurityStatus {
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub enum CommandCache {
|
||||
GetData(GetData),
|
||||
AuthenticateChallenge(Bytes<16>),
|
||||
WitnessChallenge(Bytes<16>),
|
||||
SingleAuthChallenge(Bytes<16>),
|
||||
MutualAuthChallenge(Bytes<16>),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct GetData {}
|
||||
|
||||
impl Persistent {
|
||||
pub const PIN_RETRIES_DEFAULT: u8 = 3;
|
||||
// hmm...!
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
key: "0102030405060708 0102030405060708 0102030405060708 0102030405060708"
|
||||
),
|
||||
expected_status_challenge: IncorrectP1OrP2Parameter,
|
||||
expected_status_response: ConditionsOfUseNotSatisfied,
|
||||
expected_status_response: IncorrectP1OrP2Parameter,
|
||||
)
|
||||
]
|
||||
),
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ fn admin_mutual() {
|
||||
});
|
||||
}
|
||||
|
||||
// I can't understand the error for this specific case, it may be comming from opensc and not us.
|
||||
/// Fails because of https://github.com/OpenSC/OpenSC/issues/2658
|
||||
#[test_log::test]
|
||||
#[ignore]
|
||||
fn admin_card() {
|
||||
|
||||
Reference in New Issue
Block a user