From: "Stephan Müller" <smueller@chronox.de>
To: Eric Biggers <ebiggers3@gmail.com>
Cc: linux-crypto@vger.kernel.org,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S . Miller" <davem@davemloft.net>,
Eric Biggers <ebiggers@google.com>
Subject: Re: [PATCH 1/3] crypto: salsa20-generic - cleanup and convert to skcipher API
Date: Mon, 01 Jan 2018 15:04:47 +0100 [thread overview]
Message-ID: <1634837.0VVt3iBXeX@positron.chronox.de> (raw)
In-Reply-To: <20171231234642.22621-2-ebiggers3@gmail.com>
Am Montag, 1. Januar 2018, 00:46:40 CET schrieb Eric Biggers:
Hi Eric,
>
> -static void salsa20_wordtobyte(u8 output[64], const u32 input[16])
> +static void salsa20_block(u32 *state, u32 *stream)
Shouldn't stream be __le32? This could get rid of the type casting further
down.
> {
> u32 x[16];
> int i;
>
> - memcpy(x, input, sizeof(x));
> - for (i = 20; i > 0; i -= 2) {
> + memcpy(x, state, sizeof(x));
> +
> + for (i = 0; i < 20; i += 2) {
> x[ 4] ^= rol32((x[ 0] + x[12]), 7);
> x[ 8] ^= rol32((x[ 4] + x[ 0]), 9);
> x[12] ^= rol32((x[ 8] + x[ 4]), 13);
> @@ -95,145 +73,135 @@ static void salsa20_wordtobyte(u8 output[64], const
> u32 input[16]) x[14] ^= rol32((x[13] + x[12]), 13);
> x[15] ^= rol32((x[14] + x[13]), 18);
> }
> - for (i = 0; i < 16; ++i)
> - x[i] += input[i];
> - for (i = 0; i < 16; ++i)
> - U32TO8_LITTLE(output + 4 * i,x[i]);
> -}
>
> -static const char sigma[16] = "expand 32-byte k";
> -static const char tau[16] = "expand 16-byte k";
> + for (i = 0; i < 16; i++)
> + stream[i] = (__force u32)cpu_to_le32(x[i] + state[i]);
> +
> + if (++state[8] == 0)
> + state[9]++;
> +}
>
> -static void salsa20_keysetup(struct salsa20_ctx *ctx, const u8 *k, u32
> kbytes) +static void salsa20_docrypt(u32 *state, u8 *dst, const u8 *src,
> + unsigned int bytes)
> {
> - const char *constants;
> + u32 stream[SALSA20_BLOCK_SIZE / sizeof(u32)];
dto, __le32?
Ciao
Stephan
next prev parent reply other threads:[~2018-01-01 14:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-31 23:46 [PATCH 0/3] crypto: salsa20 - cleanup and convert to skcipher API Eric Biggers
2017-12-31 23:46 ` [PATCH 1/3] crypto: salsa20-generic " Eric Biggers
2018-01-01 14:04 ` Stephan Müller [this message]
2017-12-31 23:46 ` [PATCH 2/3] crypto: salsa20 - export generic helpers Eric Biggers
2017-12-31 23:46 ` [PATCH 3/3] crypto: x86/salsa20 - cleanup and convert to skcipher API Eric Biggers
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=1634837.0VVt3iBXeX@positron.chronox.de \
--to=smueller@chronox.de \
--cc=davem@davemloft.net \
--cc=ebiggers3@gmail.com \
--cc=ebiggers@google.com \
--cc=herbert@gondor.apana.org.au \
--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;
as well as URLs for NNTP newsgroup(s).