Question about use of --cipher-algo AES & --openpgp
Peter S. May
me at psmay.com
Fri Nov 10 18:06:14 CET 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Henry Hertz Hobbit wrote:
> It is a worthwhile and at a much higher value than two cents, but I
> was NOT thinking of a new program. I was thinking of the magic number
> and the "file" command. Evidently, OpenPGP is totally incompatible
> with that and always will be. At least I can't see a way to make it
> fit. If you can, be my guest. It would require enumerating all of the
> possibilities and putting in ALL of them, but being careful you don't
> clobber something else in the process.
I don't know how the internals of "file" work. If I were trying to get
a generic file-like program to grok OpenPGP, here's probably how I'd go
about it:
* If the first non-blank line started "--- BEGIN PGP ", it would
probably be reasonable to call it armored OpenPGP and perhaps look into
it further, to figure out a subtype.
* If the file program decides the file isn't any other type it
recognizes, take a look at the first byte of the file, which must be a
valid OpenPGP packet tag. You could run some or all of these tests
before passing the file on to GPGME, which would ultimately determine a
file's reasonable OpenPGP compatibility. Some assumptions based on bis-18:
(in pseudocode, of course)
function is_pgp_packet_tag (byte)
if byte & 0xC0 == 0xC0 // new format tag
tag_number = byte & 0x3f
else if byte & 0xC0 == 0x80 // old format tag
tag_number = (byte & 0x3c) >> 2
else
return false // first bit is always set
if tag_number == 0
return false // 0 is reserved
// the rest of the assumptions may change with future
// versions of the spec and need to be kept up to date
if tag_number == 15 or tag_number == 16
return false // 15 and 16 are not currently defined
if tag_number >= 20
return false
// Values 20 to 59 are not currently defined
// Values 60 to 63 are defined as private and GPG can't grok them
After those checks, I would either pass the file on to GPGME or run one
more heuristic first: Read a packet header. If it's valid, extract the
length it specifies and jump forward that many bytes. Then repeat. If
any of the tags are !is_pgp_packet_tag(), or if the last length
specifier you find leads you past the end of the file, it's not OpenPGP.
Else, it has a significant chance of being formally correct.
Might be too complicated a check for file, but I think it would work.
PSM
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFVLGDei6R+3iF2vwRAputAKCHDJd+amCEfpx4Bqr/Rdhg6bhYDQCfTWrB
eiuu9uMUKolveQBULvybWv4=
=VsH/
-----END PGP SIGNATURE-----
More information about the Gnupg-users
mailing list