summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2010-02-19 20:10:30 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2010-02-19 20:10:30 +0100
commit119103e0e156be1b4a9cae5b6e5855b561292caa (patch)
tree9f6c48e9b60e8f5f08abdb86914c25c8c1d697ae
parent28bde7b11127a67908909922ab9248e114f0232e (diff)
downloadcryptodev-linux-119103e0e156be1b4a9cae5b6e5855b561292caa.tar.gz
cryptodev-linux-119103e0e156be1b4a9cae5b6e5855b561292caa.tar.xz
cryptodev-linux-119103e0e156be1b4a9cae5b6e5855b561292caa.zip
Corrected bug in IV setting for ciphers.
-rw-r--r--cryptodev_cipher.c14
-rw-r--r--cryptodev_main.c5
2 files changed, 11 insertions, 8 deletions
diff --git a/cryptodev_cipher.c b/cryptodev_cipher.c
index 49bd618..9cc42ac 100644
--- a/cryptodev_cipher.c
+++ b/cryptodev_cipher.c
@@ -187,12 +187,16 @@ void cryptodev_cipher_deinit(struct cipher_data* cdata)
cdata->type = 0;
}
-void cryptodev_cipher_set_iv(struct cipher_data* cdata, void* iv, size_t iv_size)
+void cryptodev_cipher_set_iv(struct cipher_data* cdata, __user void* iv, size_t iv_size)
{
- if (cdata->type == 1)
- crypto_blkcipher_set_iv(cdata->u.blk.s, iv, iv_size);
- else
- memcpy(cdata->u.ablk.iv, iv, min(iv_size,sizeof(*cdata->u.ablk.iv)));
+ if (cdata->type == 1) {
+ uint8_t _iv[EALG_MAX_BLOCK_LEN];
+
+ copy_from_user(_iv, iv, min(iv_size,sizeof(_iv)));
+ crypto_blkcipher_set_iv(cdata->u.blk.s, _iv, iv_size);
+ } else {
+ copy_from_user(cdata->u.ablk.iv, iv, min(iv_size,sizeof(cdata->u.ablk.iv)));
+ }
}
static inline int waitfor (struct cryptodev_result* cr, ssize_t ret)
diff --git a/cryptodev_main.c b/cryptodev_main.c
index 139bb26..c065065 100644
--- a/cryptodev_main.c
+++ b/cryptodev_main.c
@@ -357,7 +357,7 @@ crypto_get_session_by_sid(struct fcrypt *fcr, uint32_t sid)
static int
crypto_run(struct fcrypt *fcr, struct crypt_op *cop)
{
- char *data, ivp[EALG_MAX_BLOCK_LEN];
+ char *data;
char __user *src, __user *dst;
struct scatterlist sg;
struct csession *ses_ptr;
@@ -411,8 +411,7 @@ crypto_run(struct fcrypt *fcr, struct crypt_op *cop)
ivsize = ses_ptr->cdata.ivsize;
if (cop->iv) {
- copy_from_user(ivp, cop->iv, ivsize);
- cryptodev_cipher_set_iv(&ses_ptr->cdata, ivp, ivsize);
+ cryptodev_cipher_set_iv(&ses_ptr->cdata, cop->iv, ivsize);
}
}