Take the 2-minute tour ×
Information Security Stack Exchange is a question and answer site for Information security professionals. It's 100% free, no registration required.

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?

share|improve this question
1  
Gpg does apply strengthening (controlled by the --s2k-* options, defaulting to an 8-byte salt and 65536 rounds of its KDF; I don't know what the KDF is). I would hope that OpenPGP does something similar. –  Gilles Jun 2 '12 at 22:52

2 Answers 2

up vote 0 down vote accepted

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.

share|improve this answer

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.

share|improve this answer
    
Hash functions supported by GnuPG can be too efficiently automated at GPU –  Andrey Botalov Jun 4 '12 at 11:55
    
@AndreyBotalov, I know, and that's one kind of threat that GPG's slow hash function is designed to mitigate / defend against. Those threats make it all the more important to use a slow hash function. –  D.W. Jun 4 '12 at 16:11
    
GnuPG's functions used for password hashing are MD5, SHA1, SHA2s, RIPEMD-160 with large number of rounds. They can be computed efficiently at GPU. –  Andrey Botalov Jun 4 '12 at 16:32
1  
GnuPG's slow hashing scheme doesn't fully mitigate GPU acceleration. –  Andrey Botalov Jul 17 '12 at 8:09
2  
@AndreyBotalov, thanks, that's a good link and very helpful! I think what you are suggesting is that GPG would be even better off to use scrypt or bcrypt. Agreed. That's a good point. (On the other hand, keep in mind the last paragraph of the answer you link to: S2K is much better than a simple non-iterated hash, though I agree bcrypt or scrypt would be even better.) –  D.W. Jul 17 '12 at 9:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.