Adjust to openpgp-card 0.2 API

This commit is contained in:
Heiko Schaefer 2022-01-16 22:26:29 +01:00
parent 405a2a1fc1
commit 111f9e9631
No known key found for this signature in database
GPG key ID: 4A849A1904CCBD7D
4 changed files with 18 additions and 18 deletions

View file

@ -16,9 +16,8 @@
//! use openpgp_card_sequoia::card::Open; //! use openpgp_card_sequoia::card::Open;
//! //!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> { //! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! for card in PcscClient::cards()? { //! for mut cc in PcscClient::cards()? {
//! let mut ca = card.into(); //! let open = Open::new(&mut cc)?;
//! let open = Open::new(&mut ca)?;
//! println!("Found OpenPGP card with ident '{}'", //! println!("Found OpenPGP card with ident '{}'",
//! open.application_identifier()?.ident()); //! open.application_identifier()?.ident());
//! } //! }
@ -33,8 +32,8 @@
//! use openpgp_card_sequoia::card::Open; //! use openpgp_card_sequoia::card::Open;
//! //!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> { //! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let mut ca = PcscClient::open_by_ident("abcd:12345678")?.into(); //! let mut cc = PcscClient::open_by_ident("abcd:12345678")?;
//! let mut open = Open::new(&mut ca)?; //! let mut open = Open::new(&mut cc)?;
//! # Ok(()) //! # Ok(())
//! # } //! # }
//! ``` //! ```
@ -55,8 +54,8 @@
//! # 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 ca = PcscClient::open_by_ident("abcd:12345678")?.into(); //! let mut cc = PcscClient::open_by_ident("abcd:12345678")?;
//! let mut open = Open::new(&mut ca)?; //! let mut open = Open::new(&mut cc)?;
//! //!
//! // Get authorization for user access to the card with password //! // Get authorization for user access to the card with password
//! open.verify_user("123456")?; //! open.verify_user("123456")?;
@ -96,8 +95,8 @@
//! # 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 ca = PcscClient::open_by_ident("abcd:12345678")?.into(); //! let mut cc = PcscClient::open_by_ident("abcd:12345678")?;
//! let mut open = Open::new(&mut ca)?; //! let mut open = Open::new(&mut cc)?;
//! //!
//! // Get authorization for signing access to the card with password //! // Get authorization for signing access to the card with password
//! open.verify_user_for_signing("123456")?; //! open.verify_user_for_signing("123456")?;
@ -126,8 +125,8 @@
//! //!
//! # 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 ca = PcscClient::open_by_ident("abcd:12345678")?.into(); //! let mut cc = PcscClient::open_by_ident("abcd:12345678")?;
//! let mut open = Open::new(&mut ca)?; //! let mut open = Open::new(&mut cc)?;
//! //!
//! // Get authorization for admin access to the card with password //! // Get authorization for admin access to the card with password
//! open.verify_admin("12345678")?; //! open.verify_admin("12345678")?;

View file

@ -4,7 +4,7 @@
use anyhow::Result; use anyhow::Result;
use structopt::StructOpt; use structopt::StructOpt;
use openpgp_card::{Error, StatusBytes}; use openpgp_card::{CardClient, Error, StatusBytes};
use openpgp_card_pcsc::PcscClient; use openpgp_card_pcsc::PcscClient;
use openpgp_card_sequoia::card::Open; use openpgp_card_sequoia::card::Open;

View file

@ -11,12 +11,13 @@ use sequoia_openpgp::serialize::stream::{Armorer, Message, Signer};
use sequoia_openpgp::serialize::SerializeInto; use sequoia_openpgp::serialize::SerializeInto;
use sequoia_openpgp::Cert; use sequoia_openpgp::Cert;
use openpgp_card::algorithm::AlgoSimple;
use openpgp_card::{card_do::Sex, CardApp, KeyType};
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};
use openpgp_card_sequoia::{sq_util, PublicKey}; use openpgp_card_sequoia::{sq_util, PublicKey};
use openpgp_card::algorithm::AlgoSimple;
use openpgp_card::{card_do::Sex, KeyType};
use std::io::Write; use std::io::Write;
mod cli; mod cli;
@ -150,7 +151,7 @@ fn set_identity(
) -> 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)?;
card.set_identity(id)?; CardApp::set_identity(&mut card, id)?;
Ok(()) Ok(())
} }

View file

@ -4,15 +4,15 @@
use anyhow::{anyhow, Context, Result}; use anyhow::{anyhow, Context, Result};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use openpgp_card::{CardApp, Error}; use openpgp_card::Error;
use openpgp_card_pcsc::PcscClient; use openpgp_card_pcsc::PcscClient;
use openpgp_card_sequoia::card::{Admin, Open, Sign, User}; use openpgp_card_sequoia::card::{Admin, Open, Sign, User};
pub(crate) fn cards() -> Result<Vec<CardApp>, Error> { pub(crate) fn cards() -> Result<Vec<PcscClient>, Error> {
PcscClient::cards() PcscClient::cards()
} }
pub(crate) fn open_card(ident: &str) -> Result<CardApp, Error> { pub(crate) fn open_card(ident: &str) -> Result<PcscClient, Error> {
PcscClient::open_by_ident(ident) PcscClient::open_by_ident(ident)
} }