0

I'm using bouncycastle to access my public keys in gpg. Currently the public key, when read to base64 gives me this:

    mQENBFh1kBcBCADMUkNW2qFgeRnornjhT3lt73wTGcO9rt+Ktr1tcopmOPTfNq3
    feZNFHRUsBt0Nnuj9+vSD2cwFRoZDNulhnBD8lAJYOD427uvV+KBDF/5pCQKh2S
    mDK8tJI/ncLIlX4SFa8F9f36FySglpkzA59IFtHdUBz9w+PJRqUQ5MVRzNHYBbv
    6aeIWwl46KrL3eibRgBDVuEOKAoesdb+xErs9cqg3KSVi01XBgr+XMSgOBz4J3f
    J4HdibsJdz1+113aKT++4LUSuuyeVbw3K/ZgMkrsyeJw84sHhF2kDu61atSUsQE
    nJwBF2sPA9V/i28fftxodgg5qbEs8egdsw/wxGzsfABEBAAG0K0NocmlzIFpoZW
    5nIChjemhlbmcpIDxjemhlbmdAYXRsYXNzaWFuLmNvbT6JATkEEwEIACMFAlh1k
    BcCGwMHCwkIBwMCAQYVCAIJCgsEFgIDAQIeAQIXgAAKCRARY82BslwTrMvtB/4t
    LoRH91p09vM1sSQ77RC+XwQqhhvN1BAeqGxqZpgCO6Ld5KRh8f4mFY8nXjDCSyy
    ydTBzIUp6aG0f+2EBhArtk/oU/pi8D4zHoeBkrl23/234s1kBI5F2g2kd6itwP8
    ekimaUyNFdPIN1dPwdxhuspOUtFNR+HsT3BT32v4Afd7sWVNTFrkapxTdxxZkVb
    +FS0wbuzFzB2gb8AvEGevzF/hQXOf3r8QzUQoEZ14pigNu/arlXzEuzXJXXT/AQ
    nAzbVENoFrhojxqEU7RxH8J4nao8OfpYfL7w3T7PC3nFFSTYSwvYItGkl9DPPiZ
    GWZTrb6VfpFGNLHwCoLOaf8ShsAIAAA==

I thought that this should be a length 4096 RSA key but it's the wrong length. What I really want to do is to use this public key to verify a signature. Would anyone be able be help shed some light on what format this is?

2

This is base64 (but not full 'armor') of a public key block in OpenPGP (rfc4880 et pred) format used by GPG. Aside: there is no such thing as opengpg; PGP was the original software by Phil Zimmerman and the company he turned it over to, OpenPGP is the standard, and GNU Privacy Guard aka GnuPG aka GPG implements that standard, as also does BouncyCastle.

OpenPGP and thus GPG key blocks include much more than just the raw crypto key; in particular public keys (including this one) almost always are attached to a user-id and carry one or more signatures -- at least a 'self-signature' by the key or its parent, and often signatures by other (trusted) users to form the 'web of trust'. See 11.1 in the linked RFC for an overview.

After converting this base64 to binary, gpg --list-packets decodes it as:

:public key packet:
        version 4, algo 1, created 1484099607, expires 0
        pkey[0]: [2048 bits]
        pkey[1]: [17 bits]
        keyid: 1163CD81B25C13AC
:user ID packet: "Chris Zheng (czheng) <czheng@atlassian.com>"
:signature packet: algo 1, keyid 1163CD81B25C13AC
        version 4, created 1484099607, md5len 0, sigclass 0x13
        digest algo 8, begin of digest cb ed
        hashed subpkt 2 len 4 (sig created 2017-01-11)
        hashed subpkt 27 len 1 (key flags: 03)
        hashed subpkt 11 len 6 (pref-sym-algos: 9 8 7 3 2 1)
        hashed subpkt 21 len 5 (pref-hash-algos: 8 2 9 10 11)
        hashed subpkt 22 len 3 (pref-zip-algos: 2 3 1)
        hashed subpkt 30 len 1 (features: 01)
        hashed subpkt 23 len 1 (key server preferences: 80)
        subpkt 16 len 8 (issuer key ID 1163CD81B25C13AC)
        data: [2046 bits]
:trust packet: flag=00 sigcache=00

As you can see it is a 2048-bit RSA key, not 4096-bit. The algo in a pubkey packet or a signature packet is OpenPGP's encoding of a pubkey algorithm and 1 is RSA, see section 9.1.

I'm not sure how knowing the format helps you verify a signature, but that's what you asked.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.