Subject: Re: bug#3829: 23.0.96; Cannot read gpg file

From: Lars Ingebrigtsen <[email-masked]>
Date: Tue, 04 Aug 2020 21:27:33 +0200

Lars Ingebrigtsen <[email-masked]> writes:

> Emacs assumes that all files that end with .gpg are encrypted files, and
> will error out dramatically when trying to read those files.  The only
> way the user has to look at them is with `M-x find-file-literally'.
>
> But .gpg is also a common suffix for key ring files.

I had a look at this again, and there doesn't really seem to be a good
set of magic bytes for these files.  "\x01gpg" is used by some, and
"\x99\x01" for others, apparently, and ... a bunch of other two-byte
codes.  But there apparently isn't anything that ensures what the byte
prefixes are in encoded files?  (I'm trying to understand the logic in
"file"...)

On the other hand, we could just let gpg try to decrypt the data and if
we get

gpg -d /tmp/trusted.gpg 
gpg: decrypt_message failed: Unexpected error

then we can just take that as a hint that it's not encrypted data and
then insert the bytes instead.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no