From: Adrian-Ken Rueegsegger <ken@codelabs.ch>
To: herbert@gondor.apana.org.au
Cc: linux-crypto@vger.kernel.org, steffen.klassert@secunet.com,
Adrian-Ken Rueegsegger <ken@codelabs.ch>
Subject: [PATCH 1/4 v2] crypto: sha512 - Remove W (message schedule) from struct sha512_ctx
Date: Thu, 4 Dec 2008 10:32:07 +0100 [thread overview]
Message-ID: <12283831303264-git-send-email-ken@codelabs.ch> (raw)
In-Reply-To: <12283831302697-git-send-email-ken@codelabs.ch>
The message schedule W[80] is calculated anew when sha512_transform
is executed. Therefore it is local to that function and does not need
to be defined in struct sha512_ctx.
Note: the sha256 algorithm already does it this way.
Signed-off-by: Adrian-Ken Rueegsegger <ken@codelabs.ch>
---
crypto/sha512_generic.c | 13 +++++--------
1 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/crypto/sha512_generic.c b/crypto/sha512_generic.c
index bc36861..e0b0303 100644
--- a/crypto/sha512_generic.c
+++ b/crypto/sha512_generic.c
@@ -25,7 +25,6 @@ struct sha512_ctx {
u64 state[8];
u32 count[4];
u8 buf[128];
- u64 W[80];
};
static inline u64 Ch(u64 x, u64 y, u64 z)
@@ -89,10 +88,10 @@ static inline void BLEND_OP(int I, u64 *W)
}
static void
-sha512_transform(u64 *state, u64 *W, const u8 *input)
+sha512_transform(u64 *state, const u8 *input)
{
u64 a, b, c, d, e, f, g, h, t1, t2;
-
+ u64 W[80];
int i;
/* load the input */
@@ -132,6 +131,7 @@ sha512_transform(u64 *state, u64 *W, const u8 *input)
/* erase our data */
a = b = c = d = e = f = g = h = t1 = t2 = 0;
+ memset(W, 0, 80 * sizeof(u64));
}
static void
@@ -187,10 +187,10 @@ sha512_update(struct crypto_tfm *tfm, const u8 *data, unsigned int len)
/* Transform as many times as possible. */
if (len >= part_len) {
memcpy(&sctx->buf[index], data, part_len);
- sha512_transform(sctx->state, sctx->W, sctx->buf);
+ sha512_transform(sctx->state, sctx->buf);
for (i = part_len; i + 127 < len; i+=128)
- sha512_transform(sctx->state, sctx->W, &data[i]);
+ sha512_transform(sctx->state, &data[i]);
index = 0;
} else {
@@ -199,9 +199,6 @@ sha512_update(struct crypto_tfm *tfm, const u8 *data, unsigned int len)
/* Buffer remaining input */
memcpy(&sctx->buf[index], &data[i], len - i);
next prev parent reply other threads:[~2008-12-04 9:32 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-04 9:32 [PATCH 0/4 v2] Switch remaining algorithms to shash Adrian-Ken Rueegsegger
2008-12-04 9:32 ` Adrian-Ken Rueegsegger [this message]
2008-12-04 9:32 ` [PATCH 2/4 v2] crypto: sha512 - Switch " Adrian-Ken Rueegsegger
2008-12-04 9:32 ` [PATCH 3/4 v2] crypto: wp512 " Adrian-Ken Rueegsegger
2008-12-04 9:32 ` [PATCH 4/4 v2] crypto: michael_mic " Adrian-Ken Rueegsegger
2008-12-04 10:05 ` [PATCH 1/4 v2] crypto: sha512 - Remove W (message schedule) from struct sha512_ctx Herbert Xu
2008-12-04 10:51 ` Adrian-Ken Rueegsegger
2008-12-04 22:43 ` [PATCH 0/4 v3] Switch remaining algorithms to shash Adrian-Ken Rueegsegger
2008-12-04 22:43 ` [PATCH 1/4 v3] crypto: sha512 - Move message schedule W[80] to static percpu area Adrian-Ken Rueegsegger
2008-12-04 22:43 ` [PATCH 2/4 v3] crypto: sha512 - Switch to shash Adrian-Ken Rueegsegger
2008-12-04 22:43 ` [PATCH 3/4 v3] crypto: wp512 " Adrian-Ken Rueegsegger
2008-12-04 22:43 ` [PATCH 4/4 v3] crypto: michael_mic " Adrian-Ken Rueegsegger
2008-12-05 0:29 ` [PATCH 0/1] Resend correct sha512 shash patch Adrian-Ken Rueegsegger
2008-12-05 0:29 ` [PATCH] crypto: sha512 - Switch to shash Adrian-Ken Rueegsegger
2008-12-07 11:33 ` [PATCH 1/4 v3] crypto: sha512 - Move message schedule W[80] to static percpu area Herbert Xu
2008-12-07 22:17 ` [PATCH 0/2 v4] Switch remaining algorithms to shash Adrian-Ken Rueegsegger
2008-12-07 22:17 ` [PATCH 1/2 v4] crypto: sha512 - Move message schedule W[80] to static percpu area Adrian-Ken Rueegsegger
2008-12-07 22:17 ` [PATCH 2/2 v4] crypto: sha512 - Switch to shash Adrian-Ken Rueegsegger
2008-12-08 0:09 ` [PATCH 1/2 v4] crypto: sha512 - Move message schedule W[80] to static percpu area Evgeniy Polyakov
2008-12-08 0:24 ` Herbert Xu
2008-12-08 0:33 ` Evgeniy Polyakov
2008-12-17 5:49 ` [PATCH 0/2 v4] Switch remaining algorithms to shash Herbert Xu
2008-12-07 11:36 ` [PATCH 0/4 v3] " 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=12283831303264-git-send-email-ken@codelabs.ch \
--to=ken@codelabs.ch \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=steffen.klassert@secunet.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;
as well as URLs for NNTP newsgroup(s).