summaryrefslogtreecommitdiff
path: root/crypto/sha1_generic.c
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2019-01-06 18:47:42 -0800
committerHerbert Xu <herbert@gondor.apana.org.au>2019-01-18 18:40:24 +0800
commit876a053bb3938fd7b35beec1081d1db2f62a4113 (patch)
tree093eece841b196be8688b8c9f63991db475c9be5 /crypto/sha1_generic.c
parent81a913cde2c709d8322ae09a81d7064200ea56a9 (diff)
downloadlinux-crypto-876a053bb3938fd7b35beec1081d1db2f62a4113.tar.gz
linux-crypto-876a053bb3938fd7b35beec1081d1db2f62a4113.zip
crypto: hash - set CRYPTO_TFM_NEED_KEY if ->setkey() fails
Some algorithms have a ->setkey() method that is not atomic, in the sense that setting a key can fail after changes were already made to the tfm context. In this case, if a key was already set the tfm can end up in a state that corresponds to neither the old key nor the new key. It's not feasible to make all ->setkey() methods atomic, especially ones that have to key multiple sub-tfms. Therefore, make the crypto API set CRYPTO_TFM_NEED_KEY if ->setkey() fails and the algorithm requires a key, to prevent the tfm from being used until a new key is set. Note: we can't set CRYPTO_TFM_NEED_KEY for OPTIONAL_KEY algorithms, so ->setkey() for those must nevertheless be atomic. That's fine for now since only the crc32 and crc32c algorithms set OPTIONAL_KEY, and it's not intended that OPTIONAL_KEY be used much. [Cc stable mainly because when introducing the NEED_KEY flag I changed AF_ALG to rely on it; and unlike in-kernel crypto API users, AF_ALG previously didn't have this problem. So these "incompletely keyed" states became theoretically accessible via AF_ALG -- though, the opportunities for causing real mischief seem pretty limited.] Fixes: 40c60e1610b6 ("crypto: hash - prevent using keyed hashes without setting key") Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/sha1_generic.c')
0 files changed, 0 insertions, 0 deletions