From: Stefan Hellermann <stefan@the2masters.de>
To: Sebastian Siewior <linux-crypto@ml.breakpoint.cc>
Cc: linux-crypto@vger.kernel.org
Subject: Re: [PATCH] [crypto] XTS: use proper alignment.
Date: Sun, 02 Mar 2008 13:04:37 +0100 [thread overview]
Message-ID: <47CA97D5.8090804@the2masters.de> (raw)
In-Reply-To: <20080302112004.GA16659@Chamillionaire.breakpoint.cc>
Sebastian Siewior schrieb:
> The XTS blockmode uses a copy of the IV which is saved on the stack
> and may or may not be properly aligned. If it is not, it will break
> hardware cipher like the geode or padlock.
> This patch moves the copy of IV to the private structre which has the
> same aligment as the underlying cipher.
>
> Signed-off-by: Sebastian Siewior <sebastian@breakpoint.cc>
It works now! Thanks!
But I get much lower speed than with aes-cbc-essiv:sha256.
With xts I get 57MB/s while reading the cryptodev with dd, and >90% sys in top, 0% wait
With cbc-essiv I get about 75MB/s while reading it with dd, 60% sys int top, 30% wait
without cryptodev I get 75MB/s while reading the raw lvm-volume with dd, 40% sys, 50% wait
I do a blockdev --flushbufs beetween each read.
Tested-by: Stefan Hellermann <stefan@the2masters.de>
> ---
> Stefan, please try the following patch, it should fix your xts problem.
>
> crypto/xts.c | 32 +++++++++++++++++---------------
> 1 files changed, 17 insertions(+), 15 deletions(-)
>
> diff --git a/crypto/xts.c b/crypto/xts.c
> index 8eb08bf..4457022 100644
> --- a/crypto/xts.c
> +++ b/crypto/xts.c
> @@ -24,7 +24,17 @@
> #include <crypto/b128ops.h>
> #include <crypto/gf128mul.h>
>
> +struct sinfo {
> + be128 t;
> + struct crypto_tfm *tfm;
> + void (*fn)(struct crypto_tfm *, u8 *, const u8 *);
> +};
> +
> struct priv {
> + /* s.t being the first member in this struct enforces proper alignment
> + * required by the underlying cipher without explicit knowing the it.
> + */
> + struct sinfo s;
> struct crypto_cipher *child;
> struct crypto_cipher *tweak;
> };
> @@ -76,12 +86,6 @@ static int setkey(struct crypto_tfm *parent, const u8 *key,
> return 0;
> }
>
> -struct sinfo {
> - be128 t;
> - struct crypto_tfm *tfm;
> - void (*fn)(struct crypto_tfm *, u8 *, const u8 *);
> -};
> -
> static inline void xts_round(struct sinfo *s, void *dst, const void *src)
> {
> be128_xor(dst, &s->t, src); /* PP <- T xor P */
> @@ -97,13 +101,12 @@ static int crypt(struct blkcipher_desc *d,
> int err;
> unsigned int avail;
> const int bs = crypto_cipher_blocksize(ctx->child);
> - struct sinfo s = {
> - .tfm = crypto_cipher_tfm(ctx->child),
> - .fn = fn
> - };
> - be128 *iv;
> u8 *wsrc;
> u8 *wdst;
> + struct sinfo *s = &ctx->s;
> +
> + s->tfm = crypto_cipher_tfm(ctx->child);
> + s->fn = fn;
>
> err = blkcipher_walk_virt(d, w);
> if (!w->nbytes)
> @@ -115,17 +118,16 @@ static int crypt(struct blkcipher_desc *d,
> wdst = w->dst.virt.addr;
>
> /* calculate first value of T */
> - iv = (be128 *)w->iv;
> - tw(crypto_cipher_tfm(ctx->tweak), (void *)&s.t, w->iv);
> + tw(crypto_cipher_tfm(ctx->tweak), (void *)&s->t, w->iv);
>
> goto first;
>
> for (;;) {
> do {
> - gf128mul_x_ble(&s.t, &s.t);
> + gf128mul_x_ble(&s->t, &s->t);
>
> first:
> - xts_round(&s, wdst, wsrc);
> + xts_round(s, wdst, wsrc);
>
> wsrc += bs;
> wdst += bs;
next prev parent reply other threads:[~2008-03-02 12:04 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-24 11:01 [RFC] padlock aes, unification of setkey() Sebastian Siewior
2008-02-24 11:01 ` [RFC] generic_aes: export generic setkey Sebastian Siewior
2008-03-13 21:40 ` Stefan Hellermann
2008-02-24 11:01 ` [RFC] [crypto] padlock-AES, use generic setkey function Sebastian Siewior
2008-03-13 21:40 ` Stefan Hellermann
2008-03-14 11:44 ` Sebastian Siewior
2008-03-14 12:49 ` Stefan Hellermann
2008-03-14 14:16 ` Sebastian Siewior
2008-04-01 13:25 ` Herbert Xu
2008-02-24 11:54 ` [RFC] padlock aes, unification of setkey() Stefan Hellermann
2008-02-24 12:51 ` Sebastian Siewior
2008-02-24 20:07 ` Via Padlock Bug with LRW/XTS Stefan Hellermann
2008-02-27 8:30 ` Sebastian Siewior
2008-03-02 11:20 ` [PATCH] [crypto] XTS: use proper alignment Sebastian Siewior
2008-03-02 12:04 ` Stefan Hellermann [this message]
2008-03-02 13:22 ` Sebastian Siewior
2008-03-02 13:49 ` Stefan Hellermann
2008-03-02 14:04 ` Stefan Hellermann
-- strict thread matches above, loose matches on Subject: below --
2008-03-02 13:51 [PATCH] fix alignment problem in XTS and LRW blockmode Sebastian Siewior
2008-03-02 11:09 ` [PATCH] [crypto] XTS: use proper alignment Sebastian Siewior
2008-03-05 11:16 ` Herbert Xu
2008-03-05 11:46 ` Sebastian Siewior
2008-03-05 11:52 ` Herbert Xu
2008-03-05 12:01 ` Sebastian Siewior
2008-03-05 14:02 ` Stefan Hellermann
2008-03-05 16:37 ` Sebastian Siewior
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=47CA97D5.8090804@the2masters.de \
--to=stefan@the2masters.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.