From: Tim Chen <tim.c.chen@linux.intel.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
"David S.Miller" <davem@davemloft.net>,
Stephan Mueller <smueller@chronox.de>,
Chandramouli Narayanan <mouli_7982@yahoo.com>,
Vinodh Gopal <vinodh.gopal@intel.com>,
James Guilford <james.guilford@intel.com>,
Wajdi Feghali <wajdi.k.feghali@intel.com>,
Jussi Kivilinna <jussi.kivilinna@iki.fi>,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 5/5] crypto: AES CBC multi-buffer glue code
Date: Wed, 09 Dec 2015 09:23:14 -0800 [thread overview]
Message-ID: <1449681794.22260.58.camel@schen9-desk2.jf.intel.com> (raw)
In-Reply-To: <20151209025242.GA24861@gondor.apana.org.au>
On Wed, 2015-12-09 at 10:52 +0800, Herbert Xu wrote:
> On Wed, Dec 02, 2015 at 12:02:45PM -0800, Tim Chen wrote:
> >
> > +/*
> > + * CRYPTO_ALG_ASYNC flag is passed to indicate we have an ablk
> > + * scatter-gather walk.
> > + */
> > +
> > +static struct crypto_alg aes_cbc_mb_alg = {
> > + .cra_name = "__cbc-aes-aesni-mb",
> > + .cra_driver_name = "__driver-cbc-aes-aesni-mb",
> > + .cra_priority = 100,
> > + .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_ASYNC
> > + | CRYPTO_ALG_INTERNAL,
> > + .cra_blocksize = AES_BLOCK_SIZE,
> > + .cra_ctxsize = sizeof(struct crypto_aes_ctx) +
> > + AESNI_ALIGN - 1,
> > + .cra_alignmask = 0,
> > + .cra_type = &crypto_blkcipher_type,
> > + .cra_module = THIS_MODULE,
> > + .cra_list = LIST_HEAD_INIT(aes_cbc_mb_alg.cra_list),
> > + .cra_u = {
> > + .blkcipher = {
> > + .min_keysize = AES_MIN_KEY_SIZE,
> > + .max_keysize = AES_MAX_KEY_SIZE,
> > + .ivsize = AES_BLOCK_SIZE,
> > + .setkey = aes_set_key,
> > + .encrypt = mb_aes_cbc_encrypt,
> > + .decrypt = mb_aes_cbc_decrypt
> > + },
> > + },
> > +};
>
> So why do we still need this? Shouldn't a single ablkcipher cover
> all the cases?
>
> Thanks,
This is an internal algorithm. We are indeed casting the request
to the outer ablkcipher request when we do the async cipher walk.
See
static int mb_aes_cbc_decrypt(struct blkcipher_desc *desc,
struct scatterlist *dst, struct scatterlist *src,
unsigned int nbytes)
{
struct crypto_aes_ctx *aesni_ctx;
struct mcryptd_blkcipher_request_ctx *rctx =
container_of(desc, struct mcryptd_blkcipher_request_ctx, desc);
struct ablkcipher_request *req;
bool is_mcryptd_req;
unsigned long src_paddr;
unsigned long dst_paddr;
int err;
/* note here whether it is mcryptd req */
is_mcryptd_req = desc->flags & CRYPTO_TFM_REQ_MAY_SLEEP;
req = cast_mcryptd_ctx_to_req(rctx);
aesni_ctx = aes_ctx(crypto_blkcipher_ctx(desc->tfm));
ablkcipher_walk_init(&rctx->walk, dst, src, nbytes);
err = ablkcipher_walk_phys(req, &rctx->walk);
if (err || !rctx->walk.nbytes)
goto done1;
desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
kernel_fpu_begin();
while ((nbytes = rctx->walk.nbytes)) {
src_paddr = (page_to_phys(rctx->walk.src.page) + rctx->walk.src.offset);
dst_paddr = (page_to_phys(rctx->walk.dst.page) + rctx->walk.dst.offset);
aesni_cbc_dec(aesni_ctx, phys_to_virt(dst_paddr), phys_to_virt(src_paddr),
rctx->walk.nbytes & AES_BLOCK_MASK, rctx->walk.iv);
nbytes &= AES_BLOCK_SIZE - 1;
err = ablkcipher_walk_done(req, &rctx->walk, nbytes);
if (err)
goto done2;
}
done2:
kernel_fpu_end();
done1:
ablkcipher_walk_complete(&rctx->walk);
Thanks.
Tim
next prev parent reply other threads:[~2015-12-09 17:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1449091633.git.tim.c.chen@linux.intel.com>
2015-12-02 20:01 ` [PATCH v4 0/5] crypto: x86 AES-CBC encryption with multibuffer Tim Chen
2015-12-02 20:02 ` [PATCH v4 1/5] crypto: Multi-buffer encryption infrastructure support Tim Chen
2015-12-02 20:02 ` [PATCH v4 2/5] crypto: AES CBC multi-buffer data structures Tim Chen
2015-12-02 20:02 ` [PATCH v4 3/5] crypto: AES CBC multi-buffer scheduler Tim Chen
2015-12-02 20:02 ` [PATCH v4 4/5] crypto: AES CBC by8 encryption Tim Chen
2015-12-02 20:02 ` [PATCH v4 5/5] crypto: AES CBC multi-buffer glue code Tim Chen
2015-12-09 2:52 ` Herbert Xu
2015-12-09 17:23 ` Tim Chen [this message]
2015-12-10 1:45 ` Herbert Xu
2015-12-10 16:39 ` Tim Chen
2015-12-11 3:23 ` Herbert Xu
2015-12-11 16:54 ` Tim Chen
2015-12-12 5:48 ` Herbert Xu
2015-12-15 18:36 ` Tim Chen
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=1449681794.22260.58.camel@schen9-desk2.jf.intel.com \
--to=tim.c.chen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=hpa@zytor.com \
--cc=james.guilford@intel.com \
--cc=jussi.kivilinna@iki.fi \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mouli_7982@yahoo.com \
--cc=smueller@chronox.de \
--cc=vinodh.gopal@intel.com \
--cc=wajdi.k.feghali@intel.com \
/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®