Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Replace memcpy with memmove, non-ambiguous copy |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
a90f1eb37d2b65a8cd4b201e93b8c0d7 |
User & Date: | bernd 2019-03-09 13:56:49.846 |
Context
2019-03-09
| ||
14:41 | Replace memcpy with memmove, non-ambiguous copy, bump related versions check-in: 770a5861c6 user: bernd tags: trunk | |
13:56 | Replace memcpy with memmove, non-ambiguous copy check-in: a90f1eb37d user: bernd tags: trunk | |
12:11 | Markdown edits check-in: 385b2a8aa4 user: bernd tags: trunk | |
Changes
Changes to keccak/KeccakF-1600-neon.c.
︙ | ︙ | |||
29 30 31 32 33 34 35 | void KeccakInitialize() { } void KeccakExtract(keccak_state state, UINT64 *data, int byteCount) { | | | | | | | | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | void KeccakInitialize() { } void KeccakExtract(keccak_state state, UINT64 *data, int byteCount) { memmove(data, state, byteCount); } void KeccakAbsorb(keccak_state state, UINT64 *data, int byteCount) { int i; keccak_state datai; memmove(datai, data, byteCount); for(i=0; i<byteCount-7; i+=8) { state[i>>3] ^= datai[i>>3]; } if(byteCount & 7) { UINT64 m = 0xffffffffffffffffull >> ((8-byteCount) & 7)*8; state[i>>3] ^= datai[i>>3] & m; } } void KeccakEncrypt(keccak_state state, UINT64 *data, int byteCount) { int i; keccak_state datai; memmove(datai, data, byteCount); for(i=0; i<byteCount-7; i+=8) { datai[i>>3] = state[i>>3] ^= datai[i>>3]; } if(byteCount & 7) { UINT64 m = 0xffffffffffffffffull >> ((8-byteCount) & 7)*8; state[i>>3] ^= datai[i>>3] & m; datai[i>>3] = state[i>>3]; } memmove(data, datai, byteCount); } void KeccakDecrypt(keccak_state state, UINT64 *data, int byteCount) { int i; UINT64 tmp; keccak_state datai; memmove(datai, data, byteCount); for(i=0; i<byteCount-7; i+=8) { tmp = datai[i>>3] ^ state[i>>3]; state[i>>3] = datai[i>>3]; datai[i>>3] = tmp; } if(byteCount & 7) { UINT64 m = 0xffffffffffffffffull >> ((8-byteCount) & 7)*8; tmp = datai[i>>3] ^ state[i>>3]; state[i>>3] = (datai[i>>3] & m) | (state[i>>3] & ~m); datai[i>>3] = tmp; } memmove(data, datai, byteCount); } |
Changes to keccak/KeccakF-1600-opt32.c.
︙ | ︙ | |||
79 80 81 82 83 84 85 | void xorLanesIntoState(int byteCount, UINT32* state, UINT8* input) { int i; UINT64 tmp=0; for(i=0; i<(byteCount-7); i+=8) xor8bytesIntoInterleavedWords(state+(i>>2), state+(i>>2)+1, input+i); if(byteCount & 7) { | | | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | void xorLanesIntoState(int byteCount, UINT32* state, UINT8* input) { int i; UINT64 tmp=0; for(i=0; i<(byteCount-7); i+=8) xor8bytesIntoInterleavedWords(state+(i>>2), state+(i>>2)+1, input+i); if(byteCount & 7) { memmove(&tmp, input+i, byteCount & 7); xor8bytesIntoInterleavedWords(state+(i>>2), state+(i>>2)+1, (UINT8*)&tmp); } } void setInterleavedWordsInto8bytes(UINT8* dest, UINT32 even, UINT32 odd) { UINT16 d0, d1, d2, d3; |
︙ | ︙ | |||
102 103 104 105 106 107 108 | { int i; UINT64 tmp=0; for(i=0; i<(byteCount-7); i+=8) { setInterleavedWordsInto8bytes(data+i, state[i>>2], state[(i>>2)+1]); } setInterleavedWordsInto8bytes(&tmp, state[i>>2], state[(i>>2)+1]); | | | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | { int i; UINT64 tmp=0; for(i=0; i<(byteCount-7); i+=8) { setInterleavedWordsInto8bytes(data+i, state[i>>2], state[(i>>2)+1]); } setInterleavedWordsInto8bytes(&tmp, state[i>>2], state[(i>>2)+1]); memmove(data+i, &tmp, byteCount & 7); } #else // No interleaving tables #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN) // Credit: Henry S. Warren, Hacker's Delight, Addison-Wesley, 2002 |
︙ | ︙ | |||
192 193 194 195 196 197 198 | void xorLanesIntoState(int byteCount, UINT8* state, UINT8 *input) { int i; UINT64 tmp=0; for(i=0; i<(byteCount-7); i+=8) xor8bytesIntoInterleavedWords((UINT32*)(state+i), (UINT32*)(input+i)); if(byteCount & 7) { | | | 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | void xorLanesIntoState(int byteCount, UINT8* state, UINT8 *input) { int i; UINT64 tmp=0; for(i=0; i<(byteCount-7); i+=8) xor8bytesIntoInterleavedWords((UINT32*)(state+i), (UINT32*)(input+i)); if(byteCount & 7) { memmove(&tmp, input+i, byteCount & 7); xor8bytesIntoInterleavedWords((UINT32*)(state+i), (UINT32*)&tmp); } } #endif // Endianness // Credit: Henry S. Warren, Hacker's Delight, Addison-Wesley, 2002 |
︙ | ︙ | |||
239 240 241 242 243 244 245 | void extractLanes(int byteCount, UINT32* state, UINT8 *data) { int i; UINT64 tmp=0; for(i=0; i<(byteCount-7); i+=8) { setInterleavedWordsInto8bytes(data+i, state+(i>>2)); } setInterleavedWordsInto8bytes((UINT8*)&tmp, state+(i>>2)); | | | 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | void extractLanes(int byteCount, UINT32* state, UINT8 *data) { int i; UINT64 tmp=0; for(i=0; i<(byteCount-7); i+=8) { setInterleavedWordsInto8bytes(data+i, state+(i>>2)); } setInterleavedWordsInto8bytes((UINT8*)&tmp, state+(i>>2)); memmove(data+i, (UINT8*)&tmp, byteCount & 7); } #endif // With or without interleaving tables #if defined(_MSC_VER) #define ROL32(a, offset) _rotl(a, offset) #elif (defined (__arm__) && defined(__ARMCC_VERSION)) |
︙ | ︙ |
Changes to keccak/KeccakF-1600-opt64.c.
︙ | ︙ | |||
220 221 222 223 224 225 226 | { } void KeccakExtract(keccak_state state, UINT64 *data, int byteCount) { UINT64 m = ~(UINT64)0; #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN) | | | 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | { } void KeccakExtract(keccak_state state, UINT64 *data, int byteCount) { UINT64 m = ~(UINT64)0; #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN) memmove(data, state, byteCount); #else int i; for(i=0; i<byteCount-7; i+=8) fromWordToBytes(data+(i>>3), ((const UINT64*)state)[i>>3]); #endif #ifdef UseBebigokimisa |
︙ | ︙ |
Changes to threefish/threefish.c.
︙ | ︙ | |||
134 135 136 137 138 139 140 | switch(flags & 3) { case 2: // Bernd mode, fall through to ECB mode for (i=0; i<4; i++) { ctx->key[i] ^= X[i] ^ p[i]; } case 0: // ECB mode | | | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | switch(flags & 3) { case 2: // Bernd mode, fall through to ECB mode for (i=0; i<4; i++) { ctx->key[i] ^= X[i] ^ p[i]; } case 0: // ECB mode memmove(out, X, 32); break; case 1: // SKEIN mode for (i=0; i<4; i++) { out[i] = X[i] ^ p[i]; } break; default: break; } |
︙ | ︙ | |||
192 193 194 195 196 197 198 | switch(flags & 3) { case 2: // Bernd mode, fall through to ECB mode for (i=0; i<8; i++) { ctx->key[i] ^= X[i] ^ p[i]; } case 0: // ECB mode | | | 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | switch(flags & 3) { case 2: // Bernd mode, fall through to ECB mode for (i=0; i<8; i++) { ctx->key[i] ^= X[i] ^ p[i]; } case 0: // ECB mode memmove(out, X, 64); break; case 1: // SKEIN mode for (i=0; i<8; i++) { out[i] = X[i] ^ p[i]; } break; default: break; } |
︙ | ︙ | |||
232 233 234 235 236 237 238 | if(flags & 8) { tf_prep_256(ctx); } if(flags & 4) { tf_tweak_256(ctx); } | | | | 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | if(flags & 8) { tf_prep_256(ctx); } if(flags & 4) { tf_tweak_256(ctx); } memmove(X, c, 32); /* The rounds: */ ROUNDD_256(18); ROUNDD_256(17); ROUNDD_256(16); ROUNDD_256(15); ROUNDD_256(14); ROUNDD_256(13); ROUNDD_256(12); ROUNDD_256(11); ROUNDD_256(10); ROUNDD_256(9); ROUNDD_256(8); ROUNDD_256(7); ROUNDD_256(6); ROUNDD_256(5); ROUNDD_256(4); ROUNDD_256(3); ROUNDD_256(2); ROUNDD_256(1); for (i=0; i<4; i++) { X[i] -= ctx->key[i]; } X[1] -= ctx->tweak[0]; X[2] -= ctx->tweak[1]; switch(flags & 3) { case 2: // Bernd mode, fall through to ECB mode for (i=0; i<4; i++) { ctx->key[i] ^= X[i] ^ c[i]; } case 0: // ECB mode memmove(out, X, 32); break; default: break; } } #define PERMUTD_512(i) \ m = tf_perm_512[2*i]; \ |
︙ | ︙ | |||
289 290 291 292 293 294 295 | if(flags & 8) { tf_prep_512(ctx); } if(flags & 4) { tf_tweak_512(ctx); } | | | | 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | if(flags & 8) { tf_prep_512(ctx); } if(flags & 4) { tf_tweak_512(ctx); } memmove(X, c, 64); /* The rounds: */ ROUNDD_512(18); ROUNDD_512(17); ROUNDD_512(16); ROUNDD_512(15); ROUNDD_512(14); ROUNDD_512(13); ROUNDD_512(12); ROUNDD_512(11); ROUNDD_512(10); ROUNDD_512(9); ROUNDD_512(8); ROUNDD_512(7); ROUNDD_512(6); ROUNDD_512(5); ROUNDD_512(4); ROUNDD_512(3); ROUNDD_512(2); ROUNDD_512(1); for (i=0; i<8; i++) { X[i] -= ctx->key[i]; } X[5] -= ctx->tweak[0]; X[6] -= ctx->tweak[1]; switch(flags & 3) { case 2: // Bernd mode, fall through to ECB mode for (i=0; i<8; i++) { ctx->key[i] ^= X[i] ^ c[i]; } case 0: // ECB mode memmove(out, X, 64); break; default: break; } } |