diff --git a/card-functionality/src/list-cards.rs b/card-functionality/src/list-cards.rs index f63aae0..c6d7e30 100644 --- a/card-functionality/src/list-cards.rs +++ b/card-functionality/src/list-cards.rs @@ -3,14 +3,14 @@ use anyhow::Result; -use openpgp_card_pcsc::{get_txc, PcscCard, TxClient}; +use openpgp_card_pcsc::{transaction, PcscCard, TxClient}; use openpgp_card_sequoia::card::Open; fn main() -> Result<()> { println!("The following OpenPGP cards are connected to your system:"); for mut card in PcscCard::cards(None)? { - let mut txc: TxClient = get_txc!(card)?; + let mut txc: TxClient = transaction!(card)?; let open = Open::new(&mut txc)?; println!(" {}", open.application_identifier()?.ident()); diff --git a/card-functionality/src/tests.rs b/card-functionality/src/tests.rs index 922415b..f5df3b9 100644 --- a/card-functionality/src/tests.rs +++ b/card-functionality/src/tests.rs @@ -16,7 +16,7 @@ use openpgp_card; use openpgp_card::algorithm::AlgoSimple; use openpgp_card::card_do::{KeyGenerationTime, Sex}; use openpgp_card::{CardClient, Error, KeyType, StatusBytes}; -use openpgp_card_pcsc::{get_txc, TxClient}; +use openpgp_card_pcsc::{transaction, TxClient}; use openpgp_card_sequoia::card::Open; use openpgp_card_sequoia::util::{ make_cert, public_key_material_to_key, public_to_fingerprint, @@ -682,7 +682,7 @@ pub fn run_test( use anyhow::anyhow; - let mut txc = get_txc!(card_client).map_err(|e| anyhow!(e))?; + let mut txc = transaction!(card_client).map_err(|e| anyhow!(e))?; // let mut txc = TxClient::new(&mut tx, card_caps, reader_caps); t(&mut txc, param) diff --git a/openpgp-card-examples/src/bin/decrypt.rs b/openpgp-card-examples/src/bin/decrypt.rs index b41c3a9..e26216e 100644 --- a/openpgp-card-examples/src/bin/decrypt.rs +++ b/openpgp-card-examples/src/bin/decrypt.rs @@ -1,7 +1,7 @@ // SPDX-FileCopyrightText: 2021 Wiktor Kwapisiewicz // SPDX-License-Identifier: MIT OR Apache-2.0 -use openpgp_card_pcsc::{get_txc, PcscCard, TxClient}; +use openpgp_card_pcsc::{transaction, PcscCard, TxClient}; use openpgp_card_sequoia::card::Open; @@ -23,7 +23,7 @@ fn main() -> Result<(), Box> { let cert_file = &args[2]; let mut card = PcscCard::open_by_ident(card_ident, None)?; - let mut txc = get_txc!(card)?; + let mut txc = transaction!(card)?; let mut open = Open::new(&mut txc)?; diff --git a/openpgp-card-examples/src/bin/detach-sign.rs b/openpgp-card-examples/src/bin/detach-sign.rs index 4be503a..c4f547a 100644 --- a/openpgp-card-examples/src/bin/detach-sign.rs +++ b/openpgp-card-examples/src/bin/detach-sign.rs @@ -1,7 +1,7 @@ // SPDX-FileCopyrightText: 2021 Wiktor Kwapisiewicz // SPDX-License-Identifier: MIT OR Apache-2.0 -use openpgp_card_pcsc::{get_txc, PcscCard, TxClient}; +use openpgp_card_pcsc::{transaction, PcscCard, TxClient}; use openpgp_card_sequoia::card::Open; @@ -23,7 +23,7 @@ fn main() -> Result<(), Box> { let cert_file = &args[2]; let mut card = PcscCard::open_by_ident(card_ident, None)?; - let mut txc = get_txc!(card)?; + let mut txc = transaction!(card)?; let mut open = Open::new(&mut txc)?; diff --git a/openpgp-card-sequoia/src/lib.rs b/openpgp-card-sequoia/src/lib.rs index d2e76a7..8787bba 100644 --- a/openpgp-card-sequoia/src/lib.rs +++ b/openpgp-card-sequoia/src/lib.rs @@ -13,11 +13,11 @@ //! //! ```no_run //! use openpgp_card_sequoia::card::Open; -//! use openpgp_card_pcsc::{get_txc, PcscCard, TxClient}; +//! use openpgp_card_pcsc::{transaction, PcscCard, TxClient}; //! //! # fn main() -> Result<(), Box> { //! for mut card in PcscCard::cards(None)? { -//! let mut txc = get_txc!(card)?; +//! let mut txc = transaction!(card)?; //! let open = Open::new(&mut txc)?; //! println!("Found OpenPGP card with ident '{}'", //! open.application_identifier()?.ident()); @@ -30,11 +30,11 @@ //! //! ```no_run //! use openpgp_card_sequoia::card::Open; -//! use openpgp_card_pcsc::{get_txc, PcscCard, TxClient}; +//! use openpgp_card_pcsc::{transaction, PcscCard, TxClient}; //! //! # fn main() -> Result<(), Box> { //! let mut card = PcscCard::open_by_ident("abcd:12345678", None)?; -//! let mut txc = get_txc!(card)?; +//! let mut txc = transaction!(card)?; //! let mut open = Open::new(&mut txc)?; //! # Ok(()) //! # } @@ -51,13 +51,13 @@ //! //! ```no_run //! use openpgp_card_sequoia::card::Open; -//! use openpgp_card_pcsc::{get_txc, PcscCard, TxClient}; +//! use openpgp_card_pcsc::{transaction, PcscCard, TxClient}; //! //! # fn main() -> Result<(), Box> { //! // Open card via PCSC //! use sequoia_openpgp::policy::StandardPolicy; //! let mut card = PcscCard::open_by_ident("abcd:12345678", None)?; -//! let mut txc = get_txc!(card)?; +//! let mut txc = transaction!(card)?; //! let mut open = Open::new(&mut txc)?; //! //! // Get authorization for user access to the card with password @@ -93,13 +93,13 @@ //! //! ```no_run //! use openpgp_card_sequoia::card::Open; -//! use openpgp_card_pcsc::{get_txc, PcscCard, TxClient}; +//! use openpgp_card_pcsc::{transaction, PcscCard, TxClient}; //! //! # fn main() -> Result<(), Box> { //! // Open card via PCSC //! use sequoia_openpgp::policy::StandardPolicy; //! let mut card = PcscCard::open_by_ident("abcd:12345678", None)?; -//! let mut txc = get_txc!(card)?; +//! let mut txc = transaction!(card)?; //! let mut open = Open::new(&mut txc)?; //! //! // Get authorization for signing access to the card with password @@ -125,12 +125,12 @@ //! //! ```no_run //! use openpgp_card_sequoia::card::Open; -//! use openpgp_card_pcsc::{get_txc, PcscCard, TxClient}; +//! use openpgp_card_pcsc::{transaction, PcscCard, TxClient}; //! //! # fn main() -> Result<(), Box> { //! // Open card via PCSC //! let mut card = PcscCard::open_by_ident("abcd:12345678", None)?; -//! let mut txc = get_txc!(card)?; +//! let mut txc = transaction!(card)?; //! let mut open = Open::new(&mut txc)?; //! //! // Get authorization for admin access to the card with password diff --git a/openpgp-card-sequoia/src/main.rs b/openpgp-card-sequoia/src/main.rs index fedfa70..d4cc26a 100644 --- a/openpgp-card-sequoia/src/main.rs +++ b/openpgp-card-sequoia/src/main.rs @@ -11,7 +11,7 @@ use sequoia_openpgp::Cert; use openpgp_card::card_do::Sex; use openpgp_card::KeyType; -use openpgp_card_pcsc::{get_txc, PcscCard, TxClient}; +use openpgp_card_pcsc::{transaction, PcscCard, TxClient}; use openpgp_card_sequoia::card::Open; use openpgp_card_sequoia::sq_util; @@ -36,7 +36,7 @@ fn main() -> Result<(), Box> { if let Ok(test_card_ident) = test_card_ident { let mut card = PcscCard::open_by_ident(&test_card_ident, None)?; - let mut txc = get_txc!(card)?; + let mut txc = transaction!(card)?; let mut open = Open::new(&mut txc)?; @@ -147,7 +147,7 @@ fn main() -> Result<(), Box> { // Open fresh Card for decrypt // ----------------------------- let mut card = PcscCard::open_by_ident(&test_card_ident, None)?; - let mut txc = get_txc!(card)?; + let mut txc = transaction!(card)?; let mut open = Open::new(&mut txc)?; @@ -188,7 +188,7 @@ fn main() -> Result<(), Box> { // Open fresh Card for signing // ----------------------------- let mut card = PcscCard::open_by_ident(&test_card_ident, None)?; - let mut txc = get_txc!(card)?; + let mut txc = transaction!(card)?; let mut open = Open::new(&mut txc)?; @@ -220,7 +220,7 @@ fn main() -> Result<(), Box> { println!("The following OpenPGP cards are connected to your system:"); for mut card in PcscCard::cards(None)? { - let mut txc = get_txc!(card)?; + let mut txc = transaction!(card)?; let open = Open::new(&mut txc)?; println!(" {}", open.application_identifier()?.ident()); diff --git a/pcsc/src/lib.rs b/pcsc/src/lib.rs index 6734724..86f3096 100644 --- a/pcsc/src/lib.rs +++ b/pcsc/src/lib.rs @@ -19,7 +19,7 @@ const FEATURE_MODIFY_PIN_DIRECT: u8 = 0x07; /// Get a TxClient from a PcscCard (this starts a transaction on the card /// in PcscCard) #[macro_export] -macro_rules! get_txc { +macro_rules! transaction { ( $card:expr, $reselect:expr ) => {{ use openpgp_card::{Error, SmartcardError}; use pcsc::{Disposition, Protocols}; @@ -100,7 +100,7 @@ macro_rules! get_txc { } }}; ( $card:expr ) => { - get_txc!($card, true) + transaction!($card, true) }; } @@ -556,7 +556,7 @@ impl PcscCard { // start transaction log::debug!("1"); let mut p = PcscCard::new(card, mode); - let mut txc: TxClient = get_txc!(p, false)?; + let mut txc: TxClient = transaction!(p, false)?; log::debug!("3"); { @@ -682,7 +682,7 @@ impl PcscCard { let mut h: HashMap = HashMap::default(); - let mut txc: TxClient = get_txc!(self, true)?; + let mut txc: TxClient = transaction!(self, true)?; // Get Features from reader (pinpad verify/modify) if let Ok(feat) = txc.features() { diff --git a/tools/src/bin/opgpcard-pin/main.rs b/tools/src/bin/opgpcard-pin/main.rs index 2f04492..1b3ce01 100644 --- a/tools/src/bin/opgpcard-pin/main.rs +++ b/tools/src/bin/opgpcard-pin/main.rs @@ -5,7 +5,7 @@ use anyhow::Result; use structopt::StructOpt; use openpgp_card::{CardClient, Error, StatusBytes}; -use openpgp_card_pcsc::{get_txc, PcscCard, TxClient}; +use openpgp_card_pcsc::{transaction, PcscCard, TxClient}; use openpgp_card_sequoia::card::Open; mod cli; @@ -16,7 +16,7 @@ fn main() -> Result<(), Box> { let cli = cli::Cli::from_args(); let mut card = PcscCard::open_by_ident(&cli.ident, None)?; - let mut txc = get_txc!(card)?; + let mut txc = transaction!(card)?; let pinpad_verify = txc.feature_pinpad_verify(); let pinpad_modify = txc.feature_pinpad_modify(); diff --git a/tools/src/bin/opgpcard/main.rs b/tools/src/bin/opgpcard/main.rs index 08880fc..955a790 100644 --- a/tools/src/bin/opgpcard/main.rs +++ b/tools/src/bin/opgpcard/main.rs @@ -13,7 +13,7 @@ use sequoia_openpgp::Cert; use openpgp_card::algorithm::AlgoSimple; use openpgp_card::{card_do::Sex, CardClient, KeyType}; -use openpgp_card_pcsc::{get_txc, TxClient}; +use openpgp_card_pcsc::{transaction, TxClient}; use openpgp_card_sequoia::card::{Admin, Open}; use openpgp_card_sequoia::util::{make_cert, public_key_material_to_key}; @@ -72,7 +72,7 @@ fn main() -> Result<(), Box> { cmd, } => { let mut card = util::open_card(&ident)?; - let mut txc = get_txc!(card)?; + let mut txc = transaction!(card)?; let mut open = Open::new(&mut txc)?; @@ -139,7 +139,7 @@ fn list_cards() -> Result<()> { println!("Available OpenPGP cards:"); for mut card in cards { - let mut txc = get_txc!(card)?; + let mut txc = transaction!(card)?; let open = Open::new(&mut txc)?; println!(" {}", open.application_identifier()?.ident()); @@ -155,7 +155,7 @@ fn set_identity( id: u8, ) -> Result<(), Box> { let mut card = util::open_card(ident)?; - let mut txc = get_txc!(card)?; + let mut txc = transaction!(card)?; ::set_identity(&mut txc, id)?; @@ -174,7 +174,7 @@ fn print_status(ident: Option, verbose: bool) -> Result<()> { } }; - let mut txc = get_txc!(card)?; + let mut txc = transaction!(card)?; let mut open = Open::new(&mut txc)?; @@ -338,7 +338,7 @@ fn decrypt( let input = util::open_or_stdin(input.as_deref())?; let mut card = util::open_card(ident)?; - let mut txc = get_txc!(card)?; + let mut txc = transaction!(card)?; let mut open = Open::new(&mut txc)?; @@ -364,7 +364,7 @@ fn sign_detached( let mut input = util::open_or_stdin(input.as_deref())?; let mut card = util::open_card(ident)?; - let mut txc = get_txc!(card)?; + let mut txc = transaction!(card)?; let mut open = Open::new(&mut txc)?; @@ -383,7 +383,7 @@ fn sign_detached( fn factory_reset(ident: &str) -> Result<()> { println!("Resetting Card {}", ident); let mut card = util::open_card(ident)?; - let mut txc = get_txc!(card)?; + let mut txc = transaction!(card)?; Open::new(&mut txc)?.factory_reset() }