diff --git a/card-functionality/Cargo.toml b/card-functionality/Cargo.toml index a0530ae..2c7f016 100644 --- a/card-functionality/Cargo.toml +++ b/card-functionality/Cargo.toml @@ -23,6 +23,10 @@ path = "src/keygen.rs" name = "other" path = "src/other.rs" +[[bin]] +name = "list-cards" +path = "src/list-cards.rs" + [dependencies] openpgp-card = { path = "../openpgp-card" } openpgp-card-sequoia = { path = "../openpgp-card-sequoia" } diff --git a/card-functionality/src/list-cards.rs b/card-functionality/src/list-cards.rs new file mode 100644 index 0000000..3767b9e --- /dev/null +++ b/card-functionality/src/list-cards.rs @@ -0,0 +1,18 @@ +// SPDX-FileCopyrightText: 2021 Heiko Schaefer +// SPDX-License-Identifier: MIT OR Apache-2.0 + +use anyhow::Result; + +use openpgp_card_pcsc::PcscClient; +use openpgp_card_sequoia::card::Open; + +fn main() -> Result<()> { + println!("The following OpenPGP cards are connected to your system:"); + + for card in PcscClient::cards()? { + let open = Open::open_card(card)?; + println!(" {}", open.application_identifier()?.ident()); + } + + Ok(()) +}