x/crypto/openpgp missing support for uncompressed data in compressed data packets

74 views
Skip to first unread message

Aleks Rudzitis

unread,
Oct 16, 2021, 3:01:42 PM10/16/21
to golang-nuts
Hello,

I think I may have found a bug in the x/crypto/openpgp implementation. However, I wanted to ask here to make sure, before filing a bug report.

The gist of it is, the RFC for OpenPGP states that "Implementations MUST implement uncompressed data" (source: https://datatracker.ietf.org/doc/html/rfc4880#section-9.3). However, the implementation in Go does not: https://github.com/golang/crypto/blob/master/openpgp/packet/compressed.go#L50

I encountered this issue while trying to use the OpenPGP implementation in Go to read uncompressed data in a compressed data packet. For reference, GnuPG seems to handle this case.

I created a proof of concept to verify the bug: https://gist.github.com/ajrudzitis/a6b240763f2211da9990480bbd73cfbf

I was able to parse the message with GnuPG, but not Go:

# off=0 ctb=c8 tag=8 hlen=2 plen=24 new-ctb
:compressed packet: algo=0
# off=3 ctb=cb tag=11 hlen=2 plen=21 new-ctb
:literal data packet:
        mode t (74), created 0, name="hello.txt",
        raw data: 6 byte

If other folks agree, I am happy to open an issue.

Cheers,

Aleks

Sean Liao

unread,
Oct 17, 2021, 4:18:41 AM10/17/21
to golang-nuts
Note as of https://github.com/golang/go/issues/44226 x/crypto/openpgp is frozen and deprecated
Reply all
Reply to author
Forward
0 new messages