1 From cc65307405a21c3b709ca6f2a6f64ff0c67c0eed Mon Sep 17 00:00:00 2001
2 From: Cristian Stoica <cristian.stoica@freescale.com>
3 Date: Wed, 18 Sep 2013 13:42:31 +0300
4 Subject: [[Patch][fsl 02/16] use function-local storage for cipher and hmac
7 Upstream-status: Pending
9 This refactorization is necessary for next patches that add support for
10 aead composite ciphers where the aead key is the sum of cipher and hmac
13 Without this patch, the hmac and cipher keys can't be combined in the
16 Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com>
17 Tested-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com>
19 ioctl.c | 14 ++++++--------
20 1 file changed, 6 insertions(+), 8 deletions(-)
22 diff --git a/ioctl.c b/ioctl.c
23 index a0f1db1..c614373 100644
26 @@ -109,6 +109,8 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop)
27 const char *alg_name = NULL;
28 const char *hash_name = NULL;
29 int hmac_mode = 1, stream = 0, aead = 0;
30 + uint8_t enckey[CRYPTO_CIPHER_MAX_KEY_LEN];
31 + uint8_t mackey[CRYPTO_HMAC_MAX_KEY_LEN];
33 /* Does the request make sense? */
34 if (unlikely(!sop->cipher && !sop->mac)) {
35 @@ -227,8 +229,6 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop)
37 /* Set-up crypto transform. */
39 - uint8_t keyp[CRYPTO_CIPHER_MAX_KEY_LEN];
41 if (unlikely(sop->keylen > CRYPTO_CIPHER_MAX_KEY_LEN)) {
42 ddebug(1, "Setting key failed for %s-%zu.",
43 alg_name, (size_t)sop->keylen*8);
44 @@ -236,12 +236,12 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop)
48 - if (unlikely(copy_from_user(keyp, sop->key, sop->keylen))) {
49 + if (unlikely(copy_from_user(enckey, sop->key, sop->keylen))) {
54 - ret = cryptodev_cipher_init(&ses_new->cdata, alg_name, keyp,
55 + ret = cryptodev_cipher_init(&ses_new->cdata, alg_name, enckey,
56 sop->keylen, stream, aead);
58 ddebug(1, "Failed to load cipher for %s", alg_name);
59 @@ -251,8 +251,6 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop)
62 if (hash_name && aead == 0) {
63 - uint8_t keyp[CRYPTO_HMAC_MAX_KEY_LEN];
65 if (unlikely(sop->mackeylen > CRYPTO_HMAC_MAX_KEY_LEN)) {
66 ddebug(1, "Setting key failed for %s-%zu.",
67 hash_name, (size_t)sop->mackeylen*8);
68 @@ -260,14 +258,14 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop)
72 - if (sop->mackey && unlikely(copy_from_user(keyp, sop->mackey,
73 + if (sop->mackey && unlikely(copy_from_user(mackey, sop->mackey,
79 ret = cryptodev_hash_init(&ses_new->hdata, hash_name, hmac_mode,
80 - keyp, sop->mackeylen);
81 + mackey, sop->mackeylen);
83 ddebug(1, "Failed to load hash for %s", hash_name);