Skip to content

Commit d05fbdb

Browse files
mohicksgregkh
authored andcommitted
crypto: talitos - Extend max key length for SHA384/512-HMAC and AEAD
commit 03d2c5114c95797c0aa7d9f463348b171a274fd4 upstream. An updated patch that also handles the additional key length requirements for the AEAD algorithms. The max keysize is not 96. For SHA384/512 it's 128, and for the AEAD algorithms it's longer still. Extend the max keysize for the AEAD size for AES256 + HMAC(SHA512). Fixes: 357fb60 ("crypto: talitos - add sha224, sha384 and sha512 to existing AEAD algorithms") Signed-off-by: Martin Hicks <mort@bork.org> Acked-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8f93a9a commit d05fbdb

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

drivers/crypto/talitos.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ static void talitos_unregister_rng(struct device *dev)
804804
* crypto alg
805805
*/
806806
#define TALITOS_CRA_PRIORITY 3000
807-
#define TALITOS_MAX_KEY_SIZE 96
807+
#define TALITOS_MAX_KEY_SIZE (AES_MAX_KEY_SIZE + SHA512_BLOCK_SIZE)
808808
#define TALITOS_MAX_IV_LENGTH 16 /* max of AES_BLOCK_SIZE, DES3_EDE_BLOCK_SIZE */
809809

810810
struct talitos_ctx {
@@ -1388,6 +1388,11 @@ static int ablkcipher_setkey(struct crypto_ablkcipher *cipher,
13881388
{
13891389
struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher);
13901390

1391+
if (keylen > TALITOS_MAX_KEY_SIZE) {
1392+
crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN);
1393+
return -EINVAL;
1394+
}
1395+
13911396
memcpy(&ctx->key, key, keylen);
13921397
ctx->keylen = keylen;
13931398

0 commit comments

Comments
 (0)