The enclosing structure refers to both keys either as individuals
or as a group. For block ciphers and hmacs, both keys are used
independently. For composite ciphers the whole structure will be
used as a single key.

Signed-off-by: Cristian Stoica <cristian.sto...@freescale.com>
---
 ioctl.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/ioctl.c b/ioctl.c
index 1ea1f77..fecbbff 100644
--- a/ioctl.c
+++ b/ioctl.c
@@ -109,8 +109,10 @@ crypto_create_session(struct fcrypt *fcr, struct 
session_op *sop)
        const char *alg_name = NULL;
        const char *hash_name = NULL;
        int hmac_mode = 1, stream = 0, aead = 0;
-       uint8_t ckey[CRYPTO_CIPHER_MAX_KEY_LEN];
-       uint8_t mkey[CRYPTO_HMAC_MAX_KEY_LEN];
+       struct {
+               uint8_t ckey[CRYPTO_CIPHER_MAX_KEY_LEN];
+               uint8_t mkey[CRYPTO_HMAC_MAX_KEY_LEN];
+       } keys;
 
        /* Does the request make sense? */
        if (unlikely(!sop->cipher && !sop->mac)) {
@@ -231,12 +233,12 @@ crypto_create_session(struct fcrypt *fcr, struct 
session_op *sop)
                        goto error_cipher;
                }
 
-               if (unlikely(copy_from_user(ckey, sop->key, sop->keylen))) {
+               if (unlikely(copy_from_user(keys.ckey, sop->key, sop->keylen))) 
{
                        ret = -EFAULT;
                        goto error_cipher;
                }
 
-               ret = cryptodev_cipher_init(&ses_new->cdata, alg_name, ckey,
+               ret = cryptodev_cipher_init(&ses_new->cdata, alg_name, 
keys.ckey,
                                                sop->keylen, stream, aead);
                if (ret < 0) {
                        ddebug(1, "Failed to load cipher for %s", alg_name);
@@ -253,14 +255,14 @@ crypto_create_session(struct fcrypt *fcr, struct 
session_op *sop)
                        goto error_hash;
                }
 
-               if (sop->mackey && unlikely(copy_from_user(mkey, sop->mackey,
+               if (sop->mackey && unlikely(copy_from_user(keys.mkey, 
sop->mackey,
                                            sop->mackeylen))) {
                        ret = -EFAULT;
                        goto error_hash;
                }
 
                ret = cryptodev_hash_init(&ses_new->hdata, hash_name, hmac_mode,
-                                                       mkey, sop->mackeylen);
+                                                       keys.mkey, 
sop->mackeylen);
                if (ret != 0) {
                        ddebug(1, "Failed to load hash for %s", hash_name);
                        ret = -EINVAL;
-- 
1.8.3.1


_______________________________________________
Cryptodev-linux-devel mailing list
Cryptodev-linux-devel@gna.org
https://mail.gna.org/listinfo/cryptodev-linux-devel

Reply via email to