Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
5 /* This implementation is by Ted Krovetz and was submitted to SUPERCOP and | 5 /* This implementation is by Ted Krovetz and was submitted to SUPERCOP and |
6 * marked as public domain. It was been altered to allow for non-aligned inputs | 6 * marked as public domain. It was been altered to allow for non-aligned inputs |
7 * and to allow the block counter to be passed in specifically. */ | 7 * and to allow the block counter to be passed in specifically. */ |
8 | 8 |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 #if !defined(__ARM_NEON__) && !defined(__SSE2__) | 118 #if !defined(__ARM_NEON__) && !defined(__SSE2__) |
119 __attribute__ ((aligned (16))) unsigned key[8], nonce[4]; | 119 __attribute__ ((aligned (16))) unsigned key[8], nonce[4]; |
120 #endif | 120 #endif |
121 __attribute__ ((aligned (16))) unsigned chacha_const[] = | 121 __attribute__ ((aligned (16))) unsigned chacha_const[] = |
122 {0x61707865,0x3320646E,0x79622D32,0x6B206574}; | 122 {0x61707865,0x3320646E,0x79622D32,0x6B206574}; |
123 #if defined(__ARM_NEON__) || defined(__SSE2__) | 123 #if defined(__ARM_NEON__) || defined(__SSE2__) |
124 kp = (unsigned *)key; | 124 kp = (unsigned *)key; |
125 #else | 125 #else |
126 ((vec *)key)[0] = REVV_BE(((vec *)key)[0]); | 126 ((vec *)key)[0] = REVV_BE(((vec *)key)[0]); |
127 ((vec *)key)[1] = REVV_BE(((vec *)key)[1]); | 127 ((vec *)key)[1] = REVV_BE(((vec *)key)[1]); |
128 nonce[0] = REVW_BE(((unsigned *)nonce)[0]); | 128 ((unsigned *)nonce)[0] = REVW_BE(((unsigned *)nonce)[0]); |
129 nonce[1] = REVW_BE(((unsigned *)nonce)[1]); | 129 ((unsigned *)nonce)[1] = REVW_BE(((unsigned *)nonce)[1]); |
130 nonce[2] = REVW_BE(((unsigned *)nonce)[2]); | 130 ((unsigned *)nonce)[2] = REVW_BE(((unsigned *)nonce)[2]); |
131 nonce[3] = REVW_BE(((unsigned *)nonce)[3]); | 131 ((unsigned *)nonce)[3] = REVW_BE(((unsigned *)nonce)[3]); |
wtc1
2016/01/31 20:00:26
These four lines look wrong. The left-hand side of
ttaubert
2016/02/01 15:49:29
Good spot! Done.
| |
132 kp = (unsigned *)key; | 132 kp = (unsigned *)key; |
133 np = (unsigned *)nonce; | 133 np = (unsigned *)nonce; |
134 #endif | 134 #endif |
135 #if defined(__ARM_NEON__) | 135 #if defined(__ARM_NEON__) |
136 np = (unsigned*) nonce; | 136 np = (unsigned*) nonce; |
137 #endif | 137 #endif |
138 s0 = LOAD(chacha_const); | 138 s0 = LOAD(chacha_const); |
139 s1 = LOAD(&((vec*)kp)[0]); | 139 s1 = LOAD(&((vec*)kp)[0]); |
140 s2 = LOAD(&((vec*)kp)[1]); | 140 s2 = LOAD(&((vec*)kp)[1]); |
141 s3 = (vec) { | 141 s3 = (vec) { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 } | 269 } |
270 } else { | 270 } else { |
271 buf[0] = REVV_BE(v0 + s0); | 271 buf[0] = REVV_BE(v0 + s0); |
272 } | 272 } |
273 | 273 |
274 for (i=inlen & ~15; i<inlen; i++) { | 274 for (i=inlen & ~15; i<inlen; i++) { |
275 ((char *)op)[i] = ((char *)ip)[i] ^ ((char *)buf)[i]; | 275 ((char *)op)[i] = ((char *)ip)[i] ^ ((char *)buf)[i]; |
276 } | 276 } |
277 } | 277 } |
278 } | 278 } |
LEFT | RIGHT |