Rework GENERAL AUTHENTICATE implementation

This commit is contained in:
Sosthène Guédon
2023-02-16 10:49:00 +01:00
parent 16e3e24708
commit 7cca1f079f
5 changed files with 266 additions and 476 deletions
+252 -458
View File
File diff suppressed because it is too large Load Diff
+6 -6
View File
@@ -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
View File
@@ -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...!
+1 -1
View File
@@ -65,7 +65,7 @@
key: "0102030405060708 0102030405060708 0102030405060708 0102030405060708"
),
expected_status_challenge: IncorrectP1OrP2Parameter,
expected_status_response: ConditionsOfUseNotSatisfied,
expected_status_response: IncorrectP1OrP2Parameter,
)
]
),
+1 -1
View File
@@ -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() {