From 57db8c4d07a7dc25c1455de38622156502bb9770 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Sun, 26 Feb 2012 14:50:05 +0100 Subject: [PATCH] FLAG_RESET can be combined with UPDATE --- crypto/cryptodev.h | 4 +++- ioctl.c | 8 ++++++-- main.c | 7 +------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h index 32c1c6e..00193a4 100644 --- a/crypto/cryptodev.h +++ b/crypto/cryptodev.h @@ -213,7 +213,9 @@ struct crypt_auth_op { * TLS protocol rules */ #define COP_FLAG_AEAD_SRTP_TYPE (1 << 5) /* authenticate and encrypt using the * SRTP protocol rules */ -#define COP_FLAG_RESET (1 << 6) /* multi-update reset the state */ +#define COP_FLAG_RESET (1 << 6) /* multi-update reset the state. + * should be used in combination + * with COP_FLAG_UPDATE */ /* Stuff for bignum arithmetic and public key diff --git a/ioctl.c b/ioctl.c index cf7f72e..b280b9f 100644 --- a/ioctl.c +++ b/ioctl.c @@ -677,11 +677,15 @@ static int kcop_to_user(struct kernel_crypt_op *kcop, int ret; ret = fill_cop_from_kcop(kcop, fcr); - if (unlikely(ret)) + if (unlikely(ret)) { + dprintk(1, KERN_ERR, "Error in fill_cop_from_kcop\n"); return ret; + } - if (unlikely(copy_to_user(arg, &kcop->cop, sizeof(kcop->cop)))) + if (unlikely(copy_to_user(arg, &kcop->cop, sizeof(kcop->cop)))) { + dprintk(1, KERN_ERR, "Cannot copy to userspace\n"); return -EFAULT; + } return 0; } diff --git a/main.c b/main.c index d8d7ee0..bc54e47 100644 --- a/main.c +++ b/main.c @@ -200,18 +200,13 @@ int crypto_run(struct fcrypt *fcr, struct kernel_crypt_op *kcop) return -EINVAL; } - if (ses_ptr->hdata.init != 0 && !(cop->flags & (COP_FLAG_UPDATE | COP_FLAG_FINAL))) { + if (ses_ptr->hdata.init != 0 && (cop->flags == 0 || cop->flags & COP_FLAG_RESET)) { ret = cryptodev_hash_reset(&ses_ptr->hdata); if (unlikely(ret)) { dprintk(1, KERN_ERR, "error in cryptodev_hash_reset()\n"); goto out_unlock; } - - if (cop->flags & COP_FLAG_RESET) { - ret = 0; - goto out_unlock; - } } if (ses_ptr->cdata.init != 0) { -- 2.11.4.GIT