aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2008-06-02 07:30:38 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2008-07-10 08:35:15 -0400
commit5cdcc22f25b0766fe16d5dd8e3b2efc91fa4da6e (patch)
tree90078f745a3cf28efdc32db030c3505e06c3c74a /crypto
parent0936a944068ef68f8b19f437e03f4654c29f2423 (diff)
[CRYPTO] rmd: Use pointer form of endian swapping operations
This patch converts the relevant code in the rmd implementations to use the pointer form of the endian swapping operations. This allows certain architectures to generate more optimised code. For example, on sparc64 this more than halves the CPU cycles on a typical hashing operation. Based on a patch by David Miller. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/rmd128.c4
-rw-r--r--crypto/rmd160.c4
-rw-r--r--crypto/rmd256.c4
-rw-r--r--crypto/rmd320.c4
4 files changed, 8 insertions, 8 deletions
diff --git a/crypto/rmd128.c b/crypto/rmd128.c
index 89a535aa6eb8..1a481df66913 100644
--- a/crypto/rmd128.c
+++ b/crypto/rmd128.c
@@ -44,7 +44,7 @@ struct rmd128_ctx {
44#define F4(x, y, z) (y ^ (z & (x ^ y))) /* z ? x : y */ 44#define F4(x, y, z) (y ^ (z & (x ^ y))) /* z ? x : y */
45 45
46#define ROUND(a, b, c, d, f, k, x, s) { \ 46#define ROUND(a, b, c, d, f, k, x, s) { \
47 (a) += f((b), (c), (d)) + le32_to_cpu(x) + (k); \ 47 (a) += f((b), (c), (d)) + le32_to_cpup(&(x)) + (k); \
48 (a) = rol32((a), (s)); \ 48 (a) = rol32((a), (s)); \
49} 49}
50 50
@@ -285,7 +285,7 @@ static void rmd128_final(struct crypto_tfm *tfm, u8 *out)
285 285
286 /* Store state in digest */ 286 /* Store state in digest */
287 for (i = 0; i < 4; i++) 287 for (i = 0; i < 4; i++)
288 dst[i] = cpu_to_le32(rctx->state[i]); 288 dst[i] = cpu_to_le32p(&rctx->state[i]);
289 289
290 /* Wipe context */ 290 /* Wipe context */
291 memset(rctx, 0, sizeof(*rctx)); 291 memset(rctx, 0, sizeof(*rctx));
diff --git a/crypto/rmd160.c b/crypto/rmd160.c
index 136e31f56d53..e9fd5f6a0acb 100644
--- a/crypto/rmd160.c
+++ b/crypto/rmd160.c
@@ -47,7 +47,7 @@ struct rmd160_ctx {
47#define F5(x, y, z) (x ^ (y | ~z)) 47#define F5(x, y, z) (x ^ (y | ~z))
48 48
49#define ROUND(a, b, c, d, e, f, k, x, s) { \ 49#define ROUND(a, b, c, d, e, f, k, x, s) { \
50 (a) += f((b), (c), (d)) + le32_to_cpu(x) + (k); \ 50 (a) += f((b), (c), (d)) + le32_to_cpup(&(x)) + (k); \
51 (a) = rol32((a), (s)) + (e); \ 51 (a) = rol32((a), (s)) + (e); \
52 (c) = rol32((c), 10); \ 52 (c) = rol32((c), 10); \
53} 53}
@@ -329,7 +329,7 @@ static void rmd160_final(struct crypto_tfm *tfm, u8 *out)
329 329
330 /* Store state in digest */ 330 /* Store state in digest */
331 for (i = 0; i < 5; i++) 331 for (i = 0; i < 5; i++)
332 dst[i] = cpu_to_le32(rctx->state[i]); 332 dst[i] = cpu_to_le32p(&rctx->state[i]);
333 333
334 /* Wipe context */ 334 /* Wipe context */
335 memset(rctx, 0, sizeof(*rctx)); 335 memset(rctx, 0, sizeof(*rctx));
diff --git a/crypto/rmd256.c b/crypto/rmd256.c
index 88f2203751ae..b08852690706 100644
--- a/crypto/rmd256.c
+++ b/crypto/rmd256.c
@@ -44,7 +44,7 @@ struct rmd256_ctx {
44#define F4(x, y, z) (y ^ (z & (x ^ y))) /* z ? x : y */ 44#define F4(x, y, z) (y ^ (z & (x ^ y))) /* z ? x : y */
45 45
46#define ROUND(a, b, c, d, f, k, x, s) { \ 46#define ROUND(a, b, c, d, f, k, x, s) { \
47 (a) += f((b), (c), (d)) + le32_to_cpu(x) + (k); \ 47 (a) += f((b), (c), (d)) + le32_to_cpup(&(x)) + (k); \
48 (a) = rol32((a), (s)); \ 48 (a) = rol32((a), (s)); \
49} 49}
50 50
@@ -304,7 +304,7 @@ static void rmd256_final(struct crypto_tfm *tfm, u8 *out)
304 304
305 /* Store state in digest */ 305 /* Store state in digest */
306 for (i = 0; i < 8; i++) 306 for (i = 0; i < 8; i++)
307 dst[i] = cpu_to_le32(rctx->state[i]); 307 dst[i] = cpu_to_le32p(&rctx->state[i]);
308 308
309 /* Wipe context */ 309 /* Wipe context */
310 memset(rctx, 0, sizeof(*rctx)); 310 memset(rctx, 0, sizeof(*rctx));
diff --git a/crypto/rmd320.c b/crypto/rmd320.c
index 5b172f89e0c9..dba03ecf5360 100644
--- a/crypto/rmd320.c
+++ b/crypto/rmd320.c
@@ -47,7 +47,7 @@ struct rmd320_ctx {
47#define F5(x, y, z) (x ^ (y | ~z)) 47#define F5(x, y, z) (x ^ (y | ~z))
48 48
49#define ROUND(a, b, c, d, e, f, k, x, s) { \ 49#define ROUND(a, b, c, d, e, f, k, x, s) { \
50 (a) += f((b), (c), (d)) + le32_to_cpu(x) + (k); \ 50 (a) += f((b), (c), (d)) + le32_to_cpup(&(x)) + (k); \
51 (a) = rol32((a), (s)) + (e); \ 51 (a) = rol32((a), (s)) + (e); \
52 (c) = rol32((c), 10); \ 52 (c) = rol32((c), 10); \
53} 53}
@@ -353,7 +353,7 @@ static void rmd320_final(struct crypto_tfm *tfm, u8 *out)
353 353
354 /* Store state in digest */ 354 /* Store state in digest */
355 for (i = 0; i < 10; i++) 355 for (i = 0; i < 10; i++)
356 dst[i] = cpu_to_le32(rctx->state[i]); 356 dst[i] = cpu_to_le32p(&rctx->state[i]);
357 357
358 /* Wipe context */ 358 /* Wipe context */
359 memset(rctx, 0, sizeof(*rctx)); 359 memset(rctx, 0, sizeof(*rctx));