Files
craft-libs/crates/assuan/README.md
Dylan M. Taylor a1e9eb8a31 Add craft-assuan: the Assuan client and gpg-agent operations from MailCraft (#902)
Moved from MailCraft's crates/assuan at a44a45013d1c. The code is unchanged apart
from the crate name and doc wording that named the app. The S-expression reader,
socket-file reader, limits and all 60 tests come with it.
2026-11-11 18:08:00 -05:00

28 lines
1.6 KiB
Markdown

# craft-assuan
The Assuan protocol and gpg-agent's operations, without sockets.
OpenPGP private keys stay in GnuPG (on disk or on a smartcard) and are used through gpg-agent,
which asks for the PIN or passphrase in its own pinentry. This crate speaks to the agent over any
`Read + Write` stream the caller opened.
- **`Client`**: Assuan's line framing (lines of at most `MAX_LINE` bytes, percent-escaping), the
server's `OK`, `ERR`, `S`, `D`, `INQUIRE` and `#` lines, and answers to an inquiry (`D` … `END`,
or `CAN`).
- **`GpgAgent`**: whether a key is there (`HAVEKEY`, `KEYINFO`, `READKEY`), signing a digest
(`SIGKEY`, `SETHASH`, `PKSIGN`; SHA-256, SHA-384 and SHA-512 only), decrypting a session key
(`SETKEY`, `PKDECRYPT`), and the hints that let the agent's pinentry show on the owner's screen.
- **`sexp`**: a bounded reader and writer of canonical S-expressions, the form the agent hands
keys, signatures and session keys over in.
- **`socket_file`**: the two kinds of file that may stand where the agent's socket is named: a
redirect, and (on Windows) the loopback port and nonce of Assuan's socket emulation.
Finding the agent and opening the socket is the caller's. Everything the agent sends is treated
as hostile: lines, data, status lines, inquiries and S-expressions are capped (`MAX_LINE`,
`MAX_DATA`, `MAX_LINES`, `MAX_STATUS`, `MAX_INQUIRIES`, `MAX_INQUIRY_DATA`, `MAX_KEYS`), and
nothing here panics on junk. A session key that comes back is wiped from memory when it is
dropped and is never shown by `Debug`.
Written from the public documentation of the Assuan protocol and of gpg-agent's commands. Moved
from MailCraft's `mailcraft-assuan`.