Adjust to changed ScdClient API

This commit is contained in:
Heiko Schaefer 2021-08-03 15:32:48 +02:00
parent c9e7f1b0aa
commit 083db2a8be
2 changed files with 14 additions and 10 deletions

View file

@ -76,11 +76,7 @@ impl TestCard {
// FIXME // FIXME
const SOCKET: &str = "/run/user/1000/gnupg/S.scdaemon"; const SOCKET: &str = "/run/user/1000/gnupg/S.scdaemon";
let mut card = ScdClient::new(SOCKET)?; let card_client = ScdClient::open_by_serial(SOCKET, serial)?;
card.select_card(serial)?;
let card_client = Box::new(card) as CardClientBox;
let mut ca = CardApp::new(card_client); let mut ca = CardApp::new(card_client);
// Set Card Capabilities (chaining, command length, ..) // Set Card Capabilities (chaining, command length, ..)

View file

@ -8,7 +8,7 @@ use anyhow::Result;
use sequoia_openpgp::parse::Parse; use sequoia_openpgp::parse::Parse;
use sequoia_openpgp::Cert; use sequoia_openpgp::Cert;
use openpgp_card::KeyType; use openpgp_card::{CardBase, KeyType};
use openpgp_card_scdc::ScdClient; use openpgp_card_scdc::ScdClient;
// Filename of test key and test message to use: // Filename of test key and test message to use:
@ -37,8 +37,10 @@ fn main() -> Result<(), Box<dyn Error>> {
println!("** get card"); println!("** get card");
// let mut oc = CardBase::open_by_ident(&test_card_ident)?; // let mut oc = CardBase::open_by_ident(&test_card_ident)?;
// let mut oc = ScdClient::open_scdc(SOCKET)?; // let mut oc = ScdClient::open_scdc(SOCKET)?;
let mut oc = let mut oc = CardBase::open_card(ScdClient::open_by_serial(
ScdClient::open_scdc_by_serial(SOCKET, &test_card_serial)?; SOCKET,
&test_card_serial,
)?)?;
// card metadata // card metadata
@ -150,7 +152,10 @@ fn main() -> Result<(), Box<dyn Error>> {
// ----------------------------- // -----------------------------
// let mut oc = CardBase::open_by_ident(&test_card_ident)?; // let mut oc = CardBase::open_by_ident(&test_card_ident)?;
let mut oc = ScdClient::open_scdc(SOCKET)?; let mut oc = CardBase::open_card(ScdClient::open_by_serial(
SOCKET,
&test_card_serial,
)?)?;
let app_id = oc.get_aid()?; let app_id = oc.get_aid()?;
@ -191,7 +196,10 @@ fn main() -> Result<(), Box<dyn Error>> {
// Open fresh Card for signing // Open fresh Card for signing
// ----------------------------- // -----------------------------
// let oc = CardBase::open_by_ident(&test_card_ident)?; // let oc = CardBase::open_by_ident(&test_card_ident)?;
let oc = ScdClient::open_scdc(SOCKET)?; let oc = CardBase::open_card(ScdClient::open_by_serial(
SOCKET,
&test_card_serial,
)?)?;
// Sign // Sign
match oc.verify_pw1_for_signing("123456") { match oc.verify_pw1_for_signing("123456") {