summaryrefslogtreecommitdiffstats
path: root/cryptodev_cipher.c
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 /cryptodev_cipher.c
parent28bde7b11127a67908909922ab9248e114f0232e (diff)
downloadcryptodev-linux-119103e0e156be1b4a9cae5b6e5855b561292caa.tar.gz
cryptodev-linux-119103e0e156be1b4a9cae5b6e5855b561292caa.tar.xz
cryptodev-linux-119103e0e156be1b4a9cae5b6e5855b561292caa.zip
Corrected bug in IV setting for ciphers.
Diffstat (limited to 'cryptodev_cipher.c')
-rw-r--r--cryptodev_cipher.c14
1 files changed, 9 insertions, 5 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)