I'm studying cryptography and I have a question about the GnuPG tool for Windows.

From what I understand a passphrase is used to hash with MD5 the private RSA key. But when I use the Kleopatra tool it let me export my private key without asking for the passphrase. What's happening?

  • 3
    I sorted your grammar and spelling, however "encrypt or decrypt with MD5" is fundamentally wrong. MD5 is not encryption - it is a hash - so you may wish to just remove that section completely.
    – Rory Alsop
    Commented Feb 9, 2016 at 14:53
  • I dont know what MD5 has to do with this. Its a hash function and not even a secure one
    – BlueWizard
    Commented Feb 11, 2016 at 5:47

2 Answers 2


Encrypted Private Keys in OpenPGP

Generally in OpenPGP and specifically also in GnuPG, private keys can be encrypted with a symmetric key derived from a passphrase. For deriving the symmetric key (session key), a string-to-key function is used. Usually the Iterated and Salted S2K is used:

The salt is combined with the passphrase and the resulting value is hashed repeatedly.

The other methods include a simple hash and a salted hash. The hashing algorithm can also be chosen -- while MD5 is allowed, it shouldn't be used as it is considered weak. Also the symmetric encryption algorithm can be chosen, while the defaults depend on the implementation of OpenPGP you use.

You probably fetched up information for old versions of PGP, which only used plain MD5:

Older versions of PGP just stored a cipher algorithm octet preceding the secret data or a zero to indicate that the secret data was unencrypted. The MD5 hash function was always used to convert the passphrase to a key for the specified cipher algorithm.

Exporting Encrypted Private Keys without Entering the Passphrase

If Kleopatra is able to export the private key anyway, several reasons might exist:

  • it exports the encrypted copy of the private key,
  • the passphrase for the key is stored in gpg-agent or
  • the passphrase is stored somewhere else (which Kleopatra doesn't, but other graphic keyring managers do, like the GNOME keyring).

Private keys are encoded according to the OpenPGP Standard. MD5 is not used in GPG since it's insecure. GPG uses a password based key derivation called Iterated and Salted S2K which defines how a key is stored. Various hashes can be used here, and this is most likely what you mean with MD5, even though it is not used in modern GPG implementations.

Since Kleopatra is a key management tool, it either already has access to your keys or your private key has been stored without using a passphrase.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .