fscrypt: only derive the needed portion of the key
authorEric Biggers <ebiggers@google.com>
Mon, 30 Apr 2018 22:51:49 +0000 (15:51 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 28 Jun 2018 16:37:40 +0000 (09:37 -0700)
commit9637768c618d89dc6c4a0451920b884b7e5c6edb
tree30ba971ee042530c9a22d4b680cc21ea5405461a
parentdeba2007d2a1c171487752a8f99b8c4de6bf4835
fscrypt: only derive the needed portion of the key

Currently the key derivation function in fscrypt uses the master key
length as the amount of output key material to derive.  This works, but
it means we can waste time deriving more key material than is actually
used, e.g. most commonly, deriving 64 bytes for directories which only
take a 32-byte AES-256-CTS-CBC key.  It also forces us to validate that
the master key length is a multiple of AES_BLOCK_SIZE, which wouldn't
otherwise be necessary.

Fix it to only derive the needed length key.

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