diff options
author | lloyd <[email protected]> | 2010-09-13 20:53:31 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-09-13 20:53:31 +0000 |
commit | 4fe8a34f1869805d9115f39cad53d1fd7f7eb6c4 (patch) | |
tree | 2ff6c30d1a7d5f2244b6f1b459a5ea10b6d43fe0 /src/stream | |
parent | 36bfef27271eadffefbc6891a9d7fa7eed7b1e10 (diff) |
Remove more uses of vector to pointer implicit conversions
Diffstat (limited to 'src/stream')
-rw-r--r-- | src/stream/ctr/ctr.cpp | 2 | ||||
-rw-r--r-- | src/stream/salsa20/salsa20.cpp | 6 | ||||
-rw-r--r-- | src/stream/turing/turing.cpp | 28 | ||||
-rw-r--r-- | src/stream/wid_wake/wid_wake.cpp | 8 |
4 files changed, 22 insertions, 22 deletions
diff --git a/src/stream/ctr/ctr.cpp b/src/stream/ctr/ctr.cpp index 6162a76a0..66af28a15 100644 --- a/src/stream/ctr/ctr.cpp +++ b/src/stream/ctr/ctr.cpp @@ -121,7 +121,7 @@ void CTR_BE::increment_counter() for(u32bit i = 0; i != PARALLEL_BLOCKS; ++i) { - byte* this_ctr = counter + i*permutation->BLOCK_SIZE; + byte* this_ctr = &counter[i * permutation->BLOCK_SIZE]; byte last_byte = this_ctr[permutation->BLOCK_SIZE-1]; last_byte += PARALLEL_BLOCKS; diff --git a/src/stream/salsa20/salsa20.cpp b/src/stream/salsa20/salsa20.cpp index c52e305d1..58626fb2f 100644 --- a/src/stream/salsa20/salsa20.cpp +++ b/src/stream/salsa20/salsa20.cpp @@ -109,7 +109,7 @@ void Salsa20::cipher(const byte in[], byte out[], u32bit length) length -= (buffer.size() - position); in += (buffer.size() - position); out += (buffer.size() - position); - salsa20(&buffer[0], state); + salsa20(&buffer[0], &state[0]); ++state[8]; if(!state[8]) // if overflow in state[8] @@ -194,7 +194,7 @@ void Salsa20::set_iv(const byte iv[], u32bit length) state[9] = load_le<u32bit>(iv, 3); SecureVector<u32bit> hsalsa(8); - hsalsa20(hsalsa, state); + hsalsa20(&hsalsa[0], &state[0]); state[ 1] = hsalsa[0]; state[ 2] = hsalsa[1]; @@ -211,7 +211,7 @@ void Salsa20::set_iv(const byte iv[], u32bit length) state[8] = 0; state[9] = 0; - salsa20(&buffer[0], state); + salsa20(&buffer[0], &state[0]); ++state[8]; if(!state[8]) // if overflow in state[8] ++state[9]; // carry to state[9] diff --git a/src/stream/turing/turing.cpp b/src/stream/turing/turing.cpp index c53b666ad..9fa38d863 100644 --- a/src/stream/turing/turing.cpp +++ b/src/stream/turing/turing.cpp @@ -17,17 +17,17 @@ namespace { /* * Perform an N-way PHT */ -inline void PHT(u32bit buf[], u32bit buf_size) +inline void PHT(MemoryRegion<u32bit>& B) { u32bit sum = 0; - for(u32bit i = 0; i < buf_size - 1; ++i) - sum += buf[i]; + for(u32bit i = 0; i < B.size() - 1; ++i) + sum += B[i]; - buf[buf_size-1] += sum; + B[B.size()-1] += sum; - sum = buf[buf_size-1]; - for(u32bit i = 0; i < buf_size - 1; ++i) - buf[i] += sum; + sum = B[B.size()-1]; + for(u32bit i = 0; i < B.size() - 1; ++i) + B[i] += sum; } } @@ -195,11 +195,11 @@ void Turing::generate() C += R9; D += R5; - store_be(A, buffer + 20*j + 0); - store_be(B, buffer + 20*j + 4); - store_be(C, buffer + 20*j + 8); - store_be(D, buffer + 20*j + 12); - store_be(E, buffer + 20*j + 16); + store_be(A, &buffer[20*j + 0]); + store_be(B, &buffer[20*j + 4]); + store_be(C, &buffer[20*j + 8]); + store_be(D, &buffer[20*j + 12]); + store_be(E, &buffer[20*j + 16]); } position = 0; @@ -232,7 +232,7 @@ void Turing::key_schedule(const byte key[], u32bit length) for(u32bit j = 0; j != K.size(); ++j) K[j] = fixedS(K[j]); - PHT(K, K.size()); + PHT(K); for(u32bit i = 0; i != 256; ++i) { @@ -290,7 +290,7 @@ void Turing::set_iv(const byte iv[], u32bit length) S2[get_byte(2, W)] ^ S3[get_byte(3, W)]; } - PHT(R, 17); + PHT(R); generate(); } diff --git a/src/stream/wid_wake/wid_wake.cpp b/src/stream/wid_wake/wid_wake.cpp index f5897f1cc..17b0df557 100644 --- a/src/stream/wid_wake/wid_wake.cpp +++ b/src/stream/wid_wake/wid_wake.cpp @@ -18,13 +18,13 @@ void WiderWake_41_BE::cipher(const byte in[], byte out[], u32bit length) { while(length >= buffer.size() - position) { - xor_buf(out, in, buffer + position, buffer.size() - position); + xor_buf(out, in, &buffer[position], buffer.size() - position); length -= (buffer.size() - position); in += (buffer.size() - position); out += (buffer.size() - position); generate(buffer.size()); } - xor_buf(out, in, buffer + position, length); + xor_buf(out, in, &buffer[position], length); position += length; } @@ -41,7 +41,7 @@ void WiderWake_41_BE::generate(u32bit length) { u32bit R0a; - store_be(R3, buffer + j); + store_be(R3, &buffer[j]); R0a = R4 + R3; R3 += R2; R2 += R1; R1 += R0; R0a = (R0a >> 8) ^ T[(R0a & 0xFF)]; @@ -50,7 +50,7 @@ void WiderWake_41_BE::generate(u32bit length) R3 = (R3 >> 8) ^ T[(R3 & 0xFF)]; R4 = R0; R0 = R0a; - store_be(R3, buffer + j + 4); + store_be(R3, &buffer[j + 4]); R0a = R4 + R3; R3 += R2; R2 += R1; R1 += R0; R0a = (R0a >> 8) ^ T[(R0a & 0xFF)]; |