From: Cristian Stoica <cristian.sto...@freescale.com>

This allows the user to set the result length and relieves cryptodev
from making assumptions about it.

Signed-off-by: Cristian Stoica <cristian.sto...@freescale.com>
Reviewed-by: Alexandru Porosanu <alexandru.poros...@freescale.com>
Reviewed-by: Horia Ioan Geanta Neag <horia.gea...@freescale.com>
Tested-by: Horia Ioan Geanta Neag <horia.gea...@freescale.com>
Signed-off-by: Horia Geanta <horia.gea...@freescale.com>
---
 authenc.c          |   11 +++--------
 crypto/cryptodev.h |    1 +
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/authenc.c b/authenc.c
index 74f9c9b..759a67d 100644
--- a/authenc.c
+++ b/authenc.c
@@ -203,7 +203,7 @@ static int fill_kcaop_from_caop(struct kernel_crypt_auth_op 
*kcaop, struct fcryp
        kcaop->ivlen = caop->iv ? ses_ptr->cdata.ivsize : 0;
 
        if (caop->flags & COP_FLAG_AEAD_TLS_TYPE)
-               kcaop->dst_len = caop->len + ses_ptr->cdata.blocksize /* pad */ 
+ caop->tag_len;
+               kcaop->dst_len = caop->dst_len;
        else
                kcaop->dst_len = caop->len;
 
@@ -652,8 +652,6 @@ __crypto_auth_run_zc(struct csession *ses_ptr, struct 
kernel_crypt_auth_op *kcao
                        ret = tls_auth_n_crypt(ses_ptr, kcaop, auth_sg, 
caop->auth_len,
                                   dst_sg, caop->len);
                } else {
-                       int dst_len;
-
                        if (unlikely(ses_ptr->cdata.init == 0 ||
                                        (ses_ptr->cdata.stream == 0 && 
ses_ptr->cdata.aead == 0)))
                        {
@@ -662,11 +660,8 @@ __crypto_auth_run_zc(struct csession *ses_ptr, struct 
kernel_crypt_auth_op *kcao
                                goto free_auth_buf;
                        }
 
-                       if (caop->op == COP_ENCRYPT) dst_len = caop->len + 
cryptodev_cipher_get_tag_size(&ses_ptr->cdata);
-                       else dst_len = caop->len;
-
-                       ret = get_userbuf(ses_ptr, caop->src, caop->len, 
caop->dst, dst_len,
-                                         kcaop->task, kcaop->mm, &src_sg, 
&dst_sg);
+                       ret = get_userbuf(ses_ptr, caop->src, caop->len, 
caop->dst,
+                                       caop->dst_len, kcaop->task, kcaop->mm, 
&src_sg, &dst_sg);
                        if (unlikely(ret)) {
                                dprintk(1, KERN_ERR, "get_userbuf(): Error 
getting user pages.\n");
                                goto free_auth_buf;
diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h
index 7fb9c7d..95de722 100644
--- a/crypto/cryptodev.h
+++ b/crypto/cryptodev.h
@@ -136,6 +136,7 @@ struct crypt_auth_op {
        __u16   op;             /* COP_ENCRYPT or COP_DECRYPT */
        __u16   flags;          /* see COP_FLAG_AEAD_* */
        __u32   len;            /* length of source data */
+       __u32   dst_len;        /* length of result data */
        __u32   auth_len;       /* length of auth data */
        __u8    __user *auth_src;       /* authenticated-only data */
 
-- 
1.7.7.6



_______________________________________________
Cryptodev-linux-devel mailing list
Cryptodev-linux-devel@gna.org
https://mail.gna.org/listinfo/cryptodev-linux-devel

Reply via email to