feat: openpgp card test
This commit is contained in:
@@ -1,16 +1,29 @@
|
||||
use anyhow::Result;
|
||||
|
||||
use openpgp_card::OpenPgp;
|
||||
use openpgp_card_pcsc::PcscBackend;
|
||||
use openpgp_card_sequoia::card::Open;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
println!("The following OpenPGP cards are connected to your system:");
|
||||
|
||||
let cards = PcscBackend::cards(None).expect("list cards");
|
||||
println!("Found {} cards", cards.len());
|
||||
for mut card in PcscBackend::cards(None)? {
|
||||
let mut pgp = OpenPgp::new(&mut card);
|
||||
let open = Open::new(pgp.transaction()?)?;
|
||||
println!(" {}", open.application_identifier()?.ident());
|
||||
let mut trans = pgp.transaction()?;
|
||||
|
||||
// println!("== {:?}", trans);
|
||||
match trans.url() {
|
||||
Ok(url) => println!("{}", String::from_utf8_lossy(&url)),
|
||||
Err(e) => eprintln!("{:?}", e),
|
||||
}
|
||||
|
||||
// trans.verify_pw1_user(b"123456").expect("verify p1 user pin");
|
||||
// trans.verify_pw1_sign(b"123456").expect("verify p1 sign pin");
|
||||
// trans.verify_pw3(b"12345678").expect("verify p3 pin");
|
||||
|
||||
// let open = Open::new(pgp.transaction()?)?;
|
||||
|
||||
// println!(" {}", open.application_identifier()?.ident());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
21
examples/list_pgp_cards.rs
Normal file
21
examples/list_pgp_cards.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use anyhow::Result;
|
||||
|
||||
use openpgp_card::OpenPgp;
|
||||
use openpgp_card_pcsc::PcscBackend;
|
||||
use openpgp_card_sequoia::card::Open;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
println!("The following OpenPGP cards are connected to your system:");
|
||||
|
||||
for mut card in PcscBackend::cards(None)? {
|
||||
let mut pgp = OpenPgp::new(&mut card);
|
||||
let open = Open::new(pgp.transaction()?)?;
|
||||
println!(" {}", open.application_identifier()?.ident());
|
||||
println!(" {}", open.application_identifier()?.application());
|
||||
println!(" {}", open.application_identifier()?.version());
|
||||
println!(" {:?}", open.fingerprints());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user