mbox series

[0/3] crypto: set CRYPTO_TFM_NEED_KEY if ->setkey() fails

Message ID 20190107024744.4952-1-ebiggers@kernel.org (mailing list archive)
Headers show
Series crypto: set CRYPTO_TFM_NEED_KEY if ->setkey() fails | expand

Message

Eric Biggers Jan. 7, 2019, 2:47 a.m. UTC
This series makes the crypto API mark shash, ahash, skcipher, and aead
tfms as needing a key again if setting a key fails, since on failure
many algorithms can leave the tfm in an intermediate state that is
neither the old key nor the new key -- and use of such tfms for hashing,
encryption, or decryption will produce bogus results or crashes.

Eric Biggers (3):
  crypto: hash - set CRYPTO_TFM_NEED_KEY if ->setkey() fails
  crypto: skcipher - set CRYPTO_TFM_NEED_KEY if ->setkey() fails
  crypto: aead - set CRYPTO_TFM_NEED_KEY if ->setkey() fails

 crypto/aead.c     |  4 +++-
 crypto/ahash.c    | 28 +++++++++++++++++++---------
 crypto/shash.c    | 18 +++++++++++++-----
 crypto/skcipher.c | 27 ++++++++++++++++++---------
 4 files changed, 53 insertions(+), 24 deletions(-)

Comments

Herbert Xu Jan. 18, 2019, 10:55 a.m. UTC | #1
On Sun, Jan 06, 2019 at 06:47:41PM -0800, Eric Biggers wrote:
> This series makes the crypto API mark shash, ahash, skcipher, and aead
> tfms as needing a key again if setting a key fails, since on failure
> many algorithms can leave the tfm in an intermediate state that is
> neither the old key nor the new key -- and use of such tfms for hashing,
> encryption, or decryption will produce bogus results or crashes.
> 
> Eric Biggers (3):
>   crypto: hash - set CRYPTO_TFM_NEED_KEY if ->setkey() fails
>   crypto: skcipher - set CRYPTO_TFM_NEED_KEY if ->setkey() fails
>   crypto: aead - set CRYPTO_TFM_NEED_KEY if ->setkey() fails
> 
>  crypto/aead.c     |  4 +++-
>  crypto/ahash.c    | 28 +++++++++++++++++++---------
>  crypto/shash.c    | 18 +++++++++++++-----
>  crypto/skcipher.c | 27 ++++++++++++++++++---------
>  4 files changed, 53 insertions(+), 24 deletions(-)

All applied.  Thanks.