Common password derivation function for different encryption methods I'm writing a simple encryption/decryption library which has the following requirements:


For key derivation functions, support:

$SHA256 \rightarrow bcrypt$ (since $bcrypt$ limits input passphrase length, hash it using SHA-256 first, then feed output of SHA-256 into bcrypt)
$PBKDF2$

For key derivation functions, allow custom iteration count.
For encryption/decryption support:

AES-256
AES-128
Triple DES

Authenticity using HMAC+SHA256 every $n$ bytes


Since I'm potentially using multiple different symmetric key algorithms for encryption and decryption, I have the following problems:


How do I deal with different output sizes from my KDFs? 
How do I deal with different key input requirements from my symmetric key algorithms?
First, consider dropping bcrypt, because of its output limitations. If you are concerned about GPUs and ASICs, there's always scrypt. If you decide to go with bcrypt, you won't have 256-bit security with AES-256 and will need to pad the key somehow or disallow that combination.


I would simply call the KDF with a constant 256-bit output, which matches the blocksize of SHA-256-HMAC if you use that as PBKDF2 PRF (so it's ~ as fast as shorter outputs).
Then you can truncate the input of AES-128 to 128 bits and 3DES to 168 bits, which is what PBKDF2 would do anyway.