From: Vishal Kulkarni <vishal@chelsio.com>
Date: Tue, 28 Feb 2017 09:51:29 +0530
Subject: [PATCH 36/36] The patch back-ports the crypto_skcipher to
crypto_blkcipher, skcipher was introduced after 4.4 and the patch modifies
the functions using it.
Patch-mainline: Never, SUSE specific
References: bsc#1022743 FATE#322540
Signed-off-by: Harsh Jain <harsh@chelsio.com>
Acked-by: Cho, Yu-Chen <acho@suse.com>
---
drivers/crypto/chelsio/chcr_algo.c | 33 +++++++++++++++------------------
drivers/crypto/chelsio/chcr_crypto.h | 2 +-
2 files changed, 16 insertions(+), 19 deletions(-)
--- a/drivers/crypto/chelsio/chcr_algo.c
+++ b/drivers/crypto/chelsio/chcr_algo.c
@@ -1321,20 +1321,6 @@ static void chcr_hmac_cra_exit(struct cr
}
}
-static int chcr_copy_assoc(struct aead_request *req,
- struct chcr_aead_ctx *ctx)
-{
- SKCIPHER_REQUEST_ON_STACK(skreq, ctx->null);
-
- skcipher_request_set_tfm(skreq, ctx->null);
- skcipher_request_set_callback(skreq, aead_request_flags(req),
- NULL, NULL);
- skcipher_request_set_crypt(skreq, req->src, req->dst, req->assoclen,
- NULL);
-
- return crypto_skcipher_encrypt(skreq);
-}
-
static unsigned char get_hmac(unsigned int authsize)
{
switch (authsize) {
@@ -1371,6 +1357,9 @@ static struct sk_buff *create_authenc_wr
unsigned short stop_offset = 0;
unsigned int assoclen = req->assoclen;
unsigned int authsize = crypto_aead_authsize(tfm);
+ struct blkcipher_desc desc = {
+ .tfm = aeadctx->null,
+ };
int err = 0;
int null = 0;
gfp_t flags = req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL :
@@ -1388,7 +1377,8 @@ static struct sk_buff *create_authenc_wr
reqctx->dst = src;
if (req->src != req->dst) {
- err = chcr_copy_assoc(req, aeadctx);
+ err = crypto_blkcipher_encrypt(&desc, req->dst,
+ req->src, req->assoclen);
if (err)
return ERR_PTR(err);
reqctx->dst = scatterwalk_ffwd(reqctx->dstffwd, req->dst,
@@ -1719,6 +1709,9 @@ static struct sk_buff *create_aead_ccm_w
unsigned int dst_size = 0, kctx_len;
unsigned int sub_type;
unsigned int authsize = crypto_aead_authsize(tfm);
+ struct blkcipher_desc desc = {
+ .tfm = aeadctx->null,
+ };
int err = 0;
gfp_t flags = req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL :
GFP_ATOMIC;
@@ -1734,7 +1727,8 @@ static struct sk_buff *create_aead_ccm_w
reqctx->dst = src;
if (req->src != req->dst) {
- err = chcr_copy_assoc(req, aeadctx);
+ err = crypto_blkcipher_encrypt(&desc, req->dst,
+ req->src, req->assoclen);
if (err) {
pr_err("AAD copy to destination buffer fails\n");
return ERR_PTR(err);
@@ -1749,7 +1743,6 @@ static struct sk_buff *create_aead_ccm_w
goto err;
}
-
if (aead_ccm_validate_input(op_type, req, aeadctx, sub_type))
goto err;
@@ -1821,6 +1814,9 @@ static struct sk_buff *create_gcm_wr(str
unsigned int crypt_len = 0;
unsigned int authsize = crypto_aead_authsize(tfm);
unsigned char hmac_ctrl = get_hmac(authsize);
+ struct blkcipher_desc desc = {
+ .tfm = aeadctx->null,
+ };
int err = 0;
gfp_t flags = req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL :
GFP_ATOMIC;
@@ -1838,7 +1834,8 @@ static struct sk_buff *create_gcm_wr(str
src = scatterwalk_ffwd(reqctx->srcffwd, req->src, req->assoclen);
reqctx->dst = src;
if (req->src != req->dst) {
- err = chcr_copy_assoc(req, aeadctx);
+ err = crypto_blkcipher_encrypt(&desc, req->dst,
+ req->src, req->assoclen);
if (err)
return ERR_PTR(err);
reqctx->dst = scatterwalk_ffwd(reqctx->dstffwd, req->dst,
--- a/drivers/crypto/chelsio/chcr_crypto.h
+++ b/drivers/crypto/chelsio/chcr_crypto.h
@@ -187,7 +187,7 @@ struct __aead_ctx {
struct chcr_aead_ctx {
__be32 key_ctx_hdr;
unsigned int enckey_len;
- struct crypto_skcipher *null;
+ struct crypto_blkcipher *null;
u8 salt[MAX_SALT];
u8 key[CHCR_AES_MAX_KEY_LEN];
u16 hmac_ctrl;