Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=1ce73e8d6d95ceb860184c34fa1a91a82e51cbb3
Commit:     1ce73e8d6d95ceb860184c34fa1a91a82e51cbb3
Parent:     3a5e5f8108fe440657e8041afd973d2fe72180bb
Author:     Denys Vlasenko <[EMAIL PROTECTED]>
AuthorDate: Tue Nov 6 22:13:40 2007 +0800
Committer:  Herbert Xu <[EMAIL PROTECTED]>
CommitDate: Fri Jan 11 08:16:07 2008 +1100

    [CRYPTO] camellia: Code cleanup
    
    Optimize GETU32 to use 4-byte memcpy (modern gcc will convert
    such memcpy to single move instruction on i386).
    Original GETU32 did four byte fetches, and shifted/XORed those.
    
    Signed-off-by: Denys Vlasenko <[EMAIL PROTECTED]>
    Acked-by: Noriaki TAKAMIYA <[EMAIL PROTECTED]>
    Signed-off-by: Herbert Xu <[EMAIL PROTECTED]>
---
 crypto/camellia.c |   39 +++++++++++++++++++++------------------
 1 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/crypto/camellia.c b/crypto/camellia.c
index ac372e4..16529dd 100644
--- a/crypto/camellia.c
+++ b/crypto/camellia.c
@@ -330,10 +330,12 @@ static const u32 camellia_sp4404[256] = {
  *  macros
  */
 
-# define GETU32(pt) (((u32)(pt)[0] << 24)      \
-                    ^ ((u32)(pt)[1] << 16)     \
-                    ^ ((u32)(pt)[2] <<  8)     \
-                    ^ ((u32)(pt)[3]))
+# define GETU32(v, pt) \
+    do { \
+       /* latest breed of gcc is clever enough to use move */ \
+       memcpy(&(v), (pt), 4); \
+       (v) = be32_to_cpu(v); \
+    } while(0)
 
 /* rotation right shift 1byte */
 #define ROR8(x) (((x) >> 8) + ((x) << 24))
@@ -433,10 +435,11 @@ static void camellia_setup128(const unsigned char *key, 
u32 *subkey)
        /**
         *  k == kll || klr || krl || krr (|| is concatination)
         */
-       kll = GETU32(key     );
-       klr = GETU32(key +  4);
-       krl = GETU32(key +  8);
-       krr = GETU32(key + 12);
+       GETU32(kll, key     );
+       GETU32(klr, key +  4);
+       GETU32(krl, key +  8);
+       GETU32(krr, key + 12);
+
        /**
         * generate KL dependent subkeys
         */
@@ -687,8 +690,8 @@ static void camellia_setup128(const unsigned char *key, u32 
*subkey)
 
 static void camellia_setup256(const unsigned char *key, u32 *subkey)
 {
-       u32 kll,klr,krl,krr;           /* left half of key */
-       u32 krll,krlr,krrl,krrr;       /* right half of key */
+       u32 kll, klr, krl, krr;        /* left half of key */
+       u32 krll, krlr, krrl, krrr;    /* right half of key */
        u32 il, ir, t0, t1, w0, w1;    /* temporary variables */
        u32 kw4l, kw4r, dw, tl, tr;
        u32 subL[34];
@@ -698,14 +701,14 @@ static void camellia_setup256(const unsigned char *key, 
u32 *subkey)
         *  key = (kll || klr || krl || krr || krll || krlr || krrl || krrr)
         *  (|| is concatination)
         */
-       kll  = GETU32(key     );
-       klr  = GETU32(key +  4);
-       krl  = GETU32(key +  8);
-       krr  = GETU32(key + 12);
-       krll = GETU32(key + 16);
-       krlr = GETU32(key + 20);
-       krrl = GETU32(key + 24);
-       krrr = GETU32(key + 28);
+       GETU32(kll,  key     );
+       GETU32(klr,  key +  4);
+       GETU32(krl,  key +  8);
+       GETU32(krr,  key + 12);
+       GETU32(krll, key + 16);
+       GETU32(krlr, key + 20);
+       GETU32(krrl, key + 24);
+       GETU32(krrr, key + 28);
 
        /* generate KL dependent subkeys */
        /* kw1 */
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to