Encryption method for passwords

  • lloowen

    lloowen - 2014-01-13

    Is it possible to use SHA512-CRYPT when selecting encryption method in config.ing.php?

    • Lewis Butler

      Lewis Butler - 2014-01-14

      On 13 Jan 2014, at 03:48 , lloowen lloowen@users.sf.net wrote:

      Is it possible to use SHA512-CRYPT when selecting encryption method in config.ing.php?

      No, I don’t think so. It lists the methods allowed, anything else would have to go through dovecot.

      // dovecot:CRYPT-METHOD = use dovecotpw -s 'CRYPT-METHOD'. Example: dovecot:CRAM-MD5


      • Ema Nymton

        Ema Nymton - 2014-02-09

        I looked into this as well. I want to use SHA512-CRYPT or BLF-CRYPT with Dovecot 2.2. You can specify "/usr/local/sbin/doveadm pw" as for the dovecotpw variable; but the salts change each time (same reason why dovecot:md5-crypt isn't allowed).

        PHP's crypt function will support whatever crypt(3) supports. To make this work, I added a new encryption method "system:hashtype". With the patch, you can set encrypt to "system:sha512" and it will get you nice $6$ hashes.

        Here's a diff of the change: http://pastie.org/8713691

        I think the means of generating a salt needs to be more secure. Base64 encoding the output of openssl_random_pseudo_bytes() would be more cryptographically sound. I'm not sure if only some algorithms limit salts to [0-9a-zA-Z] or that's all crypt() salts. The above is really just quick hack PoC code. If there's interest I'll flesh it out a bit more and submit a proper patch.

        Last edit: Ema Nymton 2014-02-09
  • GingerDog

    GingerDog - 2014-02-17

    While I think I'm happy to merge that patch, would be we better adapting to use the newer password_ functions that PHP 5.5 gives us? (http://uk1.php.net/manual/en/intro.password.php).

    • Ema Nymton

      Ema Nymton - 2014-02-21

      It's good to see the PHP folks working on that. It's a long way from usable, though. According to the documentation, it only supports $2y bcrypt. There is no option to generate $2a bcryptand there are no algorithm constants for des, md5, sha256, or sha512. It's also PHP 5.5 only. AFAICT, most of us are still using 5.4.

      I suggest we stay with crypt() and use mcrypt_create_iv() for generating secure salts. If this sounds like a good approach, I'll revise the patch.


Log in to post a comment.