What is the key derivation function used in GnuPG, and how long may its input be? I am currently working with GnuPG on a new project of mine. It would be very useful to know two things for that, which are not described in the manual:


What is the maximum input size of a symmetric key in GnuPG?
What key derivation function does GnuPG use?
What is the maximum input size of a symmetric key for GnuPG?


The key size of the symmetric key is defined by the cipher and is derived from a passphrase using OpenPGP's string to key function. The standard does not define a maximum input length, and I'm not aware of a limitation in GnuPG (but did not look up in the source code). Be aware that providing a passphrase as input to the string to key function longer than the symmetric key (ie., having more entropy than the symmetric key) does not increase security any more.


  What key derivation function does GnuPG use?


OpenPGP calls the key derivation function "string to key function", which is defined in RFC 4880, OpenPGP, String-to-Key (S2K) Specifiers. It boils down to applying a hash function on the passphrase and optionally a salt, usually those get concatenated for a number of iterations to increase the workload for brute force attacks.