All of lore.kernel.org
 help / color / mirror / Atom feed
From: Harsh Jain <harsh@chelsio.com>
To: herbert@gondor.apana.org.au, linux-crypto@vger.kernel.org,
	hariprasad@chelsio.com, netdev@vger.kernel.org,
	arjun@chelsio.com, atul.gupta@chelsio.com
Cc: Harsh Jain <harsh@chelsio.com>
Subject: [PATCH 4/8] crypto:chcr- Use cipher instead of Block Cipher in gcm setkey
Date: Fri, 27 Jan 2017 16:09:08 +0530	[thread overview]
Message-ID: <7e30d6dd45bb5605b077127acd2f5fb0487697e3.1485501429.git.harsh@chelsio.com> (raw)
In-Reply-To: <cover.1485501428.git.harsh@chelsio.com>
In-Reply-To: <cover.1485501428.git.harsh@chelsio.com>

1 Block of encrption can be done with aes-generic. no need of
cbc(aes). This patch replaces cbc(aes-generic) with aes-generic.

Signed-off-by: Harsh Jain <harsh@chelsio.com>
---
 drivers/crypto/chelsio/chcr_algo.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c
index 6c2dea3..d335943 100644
--- a/drivers/crypto/chelsio/chcr_algo.c
+++ b/drivers/crypto/chelsio/chcr_algo.c
@@ -2189,8 +2189,7 @@ static int chcr_gcm_setkey(struct crypto_aead *aead, const u8 *key,
 	struct chcr_context *ctx = crypto_aead_ctx(aead);
 	struct chcr_aead_ctx *aeadctx = AEAD_CTX(ctx);
 	struct chcr_gcm_ctx *gctx = GCM_CTX(aeadctx);
-	struct blkcipher_desc h_desc;
-	struct scatterlist src[1];
+	struct crypto_cipher *cipher;
 	unsigned int ck_size;
 	int ret = 0, key_ctx_size = 0;
 
@@ -2223,27 +2222,26 @@ static int chcr_gcm_setkey(struct crypto_aead *aead, const u8 *key,
 						CHCR_KEYCTX_MAC_KEY_SIZE_128,
 						0, 0,
 						key_ctx_size >> 4);
-	/* Calculate the H = CIPH(K, 0 repeated 16 times) using sync aes
-	 * blkcipher It will go on key context
+	/* Calculate the H = CIPH(K, 0 repeated 16 times).
+	 * It will go in key context
 	 */
-	h_desc.tfm = crypto_alloc_blkcipher("cbc(aes-generic)", 0, 0);
-	if (IS_ERR(h_desc.tfm)) {
+	cipher = crypto_alloc_cipher("aes-generic", 0, 0);
+	if (IS_ERR(cipher)) {
 		aeadctx->enckey_len = 0;
 		ret = -ENOMEM;
 		goto out;
 	}
-	h_desc.flags = 0;
-	ret = crypto_blkcipher_setkey(h_desc.tfm, key, keylen);
+
+	ret = crypto_cipher_setkey(cipher, key, keylen);
 	if (ret) {
 		aeadctx->enckey_len = 0;
 		goto out1;
 	}
 	memset(gctx->ghash_h, 0, AEAD_H_SIZE);
-	sg_init_one(&src[0], gctx->ghash_h, AEAD_H_SIZE);
-	ret = crypto_blkcipher_encrypt(&h_desc, &src[0], &src[0], AEAD_H_SIZE);
+	crypto_cipher_encrypt_one(cipher, gctx->ghash_h, gctx->ghash_h);
 
 out1:
-	crypto_free_blkcipher(h_desc.tfm);
+	crypto_free_cipher(cipher);
 out:
 	return ret;
 }
-- 
1.8.2.3

  parent reply	other threads:[~2017-01-27 10:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-27 10:39 [PATCH 0/8] Bug fixes Harsh Jain
2017-01-27 10:39 ` [PATCH 1/8] crypto:chcr-Change flow IDs Harsh Jain
2017-01-27 10:39 ` [PATCH 2/8] crypto:chcr- Fix key length for RFC4106 Harsh Jain
2017-01-27 10:39 ` [PATCH 3/8] crypto:chcr-fix itnull.cocci warnings Harsh Jain
2017-01-27 10:39 ` Harsh Jain [this message]
2017-01-27 10:39 ` [PATCH 5/8] crypto:chcr: Change cra_flags for cipher algos Harsh Jain
2017-03-08  9:58   ` Harsh Jain
2017-03-08 10:21     ` Herbert Xu
2017-01-27 10:39 ` [PATCH 6/8] crypto:chcr- Change algo priority Harsh Jain
2017-01-27 10:39 ` [PATCH 7/8] crypto:chcr- Fix wrong typecasting Harsh Jain
2017-01-27 10:39 ` [PATCH 8/8] crypto:chcr-Fix Smatch Complaint Harsh Jain
2017-02-03 10:21 ` [PATCH 0/8] Bug fixes Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7e30d6dd45bb5605b077127acd2f5fb0487697e3.1485501429.git.harsh@chelsio.com \
    --to=harsh@chelsio.com \
    --cc=arjun@chelsio.com \
    --cc=atul.gupta@chelsio.com \
    --cc=hariprasad@chelsio.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.