# How exactly to extract information base 10 from a PGP RSA key pair?

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)

o2eIJWf0UIMvBC840efecOGKEmtubHyyas5aSDThQZM8PyCKRrJhGX02UHwCvNRi
/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
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!

• 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) :) – Maarten Bodewes Jan 4 '15 at 4:17

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.

• I copy and paste it in and it says "The requested URL /cgi-bin/pgpdump was not found on this server."? – Joe Jan 2 '15 at 16:45
• the website is probably broken at the moment, but installing pgpdump on your pc solves the issue. Here the output: nopaste.info/69da2b3980.html – ddddavidee Jan 2 '15 at 21:45
• Looks like hex to me, but there are plenty hex -> dec converters online... – Maarten Bodewes Jan 4 '15 at 4:09
• 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. – ddddavidee Jan 4 '15 at 17:43
• 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? – Joe Jan 6 '15 at 0:14