rename get_txc!() -> transaction!()
This commit is contained in:
parent
bdde317a2d
commit
87788e8912
9 changed files with 37 additions and 37 deletions
|
@ -3,14 +3,14 @@
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
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::card::Open;
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
println!("The following OpenPGP cards are connected to your system:");
|
println!("The following OpenPGP cards are connected to your system:");
|
||||||
|
|
||||||
for mut card in PcscCard::cards(None)? {
|
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)?;
|
let open = Open::new(&mut txc)?;
|
||||||
println!(" {}", open.application_identifier()?.ident());
|
println!(" {}", open.application_identifier()?.ident());
|
||||||
|
|
|
@ -16,7 +16,7 @@ use openpgp_card;
|
||||||
use openpgp_card::algorithm::AlgoSimple;
|
use openpgp_card::algorithm::AlgoSimple;
|
||||||
use openpgp_card::card_do::{KeyGenerationTime, Sex};
|
use openpgp_card::card_do::{KeyGenerationTime, Sex};
|
||||||
use openpgp_card::{CardClient, Error, KeyType, StatusBytes};
|
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::card::Open;
|
||||||
use openpgp_card_sequoia::util::{
|
use openpgp_card_sequoia::util::{
|
||||||
make_cert, public_key_material_to_key, public_to_fingerprint,
|
make_cert, public_key_material_to_key, public_to_fingerprint,
|
||||||
|
@ -682,7 +682,7 @@ pub fn run_test(
|
||||||
|
|
||||||
use anyhow::anyhow;
|
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);
|
// let mut txc = TxClient::new(&mut tx, card_caps, reader_caps);
|
||||||
|
|
||||||
t(&mut txc, param)
|
t(&mut txc, param)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Wiktor Kwapisiewicz <wiktor@metacode.biz>
|
// SPDX-FileCopyrightText: 2021 Wiktor Kwapisiewicz <wiktor@metacode.biz>
|
||||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
// 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;
|
use openpgp_card_sequoia::card::Open;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let cert_file = &args[2];
|
let cert_file = &args[2];
|
||||||
|
|
||||||
let mut card = PcscCard::open_by_ident(card_ident, None)?;
|
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)?;
|
let mut open = Open::new(&mut txc)?;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Wiktor Kwapisiewicz <wiktor@metacode.biz>
|
// SPDX-FileCopyrightText: 2021 Wiktor Kwapisiewicz <wiktor@metacode.biz>
|
||||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
// 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;
|
use openpgp_card_sequoia::card::Open;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let cert_file = &args[2];
|
let cert_file = &args[2];
|
||||||
|
|
||||||
let mut card = PcscCard::open_by_ident(card_ident, None)?;
|
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)?;
|
let mut open = Open::new(&mut txc)?;
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,11 @@
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! use openpgp_card_sequoia::card::Open;
|
//! 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<dyn std::error::Error>> {
|
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
//! for mut card in PcscCard::cards(None)? {
|
//! for mut card in PcscCard::cards(None)? {
|
||||||
//! let mut txc = get_txc!(card)?;
|
//! let mut txc = transaction!(card)?;
|
||||||
//! let open = Open::new(&mut txc)?;
|
//! let open = Open::new(&mut txc)?;
|
||||||
//! println!("Found OpenPGP card with ident '{}'",
|
//! println!("Found OpenPGP card with ident '{}'",
|
||||||
//! open.application_identifier()?.ident());
|
//! open.application_identifier()?.ident());
|
||||||
|
@ -30,11 +30,11 @@
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! use openpgp_card_sequoia::card::Open;
|
//! 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<dyn std::error::Error>> {
|
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
//! let mut card = PcscCard::open_by_ident("abcd:12345678", None)?;
|
//! 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)?;
|
//! let mut open = Open::new(&mut txc)?;
|
||||||
//! # Ok(())
|
//! # Ok(())
|
||||||
//! # }
|
//! # }
|
||||||
|
@ -51,13 +51,13 @@
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! use openpgp_card_sequoia::card::Open;
|
//! 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<dyn std::error::Error>> {
|
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
//! // Open card via PCSC
|
//! // Open card via PCSC
|
||||||
//! use sequoia_openpgp::policy::StandardPolicy;
|
//! use sequoia_openpgp::policy::StandardPolicy;
|
||||||
//! let mut card = PcscCard::open_by_ident("abcd:12345678", None)?;
|
//! 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)?;
|
//! let mut open = Open::new(&mut txc)?;
|
||||||
//!
|
//!
|
||||||
//! // Get authorization for user access to the card with password
|
//! // Get authorization for user access to the card with password
|
||||||
|
@ -93,13 +93,13 @@
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! use openpgp_card_sequoia::card::Open;
|
//! 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<dyn std::error::Error>> {
|
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
//! // Open card via PCSC
|
//! // Open card via PCSC
|
||||||
//! use sequoia_openpgp::policy::StandardPolicy;
|
//! use sequoia_openpgp::policy::StandardPolicy;
|
||||||
//! let mut card = PcscCard::open_by_ident("abcd:12345678", None)?;
|
//! 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)?;
|
//! let mut open = Open::new(&mut txc)?;
|
||||||
//!
|
//!
|
||||||
//! // Get authorization for signing access to the card with password
|
//! // Get authorization for signing access to the card with password
|
||||||
|
@ -125,12 +125,12 @@
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! use openpgp_card_sequoia::card::Open;
|
//! 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<dyn std::error::Error>> {
|
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
//! // Open card via PCSC
|
//! // Open card via PCSC
|
||||||
//! let mut card = PcscCard::open_by_ident("abcd:12345678", None)?;
|
//! 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)?;
|
//! let mut open = Open::new(&mut txc)?;
|
||||||
//!
|
//!
|
||||||
//! // Get authorization for admin access to the card with password
|
//! // Get authorization for admin access to the card with password
|
||||||
|
|
|
@ -11,7 +11,7 @@ use sequoia_openpgp::Cert;
|
||||||
|
|
||||||
use openpgp_card::card_do::Sex;
|
use openpgp_card::card_do::Sex;
|
||||||
use openpgp_card::KeyType;
|
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::card::Open;
|
||||||
use openpgp_card_sequoia::sq_util;
|
use openpgp_card_sequoia::sq_util;
|
||||||
|
@ -36,7 +36,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
if let Ok(test_card_ident) = test_card_ident {
|
if let Ok(test_card_ident) = test_card_ident {
|
||||||
let mut card = PcscCard::open_by_ident(&test_card_ident, None)?;
|
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)?;
|
let mut open = Open::new(&mut txc)?;
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
// Open fresh Card for decrypt
|
// Open fresh Card for decrypt
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
let mut card = PcscCard::open_by_ident(&test_card_ident, None)?;
|
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)?;
|
let mut open = Open::new(&mut txc)?;
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
// Open fresh Card for signing
|
// Open fresh Card for signing
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
let mut card = PcscCard::open_by_ident(&test_card_ident, None)?;
|
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)?;
|
let mut open = Open::new(&mut txc)?;
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
println!("The following OpenPGP cards are connected to your system:");
|
println!("The following OpenPGP cards are connected to your system:");
|
||||||
|
|
||||||
for mut card in PcscCard::cards(None)? {
|
for mut card in PcscCard::cards(None)? {
|
||||||
let mut txc = get_txc!(card)?;
|
let mut txc = transaction!(card)?;
|
||||||
|
|
||||||
let open = Open::new(&mut txc)?;
|
let open = Open::new(&mut txc)?;
|
||||||
println!(" {}", open.application_identifier()?.ident());
|
println!(" {}", open.application_identifier()?.ident());
|
||||||
|
|
|
@ -19,7 +19,7 @@ const FEATURE_MODIFY_PIN_DIRECT: u8 = 0x07;
|
||||||
/// Get a TxClient from a PcscCard (this starts a transaction on the card
|
/// Get a TxClient from a PcscCard (this starts a transaction on the card
|
||||||
/// in PcscCard)
|
/// in PcscCard)
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! get_txc {
|
macro_rules! transaction {
|
||||||
( $card:expr, $reselect:expr ) => {{
|
( $card:expr, $reselect:expr ) => {{
|
||||||
use openpgp_card::{Error, SmartcardError};
|
use openpgp_card::{Error, SmartcardError};
|
||||||
use pcsc::{Disposition, Protocols};
|
use pcsc::{Disposition, Protocols};
|
||||||
|
@ -100,7 +100,7 @@ macro_rules! get_txc {
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
( $card:expr ) => {
|
( $card:expr ) => {
|
||||||
get_txc!($card, true)
|
transaction!($card, true)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,7 +556,7 @@ impl PcscCard {
|
||||||
// start transaction
|
// start transaction
|
||||||
log::debug!("1");
|
log::debug!("1");
|
||||||
let mut p = PcscCard::new(card, mode);
|
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");
|
log::debug!("3");
|
||||||
{
|
{
|
||||||
|
@ -682,7 +682,7 @@ impl PcscCard {
|
||||||
|
|
||||||
let mut h: HashMap<u8, Tlv> = HashMap::default();
|
let mut h: HashMap<u8, Tlv> = HashMap::default();
|
||||||
|
|
||||||
let mut txc: TxClient = get_txc!(self, true)?;
|
let mut txc: TxClient = transaction!(self, true)?;
|
||||||
|
|
||||||
// Get Features from reader (pinpad verify/modify)
|
// Get Features from reader (pinpad verify/modify)
|
||||||
if let Ok(feat) = txc.features() {
|
if let Ok(feat) = txc.features() {
|
||||||
|
|
|
@ -5,7 +5,7 @@ use anyhow::Result;
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
use openpgp_card::{CardClient, Error, StatusBytes};
|
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;
|
use openpgp_card_sequoia::card::Open;
|
||||||
|
|
||||||
mod cli;
|
mod cli;
|
||||||
|
@ -16,7 +16,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let cli = cli::Cli::from_args();
|
let cli = cli::Cli::from_args();
|
||||||
|
|
||||||
let mut card = PcscCard::open_by_ident(&cli.ident, None)?;
|
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_verify = txc.feature_pinpad_verify();
|
||||||
let pinpad_modify = txc.feature_pinpad_modify();
|
let pinpad_modify = txc.feature_pinpad_modify();
|
||||||
|
|
|
@ -13,7 +13,7 @@ use sequoia_openpgp::Cert;
|
||||||
|
|
||||||
use openpgp_card::algorithm::AlgoSimple;
|
use openpgp_card::algorithm::AlgoSimple;
|
||||||
use openpgp_card::{card_do::Sex, CardClient, KeyType};
|
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::card::{Admin, Open};
|
||||||
use openpgp_card_sequoia::util::{make_cert, public_key_material_to_key};
|
use openpgp_card_sequoia::util::{make_cert, public_key_material_to_key};
|
||||||
|
@ -72,7 +72,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
cmd,
|
cmd,
|
||||||
} => {
|
} => {
|
||||||
let mut card = util::open_card(&ident)?;
|
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)?;
|
let mut open = Open::new(&mut txc)?;
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ fn list_cards() -> Result<()> {
|
||||||
println!("Available OpenPGP cards:");
|
println!("Available OpenPGP cards:");
|
||||||
|
|
||||||
for mut card in cards {
|
for mut card in cards {
|
||||||
let mut txc = get_txc!(card)?;
|
let mut txc = transaction!(card)?;
|
||||||
|
|
||||||
let open = Open::new(&mut txc)?;
|
let open = Open::new(&mut txc)?;
|
||||||
println!(" {}", open.application_identifier()?.ident());
|
println!(" {}", open.application_identifier()?.ident());
|
||||||
|
@ -155,7 +155,7 @@ fn set_identity(
|
||||||
id: u8,
|
id: u8,
|
||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let mut card = util::open_card(ident)?;
|
let mut card = util::open_card(ident)?;
|
||||||
let mut txc = get_txc!(card)?;
|
let mut txc = transaction!(card)?;
|
||||||
|
|
||||||
<dyn CardClient>::set_identity(&mut txc, id)?;
|
<dyn CardClient>::set_identity(&mut txc, id)?;
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ fn print_status(ident: Option<String>, verbose: bool) -> Result<()> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut txc = get_txc!(card)?;
|
let mut txc = transaction!(card)?;
|
||||||
|
|
||||||
let mut open = Open::new(&mut txc)?;
|
let mut open = Open::new(&mut txc)?;
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ fn decrypt(
|
||||||
let input = util::open_or_stdin(input.as_deref())?;
|
let input = util::open_or_stdin(input.as_deref())?;
|
||||||
|
|
||||||
let mut card = util::open_card(ident)?;
|
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)?;
|
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 input = util::open_or_stdin(input.as_deref())?;
|
||||||
|
|
||||||
let mut card = util::open_card(ident)?;
|
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)?;
|
let mut open = Open::new(&mut txc)?;
|
||||||
|
|
||||||
|
@ -383,7 +383,7 @@ fn sign_detached(
|
||||||
fn factory_reset(ident: &str) -> Result<()> {
|
fn factory_reset(ident: &str) -> Result<()> {
|
||||||
println!("Resetting Card {}", ident);
|
println!("Resetting Card {}", ident);
|
||||||
let mut card = util::open_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()
|
Open::new(&mut txc)?.factory_reset()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue