[Dovecot] password encryption

Robin
Sat, 06 Apr 2013 08:50:23 -0000

On 4/5/2013 11:36 PM, Jim Pazarena wrote:
> I have just come to the realization that password encryption using the
> crypt function in linux, ONLY USES THE FIRST 8 CHARS. I have written
> routines using crypt allowing 16+ chars, and find that anything past 8
> is ignored. Wow.
>
> Is there a way around this that can be used in dovecot, as well as
> encryption routines for an email front end? (not system users).

Remember that most Linux distros offer a way to configure the default password
salt/encryption scheme.

Look in /etc/login.defs or equivalent on your distro.

With any semi-recent glibc + contemporaneous toolchain, you'll see options
like:

#
# Only works if compiled with ENCRYPTMETHOD_SELECT defined:
# If set to MD5 , MD5-based algorithm will be used for encrypting password
# If set to SHA256, SHA256-based algorithm will be used for encrypting password
# If set to SHA512, SHA512-based algorithm will be used for encrypting password
# If set to DES, DES-based algorithm will be used for encrypting password
(default)
# Overrides the MD5_CRYPT_ENAB option
#
ENCRYPT_METHOD SHA512
#
# Only works if ENCRYPT_METHOD is set to SHA256 or SHA512.
#
# Define the number of SHA rounds.
# With a lot of rounds, it is more difficult to brute forcing the password.
# But note also that it more CPU resources will be needed to authenticate
# users.
#
SHA_CRYPT_MIN_ROUNDS 400000
SHA_CRYPT_MAX_ROUNDS 4000000

Tune the values on your system so the authentication delay isn't too bad.

I'm surprised your distro has defaulted to the ancient crypt().  Even
slackware, not noted for being "bleeding edge" has defaulted to MD5
for a very very long time now.

Of course, if you've been running the same system or one where you migrated
shadow files from old ones, you may still be using those ancient shadow password
formats.  (No system changes those in-place for you until you explicitly change
the password with new login.defs defaults in effect.)

=R=