GPG Private Key Export Question

David Shaw dshaw at
Fri Sep 27 16:40:07 CEST 2013

On Sep 27, 2013, at 9:58 AM, Paul Taukatch <ptaukat at> wrote:

> Really appreciate the help and the quick response! 
> I just wanted to clarify, where exactly is the public key information stored within the exported secret key data? Is it part of the Secret key packet as part of the "Encrypted stuff follows section" or is following that? I'm currently trying to develop some software and would like to extract the public key value along with the fingerprint/ID information from the exported secret key packet. I'm assuming that when GPG imports such a secret key packet it is able to extract the public key info and able to link it to the corresponding public key (if one exists within the keyring already) or is able to reconstruct and place the public key if it does not already exist. 

It's part of the secret key packet, immediately before the encrypted stuff.  So a secret key is effectively a public key, with a few more fields of secret stuff tacked on the end.

Your assumption is correct, for both.  When GPG imports a secret key, it creates a public key and imports it alongside the secret key.


More information about the Gnupg-users mailing list