Verifying Encryption Algorithms

Simone Cianfriglia crimer at crimer90.co.cc
Tue Sep 20 21:04:24 CEST 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Hi zerious,

First of all:
The following answer is about "how to get those informations from an
encrypted message".
If you need to force some algorithms, you can use the --cipher-algo,
--digest-algo, --compress-algo and --cert-digest-algo options.

===

> My main question is: how can i get a warm fuzzy that a file has
> [i]really[/i] been encrypted
> using the cipher and digest that i specify and not something else? I was
> thinking there might be some kind of -vv decrypt mode that would show in
> detail what it's using to decrypt a file or some file metadata or something.

The informations you're seeking for are inside the ciphertext, precisely:
a) the symmetric encryption algorithm is with the key, in the
symmetric-key encrypted session key packet;
b) the digest algorithm is inside the one-pass signature packet,
inside the symmetric ciphertext.

So, you have to decrypt the Symmetric-Key Encrypted Session Key Packet
with your public key to discover the crypto-algo and get the session
key to decrypt the Symmetrically Encrypted Data Packet and get or a
Compressed Data Packet or a Literal Data Packet, along with the
one-pass signature cited above.


> I think i've found a good way to verify the cipher-algo using
> --show-session-key. the first digit of the output indicates the symmetric
> algorithm being used:
>        10:123456789ABCDEFFFFFFFFFFFFFFFFFFFFFF
>        would indicate that it's a TWOFISH key. Also, the length of the key is a
> good hint.

Exactly, that's the way to follow to discover the symmetric encryption
algorithm using only GnuPG.


> Basically, I just want some way to look at my encrypted data and see that it
> actually uses the algorithms that I specified before I send it out somewhere
> that it could be intercepted and compromised.

You can use the --list-packets option, along with the
--show-session-key one, to see a detailed view of your packet. Let's
see an example:

===

$ gpg --list-packets --show-session-key message.asc (or .gpg)


:pubkey enc packet: version 3, algo 1, keyid 0123456789ABCDEF
        data: [4096 bits]


<insert passphrase here, then...>


:encrypted data packet:
        length: unknown
        mdc_method: 2
gpg: encrypted with ...

:compressed packet: algo=3
:onepass_sig packet: keyid FEDCBA9876543210
        version 3, sigclass 0x00, digest 10, pubkey 1, last=1
:literal data packet:
        mode b (62), created 1316543985, name="",
        raw data: 6 bytes
:signature packet: algo 1, keyid FEDCBA9876543210
        version 4, created 1316543985, md5len 0, sigclass 0x00
        digest algo 10, begin of digest dd 90
        hashed subpkt 2 len 4 (sig created 2011-09-20)
        subpkt 16 len 8 (issuer key ID 10293847586FDBCE)
        data: [4096 bits]
gpg: session key:
`9:0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF'

===

You can see:
- - RSA key (pubkey algo 1);
- - the symmetric algo used is AES256 (9, first octet of session key);
- - the message is compressed with BZIP2 (compressed algo 3)
- - the digest algo is SHA512 (10 in signature and onepass_sig packets);
- - the signature asymmetric algo is RSA (algo 1 in signature).


Of course, you need a way to decipher that message, so if you're
encrypting it without a key of yours, those informations are
unavailable.


> I have a few methods for
> checking, but they a few leave key pieces of information out. If anybody has
> a good method for verification or even knows of some 3rd party tool that can
> analyze encrypted data, I would really appreciate your input.

I don't know any tool to analyze encrypted data as you want, I'm sorry.


If you want to discover more insight details about the informations
stored inside an OpenPGP message, you can look at RFC4880, it's very
exhaustive. ;)




Hope it helps!

Simone

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iQIcBAEBCgAGBQJOeOOMAAoJEGfVQEsGVc2ANycQALZAGzd50EGkvoajUd8YRLmu
riLqf3MckNO4II0+BZbG7JeMY2MaS8J5TOxNDsNVAgtpnrQGQp/OtlEqzUbZa7tJ
YWaEAS0HrQvRPJY+O5C5yIPf6SFhxYHWhFRIpS1+zM/ZGV9d75fQqM2XvVziTTH4
CVAo5PFQuxR8tF7fsTJT6PMn262edvosYgzFgpB3a6lhMMQS0D3H0L+Nz9LrUHHW
o6Gr4yrqCChu5zAfBEJs43X/O6GF0+iJETMBjjqw9urAlOr4ZO/fIUTMMM72q1mG
6ACR7hPkSGd2MPmbxH03B5iX0ptrGyXZ1LIZTEGLzH6tG3Ffx4/HAPbsVVpfan7/
+ln3Wd9DakbaEoTmGH4ivQCsYXIsCodrkftG1MvBUqiW4DpAzik8/Ji67w8g4COI
AmGaZ0J9pgLF0MowDMeaabt9LKNokL1+axKpVrcQzaIInWPUxu7QWa7ys1PRdlg/
iGiz19vtij+owpJIbEq3CkOvUJHqQT8FOlKEoVHqTfrSu/gbGMkChs0Kh9pD+BCC
I8d/TYPuf4RfOXrZS3wiPZSUxnsClaVPlIMXpLx1bMdEvP0Yj2CKm+vJo0NuyI4y
Si+WrKLRvcmnUgimNnjKBtlNwwkaQLBrWAhM850UgMiISLL+1LGkHa6Dtb/nt30E
nEE6uu2si0OAL175NXDg
=OJPE
-----END PGP SIGNATURE-----



More information about the Gnupg-users mailing list