5
votes
$\begingroup$

RFC 4880 may be full of information, but it can be incredibly vague at times, so im looking for someone who actually knows the answer to this.

Given this public key:

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: BCPG v1.39

mQGiBE5B0h8RBAD533Z5bK1IpBx02QyQL0QoJE4uFRIMGDiwXuwmZzVl+R7Vlurd
GRLsCCbE6vOOh7XQVZGzLEBy9WNzZ9m+EbCfSVAYkjS6FhLws6hG6irrnS+b3JBf
gFJ8vNGF9Z7bhx+7y7NBk0IMyWkGnUkcnav73t5FQUI2faEBN4c/yAGJZwCgjcB7
3akWk9XVWvTCsiMXxpyvkukEALXsvB6cOoFEtQq9cQHjP63fBlvD94dhhMiM0cH6
hW9JotxdK+cxFGG9ZIWgoN2PWbMJka/H4W5EL6tS+YiNAR7I1Ozkt6X16GjnQUzZ
MlSpleK+KiKVN2anRaPEoOIinHrE3ZXd6QlJ/4+OJn4IVWmSEaJpFf4QNgvEu4rh
xinyBAD2RNzREOA+wpnFZ4lDt9NZXmXdxQME/l0J9XcvWhpGsxA/MATQKImy7N49
7GT/M38F+TrpBobag1O3buE99fOLyws4Tbc+sZMdHxoiGZDAIRNQS2rv475E6ktj
7vd5CYvOkA6+8sX1+hPcNlkHtHB1OFkJRsYp6k0zkyC9adjBM7QTYWJjIDxtYWtj
bUBhYWEuY29tPohGBBMRAgAGBQJOQdIfAAoJEDBSJUXPd92GRSQAoItbtbToOg7a
/hcg2sA/aBEQNwuxAKCGR69vmSoCWoBP5waPk0UsjM3BSbjMBE5B0h8QAgCUlP7A
lfO4XuKGVCs4NvyBpd0KA0m0wjndOHRNSIz44x24vLfTO0GrueWjPMqRRLHO8zLJ
S/BXO/BHo6ypjN87Af0VPV1hcq20MEW2iujh3hBwthNwBWhtKdPXOndJGZaB7lsh
LJuWv9z6WyDNXj/SBEiV1gnPm0ELeg8Syhy5pCjMAf9QHehP2eCFqfEwTAnaOlA6
CU+rYHKPZaI9NUwCA7qD2d93/l08/+ZtFvejZW1RWrJ8qfLDRtlPgRzigoF/CXbR
iEYEGBECAAYFAk5B0h8ACgkQMFIlRc933YZRrACfUnWTjHHN+QsEEoJrwRvFmvzj
bR4An24pTpeeN+I6R59O/sdmYsAhjULX
=sStS
-----END PGP PUBLIC KEY BLOCK-----

Can someone verify that the information below is correctly formatted?

Everything here is in hex. I might be missing a few 0s from the front of some values

Tag 1 version(3) + 8 octet keyid + PKA(0x10 = ElGamal): 03f940c4301a67779d10

Session key: b51ba8901efd091d2afcd26b560ea8899d9e2ddbf6aa5c4edea8292704f2fcfc
Checksum: 1092

EME_PKCS1_ENCODE(m): 0002c121793811f4f32f3f739b087f91e77491a0317342c45c6935a80009b51ba8901efd091d2afcd26b560ea8899d9e2ddbf6aa5c4edea8292704f2fcfc1092

k: 5f02cec2fd1f880f390f17dce824c3682015da7ea97c0053cfcdc5097d33fc263e42eeda5c9196a626fa90501a4f7a975061e9f9889f851fcb26e9c24538221e

g^k mod p: 01ff7672e5cc57aaa14b3fda05dee02ecede8a75eecb813060224c390e48f38d3bd41031c9d4659bfaa36246af145930a48d8b5dc5618b4506fb55f6347d5bddffc0

m * y^k mod p: 01ff45f15b84e8e7b95dfef0b52acea10aef4c20b3fc9b8f7c6f2487b2e43b8bfaf5ddebaeddc05643c348eb785559fa7dd74f7542b44ace3746d829fbf1f6392a53

This is a partial block created with only the data from above.

-----BEGIN PGP MESSAGE-----
Version:

wY4D+UDEMBpnd50QAf92cuXMV6qhSz/aBd7gLs7einXuy4EwYCJMOQ5I84071BAx
ydRlm/qjYkavFFkwpI2LXcVhi0UG+1X2NH1b3f/AAf9F8VuE6Oe5Xf7wtSrOoQrv
TCCz/JuPfG8kh7LkO4v69d3rrt3AVkPDSOt4VVn6fddPdUK0Ss43Rtgp+/H2OSpT
=YcRE
-----END PGP MESSAGE-----

is the packet correctly formatted? is the PKCS1 encoded data correct? Simply because pgpdump can read the packet doesnt mean its formatted correctly.

Anyone?

$\endgroup$

2 Answers 2

2
votes
$\begingroup$

Here's what pgpdump thinks of it:

New: Public-Key Encrypted Session Key Packet(tag 1)(142 bytes)
        New version(3)
        Key ID - 0xF940C4301A67779D
        Pub alg - ElGamal Encrypt-Only(pub 16)
        ElGamal g^k mod p(511 bits) - ...
        ElGamal m * y^k mod p(511 bits) - ...
                -> m = sym alg(1 byte) + checksum(2 bytes) + PKCS-1 block type 02

So there's nothing obviously wrong, but you'd have to pass it through a full PGP implementation to verify that it's all OK.

$\endgroup$
1
  • $\begingroup$ Please read the last sentence of the post. Also, m = sym alg(1 byte) + checksum(2 bytes) + PKCS-1 block type 02 conflicts with the rfc $\endgroup$
    – calccrypto
    Jul 23, 2012 at 16:23
1
vote
$\begingroup$

Hmmm, Weird key... overly small, no allowable ciphers or hash functions - BC didn't fully implement RFC 4880 so it might be worth upgrading to BC 1.47 and 'new keys please'.

That aside I doubt it will be easy to validate the output of any given public key without it's coresponding private key, plus the planitext.

If you have this info, plus the issue you face or (suitable standin info if this is not a test key(which I think it is) then it would be possible to work through the same procedure and see what I/others get on various platforms.

Cheers!

$\endgroup$
1
  • $\begingroup$ Bouncy castle didnt generate this key. I more or less manually did it. Also, i dont think the private key is necessary. I am not trying to validate the information. i want to know if the PGP format was followed. i should have given all the information. I just dont know if i converted everything into their proper strings. Also: crypto.stackexchange.com/questions/3284/… $\endgroup$
    – calccrypto
    Jul 22, 2012 at 20:01

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