Adjust openpgp-card-sequoia to changed openpgp-card API
This commit is contained in:
parent
1b1f6bc2df
commit
376072910e
3 changed files with 34 additions and 20 deletions
|
@ -16,6 +16,7 @@ sequoia-openpgp = "1.4"
|
||||||
nettle = "7"
|
nettle = "7"
|
||||||
openpgp-card = { path = "../openpgp-card", version = "0.1" }
|
openpgp-card = { path = "../openpgp-card", version = "0.1" }
|
||||||
openpgp-card-pcsc = { path = "../pcsc", version = "0.1" }
|
openpgp-card-pcsc = { path = "../pcsc", version = "0.1" }
|
||||||
|
pcsc = "2"
|
||||||
openpgp-card-scdc = { path = "../scdc", version = "0.1" }
|
openpgp-card-scdc = { path = "../scdc", version = "0.1" }
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
|
|
|
@ -12,12 +12,13 @@
|
||||||
//! With `openpgp-card-pcsc` you can either open all available cards:
|
//! With `openpgp-card-pcsc` you can either open all available cards:
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! use openpgp_card_pcsc::PcscCard;
|
|
||||||
//! use openpgp_card_sequoia::card::Open;
|
//! use openpgp_card_sequoia::card::Open;
|
||||||
|
//! use openpgp_card_pcsc::{get_txc, PcscCard, TxClient};
|
||||||
//!
|
//!
|
||||||
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
//! for mut cc in PcscCard::cards()? {
|
//! for mut card in PcscCard::cards()? {
|
||||||
//! let open = Open::new(&mut cc)?;
|
//! let mut txc = get_txc!(card)?;
|
||||||
|
//! 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());
|
||||||
//! }
|
//! }
|
||||||
|
@ -28,12 +29,13 @@
|
||||||
//! Or you can open one particular card, by ident:
|
//! Or you can open one particular card, by ident:
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! use openpgp_card_pcsc::PcscCard;
|
|
||||||
//! use openpgp_card_sequoia::card::Open;
|
//! use openpgp_card_sequoia::card::Open;
|
||||||
|
//! use openpgp_card_pcsc::{get_txc, PcscCard, TxClient};
|
||||||
//!
|
//!
|
||||||
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
//! let mut cc = PcscCard::open_by_ident("abcd:12345678")?;
|
//! let mut card = PcscCard::open_by_ident("abcd:12345678")?;
|
||||||
//! let mut open = Open::new(&mut cc)?;
|
//! let mut txc = get_txc!(card)?;
|
||||||
|
//! let mut open = Open::new(&mut txc)?;
|
||||||
//! # Ok(())
|
//! # Ok(())
|
||||||
//! # }
|
//! # }
|
||||||
//! ```
|
//! ```
|
||||||
|
@ -48,14 +50,15 @@
|
||||||
//! that corresponds to the private encryption key on the card:
|
//! that corresponds to the private encryption key on the card:
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! use openpgp_card_pcsc::PcscCard;
|
|
||||||
//! use openpgp_card_sequoia::card::Open;
|
//! use openpgp_card_sequoia::card::Open;
|
||||||
|
//! use openpgp_card_pcsc::{get_txc, 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 cc = PcscCard::open_by_ident("abcd:12345678")?;
|
//! let mut card = PcscCard::open_by_ident("abcd:12345678")?;
|
||||||
//! let mut open = Open::new(&mut cc)?;
|
//! let mut txc = get_txc!(card)?;
|
||||||
|
//! 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
|
||||||
//! open.verify_user("123456")?;
|
//! open.verify_user("123456")?;
|
||||||
|
@ -89,14 +92,15 @@
|
||||||
//! user password before each signing operation!)
|
//! user password before each signing operation!)
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! use openpgp_card_pcsc::PcscCard;
|
|
||||||
//! use openpgp_card_sequoia::card::Open;
|
//! use openpgp_card_sequoia::card::Open;
|
||||||
|
//! use openpgp_card_pcsc::{get_txc, 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 cc = PcscCard::open_by_ident("abcd:12345678")?;
|
//! let mut card = PcscCard::open_by_ident("abcd:12345678")?;
|
||||||
//! let mut open = Open::new(&mut cc)?;
|
//! let mut txc = get_txc!(card)?;
|
||||||
|
//! 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
|
||||||
//! open.verify_user_for_signing("123456")?;
|
//! open.verify_user_for_signing("123456")?;
|
||||||
|
@ -120,13 +124,14 @@
|
||||||
//! # Setting up and configuring a card
|
//! # Setting up and configuring a card
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! use openpgp_card_pcsc::PcscCard;
|
|
||||||
//! use openpgp_card_sequoia::card::Open;
|
//! use openpgp_card_sequoia::card::Open;
|
||||||
|
//! use openpgp_card_pcsc::{get_txc, 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 cc = PcscCard::open_by_ident("abcd:12345678")?;
|
//! let mut card = PcscCard::open_by_ident("abcd:12345678")?;
|
||||||
//! let mut open = Open::new(&mut cc)?;
|
//! let mut txc = get_txc!(card)?;
|
||||||
|
//! 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
|
||||||
//! open.verify_admin("12345678")?;
|
//! open.verify_admin("12345678")?;
|
||||||
|
|
|
@ -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::PcscCard;
|
use openpgp_card_pcsc::{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,9 @@ 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)?;
|
let mut card = PcscCard::open_by_ident(&test_card_ident)?;
|
||||||
let mut open = Open::new(&mut card)?;
|
let mut txc = openpgp_card_pcsc::get_txc!(card, true)?;
|
||||||
|
|
||||||
|
let mut open = Open::new(&mut txc)?;
|
||||||
|
|
||||||
// card metadata
|
// card metadata
|
||||||
|
|
||||||
|
@ -145,7 +147,9 @@ 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)?;
|
let mut card = PcscCard::open_by_ident(&test_card_ident)?;
|
||||||
let mut open = Open::new(&mut card)?;
|
let mut txc = openpgp_card_pcsc::get_txc!(card, true)?;
|
||||||
|
|
||||||
|
let mut open = Open::new(&mut txc)?;
|
||||||
|
|
||||||
// Check that we're still using the expected card
|
// Check that we're still using the expected card
|
||||||
let app_id = open.application_identifier()?;
|
let app_id = open.application_identifier()?;
|
||||||
|
@ -184,7 +188,9 @@ 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)?;
|
let mut card = PcscCard::open_by_ident(&test_card_ident)?;
|
||||||
let mut open = Open::new(&mut card)?;
|
let mut txc = openpgp_card_pcsc::get_txc!(card, true)?;
|
||||||
|
|
||||||
|
let mut open = Open::new(&mut txc)?;
|
||||||
|
|
||||||
// Sign
|
// Sign
|
||||||
open.verify_user_for_signing("123456")?;
|
open.verify_user_for_signing("123456")?;
|
||||||
|
@ -214,7 +220,9 @@ 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()? {
|
for mut card in PcscCard::cards()? {
|
||||||
let open = Open::new(&mut card)?;
|
let mut txc = openpgp_card_pcsc::get_txc!(card, true)?;
|
||||||
|
|
||||||
|
let open = Open::new(&mut txc)?;
|
||||||
println!(" {}", open.application_identifier()?.ident());
|
println!(" {}", open.application_identifier()?.ident());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue