Password space is quiet small. Therefore slow hash should be applied to password before using it for encryption.
Should slow hash function (like bcrypt) be applied to password before using it with OpenPGP/GnuPG? Do they do it itself?
Password space is quiet small. Therefore slow hash should be applied to password before using it for encryption.
Should slow hash function (like bcrypt) be applied to password before using it with OpenPGP/GnuPG? Do they do it itself?
Yes. When encrypting a file using a passphrase, they should use a slow hash function to derive the cryptographic key from the password.
Yes, GPG already does do this. See my answer that explains elsewhere how to use GPG with a slow hash, if you need to encrypt a file with passphrase-based conventional encryption. The short version is that I recommend using the following command-line flags:
gpg -c --force-mdc --s2k-mode 3 --s2k-count 65011712 personal.zip
This asks GPG to use a slow hash function for hashing the password.
OpenPGP implementations apply hashing of password during S2K process. They allow to tweak algorithm and number of iterations.
By default GnuPG 1.4.12 uses SHA1 for hashing with 65536 rounds. Algorithm can be switched to MD5, RIPEMD160 or SHA2s. Number of iterations can be changed too. Current settings can be viewed by typing gpg --list-packets ~/.gnupg/secring.gpg
However all suported by GnuPG 1.4.12 algorithms can be efficiently implemented on GPU. And thus aren't the best options for password hashing.
It will be better to use bcrypt
or scrypt
instead --s2k-*
GnuPG options. As they aren't supported by GnuPG you can use side implementation of it.