[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-crypto-vger
Subject:    Re: [PATCH 11/11] [CRYPTO] authenc: Add givcrypt operation
From:       Herbert Xu <herbert () gondor ! apana ! org ! au>
Date:       2007-11-23 11:24:43
Message-ID: 20071123112443.GA19048 () gondor ! apana ! org ! au
[Download RAW message or body]

On Thu, Nov 22, 2007 at 04:49:14PM +0800, Herbert Xu wrote:
> [CRYPTO] authenc: Add givcrypt operation
> 
> This patch implements the givcrypt function for authenc.  It simply
> calls the givcrypt operation on the underlying cipher instead of encrypt.
> 
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Another bug.  I forgot to set giv in the sub-request.

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
3ac5d3dc0fb6039b2ba8e5938ad49bf531a5649b
diff --git a/crypto/authenc.c b/crypto/authenc.c
index bc4e608..7bbdbbe 100644
--- a/crypto/authenc.c
+++ b/crypto/authenc.c
@@ -144,6 +144,27 @@ static int crypto_authenc_encrypt(struct aead_request *req)
 	return crypto_authenc_hash(req);
 }
 
+static int crypto_authenc_givcrypt(struct aead_request *req)
+{
+	struct crypto_aead *authenc = crypto_aead_reqtfm(req);
+	struct crypto_authenc_ctx *ctx = crypto_aead_ctx(authenc);
+	struct ablkcipher_request *abreq = aead_request_ctx(req);
+	int err;
+
+	ablkcipher_request_set_tfm(abreq, ctx->enc);
+	ablkcipher_request_set_callback(abreq, aead_request_flags(req),
+					crypto_authenc_encrypt_done, req);
+	ablkcipher_request_set_crypt(abreq, req->src, req->dst, req->cryptlen,
+				     req->iv);
+	ablkcipher_request_set_giv(abreq, req->giv, req->seq);
+
+	err = crypto_ablkcipher_givcrypt(abreq);
+	if (err)
+		return err;
+
+	return crypto_authenc_hash(req);
+}
+
 static int crypto_authenc_verify(struct aead_request *req)
 {
 	struct crypto_aead *authenc = crypto_aead_reqtfm(req);
@@ -346,6 +367,7 @@ static struct crypto_instance *crypto_authenc_alloc(struct rtattr **tb)
 
 	inst->alg.cra_aead.setkey = crypto_authenc_setkey;
 	inst->alg.cra_aead.encrypt = crypto_authenc_encrypt;
+	inst->alg.cra_aead.givcrypt = crypto_authenc_givcrypt;
 	inst->alg.cra_aead.decrypt = crypto_authenc_decrypt;
 
 out:
-
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic