diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-21 17:46:51 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-21 17:46:51 -0400 |
commit | 2a8ba8f032160552a3beffab8aae9019ff477504 (patch) | |
tree | b50f70a3c8f7c2e179e1587d33ea3542d68525f9 /crypto/vmac.c | |
parent | ec2a7587e0a91d5c1afe23a0a73edfce06c5e4e0 (diff) | |
parent | e954bc91bdd4bb08b8325478c5004b24a23a3522 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (46 commits)
random: simplify fips mode
crypto: authenc - Fix cryptlen calculation
crypto: talitos - add support for sha224
crypto: talitos - add hash algorithms
crypto: talitos - second prepare step for adding ahash algorithms
crypto: talitos - prepare for adding ahash algorithms
crypto: n2 - Add Niagara2 crypto driver
crypto: skcipher - Add ablkcipher_walk interfaces
crypto: testmgr - Add testing for async hashing and update/final
crypto: tcrypt - Add speed tests for async hashing
crypto: scatterwalk - Fix scatterwalk_done() test
crypto: hifn_795x - Rename ablkcipher_walk to hifn_cipher_walk
padata: Use get_online_cpus/put_online_cpus in padata_free
padata: Add some code comments
padata: Flush the padata queues actively
padata: Use a timer to handle remaining objects in the reorder queues
crypto: shash - Remove usage of CRYPTO_MINALIGN
crypto: mv_cesa - Use resource_size
crypto: omap - OMAP macros corrected
padata: Use get_online_cpus/put_online_cpus
...
Fix up conflicts in arch/arm/mach-omap2/devices.c
Diffstat (limited to 'crypto/vmac.c')
-rw-r--r-- | crypto/vmac.c | 75 |
1 files changed, 36 insertions, 39 deletions
diff --git a/crypto/vmac.c b/crypto/vmac.c index 0a9468e575de..0999274a27ac 100644 --- a/crypto/vmac.c +++ b/crypto/vmac.c | |||
@@ -43,6 +43,8 @@ const u64 m63 = UINT64_C(0x7fffffffffffffff); /* 63-bit mask */ | |||
43 | const u64 m64 = UINT64_C(0xffffffffffffffff); /* 64-bit mask */ | 43 | const u64 m64 = UINT64_C(0xffffffffffffffff); /* 64-bit mask */ |
44 | const u64 mpoly = UINT64_C(0x1fffffff1fffffff); /* Poly key mask */ | 44 | const u64 mpoly = UINT64_C(0x1fffffff1fffffff); /* Poly key mask */ |
45 | 45 | ||
46 | #define pe64_to_cpup le64_to_cpup /* Prefer little endian */ | ||
47 | |||
46 | #ifdef __LITTLE_ENDIAN | 48 | #ifdef __LITTLE_ENDIAN |
47 | #define INDEX_HIGH 1 | 49 | #define INDEX_HIGH 1 |
48 | #define INDEX_LOW 0 | 50 | #define INDEX_LOW 0 |
@@ -110,8 +112,8 @@ const u64 mpoly = UINT64_C(0x1fffffff1fffffff); /* Poly key mask */ | |||
110 | int i; u64 th, tl; \ | 112 | int i; u64 th, tl; \ |
111 | rh = rl = 0; \ | 113 | rh = rl = 0; \ |
112 | for (i = 0; i < nw; i += 2) { \ | 114 | for (i = 0; i < nw; i += 2) { \ |
113 | MUL64(th, tl, le64_to_cpup((mp)+i)+(kp)[i], \ | 115 | MUL64(th, tl, pe64_to_cpup((mp)+i)+(kp)[i], \ |
114 | le64_to_cpup((mp)+i+1)+(kp)[i+1]); \ | 116 | pe64_to_cpup((mp)+i+1)+(kp)[i+1]); \ |
115 | ADD128(rh, rl, th, tl); \ | 117 | ADD128(rh, rl, th, tl); \ |
116 | } \ | 118 | } \ |
117 | } while (0) | 119 | } while (0) |
@@ -121,11 +123,11 @@ const u64 mpoly = UINT64_C(0x1fffffff1fffffff); /* Poly key mask */ | |||
121 | int i; u64 th, tl; \ | 123 | int i; u64 th, tl; \ |
122 | rh1 = rl1 = rh = rl = 0; \ | 124 | rh1 = rl1 = rh = rl = 0; \ |
123 | for (i = 0; i < nw; i += 2) { \ | 125 | for (i = 0; i < nw; i += 2) { \ |
124 | MUL64(th, tl, le64_to_cpup((mp)+i)+(kp)[i], \ | 126 | MUL64(th, tl, pe64_to_cpup((mp)+i)+(kp)[i], \ |
125 | le64_to_cpup((mp)+i+1)+(kp)[i+1]); \ | 127 | pe64_to_cpup((mp)+i+1)+(kp)[i+1]); \ |
126 | ADD128(rh, rl, th, tl); \ | 128 | ADD128(rh, rl, th, tl); \ |
127 | MUL64(th, tl, le64_to_cpup((mp)+i)+(kp)[i+2], \ | 129 | MUL64(th, tl, pe64_to_cpup((mp)+i)+(kp)[i+2], \ |
128 | le64_to_cpup((mp)+i+1)+(kp)[i+3]); \ | 130 | pe64_to_cpup((mp)+i+1)+(kp)[i+3]); \ |
129 | ADD128(rh1, rl1, th, tl); \ | 131 | ADD128(rh1, rl1, th, tl); \ |
130 | } \ | 132 | } \ |
131 | } while (0) | 133 | } while (0) |
@@ -136,17 +138,17 @@ const u64 mpoly = UINT64_C(0x1fffffff1fffffff); /* Poly key mask */ | |||
136 | int i; u64 th, tl; \ | 138 | int i; u64 th, tl; \ |
137 | rh = rl = 0; \ | 139 | rh = rl = 0; \ |
138 | for (i = 0; i < nw; i += 8) { \ | 140 | for (i = 0; i < nw; i += 8) { \ |
139 | MUL64(th, tl, le64_to_cpup((mp)+i)+(kp)[i], \ | 141 | MUL64(th, tl, pe64_to_cpup((mp)+i)+(kp)[i], \ |
140 | le64_to_cpup((mp)+i+1)+(kp)[i+1]); \ | 142 | pe64_to_cpup((mp)+i+1)+(kp)[i+1]); \ |
141 | ADD128(rh, rl, th, tl); \ | 143 | ADD128(rh, rl, th, tl); \ |
142 | MUL64(th, tl, le64_to_cpup((mp)+i+2)+(kp)[i+2], \ | 144 | MUL64(th, tl, pe64_to_cpup((mp)+i+2)+(kp)[i+2], \ |
143 | le64_to_cpup((mp)+i+3)+(kp)[i+3]); \ | 145 | pe64_to_cpup((mp)+i+3)+(kp)[i+3]); \ |
144 | ADD128(rh, rl, th, tl); \ | 146 | ADD128(rh, rl, th, tl); \ |
145 | MUL64(th, tl, le64_to_cpup((mp)+i+4)+(kp)[i+4], \ | 147 | MUL64(th, tl, pe64_to_cpup((mp)+i+4)+(kp)[i+4], \ |
146 | le64_to_cpup((mp)+i+5)+(kp)[i+5]); \ | 148 | pe64_to_cpup((mp)+i+5)+(kp)[i+5]); \ |
147 | ADD128(rh, rl, th, tl); \ | 149 | ADD128(rh, rl, th, tl); \ |
148 | MUL64(th, tl, le64_to_cpup((mp)+i+6)+(kp)[i+6], \ | 150 | MUL64(th, tl, pe64_to_cpup((mp)+i+6)+(kp)[i+6], \ |
149 | le64_to_cpup((mp)+i+7)+(kp)[i+7]); \ | 151 | pe64_to_cpup((mp)+i+7)+(kp)[i+7]); \ |
150 | ADD128(rh, rl, th, tl); \ | 152 | ADD128(rh, rl, th, tl); \ |
151 | } \ | 153 | } \ |
152 | } while (0) | 154 | } while (0) |
@@ -156,29 +158,29 @@ const u64 mpoly = UINT64_C(0x1fffffff1fffffff); /* Poly key mask */ | |||
156 | int i; u64 th, tl; \ | 158 | int i; u64 th, tl; \ |
157 | rh1 = rl1 = rh = rl = 0; \ | 159 | rh1 = rl1 = rh = rl = 0; \ |
158 | for (i = 0; i < nw; i += 8) { \ | 160 | for (i = 0; i < nw; i += 8) { \ |
159 | MUL64(th, tl, le64_to_cpup((mp)+i)+(kp)[i], \ | 161 | MUL64(th, tl, pe64_to_cpup((mp)+i)+(kp)[i], \ |
160 | le64_to_cpup((mp)+i+1)+(kp)[i+1]); \ | 162 | pe64_to_cpup((mp)+i+1)+(kp)[i+1]); \ |
161 | ADD128(rh, rl, th, tl); \ | 163 | ADD128(rh, rl, th, tl); \ |
162 | MUL64(th, tl, le64_to_cpup((mp)+i)+(kp)[i+2], \ | 164 | MUL64(th, tl, pe64_to_cpup((mp)+i)+(kp)[i+2], \ |
163 | le64_to_cpup((mp)+i+1)+(kp)[i+3]); \ | 165 | pe64_to_cpup((mp)+i+1)+(kp)[i+3]); \ |
164 | ADD128(rh1, rl1, th, tl); \ | 166 | ADD128(rh1, rl1, th, tl); \ |
165 | MUL64(th, tl, le64_to_cpup((mp)+i+2)+(kp)[i+2], \ | 167 | MUL64(th, tl, pe64_to_cpup((mp)+i+2)+(kp)[i+2], \ |
166 | le64_to_cpup((mp)+i+3)+(kp)[i+3]); \ | 168 | pe64_to_cpup((mp)+i+3)+(kp)[i+3]); \ |
167 | ADD128(rh, rl, th, tl); \ | 169 | ADD128(rh, rl, th, tl); \ |
168 | MUL64(th, tl, le64_to_cpup((mp)+i+2)+(kp)[i+4], \ | 170 | MUL64(th, tl, pe64_to_cpup((mp)+i+2)+(kp)[i+4], \ |
169 | le64_to_cpup((mp)+i+3)+(kp)[i+5]); \ | 171 | pe64_to_cpup((mp)+i+3)+(kp)[i+5]); \ |
170 | ADD128(rh1, rl1, th, tl); \ | 172 | ADD128(rh1, rl1, th, tl); \ |
171 | MUL64(th, tl, le64_to_cpup((mp)+i+4)+(kp)[i+4], \ | 173 | MUL64(th, tl, pe64_to_cpup((mp)+i+4)+(kp)[i+4], \ |
172 | le64_to_cpup((mp)+i+5)+(kp)[i+5]); \ | 174 | pe64_to_cpup((mp)+i+5)+(kp)[i+5]); \ |
173 | ADD128(rh, rl, th, tl); \ | 175 | ADD128(rh, rl, th, tl); \ |
174 | MUL64(th, tl, le64_to_cpup((mp)+i+4)+(kp)[i+6], \ | 176 | MUL64(th, tl, pe64_to_cpup((mp)+i+4)+(kp)[i+6], \ |
175 | le64_to_cpup((mp)+i+5)+(kp)[i+7]); \ | 177 | pe64_to_cpup((mp)+i+5)+(kp)[i+7]); \ |
176 | ADD128(rh1, rl1, th, tl); \ | 178 | ADD128(rh1, rl1, th, tl); \ |
177 | MUL64(th, tl, le64_to_cpup((mp)+i+6)+(kp)[i+6], \ | 179 | MUL64(th, tl, pe64_to_cpup((mp)+i+6)+(kp)[i+6], \ |
178 | le64_to_cpup((mp)+i+7)+(kp)[i+7]); \ | 180 | pe64_to_cpup((mp)+i+7)+(kp)[i+7]); \ |
179 | ADD128(rh, rl, th, tl); \ | 181 | ADD128(rh, rl, th, tl); \ |
180 | MUL64(th, tl, le64_to_cpup((mp)+i+6)+(kp)[i+8], \ | 182 | MUL64(th, tl, pe64_to_cpup((mp)+i+6)+(kp)[i+8], \ |
181 | le64_to_cpup((mp)+i+7)+(kp)[i+9]); \ | 183 | pe64_to_cpup((mp)+i+7)+(kp)[i+9]); \ |
182 | ADD128(rh1, rl1, th, tl); \ | 184 | ADD128(rh1, rl1, th, tl); \ |
183 | } \ | 185 | } \ |
184 | } while (0) | 186 | } while (0) |
@@ -216,8 +218,8 @@ const u64 mpoly = UINT64_C(0x1fffffff1fffffff); /* Poly key mask */ | |||
216 | int i; \ | 218 | int i; \ |
217 | rh = rl = t = 0; \ | 219 | rh = rl = t = 0; \ |
218 | for (i = 0; i < nw; i += 2) { \ | 220 | for (i = 0; i < nw; i += 2) { \ |
219 | t1 = le64_to_cpup(mp+i) + kp[i]; \ | 221 | t1 = pe64_to_cpup(mp+i) + kp[i]; \ |
220 | t2 = le64_to_cpup(mp+i+1) + kp[i+1]; \ | 222 | t2 = pe64_to_cpup(mp+i+1) + kp[i+1]; \ |
221 | m2 = MUL32(t1 >> 32, t2); \ | 223 | m2 = MUL32(t1 >> 32, t2); \ |
222 | m1 = MUL32(t1, t2 >> 32); \ | 224 | m1 = MUL32(t1, t2 >> 32); \ |
223 | ADD128(rh, rl, MUL32(t1 >> 32, t2 >> 32), \ | 225 | ADD128(rh, rl, MUL32(t1 >> 32, t2 >> 32), \ |
@@ -322,8 +324,7 @@ static void vhash_abort(struct vmac_ctx *ctx) | |||
322 | ctx->first_block_processed = 0; | 324 | ctx->first_block_processed = 0; |
323 | } | 325 | } |
324 | 326 | ||
325 | static u64 l3hash(u64 p1, u64 p2, | 327 | static u64 l3hash(u64 p1, u64 p2, u64 k1, u64 k2, u64 len) |
326 | u64 k1, u64 k2, u64 len) | ||
327 | { | 328 | { |
328 | u64 rh, rl, t, z = 0; | 329 | u64 rh, rl, t, z = 0; |
329 | 330 | ||
@@ -474,7 +475,7 @@ static u64 vmac(unsigned char m[], unsigned int mbytes, | |||
474 | } | 475 | } |
475 | p = be64_to_cpup(out_p + i); | 476 | p = be64_to_cpup(out_p + i); |
476 | h = vhash(m, mbytes, (u64 *)0, &ctx->__vmac_ctx); | 477 | h = vhash(m, mbytes, (u64 *)0, &ctx->__vmac_ctx); |
477 | return p + h; | 478 | return le64_to_cpu(p + h); |
478 | } | 479 | } |
479 | 480 | ||
480 | static int vmac_set_key(unsigned char user_key[], struct vmac_ctx_t *ctx) | 481 | static int vmac_set_key(unsigned char user_key[], struct vmac_ctx_t *ctx) |
@@ -549,10 +550,6 @@ static int vmac_setkey(struct crypto_shash *parent, | |||
549 | 550 | ||
550 | static int vmac_init(struct shash_desc *pdesc) | 551 | static int vmac_init(struct shash_desc *pdesc) |
551 | { | 552 | { |
552 | struct crypto_shash *parent = pdesc->tfm; | ||
553 | struct vmac_ctx_t *ctx = crypto_shash_ctx(parent); | ||
554 | |||
555 | memset(&ctx->__vmac_ctx, 0, sizeof(struct vmac_ctx)); | ||
556 | return 0; | 553 | return 0; |
557 | } | 554 | } |
558 | 555 | ||