Regenerate Openpgp Public Key from Private Key

halfdog me at
Tue Sep 17 08:51:11 CEST 2019

Hello list,

Regenerating private 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

Since a Gnupg update the tool will refuse to perform decryption
with private keys only. As gpg seems to provide no easy option
to regenerate/calculate the public key from the private keys
or ignore the missing keys, I used the method described in [0]
as a hacky way to regenerate 4096 bit public keys from private
keys using peculiarities of the Openpgp storage format and minimal
binary editing.

I needed this to decrypt some old data, maybe someone else might
find it useful too.



More information about the Gnupg-users mailing list