openpgp-card/openpgp-card-examples
2021-12-02 18:45:46 +01:00
..
src/bin Rename Open::open() to Open::new() 2021-11-11 16:40:08 +01:00
Cargo.toml Bump versions for releases. 2021-12-02 18:45:46 +01:00
README.md Rename openpgp-card-apps into openpgp-card-examples 2021-10-29 22:38:01 +02:00

OpenPGP card usage with Sequoia PGP: Example apps

Small GnuPG replacements

This crate can be used to decrypt OpenPGP data and to sign data producing OpenPGP data.

First export the certificate that holds keys stored on the card:

$ gpg --export --armor $KEYID > cert.asc

Then create a test data, encrypted with GnuPG (as an example):

$ echo example data | gpg -ear $KEYID > encrypted.asc

And put the card PIN in a file called pin.

And then use the crate for decryption:

$ cargo run --example decrypt $CARD_ID pin cert.asc < encrypted.asc

The $CARD_ID holds card ident that can be printed using cargo run. It's a string that looks like 0006:12345678. Remember that if the GnuPG agent is holding an exclusive access to the card it will not show up. Unplugging and plugging the card again will relinquish GnuPG's agent's hold on the card.

Signing works the same way:

$ echo data to be signed | cargo run --example detach-sign $CARD_ID pin cert.asc > signature.asc