0
$\begingroup$

I think I understand the mathematics of RSA ok. I'm not so computer savvy though. How, exactly, can I extract $n$, $e$, $d$, $p$ and $q$ from a PGP RSA public key pair? Is there like a converter online? What exactly is the language used when you see a PGP key? Is it Base64 or something?

So, for example (and I am well aware that you shouldn't post private keys online). Where are $p$ and $q$ in this private key?

-----BEGIN PGP PRIVATE KEY BLOCK-----
Version: GnuPG v1.2.3 (OS/2)

lQHWBD3X7JABBADfDcT9WgUZsAXC2jaLXbVRbkI/vmZWqFT1bBTicnHEOf0EZRKl
o2eIJWf0UIMvBC840efecOGKEmtubHyyas5aSDThQZM8PyCKRrJhGX02UHwCvNRi
XzAD1wteFyGtkVYmlHTR84fjyk9V1BlsZLNTZdTbKQ//Yuxww1qPTrlqNwAGKQAD
/2ddy62aG1bUsX/CyBse8B9+BbmjKS5m+6ntZ1Y1CQOFBNySvbbn0lHS5T9Eh7gh
KJ10AU4bVclZtOg+wyb5TORKNJ6ywjvj+DDMFekoWlfMwhw+utZVEpbJkK7vJNQg
jGBX0+L2uEbv/Z5wFpucoLxNX5fg+nDUxzP+d3VXAlLJAgDrZOc2usLMfMXNh+p0
5xfSAa8QmpumEM/1ARyV12BLhf0/nuVIZPkK9mfTdO5xk/OC35FhJLqQzHSoyNeW
wPRvAgDylFK+/3F5O1ssj2SQ4KRmULhoOs/Lpj9XgTPOFcbkoT58XYmkNvNbKCxS
It1QS0LQNHtOOqIvZKbagnckopq5Af9IGvyE53vEmp6lfop0yZFmO8NQPbcv+B5k
rUAValTyeDTyH7Qc2pdm/SGok47vSc+5Uyyx6/X6hUHF1sfSIoVVrC60hFJ1c3Nl
bGwgU3RldmVuIFNoYXduIE8nQ29ubm9yIChMT1cgU0VDVVJJVFkgLSBzZWUgPGh0
dHA6Ly9tYXRoLmJlcmtlbGV5LmVkdS9+cm9jb25ub3IvcHVibGlja2V5cy5odG1s
PikgPHJvY29ubm9yQG1hdGguYmVya2VsZXkuZWR1Poi4BBMBAgAiBQI91+yQAhsD
BQkB4TOABAsHAwIDFQIDAxYCAQIeAQIXgAAKCRBNPmjuaEZDWZ9vBADQCY9J5ZnV
VYfQBf5F3d6yhNxzXJaFIHEemsBA37dgwCJc3+49KBBJFB91PFlVwgz9PCgux8YJ
yUDsDh56pzXycCxcBav0O/MBapN1rq5/X22vtKrKxSfKjMLfQlto7VWv9vNwzlZA
ClJPYBDOZt5DxA3RECsuNxEvb28bfT5epQ==
=VufU
-----END PGP PRIVATE KEY BLOCK-----

And in general, given anything like this or a public key, how do I go about extracting the actual integers base 10?

Thanks!

$\endgroup$
1
  • $\begingroup$ The PGP format is described in RFC 4880, the rest is more or less a question for superuser (and that question more or less belong here) :) $\endgroup$
    – Maarten Bodewes
    Commented Jan 4, 2015 at 4:17

1 Answer 1

1
$\begingroup$

You can use the Web tool pgpdump, available at this address http://www.pgpdump.net/ or the same tool ( http://www.mew.org/~kazu/proj/pgpdump/en/) to install on your pc. This latter is to use if you are poking with your real secret key.

At the moment I don't remember if the tool outputs in hex or dec, but you can easily convert to your favourite Base using python or pari/gp or whatever mathematical tool you love more.

$\endgroup$
5
  • $\begingroup$ I copy and paste it in and it says "The requested URL /cgi-bin/pgpdump was not found on this server."? $\endgroup$
    – Joe
    Commented Jan 2, 2015 at 16:45
  • $\begingroup$ the website is probably broken at the moment, but installing pgpdump on your pc solves the issue. Here the output: nopaste.info/69da2b3980.html $\endgroup$
    – ddddavidee
    Commented Jan 2, 2015 at 21:45
  • $\begingroup$ Looks like hex to me, but there are plenty hex -> dec converters online... $\endgroup$
    – Maarten Bodewes
    Commented Jan 4, 2015 at 4:09
  • $\begingroup$ yes, it is hex. when I wrote the answer I was from mobile and cannot check. But, as you said, the world is full of hex to dec converters: online or as a function in almost every programming language. $\endgroup$
    – ddddavidee
    Commented Jan 4, 2015 at 17:43
  • $\begingroup$ Thanks for the help. It seems a little odd that they actually keep (i think redundent?) information such as the actual primes p and q, why not just delete them after calculating d? $\endgroup$
    – Joe
    Commented Jan 6, 2015 at 0:14

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.