![]() |
The wallet, system keychains and passwords | ![]() |
File names below are relative to
src/TeXmacs/progs/
.
The wallet is an encrypted table from keys to passphrases, so that the user does not have to retype the passphrases of keys and documents. It is built on GnuPG and only available when supports-gpg? holds. The interface is
security/wallet/wallet-base.scm
; the implementation is
security/gpg/gpg-wallet.scm
.
init-texmacs.scm
, expanded by expand-with-wallet in
security/wallet/wallet-menu.scm
): if the wallet is initialized, should be on persistently, but is off, the body is run after the dialog which turns the wallet on; otherwise it is run at once. Then wallet-get, wallet-set and wallet-delete do nothing (and return #f) while the wallet is off. The encryption code stores
under the key ("gpg" fingerprint) the passphrase of a secret key, after a successful decryption, and only if the wallet is on persistently (gpg-try-decrypt);
under the key (gpg-buffer-passphrase file) the passphrase of an encrypted document, for the file and for its autosave file (gpg-set-buffer-passphrase).
security/wallet/wallet-menu.scm
; they warn about passphrases with fewer than 8 characters or without upper case letters, lower case letters, digits and symbols, but accept them after a second confirmation.
On macOS and Windows, the wallet passphrase itself can be stored in the keychain of the operating system, under the service TeXmacs and the account wallet (wallet-save-passphrase, wallet-load-passphrase). When the user turns the wallet on, wallet-dialogue-turn-on first tries the passphrase from the keychain and only asks if it is missing or wrong.
security/keychain/macos-security.scm
runs the system command security -i and sends it add-generic-password, find-generic-password or delete-generic-password requests on standard input, so that the password is not visible on the command line; error reports show ******** instead of the password.
security/keychain/win-security.scm
runs the helper $TEXMACS_PATH/bin/winwallet with the arguments ADD, GET or RM, the account and the service, and sends the password on standard input.
Both modules define the same functions (system-security-add-generic-password, system-security-find-generic-password, system-security-quiet-find-generic-password, system-security-delete-generic-password); the right one is loaded by
wallet-menu.scm
according to the operating system.
security/password.scm
provides generate-password n, which returns a random password of \(n\) characters containing at least one lower case letter, one upper case letter, one digit and one symbol, and generate-salt. The characters are drawn with gnutls-random-number when GnuTLS is available (supports-gnutls?), and with the ordinary random otherwise; salts always come from gnutls-generate-salt. The TeXmacs server uses these functions for the administrator password and for password hashes (
server/server-base.scm
, see the server).