Short Version of the Question: I would like to remove any predictable information from an encrypted private keys binary representation. Does anyone have a hint where the binary format for encrypted GnuPG private keys (.gpg) is documented?

Longer Explanatory Version of the Question: Hey guys, basically I'm trying to write a program which hides the encrypted private key in a random user-selectable medium (e.g. JPEG image) using steganography.

I'm assuming the attacker knows the kind of medium, but not the specific file, it would be rather useless if the private key doesn't appear completely random.

Basically, I would like to remove any predictable information for example on the type of encryption (maybe AES-128-CBC) used, and reconstruct the key after retrieval from the medium. A wrongly chosen medium should deliver a seemingly valid private key. So the attacker would have to brute-force all possible passphrases for all possible storage mediums.

Is that generally a stupid and futile endeavor?

From the encrypted keys I looked at and the information I collected I would guess that the key is concatenated like "SALT + EncryptedByteStream + InformationOnEncryptionAlgorithm". Does anyone have a hint where to find that? I'm a little tired from digging haphazardly through source code right now.

  • $\begingroup$ When in doubt / as a last ressort, the specification is always (somewhere) in the code. $\endgroup$
    – SEJPM
    Commented Jun 20, 2016 at 21:46

1 Answer 1


PGP key formats are defined in RFC 4880. Specifically, section 5.5.

The private key format includes the public key and quite a bit of other information in unencrypted form. It might be easier to add another layer of encryption on top of that before you use steganography.


Your Answer

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

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