GNU TeXmacsUser manualReferenceAboutEnglish
The wallet, system keychains and passwords

File names below are relative to

src/TeXmacs/progs/

.

1.The wallet

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

.

Storage.
The wallet lives in the directory $TEXMACS_HOME_PATH/system/gnupg/wallet, which is a separate GnuPG home directory. It contains one key pair, generated by gpg-wallet-initialize with the user name __TeXmacs_wallet__ and protected by the wallet passphrase, and the file table.gpg, the table encrypted for that key (gpg-encrypt-save-object). The fingerprint of the wallet key is kept in the preference gpg wallet key fingerprint; gpg-wallet-initialized? checks that the directory, the table and a secret key with this fingerprint exist.
On and off.
When the wallet is on, the decrypted table is held in memory (gpg-wallet-table) and every change is written back at once, encrypted (gpg-wallet-set, gpg-wallet-delete). wallet-turn-on decrypts the table with the wallet passphrase; wallet-turn-off saves it and forgets it. Both also set the preference wallet persistent status, which records whether the user wants the wallet to be on in later sessions.
Use.
Code which wants a stored passphrase wraps the access in the macro with-wallet (defined in
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

Maintenance.
wallet-reinitialize moves the old wallet directory aside, creates a new one with the new passphrase, copies the table over and removes the old directory (or moves it back on failure). wallet-destroy removes the wallet directory. The dialogs and the preferences are in
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.

2.System keychains

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.

macOS
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.

Windows
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.

3.Passwords and salts

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).

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".