Skip to content

Commit 03d2c51

Browse files
mohicksherbertx
authored andcommitted
crypto: talitos - Extend max key length for SHA384/512-HMAC and AEAD
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). Cc: <[email protected]> # 3.6+ Fixes: 357fb60 ("crypto: talitos - add sha224, sha384 and sha512 to existing AEAD algorithms") Signed-off-by: Martin Hicks <[email protected]> Acked-by: Horia Geantă <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 48df28b commit 03d2c51

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/crypto/talitos.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ static void talitos_unregister_rng(struct device *dev)
816816
* HMAC_SNOOP_NO_AFEA (HSNA) instead of type IPSEC_ESP
817817
*/
818818
#define TALITOS_CRA_PRIORITY_AEAD_HSNA (TALITOS_CRA_PRIORITY - 1)
819-
#define TALITOS_MAX_KEY_SIZE 96
819+
#define TALITOS_MAX_KEY_SIZE (AES_MAX_KEY_SIZE + SHA512_BLOCK_SIZE)
820820
#define TALITOS_MAX_IV_LENGTH 16 /* max of AES_BLOCK_SIZE, DES3_EDE_BLOCK_SIZE */
821821

822822
struct talitos_ctx {
@@ -1495,6 +1495,11 @@ static int ablkcipher_setkey(struct crypto_ablkcipher *cipher,
14951495
{
14961496
struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher);
14971497

1498+
if (keylen > TALITOS_MAX_KEY_SIZE) {
1499+
crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN);
1500+
return -EINVAL;
1501+
}
1502+
14981503
memcpy(&ctx->key, key, keylen);
14991504
ctx->keylen = keylen;
15001505

0 commit comments

Comments
 (0)