1

I would like to be able to check which (inner) symmetric algorithm was used to encrypt a file with GPG using a public key.

Somewhere I've read this can be done with --list-packets, so I tried

$ gpg --list-packets encrypted_file.asc 
gpg: encrypted with 256-Bit ECDH key, ID 0865135E90D1AF38, created 2020-03-20
      "First Last <first.last@somewhere.net>"
# off=0 ctb=84 tag=1 hlen=2 plen=94
:pubkey enc packet: version 3, algo 18, keyid 0865135E90D1AF38
    data: [263 bits]
    data: [392 bits]
# off=96 ctb=d2 tag=18 hlen=3 plen=1965 new-ctb
:encrypted data packet:
    length: 1965
    mdc_method: 2
# off=118 ctb=a3 tag=8 hlen=1 plen=0 indeterminate
:compressed packet: algo=1
# off=120 ctb=cb tag=11 hlen=2 plen=0 partial new-ctb
:literal data packet:
    mode b (62), created 0, name="_CONSOLE",
    raw data: unknown length

I thought the symmetric encryption algorithm was encoded in mdc_method, but whatever algorithm I use to encrypt, it always displays 2 there. So this doesn't seem to be the correct approach.

How can I find out the symmetric algorithm?

1 Answer 1

4

The trick is to add option -vv --show-session-key to the command:

$ gpg -vv --show-session-key --list-packets encrypted_file.asc 

This adds a line like the following to the output:

gpg: AES192 encrypted data
gpg: session key: '8:32050C047C47C519E76901EFC47FDFED0CD87CDB85809AFE'

The number before the colon (8 here) is the symmetric algorithm used to encrypt the file contents according to this list (taken from GnuPG sources):

typedef enum
 {
 CIPHER_ALGO_NONE = 0,
 CIPHER_ALGO_IDEA = 1,
 CIPHER_ALGO_3DES = 2,
 CIPHER_ALGO_CAST5 = 3,
 CIPHER_ALGO_BLOWFISH = 4, /* 128 bit */
 /* 5 & 6 are reserved */
 CIPHER_ALGO_AES = 7,
 CIPHER_ALGO_AES192 = 8,
 CIPHER_ALGO_AES256 = 9,
 CIPHER_ALGO_TWOFISH = 10, /* 256 bit */
 CIPHER_ALGO_CAMELLIA128 = 11,
 CIPHER_ALGO_CAMELLIA192 = 12,
 CIPHER_ALGO_CAMELLIA256 = 13
 }
cipher_algo_t;

So in this case, the file was encoded using AES-192.

Note that AES means AES-128.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.