summaryrefslogtreecommitdiffstats
path: root/cryptodev_cipher.c
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2010-08-25 06:06:16 +0200
committerMiloslav Trmač <mitr@redhat.com>2010-08-25 06:06:16 +0200
commitf90894ca4a2f56c42b787504e59421b89030c75e (patch)
tree912392aa002babcafa3b54266f85e203e89d6990 /cryptodev_cipher.c
parent7f6e65351ae2c214f28496609103711773721ca5 (diff)
parent5d586cad2979ad279e9a7f0985d008e5d649bbc5 (diff)
downloadcryptodev-linux-f90894ca4a2f56c42b787504e59421b89030c75e.tar.gz
cryptodev-linux-f90894ca4a2f56c42b787504e59421b89030c75e.tar.xz
cryptodev-linux-f90894ca4a2f56c42b787504e59421b89030c75e.zip
Merge branch 'clone-session'
Conflicts: cryptodev_int.h ncr-sessions.c
Diffstat (limited to 'cryptodev_cipher.c')
-rw-r--r--cryptodev_cipher.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/cryptodev_cipher.c b/cryptodev_cipher.c
index dae4a63..1fb1147 100644
--- a/cryptodev_cipher.c
+++ b/cryptodev_cipher.c
@@ -278,6 +278,48 @@ error:
return ret;
}
+int cryptodev_hash_clone(struct hash_data *hdata, struct hash_data *old_data,
+ const void *mackey, size_t mackeylen)
+{
+ const char *algo;
+ void *state;
+ int ret;
+
+ /* We want exactly the same driver. */
+ algo = crypto_tfm_alg_driver_name(crypto_ahash_tfm(old_data->async.s));
+ ret = cryptodev_hash_init(hdata, algo, mackey, mackeylen);
+ if (unlikely(ret != 0))
+ return ret;
+
+ state = kmalloc(crypto_ahash_statesize(hdata->async.s), GFP_KERNEL);
+ if (unlikely(state == NULL)) {
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ ret = crypto_ahash_export(old_data->async.request, state);
+ if (unlikely(ret != 0)) {
+ dprintk(0, KERN_ERR, "error exporting hash state\n");
+ goto err;
+ }
+ ret = crypto_ahash_import(hdata->async.request, state);
+ if (unlikely(ret != 0)) {
+ dprintk(0,KERN_ERR,
+ "error in crypto_hash_init()\n");
+ goto err;
+ }
+
+ kfree(state);
+
+ hdata->init = 1;
+ return 0;
+
+err:
+ kfree(state);
+ cryptodev_hash_deinit(hdata);
+ return ret;
+}
+
void cryptodev_hash_deinit(struct hash_data* hdata)
{
if (hdata->init) {