Skip to contentSkip to conversation

crypto: talitos: Extend max key length for SHA384/512-HMAC

PATCH Superseded Martin Hicks 2 participants 2 messages Apr 27, 2017 – Apr 28, 2017 Crypto API

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: talitos: Extend max key length for SHA384/512-HMAC

The max keysize for both of these is 128, not 96. Before, with keysizes over 96, the memcpy in ahash_setkey() would overwrite memory beyond the key field.

---
 drivers/crypto/talitos.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/talitos.c +1 -1
index 0bba6a1..97dc85e 100644
@@ -816,7 +816,7 @@ static void talitos_unregister_rng(struct device *dev)
  * HMAC_SNOOP_NO_AFEA (HSNA) instead of type IPSEC_ESP
  */
 #define TALITOS_CRA_PRIORITY_AEAD_HSNA	(TALITOS_CRA_PRIORITY - 1)
-#define TALITOS_MAX_KEY_SIZE		96
+#define TALITOS_MAX_KEY_SIZE		SHA512_BLOCK_SIZE /* SHA512 has the largest keysize input */
 #define TALITOS_MAX_IV_LENGTH		16 /* max of AES_BLOCK_SIZE, DES3_EDE_BLOCK_SIZE */
 
 struct talitos_ctx {
Signature · 6 lines
1.7.10.4


-- 
Martin Hicks P.Eng.    |      [email protected]
Bork Consulting Inc.   |  +1 (613) 266-2296
#1 lore raw
Quoted 5 lines · Martin Hicks

The max keysize for both of these is 128, not 96. Before, with keysizes over 96, the memcpy in ahash_setkey() would overwrite memory beyond the key field.

While here, what about aead_setkey()?
AFAICT, TALITOS_MAX_KEY_SIZE value has been incorrect since forever; it does not cover the maximum values of encryption key + authentication key for authenc algorithms.

So, based on algorithms currently registered, I think this should be:

#define TALITOS_MAX_KEY_SIZE		(AES_MAX_KEY_SIZE + \
					 SHA512_BLOCK_SIZE)
Quoted 1 line
Fixes 357fb60502ede ("crypto: talitos - add sha224, sha384 and sha512

to existing AEAD algorithms")

Quoted 18 lines
---
 drivers/crypto/talitos.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/talitos.c +1 -1
index 0bba6a1..97dc85e 100644
@@ -816,7 +816,7 @@ static void talitos_unregister_rng(struct device *dev)
  * HMAC_SNOOP_NO_AFEA (HSNA) instead of type IPSEC_ESP
  */
 #define TALITOS_CRA_PRIORITY_AEAD_HSNA	(TALITOS_CRA_PRIORITY - 1)
-#define TALITOS_MAX_KEY_SIZE		96
+#define TALITOS_MAX_KEY_SIZE		SHA512_BLOCK_SIZE /* SHA512 has the largest keysize input */
 #define TALITOS_MAX_IV_LENGTH		16 /* max of AES_BLOCK_SIZE, DES3_EDE_BLOCK_SIZE */
 
 struct talitos_ctx {