diff options
| author | Herbert Xu <herbert@gondor.apana.org.au> | 2012-02-15 23:18:21 -0500 |
|---|---|---|
| committer | Herbert Xu <herbert@gondor.apana.org.au> | 2012-02-15 23:18:21 -0500 |
| commit | d97055e62dd8c6f2150b6062ffbd4a6d836658ff (patch) | |
| tree | 5b751b4ca74f2baba8769cd9ffd1081a62f78833 /crypto | |
| parent | 6e77fe8c1100bfb3c6f5b2558d4556519b837b65 (diff) | |
| parent | f2ea0f5f04c97b48c88edccba52b0682fbe45087 (diff) | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Merge crypto tree as it has cherry-picked the ror64 patch from cryptodev.
Diffstat (limited to 'crypto')
| -rw-r--r-- | crypto/sha512_generic.c | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/crypto/sha512_generic.c b/crypto/sha512_generic.c index 20df86f51406..107f6f7be5e1 100644 --- a/crypto/sha512_generic.c +++ b/crypto/sha512_generic.c | |||
| @@ -21,8 +21,6 @@ | |||
| 21 | #include <linux/percpu.h> | 21 | #include <linux/percpu.h> |
| 22 | #include <asm/byteorder.h> | 22 | #include <asm/byteorder.h> |
| 23 | 23 | ||
| 24 | static DEFINE_PER_CPU(u64[80], msg_schedule); | ||
| 25 | |||
| 26 | static inline u64 Ch(u64 x, u64 y, u64 z) | 24 | static inline u64 Ch(u64 x, u64 y, u64 z) |
| 27 | { | 25 | { |
| 28 | return z ^ (x & (y ^ z)); | 26 | return z ^ (x & (y ^ z)); |
| @@ -75,7 +73,7 @@ static inline void LOAD_OP(int I, u64 *W, const u8 *input) | |||
| 75 | 73 | ||
| 76 | static inline void BLEND_OP(int I, u64 *W) | 74 | static inline void BLEND_OP(int I, u64 *W) |
| 77 | { | 75 | { |
| 78 | W[I] = s1(W[I-2]) + W[I-7] + s0(W[I-15]) + W[I-16]; | 76 | W[I & 15] += s1(W[(I-2) & 15]) + W[(I-7) & 15] + s0(W[(I-15) & 15]); |
| 79 | } | 77 | } |
| 80 | 78 | ||
| 81 | static void | 79 | static void |
| @@ -84,15 +82,7 @@ sha512_transform(u64 *state, const u8 *input) | |||
| 84 | u64 a, b, c, d, e, f, g, h, t1, t2; | 82 | u64 a, b, c, d, e, f, g, h, t1, t2; |
| 85 | 83 | ||
| 86 | int i; | 84 | int i; |
| 87 | u64 *W = get_cpu_var(msg_schedule); | 85 | u64 W[16]; |
| 88 | |||
| 89 | /* load the input */ | ||
| 90 | for (i = 0; i < 16; i++) | ||
| 91 | LOAD_OP(i, W, input); | ||
| 92 | |||
| 93 | for (i = 16; i < 80; i++) { | ||
| 94 | BLEND_OP(i, W); | ||
| 95 | } | ||
| 96 | 86 | ||
| 97 | /* load the state into our registers */ | 87 | /* load the state into our registers */ |
| 98 | a=state[0]; b=state[1]; c=state[2]; d=state[3]; | 88 | a=state[0]; b=state[1]; c=state[2]; d=state[3]; |
| @@ -100,21 +90,35 @@ sha512_transform(u64 *state, const u8 *input) | |||
| 100 | 90 | ||
| 101 | /* now iterate */ | 91 | /* now iterate */ |
| 102 | for (i=0; i<80; i+=8) { | 92 | for (i=0; i<80; i+=8) { |
| 103 | t1 = h + e1(e) + Ch(e,f,g) + sha512_K[i ] + W[i ]; | 93 | if (!(i & 8)) { |
| 94 | int j; | ||
| 95 | |||
| 96 | if (i < 16) { | ||
| 97 | /* load the input */ | ||
| 98 | for (j = 0; j < 16; j++) | ||
| 99 | LOAD_OP(i + j, W, input); | ||
| 100 | } else { | ||
| 101 | for (j = 0; j < 16; j++) { | ||
| 102 | BLEND_OP(i + j, W); | ||
| 103 | } | ||
| 104 | } | ||
| 105 | } | ||
| 106 | |||
| 107 | t1 = h + e1(e) + Ch(e,f,g) + sha512_K[i ] + W[(i & 15)]; | ||
| 104 | t2 = e0(a) + Maj(a,b,c); d+=t1; h=t1+t2; | 108 | t2 = e0(a) + Maj(a,b,c); d+=t1; h=t1+t2; |
| 105 | t1 = g + e1(d) + Ch(d,e,f) + sha512_K[i+1] + W[i+1]; | 109 | t1 = g + e1(d) + Ch(d,e,f) + sha512_K[i+1] + W[(i & 15) + 1]; |
| 106 | t2 = e0(h) + Maj(h,a,b); c+=t1; g=t1+t2; | 110 | t2 = e0(h) + Maj(h,a,b); c+=t1; g=t1+t2; |
| 107 | t1 = f + e1(c) + Ch(c,d,e) + sha512_K[i+2] + W[i+2]; | 111 | t1 = f + e1(c) + Ch(c,d,e) + sha512_K[i+2] + W[(i & 15) + 2]; |
| 108 | t2 = e0(g) + Maj(g,h,a); b+=t1; f=t1+t2; | 112 | t2 = e0(g) + Maj(g,h,a); b+=t1; f=t1+t2; |
| 109 | t1 = e + e1(b) + Ch(b,c,d) + sha512_K[i+3] + W[i+3]; | 113 | t1 = e + e1(b) + Ch(b,c,d) + sha512_K[i+3] + W[(i & 15) + 3]; |
| 110 | t2 = e0(f) + Maj(f,g,h); a+=t1; e=t1+t2; | 114 | t2 = e0(f) + Maj(f,g,h); a+=t1; e=t1+t2; |
| 111 | t1 = d + e1(a) + Ch(a,b,c) + sha512_K[i+4] + W[i+4]; | 115 | t1 = d + e1(a) + Ch(a,b,c) + sha512_K[i+4] + W[(i & 15) + 4]; |
| 112 | t2 = e0(e) + Maj(e,f,g); h+=t1; d=t1+t2; | 116 | t2 = e0(e) + Maj(e,f,g); h+=t1; d=t1+t2; |
| 113 | t1 = c + e1(h) + Ch(h,a,b) + sha512_K[i+5] + W[i+5]; | 117 | t1 = c + e1(h) + Ch(h,a,b) + sha512_K[i+5] + W[(i & 15) + 5]; |
| 114 | t2 = e0(d) + Maj(d,e,f); g+=t1; c=t1+t2; | 118 | t2 = e0(d) + Maj(d,e,f); g+=t1; c=t1+t2; |
| 115 | t1 = b + e1(g) + Ch(g,h,a) + sha512_K[i+6] + W[i+6]; | 119 | t1 = b + e1(g) + Ch(g,h,a) + sha512_K[i+6] + W[(i & 15) + 6]; |
| 116 | t2 = e0(c) + Maj(c,d,e); f+=t1; b=t1+t2; | 120 | t2 = e0(c) + Maj(c,d,e); f+=t1; b=t1+t2; |
| 117 | t1 = a + e1(f) + Ch(f,g,h) + sha512_K[i+7] + W[i+7]; | 121 | t1 = a + e1(f) + Ch(f,g,h) + sha512_K[i+7] + W[(i & 15) + 7]; |
| 118 | t2 = e0(b) + Maj(b,c,d); e+=t1; a=t1+t2; | 122 | t2 = e0(b) + Maj(b,c,d); e+=t1; a=t1+t2; |
| 119 | } | 123 | } |
| 120 | 124 | ||
| @@ -123,8 +127,6 @@ sha512_transform(u64 *state, const u8 *input) | |||
| 123 | 127 | ||
| 124 | /* erase our data */ | 128 | /* erase our data */ |
| 125 | a = b = c = d = e = f = g = h = t1 = t2 = 0; | 129 | a = b = c = d = e = f = g = h = t1 = t2 = 0; |
| 126 | memset(W, 0, sizeof(__get_cpu_var(msg_schedule))); | ||
| 127 | put_cpu_var(msg_schedule); | ||
| 128 | } | 130 | } |
| 129 | 131 | ||
| 130 | static int | 132 | static int |
