aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCristian Stoica <cristian.stoica@freescale.com>2014-05-30 13:59:03 +0300
committerBruce Ashfield <bruce.ashfield@windriver.com>2016-08-30 12:11:58 -0400
commit080baf5d77fe042f7594bd24dc3b713df6480aec (patch)
tree701bd8c18cb0add769517f9c6aebef2716188569
parent1cf85c983453ef1ebf43f5f6f14f5e39dc26f260 (diff)
downloadlinux-yocto-080baf5d77fe042f7594bd24dc3b713df6480aec.tar.gz
linux-yocto-080baf5d77fe042f7594bd24dc3b713df6480aec.tar.bz2
linux-yocto-080baf5d77fe042f7594bd24dc3b713df6480aec.zip
cryptodev: refactoring:
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.stoica@freescale.com> Signed-off-by: Phil Sutter <phil@nwl.cc>
-rw-r--r--drivers/staging/crypto/cryptodev/ioctl.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/staging/crypto/cryptodev/ioctl.c b/drivers/staging/crypto/cryptodev/ioctl.c
index 1ea1f7740a47..fecbbff3c628 100644
--- a/drivers/staging/crypto/cryptodev/ioctl.c
+++ b/drivers/staging/crypto/cryptodev/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;