fscrypt: switch fscrypt_do_sha256() to use the SHA-256 library
authorEric Biggers <ebiggers@google.com>
Tue, 21 Jul 2020 22:59:16 +0000 (15:59 -0700)
committerEric Biggers <ebiggers@google.com>
Tue, 21 Jul 2020 23:02:13 +0000 (16:02 -0700)
commitbd0d97b7191e8f3573681fa854fdb04c1a970c1e
treea32b0fd5de253bfef08c6d9730bff73998028b77
parentf000223c981a7c75f6f3ab7288f0be7b571c3644
fscrypt: switch fscrypt_do_sha256() to use the SHA-256 library

fscrypt_do_sha256() is only used for hashing encrypted filenames to
create no-key tokens, which isn't performance-critical.  Therefore a C
implementation of SHA-256 is sufficient.

Also, the logic to create no-key tokens is always potentially needed.
This differs from fscrypt's other dependencies on crypto API algorithms,
which are conditionally needed depending on what encryption policies
userspace is using.  Therefore, for fscrypt there isn't much benefit to
allowing SHA-256 to be a loadable module.

So, make fscrypt_do_sha256() use the SHA-256 library instead of the
crypto_shash API.  This is much simpler, since it avoids having to
implement one-time-init (which is hard to do correctly, and in fact was
implemented incorrectly) and handle failures to allocate the
crypto_shash object.

Fixes: edc440e3d27f ("fscrypt: improve format of no-key names")
Cc: Daniel Rosenberg <drosen@google.com>
Link: https://lore.kernel.org/r/20200721225920.114347-2-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
fs/crypto/Kconfig
fs/crypto/fname.c