KB Article #157425
PGP: Which algorithm is used for PGP encryption
Problem
How to determine which encryption algorithm is used during PGP encryption in SecureTransport? Such info is not displayed in the Server Log.
Resolution
The encryption algorithm depends on the list of "preferred algorithms" specified in the PGP public key that would be used for the encryption.According to the RFC for PGP, each encryption key should have such list of preferred algorithms. SecureTransport (ST) will try to comply with the list when possible.
If you need to determine what are the preferred algorithms for a specific key, you should export that key to a UNIX based OS and run the following command:
gpg -vv ./public_key.asc
or
gpg --list-packets ./public_key.asc
The output should be inspected. The example PGP key public_key.asc
from the commands above is generated in SecureTransport (ST) and will show the following:
:public key packet: version 4, algo 17, created 1576272146, expires 0 pkey[0]: [1024 bits] pkey[1]: [160 bits] pkey[2]: [1024 bits] pkey[3]: [1018 bits] :user ID packet: "FULL NAME <EMAIL>" :signature packet: algo 17, keyid 9C998E38DE85D9D0 version 4, created 1576272146, md5len 0, sigclass 0x13 digest algo 2, begin of digest 13 78 hashed subpkt 2 len 4 (sig created 2019-12-13) hashed subpkt 9 len 4 (key expires after 1y0d0h0m) hashed subpkt 11 len 5 (pref-sym-algos: 9 8 7 3 2) hashed subpkt 21 len 5 (pref-hash-algos: 10 9 8 2 1) hashed subpkt 22 len 4 (pref-zip-algos: 2 1 3 0) subpkt 16 len 8 (issuer key ID 9C998E38DE85D9D0) data: [160 bits] data: [160 bits] :public sub key packet: version 4, algo 16, created 1576272147, expires 0 pkey[0]: [2048 bits] pkey[1]: [2047 bits] pkey[2]: [2046 bits] :signature packet: algo 17, keyid 9C998E38DE85D9D0 version 4, created 1576272147, md5len 0, sigclass 0x18 digest algo 2, begin of digest 36 08 hashed subpkt 2 len 4 (sig created 2019-12-13) hashed subpkt 9 len 4 (key expires after 1y0d0h0m) hashed subpkt 11 len 5 (pref-sym-algos: 9 8 7 3 2) hashed subpkt 21 len 5 (pref-hash-algos: 10 9 8 2 1) hashed subpkt 22 len 4 (pref-zip-algos: 2 1 3 0) subpkt 16 len 8 (issuer key ID 9C998E38DE85D9D0) data: [158 bits] data: [158 bits] pub 1024D/DE85D9D0 2019-12-13 FULL NAME <EMAIL> sig DE85D9D0 2019-12-13 [selfsig] sub 2048g/8E1BC40D 2019-12-13 [expires: 2020-12-12] sig DE85D9D0 2019-12-13 [keybind]
In this output, each key and subkey have lines like those below:
hashed subpkt 11 len 5 (pref-sym-algos: 9 8 7 3 2) hashed subpkt 21 len 5 (pref-hash-algos: 10 9 8 2 1) hashed subpkt 22 len 4 (pref-zip-algos: 2 1 3 0)
What is of interest to us here is the list of numeric IDs for the algorithms used for the specific actions - the symetric algos for encryption, the hashing algos and the compression algos. Human-readable definitions for the IDs can be obtained with the following command:
gpg --verbose --version
which produces this:
Cipher: IDEA (S1), 3DES (S2), CAST5 (S3), BLOWFISH (S4), AES (S7), AES192 (S8), AES256 (S9), TWOFISH (S10), CAMELLIA128 (S11), CAMELLIA192 (S12), CAMELLIA256 (S13) Hash: MD5 (H1), SHA1 (H2), RIPEMD160 (H3), SHA256 (H8), SHA384 (H9), SHA512 (H10), SHA224 (H11) Compression: Uncompressed (Z0), ZIP (Z1), ZLIB (Z2), BZIP2 (Z3)
You will notice that each algorithm has an ID here as well (i.e. H1 or S3 or Z3), which is composed of the type of the algo (S for symetric, H for hashing and Z for compression/zip) and a number. These numbers are what we see in the example key's output above and we can compose their IDs. For example
(pref-hash-algos: 10 9 8 2 1)
will corresponds to
H10 H9 H8 H2 H1
This sequence means that the key will prefer those 5 algorithms in the listed order when the keys is used for hashing. Comparing to the output of gpg --verbose --version
command, we obtain the names of the preferred hash algos, which for our example key are:
SHA512, SHA384, SHA256, SHA1, MD5
Repeating the same steps for the other two groups of algorithms, we obtain the preferred symmetric and compression algos. At the end, our example key prefers the following algos:
For encryption (symetric group): AES256, AES192, AES, CAST5, 3DES
For hasning (hashing group): SHA512, SHA384, SHA256, SHA1, MD5
For compression (zip group): ZLIB, ZIP, BZIP2, Uncompressed
The output for the example key could also be compared against RFC 4880, from Section 9.1 to Section 9.4.