So Bob grabs Alice's secret key when she isn't looking and her encrypted files, doesn't he need to know her passphrase to read her files?

What I am reading is that no he does not need it but as far as I understand GPG, it would still ask for a passphrase to decrypt a document. Please explain why Bob would not need to know Alice's passphrase to read her documents in a step by step example.


3 Answers 3


GPG's (or OpenPGP's) public-key file encryption uses multiple steps:

  • Generate a random session key
  • encrypt the file using this random session key
  • encrypt the random session key using the public key of the receiver (or using multiple keys in parallel, if the file is meant to be decrypted by multiple receivers).
  • store the encrypted file together with the encrypted session key.

To decrypt it, the receiver (or attacker) needs the private key corresponding to (one of) the used public key(s).

Now, Alice should have protected her private keys with a passphrase - this way, Bob would get not the private key itself, only an encrypted version of it. If so, Bob's only way for decrypting the key (and thus the file) would be to guess the encryption passphrase (which can be possible if the passphrase is not that long/complicated).

If Alice didn't protect her private keys, Bob would get the private key, and could directly use it to decrypt the session key, and thus decrypt the file.

  • $\begingroup$ What would be a command line way to attack a private key with a passphrase? $\endgroup$
    – Andrew
    Oct 1, 2011 at 17:34
  • 6
    $\begingroup$ I don't know any command line programs which can be used for this, and this would be off-topic here anyways. $\endgroup$ Oct 1, 2011 at 18:16

GPG typically lets the user choose whether or not to encrypt the private key with a passphrase. So, if Alice has encrypted the private key with a passphrase, Bob would need it. If she chose not to, he would not need a passphrase and could use the private key to decrypt files, etc.


If Alice has used a good, long, and complex passphrase then Bob will have to resort to brute force attack methods and put many GPUs or a botnet's power behind generating as many as possible passphrases and trying them until either thermal death of the universe or a matching passphrase had been found. For Alice, once losing her keyring, this becomes a gamble of how good her passphrase is vs how much computing cycles Bob has at his disposal.

If Bob has a friendly owner of a Crypto-coin mining farm then he maybe able to rent hashing time for mining passphrases instead of coins or if Bob managed to backdoor such a farm then he maybe able to employ significant computing power to generation of passphrases. Which may give Bob the required edge over Alice's security practices by throwing tons of attempts at her private key per second. Think of the infinite room of monkeys on typewriters that could have written Shakespeare if given enough time; more monkeys is more password attempts per interval of finite time measured.

If Bob lives in the future then according to lots of FUDers out there, all our crypto maybe at risk once quantum computers are reliable and cheap enough for state level actors to put a dedicated teem on. So if Bob has a friendly aunt Pam who works in a quantum server farm then all bets for Alice's passphrase keeping her docs secure are off.

Now if Alice has not used a passphrase or has used a weak passphrase then once her keys are in Bob's control, then Bob has effectively the permissions to be Alice; digital sex change... kinky.

As you've asked what that sort of attack would look like but my being to specific would be frowned upon, I'll leave you with one link that shows how to push a passphrase into GnuPG for automation and some key search terms; rainbow tables, john the ripper, dictionary attack. Try inputting any of those three in any combination with GnuPG and you'll likely find some teams working on testing/auditing passphrase security.

Note that password cracking software may not be designed with how GnuPG handles passphrases in mind. So if you're planning on testing your own key's security then you'll likely need to get creative with input/output between cracking software and GnuPG; hint understand the code linked above for input and output with GnuPG... as far as the passphrase cracking side, I can't offer any code examples on that subject publicly just yet.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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