aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-09-14 02:27:02 +0000
committerlloyd <[email protected]>2010-09-14 02:27:02 +0000
commitd472ea829a530fd6995293904d4f07a7ef8b5472 (patch)
tree3b1fd3913aa1b223444753cb39e973d5753f3b4b /src
parent77a33b0c16880884cc0326e92c0c30d0e8444a91 (diff)
Remove more implicit vector to pointer conversions
Diffstat (limited to 'src')
-rw-r--r--src/block/lubyrack/lubyrack.cpp22
-rw-r--r--src/filters/base64/base64.cpp20
-rw-r--r--src/filters/modes/cfb/cfb.cpp8
-rw-r--r--src/filters/modes/eax/eax.cpp4
-rw-r--r--src/filters/modes/eax/eax_dec.cpp8
-rw-r--r--src/filters/modes/xts/xts.cpp4
-rw-r--r--src/mac/cbc_mac/cbc_mac.cpp2
-rw-r--r--src/pbkdf/pbkdf2/pbkdf2.cpp7
-rw-r--r--src/pbkdf/pgps2k/pgp_s2k.cpp2
-rw-r--r--src/pubkey/dlies/dlies.cpp8
-rw-r--r--src/rng/x931_rng/x931_rng.cpp10
-rw-r--r--src/ssl/cert_req.cpp2
12 files changed, 49 insertions, 48 deletions
diff --git a/src/block/lubyrack/lubyrack.cpp b/src/block/lubyrack/lubyrack.cpp
index 99f8e6da1..cdaff1b1e 100644
--- a/src/block/lubyrack/lubyrack.cpp
+++ b/src/block/lubyrack/lubyrack.cpp
@@ -17,28 +17,29 @@ void LubyRackoff::encrypt_n(const byte in[], byte out[], u32bit blocks) const
{
const u32bit len = hash->OUTPUT_LENGTH;
- SecureVector<byte> buffer(len);
+ SecureVector<byte> buffer_vec(len);
+ byte* buffer = &buffer_vec[0];
for(u32bit i = 0; i != blocks; ++i)
{
hash->update(K1);
hash->update(in, len);
- hash->final(&buffer[0]);
+ hash->final(buffer);
xor_buf(out + len, in + len, buffer, len);
hash->update(K2);
hash->update(out + len, len);
- hash->final(&buffer[0]);
+ hash->final(buffer);
xor_buf(out, in, buffer, len);
hash->update(K1);
hash->update(out, len);
- hash->final(&buffer[0]);
+ hash->final(buffer);
xor_buf(out + len, buffer, len);
hash->update(K2);
hash->update(out + len, len);
- hash->final(&buffer[0]);
+ hash->final(buffer);
xor_buf(out, buffer, len);
in += BLOCK_SIZE;
@@ -53,28 +54,29 @@ void LubyRackoff::decrypt_n(const byte in[], byte out[], u32bit blocks) const
{
const u32bit len = hash->OUTPUT_LENGTH;
- SecureVector<byte> buffer(len);
+ SecureVector<byte> buffer_vec(len);
+ byte* buffer = &buffer_vec[0];
for(u32bit i = 0; i != blocks; ++i)
{
hash->update(K2);
hash->update(in + len, len);
- hash->final(&buffer[0]);
+ hash->final(buffer);
xor_buf(out, in, buffer, len);
hash->update(K1);
hash->update(out, len);
- hash->final(&buffer[0]);
+ hash->final(buffer);
xor_buf(out + len, in + len, buffer, len);
hash->update(K2);
hash->update(out + len, len);
- hash->final(&buffer[0]);
+ hash->final(buffer);
xor_buf(out, buffer, len);
hash->update(K1);
hash->update(out, len);
- hash->final(&buffer[0]);
+ hash->final(buffer);
xor_buf(out + len, buffer, len);
in += BLOCK_SIZE;
diff --git a/src/filters/base64/base64.cpp b/src/filters/base64/base64.cpp
index 5f365ca5a..134e42dd6 100644
--- a/src/filters/base64/base64.cpp
+++ b/src/filters/base64/base64.cpp
@@ -42,8 +42,8 @@ void Base64_Encoder::encode_and_send(const byte block[], u32bit length)
{
for(u32bit j = 0; j != length; j += 3)
{
- encode(block + j, out);
- do_output(out, 4);
+ encode(block + j, &out[0]);
+ do_output(&out[0], 4);
}
}
@@ -81,7 +81,7 @@ void Base64_Encoder::write(const byte input[], u32bit length)
in.copy(position, input, length);
if(position + length >= in.size())
{
- encode_and_send(in, in.size());
+ encode_and_send(&in[0], in.size());
input += (in.size() - position);
length -= (in.size() - position);
while(length >= in.size())
@@ -103,14 +103,14 @@ void Base64_Encoder::end_msg()
{
u32bit start_of_last_block = 3 * (position / 3),
left_over = position % 3;
- encode_and_send(in, start_of_last_block);
+ encode_and_send(&in[0], start_of_last_block);
if(left_over)
{
SecureVector<byte> remainder(3);
copy_mem(&remainder[0], &in[start_of_last_block], left_over);
- encode(remainder, out);
+ encode(&remainder[0], &out[0]);
u32bit empty_bits = 8 * (3 - left_over), index = 4 - 1;
while(empty_bits >= 8)
@@ -119,7 +119,7 @@ void Base64_Encoder::end_msg()
empty_bits -= 6;
}
- do_output(out, 4);
+ do_output(&out[0], 4);
}
if(trailing_newline || (counter && line_length))
@@ -163,7 +163,7 @@ void Base64_Decoder::decode_and_send(const byte block[], u32bit length)
{
for(u32bit j = 0; j != length; j += 4)
{
- decode(block + j, out);
+ decode(block + j, &out[0]);
send(out, 3);
}
}
@@ -199,7 +199,7 @@ void Base64_Decoder::write(const byte input[], u32bit length)
if(position == in.size())
{
- decode_and_send(in, in.size());
+ decode_and_send(&in[0], in.size());
position = 0;
}
}
@@ -214,13 +214,13 @@ void Base64_Decoder::end_msg()
{
u32bit start_of_last_block = 4 * (position / 4),
left_over = position % 4;
- decode_and_send(in, start_of_last_block);
+ decode_and_send(&in[0], start_of_last_block);
if(left_over)
{
SecureVector<byte> remainder(4);
copy_mem(&remainder[0], &in[start_of_last_block], left_over);
- decode(remainder, out);
+ decode(&remainder[0], &out[0]);
send(out, ((left_over == 1) ? (1) : (left_over - 1)));
}
}
diff --git a/src/filters/modes/cfb/cfb.cpp b/src/filters/modes/cfb/cfb.cpp
index 9ec4c5de3..fc1490b30 100644
--- a/src/filters/modes/cfb/cfb.cpp
+++ b/src/filters/modes/cfb/cfb.cpp
@@ -72,8 +72,8 @@ void CFB_Encryption::write(const byte input[], u32bit length)
while(length)
{
u32bit xored = std::min(feedback - position, length);
- xor_buf(buffer + position, input, xored);
- send(buffer + position, xored);
+ xor_buf(&buffer[position], input, xored);
+ send(&buffer[position], xored);
input += xored;
length -= xored;
position += xored;
@@ -149,8 +149,8 @@ void CFB_Decryption::write(const byte input[], u32bit length)
while(length)
{
u32bit xored = std::min(feedback - position, length);
- xor_buf(buffer + position, input, xored);
- send(buffer + position, xored);
+ xor_buf(&buffer[position], input, xored);
+ send(&buffer[position], xored);
buffer.copy(position, input, xored);
input += xored;
length -= xored;
diff --git a/src/filters/modes/eax/eax.cpp b/src/filters/modes/eax/eax.cpp
index aa1fce507..89ba8edcd 100644
--- a/src/filters/modes/eax/eax.cpp
+++ b/src/filters/modes/eax/eax.cpp
@@ -117,8 +117,8 @@ void EAX_Encryption::write(const byte input[], u32bit length)
{
u32bit copied = std::min<u32bit>(length, ctr_buf.size());
- ctr->cipher(input, ctr_buf, copied);
- cmac->update(ctr_buf, copied);
+ ctr->cipher(input, &ctr_buf[0], copied);
+ cmac->update(&ctr_buf[0], copied);
send(ctr_buf, copied);
input += copied;
diff --git a/src/filters/modes/eax/eax_dec.cpp b/src/filters/modes/eax/eax_dec.cpp
index 71b676ae3..96e19efe4 100644
--- a/src/filters/modes/eax/eax_dec.cpp
+++ b/src/filters/modes/eax/eax_dec.cpp
@@ -55,7 +55,7 @@ void EAX_Decryption::write(const byte input[], u32bit length)
while((queue_end - queue_start) > TAG_SIZE)
{
u32bit removed = (queue_end - queue_start) - TAG_SIZE;
- do_write(queue + queue_start, removed);
+ do_write(&queue[queue_start], removed);
queue_start += removed;
}
@@ -63,8 +63,8 @@ void EAX_Decryption::write(const byte input[], u32bit length)
queue_start >= queue.size() / 2)
{
SecureVector<byte> queue_data(TAG_SIZE);
- queue_data.copy(queue + queue_start, TAG_SIZE);
- queue.copy(queue_data, TAG_SIZE);
+ queue_data.copy(&queue[queue_start], TAG_SIZE);
+ queue.copy(&queue_data[0], TAG_SIZE);
queue_start = 0;
queue_end = TAG_SIZE;
}
@@ -85,7 +85,7 @@ void EAX_Decryption::do_write(const byte input[], u32bit length)
help cache locality.
*/
cmac->update(input, copied);
- ctr->cipher(input, ctr_buf, copied);
+ ctr->cipher(input, &ctr_buf[0], copied);
send(ctr_buf, copied);
input += copied;
length -= copied;
diff --git a/src/filters/modes/xts/xts.cpp b/src/filters/modes/xts/xts.cpp
index e40dd3cf5..54d043d58 100644
--- a/src/filters/modes/xts/xts.cpp
+++ b/src/filters/modes/xts/xts.cpp
@@ -198,7 +198,7 @@ void XTS_Encryption::buffered_final(const byte input[], u32bit length)
cipher->encrypt(temp);
xor_buf(temp, tweak, cipher->BLOCK_SIZE);
- poly_double(tweak, cipher->BLOCK_SIZE);
+ poly_double(&tweak[0], cipher->BLOCK_SIZE);
for(u32bit i = 0; i != length - cipher->BLOCK_SIZE; ++i)
std::swap(temp[i], temp[i + cipher->BLOCK_SIZE]);
@@ -364,7 +364,7 @@ void XTS_Decryption::buffered_final(const byte input[], u32bit length)
SecureVector<byte> temp(input, length);
SecureVector<byte> tweak_copy(&tweak[0], cipher->BLOCK_SIZE);
- poly_double(tweak_copy, cipher->BLOCK_SIZE);
+ poly_double(&tweak_copy[0], cipher->BLOCK_SIZE);
xor_buf(temp, tweak_copy, cipher->BLOCK_SIZE);
cipher->decrypt(temp);
diff --git a/src/mac/cbc_mac/cbc_mac.cpp b/src/mac/cbc_mac/cbc_mac.cpp
index 387737eac..5b9708d41 100644
--- a/src/mac/cbc_mac/cbc_mac.cpp
+++ b/src/mac/cbc_mac/cbc_mac.cpp
@@ -17,7 +17,7 @@ namespace Botan {
void CBC_MAC::add_data(const byte input[], u32bit length)
{
u32bit xored = std::min(OUTPUT_LENGTH - position, length);
- xor_buf(state + position, input, xored);
+ xor_buf(&state[position], input, xored);
position += xored;
if(position < OUTPUT_LENGTH)
diff --git a/src/pbkdf/pbkdf2/pbkdf2.cpp b/src/pbkdf/pbkdf2/pbkdf2.cpp
index d234fa7f0..b1c7b2e07 100644
--- a/src/pbkdf/pbkdf2/pbkdf2.cpp
+++ b/src/pbkdf/pbkdf2/pbkdf2.cpp
@@ -37,22 +37,23 @@ OctetString PKCS5_PBKDF2::derive_key(u32bit key_len,
byte* T = &key[0];
+ SecureVector<byte> U(mac->OUTPUT_LENGTH);
+
u32bit counter = 1;
while(key_len)
{
u32bit T_size = std::min(mac->OUTPUT_LENGTH, key_len);
- SecureVector<byte> U(mac->OUTPUT_LENGTH);
mac->update(salt, salt_size);
for(u32bit j = 0; j != 4; ++j)
mac->update(get_byte(j, counter));
- mac->final(U);
+ mac->final(&U[0]);
xor_buf(T, U, T_size);
for(u32bit j = 1; j != iterations; ++j)
{
mac->update(U);
- mac->final(U);
+ mac->final(&U[0]);
xor_buf(T, U, T_size);
}
diff --git a/src/pbkdf/pgps2k/pgp_s2k.cpp b/src/pbkdf/pgps2k/pgp_s2k.cpp
index db18adaf1..8ad8592c4 100644
--- a/src/pbkdf/pgps2k/pgp_s2k.cpp
+++ b/src/pbkdf/pgps2k/pgp_s2k.cpp
@@ -46,7 +46,7 @@ OctetString OpenPGP_S2K::derive_key(u32bit key_len,
}
hash_buf = hash->final();
- key.copy(generated, hash_buf, hash->OUTPUT_LENGTH);
+ key.copy(generated, &hash_buf[0], hash->OUTPUT_LENGTH);
generated += hash->OUTPUT_LENGTH;
++pass;
}
diff --git a/src/pubkey/dlies/dlies.cpp b/src/pubkey/dlies/dlies.cpp
index 5dd557b6f..f53aa71f9 100644
--- a/src/pubkey/dlies/dlies.cpp
+++ b/src/pubkey/dlies/dlies.cpp
@@ -43,18 +43,18 @@ SecureVector<byte> DLIES_Encryptor::enc(const byte in[], u32bit length,
throw Invalid_State("DLIES: The other key was never set");
SecureVector<byte> out(my_key.size() + length + mac->OUTPUT_LENGTH);
- out.copy(my_key, my_key.size());
+ out.copy(&my_key[0], my_key.size());
out.copy(my_key.size(), in, length);
SecureVector<byte> vz = my_key;
vz.append(ka.derive_key(0, other_key).bits_of());
const u32bit K_LENGTH = length + mac_keylen;
- OctetString K = kdf->derive_key(K_LENGTH, vz, vz.size());
+ OctetString K = kdf->derive_key(K_LENGTH, vz);
if(K.length() != K_LENGTH)
throw Encoding_Error("DLIES: KDF did not provide sufficient output");
- byte* C = out + my_key.size();
+ byte* C = &out[my_key.size()];
xor_buf(C, K.begin() + mac_keylen, length);
mac->set_key(K.begin(), mac_keylen);
@@ -123,7 +123,7 @@ SecureVector<byte> DLIES_Decryptor::dec(const byte msg[], u32bit length) const
vz.append(ka.derive_key(0, v).bits_of());
const u32bit K_LENGTH = C.size() + mac_keylen;
- OctetString K = kdf->derive_key(K_LENGTH, vz, vz.size());
+ OctetString K = kdf->derive_key(K_LENGTH, vz);
if(K.length() != K_LENGTH)
throw Encoding_Error("DLIES: KDF did not provide sufficient output");
diff --git a/src/rng/x931_rng/x931_rng.cpp b/src/rng/x931_rng/x931_rng.cpp
index ddb7c138c..1d5e57f6e 100644
--- a/src/rng/x931_rng/x931_rng.cpp
+++ b/src/rng/x931_rng/x931_rng.cpp
@@ -41,10 +41,10 @@ void ANSI_X931_RNG::update_buffer()
SecureVector<byte> DT = prng->random_vec(cipher->BLOCK_SIZE);
cipher->encrypt(DT);
- xor_buf(R, V, DT, cipher->BLOCK_SIZE);
+ xor_buf(&R[0], &V[0], &DT[0], cipher->BLOCK_SIZE);
cipher->encrypt(R);
- xor_buf(V, R, DT, cipher->BLOCK_SIZE);
+ xor_buf(&V[0], &R[0], &DT[0], cipher->BLOCK_SIZE);
cipher->encrypt(V);
position = 0;
@@ -57,13 +57,11 @@ void ANSI_X931_RNG::rekey()
{
if(prng->is_seeded())
{
- SecureVector<byte> key(cipher->MAXIMUM_KEYLENGTH);
- prng->randomize(key, key.size());
- cipher->set_key(key, key.size());
+ cipher->set_key(prng->random_vec(cipher->MAXIMUM_KEYLENGTH));
if(V.size() != cipher->BLOCK_SIZE)
V.resize(cipher->BLOCK_SIZE);
- prng->randomize(V, V.size());
+ prng->randomize(&V[0], V.size());
update_buffer();
}
diff --git a/src/ssl/cert_req.cpp b/src/ssl/cert_req.cpp
index 7a7e6eed9..7a32af03b 100644
--- a/src/ssl/cert_req.cpp
+++ b/src/ssl/cert_req.cpp
@@ -131,7 +131,7 @@ void Certificate::deserialize(const MemoryRegion<byte>& buf)
u32bit total_size = make_u32bit(0, buf[0], buf[1], buf[2]);
SecureQueue queue;
- queue.write(buf + 3, buf.size() - 3);
+ queue.write(&buf[3], buf.size() - 3);
if(queue.size() != total_size)
throw Decoding_Error("Certificate: Message malformed");