Regenerate Openpgp Public Key from Private Key

halfdog me at halfdog.net
Tue Sep 17 13:09:58 CEST 2019


Werner Koch writes:
> On Tue, 17 Sep 2019 06:51, me at halfdog.net said:
>
>> Regenerating private keys is mathematically trivial but tool-wise
>> a little tricky. It seems that quite some people were troubled
>
> What's wrong with
>
> gpg --import backup-of-private-key.gpg
>
> the private key include the entire public key.

That it won't work in some circumstances, e.g. those cited the
line below those you have quoted (fixing the wrong private/public
you got obviously right anyway drafting your reply):

"""Regenerating public keys is mathematically trivial but tool-wise
a little tricky. It seems that quite some people were troubled
by this problem due to different reasons (I not attempted to
confirm all of these):

* Using (old) backups of keys for decrypting with only private
  key available.
* Smartcards with only private key on them
* Forensic scenarios
"""

Therefore some exports (or copies of old secring.gpg) just do
no include the public key, otherwise import would be trivial.
Usually problem reports of other users look like [0] and do not
contain any direct solution, only workarounds e.g. "get your
missing public key from somewhere else".

As the key causing me problems was very old, I do not have the
software at hand that was used to create it, nor it is clear
if I only stored away the secring or an explicit private key
export, therefore I cannot find out what exactly caused the
situation, just that for me as for many others import or decrypt
does not work any more.

I believe that decryption worked with older gpg1 versions and
this kind of key data but I do not remember when and the gpg1
software version used back then.

hd

[0] https://unix.stackexchange.com/questions/267844/gpg-secret-key-not-available-when-sec-pub-key-are-in-keyring




More information about the Gnupg-users mailing list