View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000144 | file | General | public | 2020-02-22 01:27 | 2020-03-20 16:11 |
Reporter | hlein | Assigned To | christos | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Platform | amd64 | OS | Linux | ||
Product Version | 5.38 | ||||
Fixed in Version | 5.39 | ||||
Summary | 0000144: PGP keyids are printed in the wrong byte order | ||||
Description | Magdir/pgp includes rules like: # 1024b RSA encrypted data 0 string \x84\x8c\x03 PGP RSA encrypted session key - >3 lelong x keyid: %X >7 lelong x %X >11 byte 0x01 RSA (Encrypt or Sign) 1024b >11 byte 0x02 RSA Encrypt-Only 1024b ... # 2048b RSA encrypted data 0 string \x85\x01\x0c\x03 PGP RSA encrypted session key - >4 lelong x keyid: %X >8 lelong x %X ... I think all of these should be belong instead of lelong. Also, a keyid may begin with a zero, which is meaningful. So these %X's ought to be %08X's. | ||||
Steps To Reproduce | 1) (Optional) generate a test key. 2) List the key to use with its subkeys: $ gpg --list-keys --with-colons 5AB23C204B1829F3E33BBA37DBEA6F441E3DF797 tru::0:1582326417:1582758336:3:1:5 pub:u:2048:1:DBEA6F441E3DF797:1582326336:1582758336::u:::scESC::::::23::0: fpr:::::::::5AB23C204B1829F3E33BBA37DBEA6F441E3DF797: uid:u::::1582326336::F659DAB0221BFC1C737B3BF9C9CD9292ECDDEED7::Test RSA/RSA Key::::::::::0: sub:u:2048:1:577B8DB374A47B2B:1582326336:1582758336:::::e::::::23: fpr:::::::::C161291BD41A414C8B16CF66577B8DB374A47B2B: 3) Note the keyid of the subkey: 577B8DB3 74A47B2B 4) Use that key to encrypt+sign a test file to itself: $ echo test | gpg --local-user 5AB23C204B1829F3E33BBA37DBEA6F441E3DF797 -se -r 5AB23C204B1829F3E33BBA37DBEA6F441E3DF797 -o test.pgp 5) Use file to check the file: $ file test.pgp test.pgp: PGP RSA encrypted session key - keyid: B38D7B57 2B7BA474 RSA (Encrypt or Sign) 2048b . 6) Observe that 577B8DB3 74A47B2B != B38D7B57 2B7BA474 7) Use gpg --list-packets to see what it has to say about the recipient key: $ gpg --list-packets test.pgp gpg: encrypted with 2048-bit RSA key, ID 577B8DB374A47B2B, created 2020-02-21 "Test RSA/RSA Key" # off=0 ctb=85 tag=1 hlen=3 plen=268 :pubkey enc packet: version 3, algo 1, keyid 577B8DB374A47B2B 8) Use hexdump -C to look at the raw bytes: $ hexdump -C test.pgp | head -n1 00000000 85 01 0c 03 57 7b 8d b3 74 a4 7b 2b 01 07 ff 46 |....W{..t.{+...F| | ||||
Additional Information | AFAIK just switching all of the lelong's to belong's in Magdir/pgp is the right thing to do. With that: $ file test.pgp test.pgp: PGP RSA encrypted session key - keyid: 577B8DB3 74A47B2B RSA (Encrypt or Sign) 2048b . I'll attach a patch to make those changes, and also switch from %X to %08X. | ||||
Tags | magic | ||||
|
file-magic-pgp-keyid-printing.diff (1,641 bytes)
--- magic/Magdir/pgp.orig 2019-04-18 20:42:27.000000000 -0400 +++ magic/Magdir/pgp 2020-02-21 18:26:43.526378352 -0500 @@ -127,8 +127,8 @@ # 1024b RSA encrypted data 0 string \x84\x8c\x03 PGP RSA encrypted session key - ->3 lelong x keyid: %X ->7 lelong x %X +>3 belong x keyid: %08X +>7 belong x %08X >11 byte 0x01 RSA (Encrypt or Sign) 1024b >11 byte 0x02 RSA Encrypt-Only 1024b >12 string \x04\x00 @@ -144,8 +144,8 @@ # 2048b RSA encrypted data 0 string \x85\x01\x0c\x03 PGP RSA encrypted session key - ->4 lelong x keyid: %X ->8 lelong x %X +>4 belong x keyid: %08X +>8 belong x %08X >12 byte 0x01 RSA (Encrypt or Sign) 2048b >12 byte 0x02 RSA Encrypt-Only 2048b >13 string \x08\x00 @@ -161,8 +161,8 @@ # 3072b RSA encrypted data 0 string \x85\x01\x8c\x03 PGP RSA encrypted session key - ->4 lelong x keyid: %X ->8 lelong x %X +>4 belong x keyid: %08X +>8 belong x %08X >12 byte 0x01 RSA (Encrypt or Sign) 3072b >12 byte 0x02 RSA Encrypt-Only 3072b >13 string \x0c\x00 @@ -178,8 +178,8 @@ # 3072b RSA encrypted data 0 string \x85\x02\x0c\x03 PGP RSA encrypted session key - ->4 lelong x keyid: %X ->8 lelong x %X +>4 belong x keyid: %08X +>8 belong x %08X >12 byte 0x01 RSA (Encrypt or Sign) 4096b >12 byte 0x02 RSA Encrypt-Only 4096b >13 string \x10\x00 @@ -195,8 +195,8 @@ # 4096b RSA encrypted data 0 string \x85\x04\x0c\x03 PGP RSA encrypted session key - ->4 lelong x keyid: %X ->8 lelong x %X +>4 belong x keyid: %08X +>8 belong x %08X >12 byte 0x01 RSA (Encrypt or Sign) 8129b >12 byte 0x02 RSA Encrypt-Only 8129b >13 string \x20\x00 |
|
Patch applied, thanks! |
Date Modified | Username | Field | Change |
---|---|---|---|
2020-02-22 01:27 | hlein | New Issue | |
2020-02-22 01:27 | hlein | File Added: file-magic-pgp-keyid-printing.diff | |
2020-02-22 01:27 | hlein | Tag Attached: magic | |
2020-03-20 16:11 | christos | Assigned To | => christos |
2020-03-20 16:11 | christos | Status | new => assigned |
2020-03-20 16:11 | christos | Status | assigned => resolved |
2020-03-20 16:11 | christos | Resolution | open => fixed |
2020-03-20 16:11 | christos | Fixed in Version | => 5.39 |
2020-03-20 16:11 | christos | Note Added: 0003395 |