From 2eb31ede6afc2e45cca225cbdb8d3f2ea7cd0944 Mon Sep 17 00:00:00 2001 From: Heiko Schaefer Date: Thu, 27 Oct 2022 11:01:48 +0200 Subject: [PATCH] card-functionality: use new Card interface --- card-functionality/src/list-cards.rs | 7 +++---- card-functionality/src/tests.rs | 18 +++++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/card-functionality/src/list-cards.rs b/card-functionality/src/list-cards.rs index 701fe69..9af379d 100644 --- a/card-functionality/src/list-cards.rs +++ b/card-functionality/src/list-cards.rs @@ -4,15 +4,14 @@ use anyhow::Result; use openpgp_card_pcsc::PcscBackend; -use openpgp_card_sequoia::card::Card; +use openpgp_card_sequoia::card::{Card, Open}; fn main() -> Result<()> { println!("The following OpenPGP cards are connected to your system:"); for backend in PcscBackend::cards(None)? { - let mut card = Card::new(backend); - let open = card.transaction()?; - println!(" {}", open.application_identifier()?.ident()); + let mut card: Card = backend.into(); + println!(" {}", card.transaction()?.application_identifier()?.ident()); } Ok(()) diff --git a/card-functionality/src/tests.rs b/card-functionality/src/tests.rs index 4a2929a..d713706 100644 --- a/card-functionality/src/tests.rs +++ b/card-functionality/src/tests.rs @@ -16,7 +16,7 @@ use sequoia_openpgp::Cert; use openpgp_card::algorithm::AlgoSimple; use openpgp_card::card_do::{KeyGenerationTime, Sex}; use openpgp_card::{Error, KeyType, OpenPgp, OpenPgpTransaction, StatusBytes}; -use openpgp_card_sequoia::card::Open; +use openpgp_card_sequoia::card::{Card, Transaction}; use openpgp_card_sequoia::util::{ make_cert, public_key_material_and_fp_to_key, public_key_material_to_key, }; @@ -67,9 +67,9 @@ pub fn test_decrypt(pgp: &mut OpenPgp, param: &[&str]) -> Result::new(pgpt)?; - let mut user = open.user_card().unwrap(); + let mut user = transaction.user_card().unwrap(); let d = user.decryptor(&|| {})?; let res = openpgp_card_sequoia::util::decrypt(d, msg.into_bytes(), &p)?; @@ -90,9 +90,9 @@ pub fn test_sign(pgp: &mut OpenPgp, param: &[&str]) -> Result::new(pgpt)?; - let mut sign = open.signing_card().unwrap(); + let mut sign = transaction.signing_card().unwrap(); let s = sign.signer(&|| {})?; let msg = "Hello world, I am signed."; @@ -216,9 +216,9 @@ pub fn test_upload_keys(pgp: &mut OpenPgp, param: &[&str]) -> Result Result { let pgpt = pgp.transaction()?; - let mut open = Open::new(pgpt)?; - open.verify_admin(b"12345678")?; - let mut admin = open.admin_card().expect("Couldn't get Admin card"); + let mut transaction = Card::::new(pgpt)?; + transaction.verify_admin(b"12345678")?; + let mut admin = transaction.admin_card().expect("Couldn't get Admin card"); // Generate all three subkeys on card let algo = param[0]; @@ -245,7 +245,7 @@ pub fn test_keygen(pgp: &mut OpenPgp, param: &[&str]) -> Result