If I run the openssl command line in hmac mode (as below), is the key used for the hmac used directly or is it hashed before using it as the key?
echo "foo" | openssl dgst -sha256 -binary -hmac "test" | openssl base64
Similarly, when encrypting a file with openssl (as below)is the pass phrase hashed with the salt? (If so how is it done? A pointer to the right source file would be even better.)
openssl enc -salt
The hmac option does not use salting or hashing; it just uses the passphrase directly as the key. See
apps/dgst.cin the source distribution:The
enccommand does seem to use some form of salting, at least in some cases. The relevant source file isapps/enc.c, but seems to come with some caveats:It then uses the function
EVP_BytesToKey(incrypto/evp/evp_key.c) to generate a random key. This function seems to be a non-standard algorithm, which looked perhaps plausibly OK at a very brief glance but I couldn’t attest to it beyond that.Source snippets and comments are all from the OpenSSL 1.0.0 release.