fscrypt: separate key lookup from key derivation
authorEric Biggers <ebiggers@google.com>
Mon, 30 Apr 2018 22:51:48 +0000 (15:51 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 28 Jun 2018 16:37:40 +0000 (09:37 -0700)
commitdeba2007d2a1c171487752a8f99b8c4de6bf4835
tree18659aacebf51c0a744b20d5446b2989f876aa6f
parent04566cd68241737af8ea897c36c361f59730c88a
fscrypt: separate key lookup from key derivation

Refactor the confusingly-named function 'validate_user_key()' into a new
function 'find_and_derive_key()' which first finds the keyring key, then
does the key derivation.  Among other benefits this avoids the strange
behavior we had previously where if key derivation failed for some
reason, then we would fall back to the alternate key prefix.  Now, we'll
only fall back to the alternate key prefix if a valid key isn't found.

This patch also improves the warning messages that are logged when the
keyring key's payload is invalid.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/crypto/keyinfo.c