openpgp-card/openpgp-card-examples
Heiko Schaefer d55985807c
Change the API for interactions between openpgp-card and backends.
The goal of this change is a cleaner structure, and in particular to make it the default for client-code to obtain a CardApp with pre-initialized "capabilities" (that is, init_caps() gets called implicitely).
2021-11-11 16:40:08 +01:00
..
src/bin Change the API for interactions between openpgp-card and backends. 2021-11-11 16:40:08 +01:00
Cargo.toml Release tools 2021-11-05 23:14:48 +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