Add $reselect parameter to start_tx! that specifies if the card should be re-selected if it was reset
This commit is contained in:
parent
f4eaca229d
commit
c43b53d210
2 changed files with 9 additions and 6 deletions
|
@ -706,8 +706,9 @@ pub fn run_test(
|
|||
|
||||
let card_caps = card_client.card_caps();
|
||||
|
||||
let mut tx: Transaction = openpgp_card_pcsc::start_tx!(card_client.card())
|
||||
.map_err(|e| anyhow!(e))?;
|
||||
let mut tx: Transaction =
|
||||
openpgp_card_pcsc::start_tx!(card_client.card(), true)
|
||||
.map_err(|e| anyhow!(e))?;
|
||||
let mut txc = PcscTxClient::new(&mut tx, card_caps);
|
||||
|
||||
t(&mut txc, param)
|
||||
|
|
|
@ -19,7 +19,7 @@ const FEATURE_MODIFY_PIN_DIRECT: u8 = 0x07;
|
|||
|
||||
#[macro_export]
|
||||
macro_rules! start_tx {
|
||||
($card:expr) => {{
|
||||
($card:expr, $reselect:expr) => {{
|
||||
use pcsc::{Disposition, Protocols, ShareMode};
|
||||
|
||||
let mut was_reset = false;
|
||||
|
@ -37,7 +37,9 @@ macro_rules! start_tx {
|
|||
);
|
||||
|
||||
let mut txc = PcscTxClient::new(&mut tx, None);
|
||||
PcscTxClient::select(&mut txc)?;
|
||||
if $reselect {
|
||||
PcscTxClient::select(&mut txc)?;
|
||||
}
|
||||
}
|
||||
|
||||
break Ok(tx);
|
||||
|
@ -260,7 +262,7 @@ impl PcscClient {
|
|||
{
|
||||
// start transaction
|
||||
log::debug!("1");
|
||||
let mut tx: Transaction = start_tx!(card)?;
|
||||
let mut tx: Transaction = start_tx!(card, false)?;
|
||||
|
||||
let mut txc = PcscTxClient::new(&mut tx, None);
|
||||
log::debug!("3");
|
||||
|
@ -430,7 +432,7 @@ impl CardClient for PcscClient {
|
|||
let stat = self.card.status2_owned();
|
||||
log::debug!("PcscClient transmit - status2: {:x?}", stat);
|
||||
|
||||
let mut tx: Transaction = start_tx!(self.card)?;
|
||||
let mut tx: Transaction = start_tx!(self.card, true)?;
|
||||
|
||||
log::debug!("PcscClient transmit 2");
|
||||
let mut txc = PcscTxClient::new(&mut tx, self.card_caps);
|
||||
|
|
Loading…
Reference in a new issue