GNU TeXmacsUser manualReferenceAboutEnglish
Security, encryption and trusted documents

1.Introduction

TeXmacs documents are not just passive data: they may contain Scheme code, through the extern primitive, through hyperlinks and action tags whose target is a script, through observers attached to loci, and through the scripts of interactive widgets. Documents may also contain confidential material which should be stored encrypted on disk. This chapter describes the mechanisms which TeXmacs provides for both concerns:

The cryptography of the client/server system (TLS, certificates, password hashing on the server) is described in the chapters on the server and on the protocol, and is not repeated here.

2.Overview

The two concerns are handled by independent code:

Script security

is implemented partly in C++ and partly in Scheme. A document is trusted if its file name lies below one of the directories of $TEXMACS_SECURE_PATH (is_secure,

System/Classes/url.cpp

). The typesetter records this in the environment (edit_env_rep::secure); code coming from untrusted documents is passed to the Scheme predicate secure? (

kernel/texmacs/tm-secure.scm

), which accepts an expression only if it calls functions declared secure. The user preference security (“accept no scripts”, “prompt on scripts”, “accept all scripts”) decides what happens to the other expressions.

Encryption

is implemented entirely in Scheme, in

progs/security/

, on top of the external program gpg. The only hooks in C++ are the call of tree-export-encrypted in export_tree (

Texmacs/Data/new_buffer.cpp

) and the generic evaluate_system routine which runs gpg with passphrases sent through pipes. The markup for encrypted regions is defined in

packages/standard/std-security.ts

. All encryption features are disabled unless the preference experimental encryption is on and a gpg executable is found.

3.Source files

Paths below are relative to

src/TeXmacs/progs/

for Scheme files and to

src/src/

for C++ files.

kernel/texmacs/tm-secure.scm

The checker secure?, secure-eval and the list of primitive functions which are declared secure.

kernel/texmacs/tm-define.scm

The option :secure of tm-define.

System/Classes/url.cpp
,
System/Boot/init_texmacs.cpp

The predicate is_secure and the default value of $TEXMACS_SECURE_PATH.

Typeset/Env/env_exec.cpp
,
Style/Evaluate/evaluate_rewrite.cpp
,
Typeset/Concat/concat_active.cpp

The checks on extern and on observers, and the transmission of the trust status to links.

link/link-navigate.scm

The execution of scripts which are the target of a link or an action (execute-script).

texmacs/texmacs/tm-server.scm

The preference security and set-script-status.

security/gpg/gpg-base.scm

The interface to gpg: key generation, key listing, import and export, encryption and decryption, passphrase encryption, collected public keys.

security/gpg/gpg-edit.scm

Encrypted regions in documents, encryption of whole buffers, the save and load hooks.

security/gpg/gpg-widgets.scm
,
security/gpg/gpg-menu.scm

Dialogs (key manager, passphrase prompts, recipient selection), menus and preferences.

security/gpg/gpg-wallet.scm
,
security/wallet/

The wallet.

security/keychain/

Access to the keychain of macOS (security command) and Windows (winwallet helper).

security/password.scm

Generation of passwords and salts.

packages/standard/std-security.ts

Rendering of the encrypted and decrypted regions; the packages packages/customize/encryption/gpg-info-level-*.ts choose how much information about the recipients is displayed.

4.Contents of this chapter

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