Skip to main content

Module pgp

Module pgp 

Source
Expand description

OpenPGP (RFC 9580) for mail, with Sequoia and its pure-Rust cryptography.

  • Your keys live in ~/.local/share/sioul/pgp/own/. A key made here keeps its revocation certificate beside it, <fingerprint>.rev, yours alone as the key is (revocation_path); revoking is not built. A key’s private part is in one of two places (Place): here, encrypted with a passphrase the system keyring keeps (sioul-sync asks it), so nothing is asked at each message; or on a security key, which signs and opens itself after its PIN (crate::securitykey), Sioul keeping only its public certificate. Keys come from an import (a file, GnuPG’s export), are made here, or are a security key’s.
  • Others’ keys live in …/pgp/others/: imported, found in their messages (Autocrypt), or looked up on request.
  • Signing and opening take Sequoia’s own Signer and Decryptor traits: a key here or a security key, the same way. A message a security key opened keeps its session key in memory (SessionKeys), so that it opens again without the key until Sioul closes.
  • What this module does not do: talk to the network, or to the keyring. Passphrases and PINs come in as arguments.

Structs§

Checked
A signature, checked.
Helper 🔒
KeySummary
A key as the window lists it.
Keys
The keys Sioul knows: yours (their secret parts here, or on a security key), others’, and your security keys.
Lent 🔒
A signer lent for one message: Sequoia’s stream takes its signer by value, and a security key’s signer borrows what it needs to reach the key.
Opened
What opening a message found.
Own
Your key for an address: its certificate, and where its private part is.
PgpView
What a protected message showed when opened, for the reader’s line.
SessionKeys
The session keys of messages a security key opened, by message: such a message opens again, with its attachments and its answer, without the key, until Sioul closes. In memory only, never on disk.
Unlock
How your keys open what is encrypted to you.

Enums§

Fingerprint
A key’s fingerprint, as the crates that do not use Sequoia themselves name it. A long identifier for certificates and keys.
Place
Where the private part of one of your keys is.

Constants§

LARGEST_DECRYPTED 🔒
The most a decrypted message may hold: anyone can encrypt to your key, and a few kilobytes of compressed data can inflate to gigabytes.

Functions§

autocrypt_header
The Autocrypt header for your outgoing mail: your key, smallest form (primary, encryption subkey, the user ID with your address).
autocrypt_key
Autocrypt (Level 1, §2.1): the key a message’s header carries for its sender.
can_sign_with 🔒
Whether the key fingerprint of cert can sign now: valid, alive, not revoked, allowed to sign.
canonical 🔒
Lone LF become CRLF: what was signed is the canonical form (RFC 3156 §5).
certificates_in
The certificates of bytes (armored or binary), read, not kept.
decrypt
Decrypts an OpenPGP message (armored or not) with your keys, checking the signatures inside. unlock gives the passphrase of a key of yours here, the session keys kept, and your security key when you asked to use it.
encrypt
data encrypted to the recipients’ keys, signed by yours when given; armored.
export_public
A key’s public part, armored, to give to others.
generate
Makes a key for you: Curve25519, for signing and encrypting, valid three years; its secret parts encrypted with passphrase. Its revocation certificate, which Sequoia makes with it, is kept beside it (revocation_path): the only way to revoke the key once it is lost.
generate_at 🔒
generate into the folder root (pgp/).
here_signer
Your key here that signs, its secret part opened with passphrase: the signer of a key kept on this device.
import
Imports the keys of a file: armored or binary, public or secret.
keep_card_certificate
Keeps the certificate of your security key with your keys: public parts only.
key_of
The key fingerprint of cert, its public part, primary or subkey.
kind_of 🔒
learn
Keeps keys found for address: public parts only, and only those naming it.
learn_autocrypt
Keeps a key from an Autocrypt header: only public parts, only when it names its sender.
message_id 🔒
A message’s name among the session keys: SHA-256 of its encrypted bytes.
names 🔒
Whether a key holds address among its user IDs.
new_passphrase
A long random passphrase for a key made here: nobody types it, the keyring keeps it.
open
Opens a protected message: PGP/MIME encrypted or signed (RFC 3156), or inline PGP. Gives back the message as it reads once decrypted (its own headers, then what was inside), when it was encrypted, and what was found; None when nothing is protected. A message encrypted to your security key opens only when unlock carries it, or from a session key kept; otherwise its view names the key it waits for.
opens
Whether passphrase opens the secret parts of your key fingerprint.
others_dir 🔒
outer_headers 🔒
The message’s own header lines but its MIME ones, which the decrypted body brings.
own_dir 🔒
pgp_dir 🔒
policy 🔒
read_certs 🔒
remove
Removes a key; yours are kept aside in pgp/removed, never deleted, with their revocation certificate.
revocation_path
Where the revocation certificate of your key made here is kept: beside the key, pgp/own/<fingerprint>.rev, readable by you alone (write_key), as GnuPG keeps its own in openpgp-revocs.d.
revocation_text 🔒
A revocation certificate as a file to keep: what it is, in a few lines, then the signature armored, a colon before its first line so that it cannot be imported by mistake (as GnuPG writes its own).
save_revocation
Copies the revocation certificate of your key fingerprint into folder, as <fingerprint>.rev (a number added when that name is taken), yours alone; none kept for that key, an error.
save_revocation_at 🔒
save_revocation from the folder root (pgp/).
sign_detached
A detached signature of data, armored, and the hash it used (“pgp-sha512”), for multipart/signed (RFC 3156 §5). signer is your key here (here_signer) or on a security key (securitykey::CardSigner).
store 🔒
Keeps a key, merged with what was known of it. Secret parts go with yours, and so does the certificate of a security key of yours, whatever brings it again (an Autocrypt header, a lookup).
store_at 🔒
store into the folder root (pgp/).
store_in 🔒
summaries
Every key, yours first; a security key’s certificate names its key.
summary 🔒
verify_detached
Checks a detached signature of data (multipart/signed).
wkd_urls
Where a domain’s Web Key Directory keeps the key of address: the advanced address, then the direct one (draft-koch-openpgp-webkey-service §3.1).
write_key 🔒
Writes a key file beside, then moves it in place. On Unix it is readable by you alone, whatever the umask: your secret keys, and whose keys you keep.
zbase32 🔒
z-base-32 (RFC 6189 §5.1.6), as WKD names keys.

Type Aliases§

Signing
A signer of yours, as Sequoia takes it: a key here (here_signer) or on a security key (securitykey::CardSigner).