openpgp-card/openpgp-card-examples
Heiko Schaefer c96377c9df
OpenPGP owns CardBackend (instead of holding a &mut CardBackend).
When OpenPgp holds a &mut CardBackend, clients of this library need to keep track of the CardBackend (which adds unnecessary complexity).
2022-09-28 20:42:27 +02:00
..
src/bin OpenPGP owns CardBackend (instead of holding a &mut CardBackend). 2022-09-28 20:42:27 +02:00
Cargo.toml Adjust paths for move to gitlab group 'openpgp-card'. 2022-06-11 21:46:32 +02: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