diff options
author | Aaron Grothe <ajgrothe@yahoo.com> | 2005-09-01 20:42:46 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-09-01 20:42:46 -0400 |
commit | fb4f10ed50f01b0f953068456bfb6e2885921b01 (patch) | |
tree | e9eb4112522d7969fdc4bbf6455b6d0d59426121 /crypto/tcrypt.h | |
parent | 75c80c382fbd08acf06fbef9d54c9844e806a8b4 (diff) |
[CRYPTO]: Fix XTEA implementation
The XTEA implementation was incorrect due to a misinterpretation of
operator precedence. Because of the wide-spread nature of this
error, the erroneous implementation will be kept, albeit under the
new name of XETA.
Signed-off-by: Aaron Grothe <ajgrothe@yahoo.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'crypto/tcrypt.h')
-rw-r--r-- | crypto/tcrypt.h | 138 |
1 files changed, 115 insertions, 23 deletions
diff --git a/crypto/tcrypt.h b/crypto/tcrypt.h index c01a0ce9b40a..522ffd4b6f43 100644 --- a/crypto/tcrypt.h +++ b/crypto/tcrypt.h | |||
@@ -2211,7 +2211,7 @@ static struct cipher_testvec xtea_enc_tv_template[] = { | |||
2211 | .klen = 16, | 2211 | .klen = 16, |
2212 | .input = { [0 ... 8] = 0x00 }, | 2212 | .input = { [0 ... 8] = 0x00 }, |
2213 | .ilen = 8, | 2213 | .ilen = 8, |
2214 | .result = { 0xaa, 0x22, 0x96, 0xe5, 0x6c, 0x61, 0xf3, 0x45 }, | 2214 | .result = { 0xd8, 0xd4, 0xe9, 0xde, 0xd9, 0x1e, 0x13, 0xf7 }, |
2215 | .rlen = 8, | 2215 | .rlen = 8, |
2216 | }, { | 2216 | }, { |
2217 | .key = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76, | 2217 | .key = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76, |
@@ -2219,31 +2219,31 @@ static struct cipher_testvec xtea_enc_tv_template[] = { | |||
2219 | .klen = 16, | 2219 | .klen = 16, |
2220 | .input = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e }, | 2220 | .input = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e }, |
2221 | .ilen = 8, | 2221 | .ilen = 8, |
2222 | .result = { 0x82, 0x3e, 0xeb, 0x35, 0xdc, 0xdd, 0xd9, 0xc3 }, | 2222 | .result = { 0x94, 0xeb, 0xc8, 0x96, 0x84, 0x6a, 0x49, 0xa8 }, |
2223 | .rlen = 8, | 2223 | .rlen = 8, |
2224 | }, { | 2224 | }, { |
2225 | .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25, | 2225 | .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25, |
2226 | 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e }, | 2226 | 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e }, |
2227 | .klen = 16, | 2227 | .klen = 16, |
2228 | .input = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, | 2228 | .input = { 0x3e, 0xce, 0xae, 0x22, 0x60, 0x56, 0xa8, 0x9d, |
2229 | 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 }, | 2229 | 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 }, |
2230 | .ilen = 16, | 2230 | .ilen = 16, |
2231 | .result = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea, | 2231 | .result = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea, |
2232 | 0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c }, | 2232 | 0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c }, |
2233 | .rlen = 16, | 2233 | .rlen = 16, |
2234 | }, { | 2234 | }, { |
2235 | .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c, | 2235 | .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c, |
2236 | 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f }, | 2236 | 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f }, |
2237 | .klen = 16, | 2237 | .klen = 16, |
2238 | .input = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, | 2238 | .input = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, |
2239 | 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, | 2239 | 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, |
2240 | 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, | 2240 | 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, |
2241 | 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 }, | 2241 | 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 }, |
2242 | .ilen = 32, | 2242 | .ilen = 32, |
2243 | .result = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1, | 2243 | .result = { 0x99, 0x81, 0x9f, 0x5d, 0x6f, 0x4b, 0x31, 0x3a, |
2244 | 0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4, | 2244 | 0x86, 0xff, 0x6f, 0xd0, 0xe3, 0x87, 0x70, 0x07, |
2245 | 0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f, | 2245 | 0x4d, 0xb8, 0xcf, 0xf3, 0x99, 0x50, 0xb3, 0xd4, |
2246 | 0xea, 0xa5, 0x6a, 0x85, 0xd1, 0xf4, 0xa8, 0xa5 }, | 2246 | 0x73, 0xa2, 0xfa, 0xc9, 0x16, 0x59, 0x5d, 0x81 }, |
2247 | .rlen = 32, | 2247 | .rlen = 32, |
2248 | } | 2248 | } |
2249 | }; | 2249 | }; |
@@ -2252,7 +2252,7 @@ static struct cipher_testvec xtea_dec_tv_template[] = { | |||
2252 | { | 2252 | { |
2253 | .key = { [0 ... 15] = 0x00 }, | 2253 | .key = { [0 ... 15] = 0x00 }, |
2254 | .klen = 16, | 2254 | .klen = 16, |
2255 | .input = { 0xaa, 0x22, 0x96, 0xe5, 0x6c, 0x61, 0xf3, 0x45 }, | 2255 | .input = { 0xd8, 0xd4, 0xe9, 0xde, 0xd9, 0x1e, 0x13, 0xf7 }, |
2256 | .ilen = 8, | 2256 | .ilen = 8, |
2257 | .result = { [0 ... 8] = 0x00 }, | 2257 | .result = { [0 ... 8] = 0x00 }, |
2258 | .rlen = 8, | 2258 | .rlen = 8, |
@@ -2260,7 +2260,7 @@ static struct cipher_testvec xtea_dec_tv_template[] = { | |||
2260 | .key = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76, | 2260 | .key = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76, |
2261 | 0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 }, | 2261 | 0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 }, |
2262 | .klen = 16, | 2262 | .klen = 16, |
2263 | .input = { 0x82, 0x3e, 0xeb, 0x35, 0xdc, 0xdd, 0xd9, 0xc3 }, | 2263 | .input = { 0x94, 0xeb, 0xc8, 0x96, 0x84, 0x6a, 0x49, 0xa8 }, |
2264 | .ilen = 8, | 2264 | .ilen = 8, |
2265 | .result = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e }, | 2265 | .result = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e }, |
2266 | .rlen = 8, | 2266 | .rlen = 8, |
@@ -2268,24 +2268,24 @@ static struct cipher_testvec xtea_dec_tv_template[] = { | |||
2268 | .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25, | 2268 | .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25, |
2269 | 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e }, | 2269 | 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e }, |
2270 | .klen = 16, | 2270 | .klen = 16, |
2271 | .input = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea, | 2271 | .input = { 0x3e, 0xce, 0xae, 0x22, 0x60, 0x56, 0xa8, 0x9d, |
2272 | 0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c }, | 2272 | 0x77, 0x4d, 0xd4, 0xb4, 0x87, 0x24, 0xe3, 0x9a }, |
2273 | .ilen = 16, | 2273 | .ilen = 16, |
2274 | .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, | 2274 | .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, |
2275 | 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 }, | 2275 | 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 }, |
2276 | .rlen = 16, | 2276 | .rlen = 16, |
2277 | }, { | 2277 | }, { |
2278 | .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c, | 2278 | .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c, |
2279 | 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f }, | 2279 | 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f }, |
2280 | .klen = 16, | 2280 | .klen = 16, |
2281 | .input = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1, | 2281 | .input = { 0x99, 0x81, 0x9f, 0x5d, 0x6f, 0x4b, 0x31, 0x3a, |
2282 | 0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4, | 2282 | 0x86, 0xff, 0x6f, 0xd0, 0xe3, 0x87, 0x70, 0x07, |
2283 | 0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f, | 2283 | 0x4d, 0xb8, 0xcf, 0xf3, 0x99, 0x50, 0xb3, 0xd4, |
2284 | 0xea, 0xa5, 0x6a, 0x85, 0xd1, 0xf4, 0xa8, 0xa5 }, | 2284 | 0x73, 0xa2, 0xfa, 0xc9, 0x16, 0x59, 0x5d, 0x81 }, |
2285 | .ilen = 32, | 2285 | .ilen = 32, |
2286 | .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, | 2286 | .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, |
2287 | 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, | 2287 | 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, |
2288 | 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, | 2288 | 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, |
2289 | 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 }, | 2289 | 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 }, |
2290 | .rlen = 32, | 2290 | .rlen = 32, |
2291 | } | 2291 | } |
@@ -2594,6 +2594,98 @@ static struct cipher_testvec anubis_cbc_dec_tv_template[] = { | |||
2594 | }, | 2594 | }, |
2595 | }; | 2595 | }; |
2596 | 2596 | ||
2597 | /* | ||
2598 | * XETA test vectors | ||
2599 | */ | ||
2600 | #define XETA_ENC_TEST_VECTORS 4 | ||
2601 | #define XETA_DEC_TEST_VECTORS 4 | ||
2602 | |||
2603 | static struct cipher_testvec xeta_enc_tv_template[] = { | ||
2604 | { | ||
2605 | .key = { [0 ... 15] = 0x00 }, | ||
2606 | .klen = 16, | ||
2607 | .input = { [0 ... 8] = 0x00 }, | ||
2608 | .ilen = 8, | ||
2609 | .result = { 0xaa, 0x22, 0x96, 0xe5, 0x6c, 0x61, 0xf3, 0x45 }, | ||
2610 | .rlen = 8, | ||
2611 | }, { | ||
2612 | .key = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76, | ||
2613 | 0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 }, | ||
2614 | .klen = 16, | ||
2615 | .input = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e }, | ||
2616 | .ilen = 8, | ||
2617 | .result = { 0x82, 0x3e, 0xeb, 0x35, 0xdc, 0xdd, 0xd9, 0xc3 }, | ||
2618 | .rlen = 8, | ||
2619 | }, { | ||
2620 | .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25, | ||
2621 | 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e }, | ||
2622 | .klen = 16, | ||
2623 | .input = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, | ||
2624 | 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 }, | ||
2625 | .ilen = 16, | ||
2626 | .result = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea, | ||
2627 | 0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c }, | ||
2628 | .rlen = 16, | ||
2629 | }, { | ||
2630 | .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c, | ||
2631 | 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f }, | ||
2632 | .klen = 16, | ||
2633 | .input = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, | ||
2634 | 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, | ||
2635 | 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, | ||
2636 | 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 }, | ||
2637 | .ilen = 32, | ||
2638 | .result = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1, | ||
2639 | 0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4, | ||
2640 | 0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f, | ||
2641 | 0xea, 0xa5, 0x6a, 0x85, 0xd1, 0xf4, 0xa8, 0xa5 }, | ||
2642 | .rlen = 32, | ||
2643 | } | ||
2644 | }; | ||
2645 | |||
2646 | static struct cipher_testvec xeta_dec_tv_template[] = { | ||
2647 | { | ||
2648 | .key = { [0 ... 15] = 0x00 }, | ||
2649 | .klen = 16, | ||
2650 | .input = { 0xaa, 0x22, 0x96, 0xe5, 0x6c, 0x61, 0xf3, 0x45 }, | ||
2651 | .ilen = 8, | ||
2652 | .result = { [0 ... 8] = 0x00 }, | ||
2653 | .rlen = 8, | ||
2654 | }, { | ||
2655 | .key = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76, | ||
2656 | 0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 }, | ||
2657 | .klen = 16, | ||
2658 | .input = { 0x82, 0x3e, 0xeb, 0x35, 0xdc, 0xdd, 0xd9, 0xc3 }, | ||
2659 | .ilen = 8, | ||
2660 | .result = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e }, | ||
2661 | .rlen = 8, | ||
2662 | }, { | ||
2663 | .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25, | ||
2664 | 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e }, | ||
2665 | .klen = 16, | ||
2666 | .input = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea, | ||
2667 | 0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c }, | ||
2668 | .ilen = 16, | ||
2669 | .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, | ||
2670 | 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 }, | ||
2671 | .rlen = 16, | ||
2672 | }, { | ||
2673 | .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c, | ||
2674 | 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f }, | ||
2675 | .klen = 16, | ||
2676 | .input = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1, | ||
2677 | 0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4, | ||
2678 | 0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f, | ||
2679 | 0xea, 0xa5, 0x6a, 0x85, 0xd1, 0xf4, 0xa8, 0xa5 }, | ||
2680 | .ilen = 32, | ||
2681 | .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, | ||
2682 | 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, | ||
2683 | 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, | ||
2684 | 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 }, | ||
2685 | .rlen = 32, | ||
2686 | } | ||
2687 | }; | ||
2688 | |||
2597 | /* | 2689 | /* |
2598 | * Compression stuff. | 2690 | * Compression stuff. |
2599 | */ | 2691 | */ |