Introduction

Crymap is an IMAP server implementation for FreeBSD and Linux with a strong focus on security and simplicity of administration. Its spotlight feature is transparent encryption of data at rest — it is not possible to read any user’s mail without knowing their password, while a regular IMAP experience is provided and mail can be received while the user is offline.

Crymap supports both traditional UNIX-style deployments, where each user corresponds to a UNIX account and owns their own mail, and “black box” deployments, where users do not have shell access and all mail is owned by a single system UNIX account.

Crymap does not provide an SMTP server; i.e., it does not provide a solution for sending or receiving mail from the outside world, and a third party application such as OpenSMTPD must be used for this. Crymap can act as a UNIX MDA or as an LMTP server to transfer incoming mail from your SMTP server to the Crymap mail store.

Features

  • Fully compliant with the IMAP4rev1 specification.
  • Secure by default. IMAPS only.
  • Minimal configuration.
  • Messages and metadata transparently encrypted at rest.
  • Automatic key rotation.
  • Transparent file and over-the-wire compression.
  • All normal mailboxes are “dual-use” (allow both messages and sub-mailboxes).
  • Instant mail delivery notifications.
  • QRESYNC support.
  • “Special-use” mailbox support.
  • A decent number of additional IMAP extensions.
  • Supports messages with 8-bit and binary content.
  • Mail delivery as an MDA.
  • Mail delivery via LMTP.
  • Interoperates properly with filesystem-based backup systems.

Status and Support

The author uses Crymap for all personal email. It is known to work well in this use case. But this is naturally a fairly small amount of experience; in particular, Crymap has only seen day-to-day use in conjunction with OpenSMTPD and Thunderbird.

Crymap is currently maintained by its author alone. I am motivated to address bugs, but feature requests are unlikely to be accepted unless they offer substantial benefits to security or very common use cases. I will try to answer questions but cannot make commitments.

Caveats

  • If a password is forgotten, all data owned by that user is lost forever. There is no way for an administrator to reset a user’s password, as that would defeat Crymap’s purpose.

  • Crymap has no ability to integrate into the host authentication system. I.e., Crymap user accounts are fully independent of host user accounts in terms of password, enabled/disabled status, etc. This is because Crymap needs full control of the password change process for password changes to happen without destroying the user’s data. It would be technologically feasible to make, e.g., a PAM module that delegates to Crymap, but this is not implemented nor are there any plans to ever do so.

  • The maximum size of an email is currently hard-coded to 64MB.

How Crymap Encryption Works

Crymap uses a number of modern, well-understood cryptographic primitives to securely store email data.

Encrypting Message Data

Messages must be stored in a way that ensures two properties:

  • Only the owner can read mail.

  • Anyone with file system access (e.g., the mail daemon) can add mail to the user’s mailbox.

This is a natural fit for asymmetric encryption. Currently, Crymap exclusively uses 4096-bit RSA for this purpose.

Each account has, at any given time, a single active public key. When mail is received, an encryption key (the “session key”) for the message is randomly generated, and the message data is stored encrypted with that session key. The session key itself is first encrypted with the active public key. This lets the user (who has access to the corresponding private key) decrypt the session key and then decrypt the message content.

The message content itself is encrypted with 128-bit AES-GCM. Besides making it impossible for others to read the message, it also ensures that if the data is corrupted, Crymap will signal an error instead of returning the corrupt data.

A Crymap account typically has more than one RSA private key, though only one at a time corresponds to the active public key. By default, keys are rotated once per month. (The old keys are retained though, so old messages are still readable.) By default, there is also a distinction between “internal” keys, which never have their public key exposed and are used for all encryptions done by the user while logged in, and “external” keys, whose public keys are made available as the primary public key as each key is introduced.

RSA private keys are stored in standard PEM format with a passphrase. The passphrase is not the user’s passphrase, but one autogenerated from the user’s login data (see next section).

User Credentials

Handling of each user’s passphrase is performed with a combination of two cryptographic primitives:

  • The Argon2 password hashing function, which makes password brute-force attacks extremely costly.

  • The KMAC function (essentially an HMAC based on Keccak, i.e., SHA-3), which is used to generate secondary keys from an input secret.

The user configuration stores three pieces of information about the user’s credentials:

  • A password salt
  • A password hash
  • The “master key XOR”

When the user inputs their password, it is first hashed using Argon2 with the given salt, giving what we’ll call the “argon hash”. A KMAC value is generated from the argon hash. If that KMAC is not equal to the user’s password hash, we know the password is wrong and can reject the log in. Otherwise, we know the password is right, and take a different KMAC value from the argon hash to produce an “intermediate hash”. Finally, every byte of the intermediate hash is XORed with the corresponding byte of the master key XOR to output the master key.

The “master key XOR” is functionally a one-time pad between the intermediate hash and the master key. Its significance is that it makes it possible for the user to change their password: there is no way to control what the intermediate hash of the new password will be, but whatever it is, a master key XOR can be chosen which still outputs the same master key for the new password as the previous set of parameters did for the old password.

The master key is the primary credential used for all further key derivation in Crymap. Currently, the only derived keys are the PEM passphrases for the RSA private keys, which are each generated from different KMACs of the master key.

Protection Crymap Provides

There are a number of different approaches one can take with encrypting mail. None is a perfect solution, and Crymap fills what is currently a unique niche.

Protection from...DiskEnd-to-endPGPipeCrymap
Theft of storage mediumYesPartialPartialYes
File exfiltrationNoPartialPartialYes
Metadata exposureNoNoNoPartial
Eavesdropping in-transitNoPartialNoNo
Connection compromiseNoPartialPartialNo

Disk encryption

Disk encryption is a simple, effective way of protecting data in case someone walks away with the physical storage medium. It does not protect against attackers gaining shell access to the server or any form of file exfiltration since all the encrypted files are available in cleartext to anyone who can access that part of the file system. Disk encryption also poses challenges with respect to booting the server up without human intervention.

  • Protects from theft of storage medium.

  • No protection from file exfiltration.

  • No protection of message metadata.

  • No protection from eavesdropping on message in-transit.

  • No protection from IMAP connection compromise.

End-to-End Encryption

PGP and S/MIME provide ways for a sender to encrypt a message so that only the receiver can read it. Unlike the other solutions in this list, the message is also secure in-transit. The only way to compromise email content is to compromise the end email client itself. Unfortunately, not many people send encrypted messages this way. End-to-end encryption also typically reduces the quality of the mail experience. There is no protection of message metadata which is outside the message itself. Finally, PGP fails to encrypt any of the message headers.

  • Protects from theft of storage medium, except for parts of the message that can’t be encrypted.

  • Protects from file exfiltration, except for parts of the message that can’t be encrypted.

  • No protection of message metadata.

  • Protects from eavesdropping on message in-transit, except for parts of the message that can’t be encrypted.

  • Protects from IMAP connection compromise, except for parts of the message that can’t be encrypted.

Better-late-than-never encryption

This means using a solution like PGPipe to apply PGP encryption to unencrypted messages right before delivered. This protects the message after it has been delivered, but comes with the other downsides of PGP.

  • Protects from theft of storage medium, except for parts of the message that can’t be encrypted.

  • Protects from file exfiltration, except for parts of the message that can’t be encrypted.

  • No protection of message metadata.

  • No protection from eavesdropping on message in-transit.

  • Protects from IMAP connection compromise, except for parts of the message that can’t be encrypted.

Crymap

Since Crymap encrypts all message data at rest and has per-user isolation, it provides full defence against theft of storage medium and file exfiltration. It is also able to protect most message metadata, such as message flags. An attacker with file system access can still use that access to form educated guesses about when certain messages were delivered, whether they have been read, and their approximate size. Also note that the user folder structure is fully exposed. On the other hand, since Crymap transparently decrypts data before sending it over IMAP, compromising an IMAP connection reveals all data going over the wire.

  • Protects from theft of storage medium.

  • Protects from file exfiltration.

  • Partial protection of message metadata.

  • No protection from eavesdropping on message in-transit.

  • No protection from IMAP connection compromise.

Installation Guide

System Requirements

Crymap is designed to run on FreeBSD and Linux. It probably works on the other BSDs, but is not tested on them. Windows is not supported and most likely never will be since its filesystem is incompatible with Crymap’s requirements on many fronts.

The host file system must support symlinks and hard links, be case-sensitive, and either be non-normalising or use NFC normalisation. There must not be mount points inside any user directory. Remote file systems like NFS are supported if they provide sufficient consistency guarantees, but Crymap is not specifically designed to work with them, and IDLE notifications will only work properly if all Crymap instances for a given user are run on the same host.

When run on a single-CPU host or with appropriate tuning on a multi-CPU host, each Crymap instance typically only consumes a few MB of RAM. However, do be aware that Crymap is a one-process-per-connection system.

Crymap generally only holds at most a few dozen file handles open at any given time.

Installation

Crymap requires having the OpenSSL libraries installed. On Debian/Ubuntu, you can get them with apt install openssl. FreeBSD has the required libraries in the base distribution. (There is a way to cause OpenSSL to be built along with Crymap and statically linked, but this is not recommended since you won’t be able to get OpenSSL updates with your OS and this process is not described in this manual.)

Each [https://github.com/AltSysrq/crymap/releases/](release of Crymap) has pre-built binaries for AMD64 Debian and FreeBSD. Simply download the appropriate one of these and save it in a place you consider appropriate; for example (# means “as root”):

# cp crymap-$version-$os-amd64 /usr/local/bin/crymap
# chmod a=rx /usr/local/bin/crymap

If you do not want to use the pre-built binary or need to run on a different OS or architecture, you need to build Crymap from source. This requires having Rust installed, which you can get through rustup.

The easiest way to build Crymap is to get it with cargo:

$ cargo install crymap
# cp ~yourusername/.cargo/bin/crymap /usr/local/bin/crymap

You can also clone the repository directly:

$ git clone git@github.com:altsysrq/crymap
$ cd crymap
$ cargo build --release
# cp target/release/crymap /usr/local/bin/crymap

Initial System Setup

First, make sure you have valid SSL certificates for your domain. A full explanation of how to do this is beyond the scope of this document, but Let’s Encrypt is a good place to start if you are new to this.

All files used by Crymap are reachable from (though not necessarily “in”) a directory referred to as the “Crymap root”. By default, this is either /etc/crymap or /usr/local/etc/crymap (whichever exists); you can use something else, but if you do so, you must pass --root to all crymap server commands to tell Crymap where its data is. For this tutorial, we’ll use /usr/local/etc/crymap as the root.

Start by creating the Crymap root directory. The files we’re setting up below shouldn’t be modified in normal operation, so they should be owned by root.

# mkdir /usr/local/etc/crymap

Next, we create Crymap’s system configuration file, which is a file named crymap.toml under the Crymap root. A minimal configuration example is shown below.

# /usr/local/etc/crymap/crymap.toml
[tls]
# The path to your X509 private key. The example here would be correct for
# a FreeBSD system at `example.org` using Let's Encrypt with the default
# configuration.
private_key = "/usr/local/etc/letsencrypt/live/example.org/privkey.pem"
# The path to the full X509 certificate chain.
certificate_chain = "/usr/local/etc/letsencrypt/live/example.org/fullchain.pem"

(Yes, that’s all there is to the required configuration.)

Before we go further, we need to decide what style of deployment we’re going to do. Crymap supports three general patterns:

  • UNIX-style deployment, in which each Crymap user corresponds to a UNIX user on the host system and owns their Crymap files.

  • Simple black box deployment, where Crymap users are unrelated to UNIX users, and all Crymap data is owned by a dedicated UNIX account. Crymap is always run under that UNIX account.

  • Two-step black box deployment. As above, but Crymap is run as root and then allowed to drop privileges once it no longer needs them. This requires more work to set up but means that the dedicated Crymap user doesn’t need permission to read SSL certificates and the like. This chapter won’t talk about this approach; simply go through the setup for the simple black box deployment, then refer to the configuration reference to see what to change.

If doing a black box deployment, set up the dedicated Crymap user now. Below, we’ll assume the user has name crymap and group mail, but of course that will vary with your system.

The next step is to create the users directory.

If doing a UNIX-style deployment, the user’s mail will typically be stored in their home directory. This means that users will not actually contain the data and we can just make it a normal directory.

# mkdir /usr/local/etc/crymap/users

On a black-box deployment, the user data will end up under whatever directory we create, and we don’t really want to be storing data under /etc. Thus, we will create the users directory elsewhere and symlink it from the nominal location. In this example, we store users under /srv/crymap-users.

# mkdir -m 750 /srv/crymap-users
# chown crymap:mail /srv/crymap-users
# ln -s /srv/crymap-users /usr/local/etc/crymap/users

To see if your configuration so far is good, try running crymap serve serve-imaps under the same UNIX account you intend using in the real deployment. If you get the message stdin and stdout must not be a terminal, it means the configuration is valid and Crymap was ready to serve network traffic.

We won’t create any users just yet.

Running Crymap in IMAPS mode

Crymap does not run as a daemon. Instead, it uses a one-process-per-connection model in which some other process listens for connections and spawns Crymap processes as connections arrive. There are a number of options here, including xinetd and systemd. Here, we will use traditional inetd, available as the package openbsd-inetd on Debian and part of the base FreeBSD installation.

Arranging for Crymap to be run by inetd is just a matter of adding two lines to /etc/inetd.conf and then restarting inetd:

imaps   stream  tcp     nowait  root    /usr/local/bin/crymap   crymap server serve-imaps
imaps	stream  tcp6    nowait  root    /usr/local/bin/crymap   crymap server serve-imaps

If setting up a simple black box deployment, replace root with whatever user you want to run Crymap as.

Note the second occurrence of crymap in the command line is because inetd requires the configuration to specify the usually implicit argv[0] explicitly.

Do not add entries for the imap4 service. Crymap does not support the obsolete cleartext+STARTTLS mechanism on the IMAP4 port 143.

To test whether this setup works, run crymap remote test --trace --host=localhost. (You can of course run from another system, in which case pass the server’s host name to --host.) If successful, you should see some IMAP protocol traces and receive a prompt for a password. Of course, since no users have been created yet, it is not possible to log in, so simply cancel once it gets that far.

Creating a User

User creation is done with the crymap server user add command. By default, it generates a random password for the new user; --prompt-password can be given to input a password on the terminal instead. Refer to the user guide to see how to change the password after the account has been created.

On a UNIX-style setup, this command should be run as root, and you’ll usually want to give the path to the user data explicitly.

# crymap server user add jsmith ~jsmith/crymap-mail

On a black box setup, this command should be run as the Crymap user, and if your users directory is symlinked to a location outside of /etc, you can leave the user directory off to simply store the user data inside users.

$ crymap server user add jsmith

With that done, you should be able to test logging in as the new user:

$ crymap remote test --host=localhost --user=jsmith

It is also possible at this point to connect your favourite email application to Crymap, though you can’t receive email just yet.

Configuring Mail Delivery

Since Crymap does not provide an SMTP solution, it must be integrated with a third party application to accept incoming mail. Crymap currently offers two ways to do this integration:

  • LMTP. LMTP is a variant of SMTP which is suitable for the final step in the mail delivery process. LMTP is robust, can correctly handle binary payloads, and can be more efficient, but is inflexible in that all messages are delivered to INBOX and without flags.

  • UNIX MDA. This is more flexible than LMTP as it can be made to deliver to arbitrary mailboxes in a user’s account and to set flags on new messages. In traditional UNIX setups, users can also invoke Crymap in as an MDA from their .forward file. Its main disadvantages are that it is less robust against errors, and because UNIX MDAs are typically passed the message with all line endings converted to UNIX line endings, Crymap must convert the line endings back, which will destroy binary content.

The instructions here are for LMTP. Refer to crymap server deliver --help for more information on using Crymap as an MDA. This section also contains concrete examples of using OpenSMTPD; if you are using a different SMTP daemon, you will need to refer to its documentation.

First, we need to set something up to run Crymap in LMTP mode. This works essentially the same as how we set up IMAPS, except here we don’t want the server to be accessible to anyone in the world. There’s two ways to do that:

  • Configure inetd, etc, to only listen on localhost.

  • Use a UNIX socket. This is what we do in this example, since it is possible to set finer-grained permissions.

Here is an example inetd configuration for a UNIX-style deployment:

:root:wheel:666:/var/run/lmtp.sock stream tcp nowait root /usr/local/bin/crymap crymap server serve-lmtp

Notes:

  • Notice this uses serve-lmtp instead of serve-imaps at the end.

  • root:wheel would be written root:root on typical Linux installations.

  • As with IMAPS, for a simple black box deployment, you would configure it to run under the Crymap user and not root.

  • This example allows anyone with shell access to open the LMTP socket and deliver mail (due to the 666 permission). To prevent that, you can give the socket a different owner and less permissive permissions. But to start with, it is probably best to keep it simple so there are fewer things to debug.

Crymap has a number of configurable options for LMTP. The defaults are fine for simple installations, but you may want to have a look at the configuration reference.

You can use socat to see if LMTP is working:

$ socat STDIO UNIX:/var/run/lmtp.sock
220 yourhostname crymap 1.0.0 LMTP ready
^C

Finally, you need to configure your SMTP server to deliver mail through LMTP. For OpenSMTPD, your smtpd.conf file might contain something like this:

action "local_mail" lmtp "/var/run/lmtp.sock"
match from any for domain "lin.gl" action "local_mail"
match for local action "local_mail"

After that, all that’s left to test is to send the user an email and see if it shows up!

Troubleshooting

By default, Crymap logs to syslog under the “mail” utility. When Crymap is not run from a terminal, this means its logs should end up someplace like /var/log/maillog or /var/log/mail.log.

In certain cases of severe misconfiguration (for example, by passing invalid parameters in inetd.conf), Crymap may instead print an error on standard error and exit. Where these messages end up depends on what you are using to run Crymap. The output might be in a system log like /var/log/messages, or it could be getting sent over the socket. To check for the latter case, you can run a command like socat STDIO TCP:localhost:993 to see if anything shows up.

Administration Guide

These sections cover (hopefully) everything you need to know about operating and maintaining a Crymap installation beyond the initial setup.

Configuration Reference

crymap.toml

Below is an example crymap.toml with every option explicitly set to the default and comments explaining what each one does.

[tls]
# The path to your X509 private key.
private_key = "<no default>"
# The path to the full X509 certificate chain.
certificate_chain = "<no default>"

# Additional identification information to send to clients.
# This is a free-form map. Refer to RFC 2971 § 3.3 to see what standard
# identification names exist. You do not need to set all the values.
# `support_url` is probably the most important one since some mail clients
# can use it to help the user get assistance.
# Underscores in key names are replaced with hyphens.
[identification]
vendor = "Example Company"
support_url = "mailto:it@example.com"
address = "1313 Dead End Dr"

# The [security] section applies any time any of the `crymap server ...`
# commands is run.
[security]
# If this is set to true and Crymap is run as `root`, it will chroot into the
# `users` path under the Crymap root once it has accessed all system files it needs
# which are outside that directory.
#
# This can be set for any style of deployment where Crymap is started as
# `root`, but note that if this is set, user directories inside `users` may not
# be absolute symlinks or symlinks to anywhere outside `users`.
chroot_system = false

# If this is set to a non-empty value and Crymap is run as `root`, it will drop
# privileges to this UNIX user once it has accessed all system files it needs
# which are outside the Crymap root. This occurs before any interaction with the
# incoming connection occurs. This makes it possible to run Crymap in a
# configuration where it does not normally have access to SSL certificates, for
# example.
#
# This setting is the main difference between a "simple" black box deployment,
# where Crymap is started as the desired non-root user, and a "two-step" black
# box deployment, where Crymap is started as root and then drops to the user
# given here.
system_user = ""

# The [lmtp] section applies when Crymap is run with `crymap server serve-lmtp`.
[lmtp]
# If non-empty, Crymap will report this value as its hostname.
# By default, Crymap reports the system host name.
host_name = ""

# By default, Crymap will strip everything after the `@` in destination
# addresses to determine the name of the Crymap user (so an email addressed
# to "foo@bar.com" gets delivered to Crymap user "foo"). Setting this to true
# suppresses this behaviour. Note that your SMTP daemon may also do this
# stripping, in which case you must configure both Crymap and the SMTP daemon
# to retain the domain.
#
# Set to true if your users log in as `user@domain.com` instead of `user`.
keep_recipient_domain = false

# By default, Crymap will make the recipient user name lower case, remove all
# periods, and strip everything including and after the first `+`. (If
# `keep_recipient_domain` is `true`, the `@` and domain part are not affected
# by these rules, but the local part is.) Setting this to true prevents all
# these normalisations, which may be useful if you want something different to
# happen. Note that this means that your SMTP daemon must make the
# normalisations you want. Most importantly, enabling this option will make
# Crymap mail delivery CASE SENSITIVE TO USER NAMES.
verbatim_user_names = false

[diagnostic]
# If set, redirect standard error to this file on startup.
#
# This is applied before any part of the security configuration is
# applied and before any communication with the remote host.
#
# This is useful if `inetd` (or equivalent) or your MTA runs Crymap such
# that standard error goes to a less useful place, such as to the remote
# host. If anything actually ends up in this file, it represents a bug in
# Crymap, as actual errors should go through the logging system.
stderr = null

Logging

By default, Crymap logs to syslog under the “mail” facility.

If you want to do something else, you can create a file named logging.toml next to crymap.toml. This file is a log4rs configuration file. The exact format of this file is not extensively documented, so if you want to do this, you’re unfortunately on your own for now. Note that there is not currently a way to log to syslog and a separate logging system simultaneously at this time.

Here is a basic example of a logging.toml file:

[appenders.file]
kind = "rolling_file"
path = "/var/log/crymap/crymap.log"
append = true

[appenders.file.policy.trigger]
kind = "size"
limit = "10 MB"

[appenders.file.policy.roller]
kind = "delete"

[appenders.file.encoder]
kind = "pattern"
pattern = "{d(%Y-%m-%dT%H:%M:%S)} [{l}][{t}] {m}{n}"

[root]
level = "info"
appenders = ["file"]

Managing Users

Crymap’s notion of a user

A “user” in Crymap simply refers to an entry within the users directory. Each entry may either be a directory, or be a symlink to a directory. Whichever it is, that directory is the user data directory.

In traditional UNIX-style deployments, Crymap uses the owner of the user data directory to determine which UNIX account to assume for operations on that user. In black box deployments, the exact ownership of the user data directory is less important, but it is still necessarily something that the Crymap user has access to and which doesn’t let unauthorised users access it.

Creating users

Creation of a user is (internally) a non-trivial operation since it needs to generate a master key for the user and make it derivable from the user’s initial password. The process also must set up the user’s basic directory structure and mailboxes, most importantly INBOX.

User creation is done through the crymap user add command. This command should be run as root for traditional UNIX-style deployments and as the Crymap user for black box deployments.

The first argument of the command is the name of the user to create, e.g., jsmith. If the command is run as root, Crymap will by default assume that that name also refers to the name of the UNIX account that will own the mail data, and will fail if no such account exists. The --uid option can be passed to provide the UID that should own the user data directory.

The optional second argument of the command gives the path to the user data directory. If this argument is not given, the user data directory is simply a directory within users. The command will fail if this would cause the user data to be stored inside /etc or /usr/local/etc; in this case, you need to explicitly give a path for the user data.

By default, a password for the user is randomly generated. You can pass --prompt-password to input your own.

Renaming, aliasing, and deleting users

Crymap does not currently have special commands for these operations. Once created, users can be treated as regular file system objects. In particular:

  • A user can be renamed by simply renaming the entry under users.

  • User aliases can be created by symlinking the additional alias to the user data directory.

  • Users can be deleted by removing their entry from users.

  • Users can be disabled by renaming them to an illegal user name. The simplest way is to just prefix their name with %.

  • A user can be imported from another Crymap installation by simply moving the user data directory (or a symlink thereto) into users.

Password Resets

When a user changes their password, a backup of the user configuration is created in the tmp directory within the user data directory, with a name of the format config-backup-DATETIME.toml. If necessary (for example, because the user mistyped their new password), the password change can be undone by replacing the user.toml file at the top of the user data directory with the backup file. Note that these backup files are automatically deleted after a successful login 24 hours after the change was made.

If a user forgets their password, there is no recourse. Their data is gone forever. The best thing to do is to move their user data directory to somewhere else in case they remember the password later and create a new account for them.

Backups and Recovery

Backups

Crymap uses a “filesystem as a database” model for its storage. This means that no exotic tooling is required to back the Crymap data up. Even simple tools such as rsync are sufficient.

A proper backup system should be able to handle the following:

  • Binary file content
  • Unicode file names
  • Symlinks must be backed up as symlinks, not copies of what they point to, and must retain their exact target
  • Cyclic and dangling symlinks must be tolerated

Exact file modes and owners do not need to be preserved, but it is better if they are. While Crymap creates hard links, it does not require them to be preserved, and a backup will function properly if the hard-linked files are reconstructed as separate files. Crymap does not use file timestamps or extended attributes for anything important.

Crymap is designed to be tolerant of anomalies resulting from the backup process not capturing an atomic snapshot of the user data directory. There is one requirement: the backup system must be able to process the a user’s whole data directory in less than 24 hours. If this requirement is met, no data which existed before the backup started will be lost, with one corner case.

The corner case is has to do with mailbox renaming, since Crymap uses filesystem directories to model the mailbox hierarchy. Consider a user with the below mailbox hierarchy.

|-+ INBOX
|
|-+ In Progress
| |
| \-+ TPS Reports
|
\-+ Archive

It might happen that the backup system happens to process these directories in this order: Archive, INBOX, In Progress. When it goes through Archive, it makes a backup in which Archive has no child mailboxes. Now, suppose that when it is working on INBOX, the user moves TPS Reports into Archive:

|-+ INBOX
|
|-+ In Progress
|
\-+ Archive
  |
  \-+ TPS Reports

Now, when the backup system finishes INBOX and moves on to In Progress, it makes a backup of In Progress which has no child mailboxes. Now we have a backup which does not contain TPS Reports anywhere, even though that mailbox always existed somewhere!

This is a problem inherent in any filesystem-based backup system, and means it is important to have multiple backups available in case one backup runs at just the wrong time.

This corner case does not affect moving individual messages between mailboxes because Crymap is able to retain the messages in their old location for the 24hr grace period.

Restoring from Backup

Due to the “filesystem as a database” model, restoring from backup is usually just a matter of recovering the files and putting them back in the correct place, possibly after fixing permissions if the backup system does not preserve them.

If the backup is not a fully consistent state, mail applications may have difficulty resynchronising. It may be necessary to do a “repair” or fully reconfigure the application.

It is also possible to retrieve parts of a user’s account (i.e. mailboxes) and insert them into the current account by placing the directories in an appropriate place under the mail directory within the user data directory. If there are missing RSA keys, they can also be retrieved from the keys directory in the backup and added to the current filesystem. No special configuration or notification to Crymap is needed for these operations; simply putting the files/directories into place is sufficient.

Objects from a user account are readable from only that user account. For example, in case of a system failure, you cannot set up a new system, create user accounts in it, and then expect to be able to drop data from the backups into those new user accounts. The user accounts themselves must be restored from backup.

Understanding the Filesystem

This section only covers what is useful to know when inspecting a Crymap installation with regular shell tools. For the nitty-gritty details, you’ll need to look at the Crymap source code’s internal documentation.

Crymap root

There are three files of significance at the Crymap root:

  • crymap.toml. This is the “system configuration” and provides all of Crymap’s configuration other than logging and that which is represented by the filesystem.

  • logging.toml. If present, replaces syslog-based logging with something else.

  • users. Either a directory or a symlink to a directory which contains one entry for each Crymap user.

Refer to the configuration reference for the two configuration files, and user management for the users directory.

User data directory

The user data directory contains the following files:

  • garbage. This is used internally for deleting directories. It is safe to fully delete all its contents at any time. Crymap itself aggressively cleans it.

  • keys. A directory containing the user’s RSA keys. It is a critical part the user data needed for accessing the user’s mail.

  • mail. The root of the user’s mailbox hierarchy. All the user’s mail is stored inside this directory. Each directory inside is a single mailbox.

  • maintenance-run. This is a marker file used to track the last time that a full maintenance pass was run on the account. This can be deleted safely, which will cause the next login to trigger a full maintenance pass.

  • shadow. This is a “shadow” of the mail hierarchy used to track mailbox attributes that operate independently of the mailboxes themselves. Currently, this is only for IMAP subscriptions.

  • tmp. Used for temporary files and temporary markers. Crymap will automatically clean stale files out of this directory. It is not too important to back up (though it is also the destination for config backups which allow undoing password changes) but should not be cleaned manually unless there is some clear need to do so.

  • user.toml. This contains the user’s preferences and the data needed to derive their master key from their password. This file can be overwritten with an earlier backup version (either a backup created under tmp or by some external backup system) to revert a password change.

Mailboxes

A mailbox is a directory named after the IMAP mailbox of the same name. The INBOX mailbox is quite special (and must be all upper case); other mailboxes can be named freely.

Inside a mailbox, all subdirectories not prefixed with % are child mailboxes.

Normally, each mailbox will have a directory named %$hexcode and a symlink pointing to it named %. If neither exists, it means the user at some point attempted to delete the mailbox while it had child mailboxes. This manifests as a “non selectable” mailbox in IMAP. The %$hexcode directory contains the actual mailbox data.

A mailbox data directory may contain the following:

  • c0, c1, c2, c3. These contain metadata transactions for the mailbox, such as changing flags on messages.

  • c-guess. Used in the metadata transaction process. Safe to delete or corrupt.

  • mailbox.toml. Contains immutable metadata about the mailbox.

  • recent. Contains a marker file used to track the “recent” IMAP flag. Safe to delete.

  • rollups. Contains rollups of the mailbox state.

  • socks. Contains marker symlinks used to locate sockets used to notify idling Crymap processes of changes. Safe to delete.

  • u0, u1, u2, u3. These contain the actual messages in the mailbox.

  • u-guess. Used to accelerate working with the u* directories. Safe to delete or corrupt.

It is normal for the c* and u* directory trees to contain broken or cyclic symlinks. These symlinks play an important role in how Crymap manages its data.

If you think a mailbox has been corrupted somehow, it is a reasonable last-resort step to remove the c* and rollups directories. This will destroy all the user’s message metadata and may undelete some messages. The next time the mailbox is opened, it may take a very long time. However, Crymap should be able to recover the messages themselves.

Tuning

Crymap’s tuning options are very limited; in fact, Crymap itself directly provides only one.

Thread Count

When certain operations across multiple items, such as fetches or searching, take too long, Crymap will spin up extra threads to parallelise the work and reduce latency. By default, it will create up to as many threads as there are CPU cores.

The environment variable CRYMAP_MAX_THREADS can be set to any integer to override this. Setting it to 1 will completely prevent Crymap from trying to parallelise work.

Note that you cannot make Crymap fully single-threaded for this operation. Even if it is set to 1, Crymap will still spawn extra threads for background cleanups and idling, which are sufficient to cause the memory allocator to switch to multi-threaded mode on multi-core systems.

Memory Allocator

Crymap uses the host system’s malloc(), so exactly how it gets tuned depends on your system. Often, you can refer to malloc(3) for information on how to configure the allocator.

Crymap is very conservative about allocating memory and ensures that memory not needed is freed expediently. The memory allocator itself may not be. In particular, glibc’s malloc() (used on most Linux installations) and jemalloc (used on FreeBSD) will switch to a strategy optimised for multi-core performance when running on a multi-core system. This can cause Crymap to use dramatically more memory than it actually needs, potentially by a factor of as much as 10. If running Crymap on a multi-core system with memory constraints, it is useful to disable the multi-core allocation strategies.

With glibc malloc(), this can be done by setting the environment variable M_ARENA_MAX to 1.

With jemalloc, a similar thing can be done by setting MALLOC_CONF to narenas:1.

User Guide

Mail server settings

Assuming your administrator has not indicated otherwise:

  • Protocol: IMAPS or IMAP (POP not supported)
  • Host/domain: Provided by administrator
  • Port: 993
  • Connection security: “SSL/TLS”, “Secure connection”; not “STARTTLS”
  • Password/Authentication: “Normal”, “plain”

Do not proceed if you receive certificate or security warnings.

Mail submission settings must be provided by your administrator.

Changing your password or settings

To change your Crymap password or Crymap settings, you currently need the crymap program. Your administrator should provide this; if not, refer to the installation subsection for ways to get crymap. (This is the same program used to run Crymap on the mail server.)

Changing your password

To change your IMAP password, run the below command, where USER is the username you use to log in to IMAP, and HOST is the host or domain you use to connect to IMAP:

crymap remote chpw --user=USER --host=HOST

The password change takes effect immediately, but does not terminate existing IMAP sessions.

Note that your Crymap password is independent of your other email password(s). You need to change both. (It is possible to use different passwords for the separate systems too, if you prefer, though not all mail clients can work with such a configuration.)

If you find you need to undo the password change, the administrator can help you with that.

Changing key rotation settings

By default, Crymap rotates your mail encryption keys once per month. Rotation is controlled by key name templates, which are filled in with the current time. Changing these templates to include more or less of the date will have the effect of changing the key rotation frequency.

Below are some examples of setting the key rotation.

# Rotate once per day
crymap remote config --external-key-pattern "external-%Y-m-%d" \
    --internal-key-pattern "internal-%Y-%m-%d" --user=USER --host=HOST
# Rotate once per year
crymap remote config --external-key-pattern "external-%Y" \
    --internal-key-pattern "internal-%Y" --user=USER --host=HOST
# Rotate once per week
crymap remote config --external-key-pattern "external-%Y-%W" \
    --internal-key-pattern "internal-%Y-%W" --user=USER --host=HOST

Viewing the current configuration

To view the current configuration, simply run

crymap remote config --user=USER --host=HOST

IMAP Characteristics

This section is targeted at client developers or those with an interest in the lower-level IMAP details.

Conformance

Crymap fully conforms to the IMAP4rev1 (RFC 3501) and IMAP4rev2 (RFC 9051) standards. It also conforms to a number of extensions detailed in later sections.

Crymap passes the full Dovecot imaptest compliance suite excepting tests for extensions that Crymap does not implement.

Crymap was developed with the following priorities:

  1. Don’t corrupt the user’s mail. (The “prime directive”.)
  2. Be secure.
  3. Conform to standards.
  4. Be reasonably performant and light-weight.

In spite of the earlier paragraphs, there are cases where (1) and (3) come into conflict. Usually this is a result of a specification assuming all email messages are well-formed or pre-dating another specification change that makes compliance impossible without violating the prime directive, but there are also some issues with self-contradiction. These will all be discussed in individual sections where relevant.

Notwithstanding the few exceptions discussed, Crymap’s IMAP implementation conforms to the following standards:

  • RFC 2045 MIME Extensions: Format of Internet Message Bodies
  • RFC 2046 MIME Extensions: Media types
  • RFC 2047 MIME Extensions: Message Header Extensions for Non-ASCII Text
  • RFC 2157 UTF-7
  • RFC 2177 (IDLE)
  • RFC 2183 The Content-Disposition Header Field
  • RFC 2231 MIME Parameter Value and Encoded Word Extensions: Character Sets, Languages, and Continuations
  • RFC 2342 (NAMESPACE)
  • RFC 2557 (Content-Location header field)
  • RFC 2595 (PLAIN authentication)
  • RFC 2971 (ID)
  • RFC 3066 Tags for the Identification of Languages
  • RFC 3282 Content Language Headers
  • RFC 3348 (CHILDREN)
  • RFC 3501 (IMAP4rev1)
  • RFC 3502 (MULTIAPPEND)
  • RFC 3516 (BINARY)
  • RFC 3691 (UNSELECT)
  • RFC 4315 (UIDPLUS)
  • RFC 4731 (ESEARCH)
  • RFC 4959 (SASL-IR)
  • RFC 4978 (COMPRESS=DEFLATE)
  • RFC 5161 (ENABLE)
  • RFC 5182 (SEARCHRES)
  • RFC 5253 (LIST-EXTENDED)
  • RFC 5322 (Internet Message Format)
  • RFC 5530 IMAP Response Codes
  • RFC 5819 (LIST-STATUS)
  • RFC 5918 Unicode Format for Network Interchange
  • RFC 6154 (CREATE-SPECIAL-USE and SPECIAL-USE)
  • RFC 6532 Internationalized Email Headers
  • RFC 6851 (MOVE)
  • RFC 6855 (UTF8=ACCEPT)
  • RFC 7162 (CONDSTORE and QRESYNC)
  • RFC 7888 (LITERAL+)
  • RFC 8438 (STATUS=SIZE)
  • RFC 8457 IMAP “$Important” Keyword and “\Important” Special-Use Attribute
  • RFC 8474 (OBJECTID)
  • RFC 9051 (IMAP4rev2)

Unicode support

Crymap is inherently a Unicode-aware, UTF-8-based application. All data which is returned to the client in a structured way (i.e., not as a raw byte stream) is internally managed as UTF-8.

If non-ASCII strings would be sent to a client that has not enabled UTF-8 support, one of two approaches is taken right before the data is put onto the wire, depending on the field:

  • The whole field may be put into RFC 2047 “encoded word” form, using base64-encoded UTF-8. Note that this means that returned “encoded words” are rarely in exactly the same form as they are in the original message, though the content remains the same.

  • Non-ASCII characters may be replaced by ‘X’. This is only done for fields that do not allow the previous strategy.

RFC 2184 is not implemented because it is impossible to implement its IMAP4 requirement at the same time as conforming to IMAP4rev1. Specifically, RFC 2184 would have the server decode encoded non-ASCII text in certain header parameters, but IMAP4rev1 does not allow these fields to contain non-ASCII content and the fields also may not contain encoded words. Instead, Crymap assumes the client will be able to deal with the parameters itself. This is likely to be a safe assumption, since this has always been an optional feature of IMAP servers, so clients need to be prepared to do it themselves either way.

Search uses Unicode “simple” case folding.

Limits

The maximum message size for APPEND is hard-wired to 64MB.

Batch insertions (through COPY, MOVE, or APPEND) are limited to 65536 messages.

Any operation that involves parsing message content will not process more than 20 levels of multipart or message/rfc822 nesting, nor will it process more than 1000 different body parts.

Message header lines in excess of 64kB are not processed.

Search operations will consider up to 128kB of text. Non-text body parts are ignored for search.

A mailbox can have up to 2’305’843’008 message IDs allocated. Note however that inserting multiple messages into a mailbox at once can use up to 128 times as many IDs as the number of messages actually inserted. Up to 3’999’999’999 change transactions can be performed on a mailbox. If either of these limits are reached, the mailbox will be “full” and further operations will fail. (Note that Crymap has not actually been tested in this condition.)

Mailboxes

All mailboxes other than INBOX may have children. Nesting depth is dependent on the host operating system’s maximum path length.

Mailbox names may not contain %, *, \, /, control characters or one of a few Unicode control characters, and may not begin with . or #.

Mailbox names other than INBOX are case-sensitive. INBOX is always upper-case.

The path delimiter is /. Making a mailbox path “absolute” by prefixing it with a / has no effect. Duplicate / characters in a name are ignored.

Non-normalised MUTF7 is accepted in mailbox names. Mailbox names are always returned in normalised MUTF7. MUTF7 is not returned on output nor transformed on input when the client has enabled UTF-8 support.

When UTF-8 support is enabled, including by way of IMAP4rev2, no normalisation of mailbox names occurs other than removal of extraneous path delimiters and the special case of INBOX being case-insensitive. IMAP4rev2 has a recommendation to send unsolicited LIST responses when a client uses a denormalised mailbox name. Due to the extremely limited utility of this feature in the context of Crymap’s implementation, Crymap does not implement this recommendation.

The \Marked and \Unmarked attributes are not used.

If a mailbox is deleted or renamed while a session has it open, the session will be terminated as soon as this occurrence is discovered.

When an account is created, the following mailboxes are made, with the shown special-use attributes.

MailboxSpecial-Use
INBOX
Archive\Archive
Drafts\Drafts
Sent\Sent
Spam\Junk
Trash\Trash

Messages

Crymap tolerates and preserves messages with arbitrary binary content.

Clients in sessions that have not yet observed the expungement of a message can continue to access it for 24hr after the expungement.

If a message contains 8-bit content in the headers and the client requests the raw headers, Crymap will return that 8-bit content verbatim even if the client has not enabled UTF-8 support. If a message contains binary content and the client requests that binary content, even without using the BINARY extension, Crymap will return the binary content as-is because the IMAP specification gives no other way to return the data without corrupting it. Both of these issues are described in more detail in the descriptions of the UTF8=ACCEPT and BINARY extensions.

If messages contain non-DOS line endings, the line endings are returned as-is, so as not to corrupt anything. Crymap understands both UNIX and DOS line endings in messages. This is expected to be a non-issue, given that GMail actually served messages exclusively with UNIX line endings for years before anyone noticed. (Note though that when acting as a UNIX MDA, Crymap does convert line endings as they come in. This paragraph applies to messages that come in through IMAP or LMTP.)

Unsolicited FETCH responses always include UID and FLAGS. If CONDSTORE has been enabled, they include MODSEQ as well.

Flags

All “system flags” are supported and permanent. \Recent is fully implemented and fully atomic. Arbitrary keywords can be created without limit.

Authentication

LOGIN and AUTHENTICATE PLAIN are both supported and have the same effect. AUTHENTICATE does not allow the authorisation and authentication usernames to differ.

Extensions

RFC 8457

Crymap supports the $Important keyword and the \Important special-use attribute.

RFC 5530

Extended status codes are used everywhere they make sense.

APPENDLIMIT

Crymap uses a fixed APPENDLIMIT value which is reported in the capabilities list.

BINARY

Binary literals are understood, but are not handled any differently than non-binary literals. (That is, Crymap accepts and properly handles binary content in all contexts.)

If a client requests a BINARY body section, binary literal syntax is used iff the response payload contains a NUL byte.

The BINARY fetch feature is treated as orthogonal to the rest of the fetch options, and Crymap currently allows combinations not allowed by the standard.

The BINARY extension presents an odd conundrum: An IMAP4rev1 server is required to report the actual content transfer encoding of a binary part (binary), and is required to return body parts in their original transfer encoding when queried without BINARY, but at the same time is forbidden from returning binary data. In these cases, Crymap returns the binary data anyway, since doing so is a lesser evil than corrupting the data itself.

Crymap does not perform any encoding changes of messages appended using binary literals.

The standard insinuates that if the client requests content transfer decoding of a body part, and the server finds that the body part does not use DOS newlines, it should convert the newlines to DOS newlines. Crymap does not do this, since that constitutes data corruption.

CHILDREN

If a client makes a non-extended LIST command, \HasChildren and \HasNoChildren mailbox attributes are returned implicitly.

COMPRESS=DEFLATE

Deflate-based compression may be enabled at any time.

Crymap is not aware of whether TLS itself is using compression and so will not reject enabling compression even if TLS compression is active.

CONDSTORE

This extension is fully implemented.

Atomic updates are performed with respect to all flags on a message and not just the flags being modified, since this is both simpler and more useful. (And seems like what clients expect — there has been some talk of using conditional store to maintain tri-state flags like Junk/NonJunk/(nothing) properly.)

Modseqs are 63-bit integers as required by the later QRESYNC extension.

Internally, Modseqs are a 2-element vector clock pairing the maximum known UID with a monotonic “Change ID” (CID) with additional bookkeeping to maintain the extension’s strict ordering requirements. This can be seen in returned Modseq values as the UID multiplied by 4 billion plus the CID.

If multiple messages are changed at once, they all receive the same Modseq.

Expunging a message increments the highest Modseq value.

Crymap does not return HIGHESTMODSEQ response codes until CONDSTORE is enabled.

CREATE-SPECIAL-USE

The following special-use attributes are allowed: \Archive, \Drafts, \Flagged, \Junk, \Sent, \Trash, \Important. \All is not allowed since Crymap does not support an “all mail” view.

At most one special-use can be given to a mailbox. Crymap does not take action on special-use attributes except to return them, and does not prevent creating multiple mailboxes with the same special use.

ENABLE

This extension is fully implemented.

ESEARCH

This extension is fully implemented.

Crymap does not attempt to optimise searches for MIN or MAX alone.

ID

This extension is fully implemented.

The client-submitted identifying information is written into the server logs.

The [identification] section of the server configuration can provide additional attributes to be returned here. By default, Crymap returns name and version.

IDLE

This extension is fully implemented.

Notifications about changes are typically delivered within a millisecond of when they occurred (modulo client-server latency of course). Message creation and expungement and flag operations are all monitored.

Crymap does not strictly validate that the idle is terminated with “DONE”.

LIST-EXTENDED

This extension is fully implemented.

LIST-STATUS

This extension is fully implemented, but only because IMAP4rev2 requires it. No optimisations are made over simply making separate STATUS calls.

LITERAL+

This extension is fully implemented.

MOVE

This extension is fully implemented.

Moves occur as three separate atomic steps:

  • Messages are added to the destination.
  • Flags are set on the destination messages.
  • Messages are removed from the source.

MULTIAPPEND

This extension is fully implemented.

Setting flags on the messages occurs in a separate step message insertion. (This is allowed by the spec since even setting the flags at all is only a SHOULD.)

NAMESPACE

Crymap does not have namespaces. The extension is implemented in that it returns a canned “no namespaces” response.

OBJECTID

This extension is fully implemented except for the optional THREADID attribute, since Crymap does not support message threads.

Mailbox IDs always begin with M, except for INBOXs mailbox ID, which always begins with I. Email IDs always begin with E.

All mailboxes support these attributes.

QRESYNC

This extension is fully implemented.

Crymap remembers the most recent 1024 expunge events.

SASL-IR

This extension is fully implemented.

SEARCHRES

This extension is fully implemented.

SPECIAL-USE

This extension is fully implemented.

See CREATE-SPECIAL-USE for a reference on what attributes are supported.

STATUS=SIZE

This extension is fully implemented to the letter of the standard and not at all to the spirit. It is only implemented because IMAP4rev2 requires it.

Returning the size of a mailbox sounds like a useful operation. However, the standard does not permit returning the actual size. Instead, it requires the returned size to be greater than or equal to the sum of the sizes of the messages as they would be fetched in full.

Since determining the size of a message requires decrypting it, Crymap has no way to do this in a way that even resembles efficiency. Instead, it takes advantage of the fact that the returned size need only be an upper bound and determines the “size” by simply multiplying the message count by 4GB.

UIDPLUS

This extension is fully supported.

No mailboxes have the UIDNOTSTICKY attribute.

UNSELECT

This extension is fully implemented.

UTF8=ACCEPT

The useful part of this extension is implemented. Clients using the extension cannot observe aspects (arguably) unimplemented. To clients not using the extension, Crymap is the same as any IMAP implementation that does not support this extension.

Once a client enables this extension, mailbox names are returned and accepted in UTF-8, and MUTF7 interpretation no longer occurs. Envelope and body structure data is returned in UTF-8, with all encoded words decoded.

The “UTF-8 literals” added by this extension are handled no differently than normal literals. The standard suggests that the server should do something to “downgrade” UTF-8 messages for the sake of clients not using this extension. Crymap does not do this, since it would violate the prime directive, and is also not useful since nearly all clients are already prepared to encounter 8-bit characters where they are not formally allowed by the older 7-bit standard.

The standard requires that non-UTF8 literals containing 8-bit characters in the message headers are rejected. Crymap also does not do this, since it is actively harmful, leaving users without the ability to copy their existing messages into Crymap, and as mentioned in the previous paragraph, clients are able to deal with such messages anyway.

XCRY

Crymap-specific extension. This entails several commands:

XCRY PURGE

No arguments.

All expunged messages in the selected mailbox are removed from the host filesystem immediately, making them inaccessible to concurrent sessions that have not yet observed the expungement.

This is mainly used as part of Crymap’s internal test suite.

XCRY GET-USER-CONFIG

No arguments.

Retrieves the current user configuration.

Response:

* XCRY USER-CONFIG (capabilities...)
  internal-key-pattern
  external-key-pattern
  password-changed-datetime
  [astring astring...]

capabilities provides a list of valid tokens that can be passed to XCRY SET-USER-CONFIG.

XCRY SET-USER-CONFIG

Arguments: key value [key value [...]]

Updates the given key-value pairs in the configuration. Using this to “configure” PASSWORD is also how password changes are done.

Response:

* XCRY BACKUP-FILE "filename"

The returned filename should be shown to the user to let them know what file to use to undo the change.

XLIST

Implements the XLIST command, which was developed for GMail before LIST-EXTENDED was standardised. Some clients may still use this instead of the extended LIST command.

XVANQUISH

Crymap-specific extension.

Adds the XVANQUISH command. This command takes one argument, a UID sequence set. The given messages are immediately expunged without having to go through the \Deleted dance first.

This is not under the XCRY umbrella since it could be useful to others.

XYZZY

This is obviously a very important extension for GMail compatibility.

Miscellaneous

Crymap always returns CAPABILITY response codes to the OK used as a greeting upon connection and after successful authentication.

Crymap accepts UNIX line endings in IMAP, but always outputs DOS line endings.

Extensions not implemented

Extensions in this list were deliberately excluded because they were not useful or harmful.

ACL, LIST-MYRIGHTS, RIGHTS=

Since users are strictly bound to their own mailboxes, permissions don’t make much sense for Crymap.

CATENATE, URL-PARTIAL, URLAUTH, URLAUTH=BINARY

Not implemented due to higher complexity with low benefit.

URLAUTH is feasible to implement, as it would work by encoding the session key of the message in question in the auth string. This would probably be sufficient to make it work with BURL. However, it’s not a feature that the author would get use of any time soon.

CONVERT

Insanity.

It also looks like, quite possibly, literally nobody has ever implemented this for server or client.

I18NLEVEL=

Requires use of an out-dated, non-standard algorithm for Unicode collation and folding.

SORT, ESORT, THREAD

These concerns are much better handled by the client. Now that QRESYNC exists, clients can cheaply keep envelope data synchronised and not only do these operations themselves, but do them using up-to-date, standardised collation algorithms which take into account the user’s locale.

Secondarily, these add a decent amount of memory overhead and aren’t something the author would ever get use of.

UNAUTHENTICATE

Incompatible with the way Crymap chroots into the user data directory in traditional UNIX-style deployments.

SAVEDATE

Incompatible with the way Crymap stores message data.

WITHIN

Should Crymap ever implement the CONTEXT extensions, this extension has a pathological interaction with them, and itself offers very little benefit.

QUOTA

Besides being useless to the author, it’s also unclear how this should really work, since mail delivery does not have access to the information it would need to maintain the quota.

LMTP Characteristics

Conformance

Crymap’s LMTP implementation is believed to conform to:

  • RFC 1652 (8BITMIME)
  • RFC 1830 (BINARY)
  • RFC 1854 (PIPELINING)
  • RFC 1870 (SIZE)
  • RFC 1893 and RFC 2034 (ENHANCEDSTATUSCODES)
  • RFC 2033 (LMTP)
  • RFC 3207 (STARTTLS)
  • RFC 5321 (SMTP)
  • RFC 6531 (SMTPUTF8)

Security

Crymap does not implement any authentication mechanism and does not require use of TLS. LMTP is not expected to be used with untrusted sources, as OS-level controls should be sufficient to prevent foreign access to LMTP.

For similar reasons, Crymap LMTP makes no attempt to verify the host name presented to it in LHLO and simply records it as-is.

Implementation notes

DOS-style line endings are strictly enforced.

Binary data is correctly processed even if sent through a DATA command.

Maximum line length is 65534 bytes.

VRFY and EXPN are not supported and return constant hardwired responses.

The same limit used for IMAP APPEND is enforced for LMTP.