aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCristian Stoica <cristian.stoica@freescale.com>2014-05-30 13:59:02 +0300
committerBruce Ashfield <bruce.ashfield@windriver.com>2016-08-30 12:11:57 -0400
commit1cf85c983453ef1ebf43f5f6f14f5e39dc26f260 (patch)
tree8133db2103de4aac51d060f254fc9236799b6305
parent9af2bb70f3c1a1ddc1bfd822f33cf720449f1946 (diff)
downloadlinux-yocto-1cf85c983453ef1ebf43f5f6f14f5e39dc26f260.tar.gz
linux-yocto-1cf85c983453ef1ebf43f5f6f14f5e39dc26f260.tar.bz2
linux-yocto-1cf85c983453ef1ebf43f5f6f14f5e39dc26f260.zip
cryptodev: use
Composite ciphers (cipher + hmac) use both keys at the same time. This patch is the first in a series that adds support for composite ciphers keys. 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, 6 insertions, 8 deletions
diff --git a/drivers/staging/crypto/cryptodev/ioctl.c b/drivers/staging/crypto/cryptodev/ioctl.c
index d4e83f4cfa4a..1ea1f7740a47 100644
--- a/drivers/staging/crypto/cryptodev/ioctl.c
+++ b/drivers/staging/crypto/cryptodev/ioctl.c
@@ -109,6 +109,8 @@ 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];
/* Does the request make sense? */
if (unlikely(!sop->cipher && !sop->mac)) {
@@ -222,8 +224,6 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop)
/* Set-up crypto transform. */
if (alg_name) {
- uint8_t keyp[CRYPTO_CIPHER_MAX_KEY_LEN];
-
if (unlikely(sop->keylen > CRYPTO_CIPHER_MAX_KEY_LEN)) {
ddebug(1, "Setting key failed for %s-%zu.",
alg_name, (size_t)sop->keylen*8);
@@ -231,12 +231,12 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop)
goto error_cipher;
}
- if (unlikely(copy_from_user(keyp, sop->key, sop->keylen))) {
+ if (unlikely(copy_from_user(ckey, sop->key, sop->keylen))) {
ret = -EFAULT;
goto error_cipher;
}
- ret = cryptodev_cipher_init(&ses_new->cdata, alg_name, keyp,
+ ret = cryptodev_cipher_init(&ses_new->cdata, alg_name, ckey,
sop->keylen, stream, aead);
if (ret < 0) {
ddebug(1, "Failed to load cipher for %s", alg_name);
@@ -246,8 +246,6 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop)
}
if (hash_name && aead == 0) {
- uint8_t keyp[CRYPTO_HMAC_MAX_KEY_LEN];
-
if (unlikely(sop->mackeylen > CRYPTO_HMAC_MAX_KEY_LEN)) {
ddebug(1, "Setting key failed for %s-%zu.",
hash_name, (size_t)sop->mackeylen*8);
@@ -255,14 +253,14 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop)
goto error_hash;
}
- if (sop->mackey && unlikely(copy_from_user(keyp, sop->mackey,
+ if (sop->mackey && unlikely(copy_from_user(mkey, sop->mackey,
sop->mackeylen))) {
ret = -EFAULT;
goto error_hash;
}
ret = cryptodev_hash_init(&ses_new->hdata, hash_name, hmac_mode,
- keyp, sop->mackeylen);
+ mkey, sop->mackeylen);
if (ret != 0) {
ddebug(1, "Failed to load hash for %s", hash_name);
ret = -EINVAL;