Commit 8356ea51 authored by Harsh Jain's avatar Harsh Jain Committed by Herbert Xu

crypto: chcr - Use cipher instead of Block Cipher in gcm setkey

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: default avatarHarsh Jain <harsh@chelsio.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent ee3bd84f
...@@ -2189,8 +2189,7 @@ static int chcr_gcm_setkey(struct crypto_aead *aead, const u8 *key, ...@@ -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_context *ctx = crypto_aead_ctx(aead);
struct chcr_aead_ctx *aeadctx = AEAD_CTX(ctx); struct chcr_aead_ctx *aeadctx = AEAD_CTX(ctx);
struct chcr_gcm_ctx *gctx = GCM_CTX(aeadctx); struct chcr_gcm_ctx *gctx = GCM_CTX(aeadctx);
struct blkcipher_desc h_desc; struct crypto_cipher *cipher;
struct scatterlist src[1];
unsigned int ck_size; unsigned int ck_size;
int ret = 0, key_ctx_size = 0; int ret = 0, key_ctx_size = 0;
...@@ -2223,27 +2222,26 @@ static int chcr_gcm_setkey(struct crypto_aead *aead, const u8 *key, ...@@ -2223,27 +2222,26 @@ static int chcr_gcm_setkey(struct crypto_aead *aead, const u8 *key,
CHCR_KEYCTX_MAC_KEY_SIZE_128, CHCR_KEYCTX_MAC_KEY_SIZE_128,
0, 0, 0, 0,
key_ctx_size >> 4); key_ctx_size >> 4);
/* Calculate the H = CIPH(K, 0 repeated 16 times) using sync aes /* Calculate the H = CIPH(K, 0 repeated 16 times).
* blkcipher It will go on key context * It will go in key context
*/ */
h_desc.tfm = crypto_alloc_blkcipher("cbc(aes-generic)", 0, 0); cipher = crypto_alloc_cipher("aes-generic", 0, 0);
if (IS_ERR(h_desc.tfm)) { if (IS_ERR(cipher)) {
aeadctx->enckey_len = 0; aeadctx->enckey_len = 0;
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
h_desc.flags = 0;
ret = crypto_blkcipher_setkey(h_desc.tfm, key, keylen); ret = crypto_cipher_setkey(cipher, key, keylen);
if (ret) { if (ret) {
aeadctx->enckey_len = 0; aeadctx->enckey_len = 0;
goto out1; goto out1;
} }
memset(gctx->ghash_h, 0, AEAD_H_SIZE); memset(gctx->ghash_h, 0, AEAD_H_SIZE);
sg_init_one(&src[0], gctx->ghash_h, AEAD_H_SIZE); crypto_cipher_encrypt_one(cipher, gctx->ghash_h, gctx->ghash_h);
ret = crypto_blkcipher_encrypt(&h_desc, &src[0], &src[0], AEAD_H_SIZE);
out1: out1:
crypto_free_blkcipher(h_desc.tfm); crypto_free_cipher(cipher);
out: out:
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment