Introduce a trait to abstract the CTAP environment

The end goal is to provide users with:
- the Env trait that they should implement
- the Ctap struct that they can use
This commit is contained in:
Julien Cretin
2022-03-02 13:50:08 +01:00
committed by Julien Cretin
parent 8a2e99960f
commit 18faf9f38f
10 changed files with 611 additions and 481 deletions

18
src/env/mod.rs vendored Normal file
View File

@@ -0,0 +1,18 @@
use crate::ctap::hid::ChannelID;
use crate::ctap::status_code::Ctap2StatusCode;
use crypto::rng256::Rng256;
#[cfg(feature = "std")]
pub mod test;
pub trait UserPresence {
fn check(&self, cid: ChannelID) -> Result<(), Ctap2StatusCode>;
}
pub trait Env {
type Rng: Rng256;
type UserPresence: UserPresence;
fn rng(&mut self) -> &mut Self::Rng;
fn user_presence(&mut self) -> &mut Self::UserPresence;
}