Open Fethbita opened 5 months ago
I think you can create a trait like:
pub trait MrtdCard {
/// Returns answer to reset
fn atr(&self) -> Result<Vec<u8>>
/// Returns R-APDU including 2 bytes SW
fn transmit(&self, c_apdu: &[u8]) -> Result<Vec<u8>>
}
so that your wrapper takes a generic param:
pub struct EmrtdComms<C: MrtdCard> {
// ...
}
impl<C: MrtdCard> EmrtdComms<C> {
// ...
}
Using test vectors and by mocking the
send
orcard.transmit
functions, unit tests for functions that call thesend
function can be written. However mocking apcsc::Card
proved to be difficult, an issue is created inpcsc
GitHub: https://github.com/bluetech/pcsc-rust/issues/50.The functions that can get unit tests after this are:
read_data_from_ef
,establish_bac_session_keys
,send
function,process_secure_rapdu
.