mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Huang Ying <ying.huang@intel.com>
To: Herbert Xu <herbert@gondor.apana.org.au>,
	Sebastian Siewior <linux-crypto@ml.breakpoint.cc>
Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org
Subject: [RFC PATCH crypto 3/4] AES-NI: Make it possible to use blkcipher_walk for ablkcipher algorithm
Date: Mon, 05 Jan 2009 10:02:21 +0800	[thread overview]
Message-ID: <1231120941.5937.30.camel@yhuang-dev.sh.intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1789 bytes --]

Current blkcipher_walk can be used for ablkcipher crypto_tfm +
blkcipher crypto_alg. This patch make it possible to use
blkcipher_walk for ablkcipher algorithm. The only field in
cra_blkcipher used is ivsize, which is wrapped in a function to
support both cra_blkcipher and cra_ablkcipher.

Signed-off-by: Huang Ying <ying.huang@intel.com>

---
 crypto/blkcipher.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

--- a/crypto/blkcipher.c
+++ b/crypto/blkcipher.c
@@ -68,6 +68,16 @@ static inline u8 *blkcipher_get_spot(u8 
 	return max(start, end_page);
 }
 
+static inline unsigned int blkcipher_walk_ivsize(struct crypto_blkcipher *tfm)
+{
+	struct crypto_tfm *tfm_base = crypto_blkcipher_tfm(tfm);
+
+	if (crypto_tfm_alg_type(tfm_base) == CRYPTO_ALG_TYPE_ABLKCIPHER)
+		return tfm_base->__crt_alg->cra_ablkcipher.ivsize;
+	else
+		return crypto_blkcipher_ivsize(tfm);
+}
+
 static inline unsigned int blkcipher_done_slow(struct crypto_blkcipher *tfm,
 					       struct blkcipher_walk *walk,
 					       unsigned int bsize)
@@ -134,7 +144,7 @@ int blkcipher_walk_done(struct blkcipher
 
 err:
 	if (walk->iv != desc->info)
-		memcpy(desc->info, walk->iv, crypto_blkcipher_ivsize(tfm));
+		memcpy(desc->info, walk->iv, blkcipher_walk_ivsize(tfm));
 	if (walk->buffer != walk->page)
 		kfree(walk->buffer);
 	if (walk->page)
@@ -280,7 +290,7 @@ static inline int blkcipher_copy_iv(stru
 				    unsigned int alignmask)
 {
 	unsigned bs = walk->blocksize;
-	unsigned int ivsize = crypto_blkcipher_ivsize(tfm);
+	unsigned int ivsize = blkcipher_walk_ivsize(tfm);
 	unsigned aligned_bs = ALIGN(bs, alignmask + 1);
 	unsigned int size = aligned_bs * 2 + ivsize + max(aligned_bs, ivsize) -
 			    (alignmask + 1);


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

                 reply	other threads:[~2009-01-05  2:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1231120941.5937.30.camel@yhuang-dev.sh.intel.com \
    --to=ying.huang@intel.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@ml.breakpoint.cc \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®