This documentation is for Dovecot v1.x, see wiki2 for v2.x documentation.

Password Schemes

Password scheme means the format in which the password is stored in password databases. The most commonly used password schemes are:

Password databases have a default password scheme:

The password scheme can be overridden for each password by prefixing it with {SCHEME}, for example: {PLAIN}pass.

Dovecot contains a utility which can be used to easily generate passwords for a wanted scheme: in Dovecot v1, dovecotpw; in Dovecot v2, doveadm pw

What scheme to use?

With most installations it doesn't really matter what scheme you're using. If you already have users with existing passwords, it's easiest to just keep using the same scheme. Otherwise just pick something strong enough, for example SSHA.

The main idea behind storing passwords in non-plaintext scheme is that if an attacker gets access to your server, he can't easily just get all users' passwords and start using them. With stronger schemes it takes more time to crack the passwords.

Non-plaintext authentication mechanisms

See Authentication/Mechanisms for explanation of auth mechanisms. Most installations use only plaintext mechanisms, so you can skip this section unless you know you want to use them.

The problem with non-plaintext auth mechanisms is that the password must be stored either in plaintext, or using a mechanism-specific scheme that's incompatible with all other non-plaintext mechanisms. For example if you're going to use CRAM-MD5 authentication, the password needs to be stored in either PLAIN or CRAM-MD5 scheme. If you want to allow both CRAM-MD5 and DIGEST-MD5, the password must be stored in plaintext.

In future it's possible that Dovecot could support multiple passwords in different schemes for a single user.

Supported schemes

PLAIN, CRYPT and MD5-CRYPT schemes were explained above.

Non-plaintext mechanism specific schemes:

MD5 based schemes:

SHA based schemes (also see below for libc's SHA* support):

For some schemes (e.g. PLAIN-MD5, SHA) Dovecot is able to detect if the password hash is base64 or hex encoded, so both can be used. dovecotpw anyway generates the passwords using the encoding mentioned above.

SHA256 and SHA512 in libc

glibc v2.7+ supports SHA256 and SHA512 based password schemes. The passwords look like:

These passwords are completely different than what Dovecot generates. They use multiple rounds of SHA, so they're also safer against brute forcing (but also requiring more CPU from your server). You can use these simply by using CRYPT scheme, assuming your libc can handle these kinds of passwords.


The base64 vs. hex encoding that is mentioned above is simply the default encoding that is used. You can override it for any scheme by adding a ".hex", ".b64" or ".base64" suffix. For example:

This can be especially useful with plaintext passwords to encode characters that would otherwise be illegal. For example in passwd-file you couldn't use a ":" character in the password without encoding it to base64 or hex. For example: {PLAIN}{\}:!" is the same as {PLAIN.b64}e1x9OiEiCg==.

You can also specify the encoding with dovecotpw. For example: dovecotpw -s plain.b64


For most of the salted password schemes (SMD5, SSHA*) the salt is stored after the password hash and its length can vary. When hashing the password, append the salt after the plaintext password, e.g.: SSHA256(pass, salt) = SHA256(pass + salt) + salt.

For example with SSHA256 you know that the hash itself is 32 bytes (256 bits/8 bits per byte). Everything after that 32 bytes is the salt. For example if you have a password:


After base64 decoding it you'll see that its length is 36 bytes, so the first 32 bytes are the hash and the following 4 bytes are the salt:

Other common hash sizes are:

The web management gui VBoxAdm has some code dealing with creation and verification of salted hashes in Perl. However not all password schemes provided by dovecotpw are supported. Have a look at the module VBoxAdm::DovecotPW for more details.

None: Authentication/PasswordSchemes (last edited 2012-04-27 18:36:34 by bugeye)