From: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org,
Sebastian Siewior <linux-crypto@ml.breakpoint.cc>
Subject: Re: [1/1 take 2] HIFN 795x driver.
Date: Thu, 4 Oct 2007 19:04:53 +0400 [thread overview]
Message-ID: <20071004150453.GA16027@2ka.mipt.ru> (raw)
In-Reply-To: <20071004100414.GA24602@gondor.apana.org.au>
Hi.
On Thu, Oct 04, 2007 at 06:04:14PM +0800, Herbert Xu (herbert@gondor.apana.org.au) wrote:
> But we still need to fix the partial block case.
Just a note: blkcipher_walk_* was not designed for async hardware, since
there is no way to know in advance how many pages will be required for
single request. For example DES second multipage test says it has three
pages, but actually it will have 4 requests and thus 4 DMA
descriptors in HIFN, but when new interrupt says about completed
descriptor, it can not know if it is the last descriptor or not, so that
callback for request should or should not be called. I've fixed that
with additional atomic ops...
Given that, new driver passes all except one DES tcrypt tests, it fails
on cbc multipage encryption (decryption works ok), which provides 13
bytes of misaligned data.
Here is a code snippet for current driver (error handling was ommitted):
blkcipher_walk_init(&walk, req->dst, req->src, nbytes);
err = blkcipher_walk_phys(&desc, &walk);
while ((nbytes = walk.nbytes)) {
spage = walk.src.phys.page;
soff = walk.src.phys.offset;
dpage = walk.dst.phys.page;
doff = walk.dst.phys.offset;
ctx->iv = walk.iv;
++i;
spin_lock_irqsave(&dev->lock, flags);
err = hifn_setup_dma(dev, spage, soff, dpage, doff, nbytes,
req, ctx);
spin_unlock_irqrestore(&dev->lock, flags);
nbytes &= blocksize - 1;
err = blkcipher_walk_done(&desc, &walk, nbytes);
}
And debug output:
Testing cbc(des) encryption across pages (chunking)
test 1 (64 bit key):
hifn0: spage: ffff81003fe8f1e8, soffset: 0, dpage: ffff81003fe8f1e8, doffset: 0, nbytes: 13, priv: ffff81003dc74138, ctx: ffff81003a9d7210.
hifn0: spage: ffff81003fe8f1e8, soffset: 8, dpage: ffff81003fe8f1e8, doffset: 0, nbytes: 8, priv: ffff81003dc74138, ctx: ffff81003a9d7210.
hifn0: spage: ffff81003fe8f1e8, soffset: 0, dpage: ffff81003fe8f1e8, doffset: 0, nbytes: 8, priv: ffff81003dc74138, ctx: ffff81003a9d7210.
page 0
ccd173ffab2039f47f81654121
fail
page 1
dbd4cf266da007deeadb88
fail
And actually there is a huge problem with blkcipher_walk* interface - it
always provides the same destination buffer, so it is possible to
overwrite it if second crypto block was encrypted before the first one.
It just can not be used in asynchronous hardware, so I will create
soemthing new for HIFN driver specially.
--
Evgeniy Polyakov
next prev parent reply other threads:[~2007-10-04 15:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-02 15:00 [1/1 take 2] HIFN 795x driver Evgeniy Polyakov
2007-10-02 19:05 ` Sebastian Siewior
2007-10-03 8:41 ` Evgeniy Polyakov
2007-10-03 11:54 ` Herbert Xu
2007-10-03 12:05 ` Evgeniy Polyakov
2007-10-04 5:49 ` Herbert Xu
2007-10-04 9:22 ` Evgeniy Polyakov
2007-10-04 10:04 ` Herbert Xu
2007-10-04 15:04 ` Evgeniy Polyakov [this message]
2007-10-05 8:18 ` Herbert Xu
2007-10-06 21:58 ` Sebastian Siewior
2007-10-08 3:15 ` Herbert Xu
2007-10-08 15:49 ` Sebastian Siewior
2007-10-08 16:07 ` 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=20071004150453.GA16027@2ka.mipt.ru \
--to=johnpol@2ka.mipt.ru \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@ml.breakpoint.cc \
--cc=linux-crypto@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