cipher used when both --encrypt and --symmetric is specified

Martin Ilchev martini5468 at gmail.com
Thu Feb 25 15:42:32 CET 2016


I am looking for some help to figure out what cipher is used for symmetric
encryption when both pass phrase and public keys are used. I have
configured my gpg.conf with my preferred cipher algorithms as follows:
personal-cipher-preferences AES256 TWOFISH CAMELLIA256 AES192 CAMELLIA192
AES CAST5 CAMELLIA128 BLOWFISH IDEA 3DES

I have ran the following tests:
1. Symmetrically encrypt a file:
$gpg2 --symmetric somefile
decrypting that file shows the correct cipher being used (I am looking at
symkey enc packet field cipher 9 - aes256):
$ gpg2 -vvv --decrypt somefile.gpg
gpg: using character set `utf-8'
:symkey enc packet: version 4, cipher 9, s2k 3, hash 10
        salt 7ff4f273bd71e14e, count 24117248 (231)
gpg: AES256 encrypted data
:encrypted data packet:
        length: 360
        mdc_method: 2
gpg: encrypted with 1 passphrase
:compressed packet: algo=1
:literal data packet:
        mode b (62), created 1456410134, name="somefile",
        raw data: 1551 bytes
gpg: original file name='somefile'

2. Symmetrically encrypt and also encrypt for my own public key:
gpg2 -vvv --symmetric --encrypt --sign -r 0x1234567890ABCDEF somefile
decrypting the file shows that the cipher used is CAST5 (again looking at
the same symkey enc packet field cipher 3 - CAST5):
$ gpg2 -vvv --decrypt somefile.gpg
gpg: using character set `utf-8'
:pubkey enc packet: version 3, algo 1, keyid 1234567890ABCDEF
        data: [4096 bits]
gpg: public key is 0x1234567890ABCDEF
gpg: using subkey 0x1234567890ABCDEF instead of primary key
0x1234567890ABCDEF
gpg: selecting openpgp failed: Card not present
:symkey enc packet: version 4, cipher 3, s2k 3, hash 10, seskey 256 bits
        salt 7fa903ae28975d77, count 24117248 (231)
gpg: CAST5 encrypted session key
:encrypted data packet:
        length: unknown
        mdc_method: 2
gpg: encrypted with 1 passphrase
gpg: using subkey 1234567890ABCDEF instead of primary key 1234567890ABCDEF
gpg: encrypted with 4096-bit RSA key, ID 1234567890ABCDEF, created
2018-13-34
      "Martin"
gpg: public key decryption failed: Operation cancelled
gpg: AES256 encrypted data
:compressed packet: algo=2
:onepass_sig packet: keyid 1234567890ABCDEF
        version 3, sigclass 0x00, digest 10, pubkey 1, last=1
:literal data packet:
        mode b (62), created 1456410193, name="somefile",
        raw data: 1551 bytes
gpg: original file name='somefile'

To get the cipher name from the cipher numbers I check RFC4880 (
https://tools.ietf.org/html/rfc4880#section-9.2).

My expectation is that symmetric encryption should use the same cipher
(AES256) in both cases.

Can someone please explain if the above is the expected behaviour or if my
expectations are wrong?

I am running Debin 8.3 with gnupg2 2.0.26-6. I use gpg2 because my 4096b
public/private keys are on a smart card.

I also apologies for the really long e-mail.

Kind Regards,
Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/attachments/20160225/0880df9b/attachment.html>


More information about the Gnupg-users mailing list