]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[CRYPTO] rmd: Use pointer form of endian swapping operations
authorHerbert Xu <herbert@gondor.apana.org.au>
Mon, 2 Jun 2008 11:30:38 +0000 (21:30 +1000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 10 Jul 2008 12:35:15 +0000 (20:35 +0800)
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>
crypto/rmd128.c
crypto/rmd160.c
crypto/rmd256.c
crypto/rmd320.c

index 89a535aa6eb8994033d933c8c68b342436f86675..1a481df66913b296243aa401fc497a89f8bb9bf2 100644 (file)
@@ -44,7 +44,7 @@ struct rmd128_ctx {
 #define F4(x, y, z) (y ^ (z & (x ^ y)))        /* z ? x : y */
 
 #define ROUND(a, b, c, d, f, k, x, s)  { \
-       (a) += f((b), (c), (d)) + le32_to_cpu(x) + (k); \
+       (a) += f((b), (c), (d)) + le32_to_cpup(&(x)) + (k);     \
        (a) = rol32((a), (s)); \
 }
 
@@ -285,7 +285,7 @@ static void rmd128_final(struct crypto_tfm *tfm, u8 *out)
 
        /* Store state in digest */
        for (i = 0; i < 4; i++)
-               dst[i] = cpu_to_le32(rctx->state[i]);
+               dst[i] = cpu_to_le32p(&rctx->state[i]);
 
        /* Wipe context */
        memset(rctx, 0, sizeof(*rctx));
index 136e31f56d539cae738ad354f992f01f833b9fdc..e9fd5f6a0acb22bb95cc6cbb89fa972f39316efb 100644 (file)
@@ -47,7 +47,7 @@ struct rmd160_ctx {
 #define F5(x, y, z) (x ^ (y | ~z))
 
 #define ROUND(a, b, c, d, e, f, k, x, s)  { \
-       (a) += f((b), (c), (d)) + le32_to_cpu(x) + (k); \
+       (a) += f((b), (c), (d)) + le32_to_cpup(&(x)) + (k); \
        (a) = rol32((a), (s)) + (e); \
        (c) = rol32((c), 10); \
 }
@@ -329,7 +329,7 @@ static void rmd160_final(struct crypto_tfm *tfm, u8 *out)
 
        /* Store state in digest */
        for (i = 0; i < 5; i++)
-               dst[i] = cpu_to_le32(rctx->state[i]);
+               dst[i] = cpu_to_le32p(&rctx->state[i]);
 
        /* Wipe context */
        memset(rctx, 0, sizeof(*rctx));
index 88f2203751ae2d7d11cd6e6e15b3f89a5ec3a109..b08852690706f9de97a4916b4edb60f5eed194a2 100644 (file)
@@ -44,7 +44,7 @@ struct rmd256_ctx {
 #define F4(x, y, z) (y ^ (z & (x ^ y)))        /* z ? x : y */
 
 #define ROUND(a, b, c, d, f, k, x, s)  { \
-       (a) += f((b), (c), (d)) + le32_to_cpu(x) + (k); \
+       (a) += f((b), (c), (d)) + le32_to_cpup(&(x)) + (k); \
        (a) = rol32((a), (s)); \
 }
 
@@ -304,7 +304,7 @@ static void rmd256_final(struct crypto_tfm *tfm, u8 *out)
 
        /* Store state in digest */
        for (i = 0; i < 8; i++)
-               dst[i] = cpu_to_le32(rctx->state[i]);
+               dst[i] = cpu_to_le32p(&rctx->state[i]);
 
        /* Wipe context */
        memset(rctx, 0, sizeof(*rctx));
index 5b172f89e0c978d065956fe40a5bba20b02f445b..dba03ecf53603f2fc7ad726426eaf5f46efef84e 100644 (file)
@@ -47,7 +47,7 @@ struct rmd320_ctx {
 #define F5(x, y, z) (x ^ (y | ~z))
 
 #define ROUND(a, b, c, d, e, f, k, x, s)  { \
-       (a) += f((b), (c), (d)) + le32_to_cpu(x) + (k); \
+       (a) += f((b), (c), (d)) + le32_to_cpup(&(x)) + (k); \
        (a) = rol32((a), (s)) + (e); \
        (c) = rol32((c), 10); \
 }
@@ -353,7 +353,7 @@ static void rmd320_final(struct crypto_tfm *tfm, u8 *out)
 
        /* Store state in digest */
        for (i = 0; i < 10; i++)
-               dst[i] = cpu_to_le32(rctx->state[i]);
+               dst[i] = cpu_to_le32p(&rctx->state[i]);
 
        /* Wipe context */
        memset(rctx, 0, sizeof(*rctx));