aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-09-14 02:05:05 +0000
committerlloyd <[email protected]>2010-09-14 02:05:05 +0000
commit77a33b0c16880884cc0326e92c0c30d0e8444a91 (patch)
treedf2d917b312abb79c8654558399521366dbb2d14
parent59a9b0ef260b010606edc3384035b6aa12dd6415 (diff)
More changes to avoid vector to pointer implicit conversions
-rw-r--r--src/codec/pem/pem.cpp4
-rw-r--r--src/constructs/tss/tss.cpp4
-rw-r--r--src/filters/secqueue.cpp10
-rw-r--r--src/hash/bmw/bmw_512.cpp4
-rw-r--r--src/kdf/kdf2/kdf2.cpp2
-rw-r--r--src/kdf/ssl_prf/prf_ssl3.cpp2
-rw-r--r--src/kdf/tls_prf/prf_tls.cpp19
-rw-r--r--src/math/bigint/big_code.cpp10
-rw-r--r--src/math/bigint/big_rand.cpp2
-rw-r--r--src/pbe/pbes1/pbes1.cpp2
-rw-r--r--src/pbe/pbes2/pbes2.cpp2
-rw-r--r--src/pbkdf/pbkdf1/pbkdf1.cpp4
-rw-r--r--src/pubkey/nr/nr.cpp4
-rw-r--r--src/pubkey/pkcs8.cpp2
-rw-r--r--src/rng/hmac_rng/hmac_rng.cpp6
-rw-r--r--src/rng/randpool/randpool.cpp10
-rw-r--r--src/ssl/rec_wri.cpp4
-rw-r--r--src/ssl/s_kex.cpp2
-rw-r--r--src/ssl/tls_client.cpp6
-rw-r--r--src/ssl/tls_server.cpp6
-rw-r--r--src/stream/ctr/ctr.cpp4
21 files changed, 55 insertions, 54 deletions
diff --git a/src/codec/pem/pem.cpp b/src/codec/pem/pem.cpp
index 5141bee21..1fe5910f3 100644
--- a/src/codec/pem/pem.cpp
+++ b/src/codec/pem/pem.cpp
@@ -33,7 +33,7 @@ std::string encode(const byte der[], u32bit length, const std::string& label,
std::string encode(const MemoryRegion<byte>& data, const std::string& label,
u32bit width)
{
- return encode(data, data.size(), label, width);
+ return encode(&data[0], data.size(), label, width);
}
/*
@@ -119,7 +119,7 @@ bool matches(DataSource& source, const std::string& extra,
const std::string PEM_HEADER = "-----BEGIN " + extra;
SecureVector<byte> search_buf(search_range);
- u32bit got = source.peek(search_buf, search_buf.size(), 0);
+ u32bit got = source.peek(&search_buf[0], search_buf.size(), 0);
if(got < PEM_HEADER.length())
return false;
diff --git a/src/constructs/tss/tss.cpp b/src/constructs/tss/tss.cpp
index 49ee4ddb3..644e8d857 100644
--- a/src/constructs/tss/tss.cpp
+++ b/src/constructs/tss/tss.cpp
@@ -247,14 +247,14 @@ RTSS_Share::reconstruct(const std::vector<RTSS_Share>& shares)
if(secret.size() != secret_len + hash->OUTPUT_LENGTH)
throw Decoding_Error("Bad length in RTSS output");
- hash->update(secret, secret_len);
+ hash->update(&secret[0], secret_len);
SecureVector<byte> hash_check = hash->final();
if(!same_mem(&hash_check[0],
&secret[secret_len], hash->OUTPUT_LENGTH))
throw Decoding_Error("RTSS hash check failed");
- return SecureVector<byte>(secret, secret_len);
+ return SecureVector<byte>(&secret[0], secret_len);
}
}
diff --git a/src/filters/secqueue.cpp b/src/filters/secqueue.cpp
index 0c45e81be..fb3bbf526 100644
--- a/src/filters/secqueue.cpp
+++ b/src/filters/secqueue.cpp
@@ -24,7 +24,7 @@ class SecureQueueNode
u32bit write(const byte input[], u32bit length)
{
u32bit copied = std::min<u32bit>(length, buffer.size() - end);
- copy_mem(buffer + end, input, copied);
+ copy_mem(&buffer[end], input, copied);
end += copied;
return copied;
}
@@ -32,7 +32,7 @@ class SecureQueueNode
u32bit read(byte output[], u32bit length)
{
u32bit copied = std::min(length, end - start);
- copy_mem(output, buffer + start, copied);
+ copy_mem(output, &buffer[start], copied);
start += copied;
return copied;
}
@@ -42,7 +42,7 @@ class SecureQueueNode
const u32bit left = end - start;
if(offset >= left) return 0;
u32bit copied = std::min(length, left - offset);
- copy_mem(output, buffer + start + offset, copied);
+ copy_mem(output, &buffer[start + offset], copied);
return copied;
}
@@ -75,7 +75,7 @@ SecureQueue::SecureQueue(const SecureQueue& input) :
SecureQueueNode* temp = input.head;
while(temp)
{
- write(temp->buffer + temp->start, temp->end - temp->start);
+ write(&temp->buffer[temp->start], temp->end - temp->start);
temp = temp->next;
}
}
@@ -105,7 +105,7 @@ SecureQueue& SecureQueue::operator=(const SecureQueue& input)
SecureQueueNode* temp = input.head;
while(temp)
{
- write(temp->buffer + temp->start, temp->end - temp->start);
+ write(&temp->buffer[temp->start], temp->end - temp->start);
temp = temp->next;
}
return (*this);
diff --git a/src/hash/bmw/bmw_512.cpp b/src/hash/bmw/bmw_512.cpp
index f511e516b..cfa0eee2c 100644
--- a/src/hash/bmw/bmw_512.cpp
+++ b/src/hash/bmw/bmw_512.cpp
@@ -145,7 +145,7 @@ void BMW_512::compress_n(const byte input[], u32bit blocks)
{
load_le(&M[0], input, M.size());
- BMW_512_compress(H, M, Q);
+ BMW_512_compress(&H[0], &M[0], &Q[0]);
input += HASH_BLOCK_SIZE;
}
@@ -166,7 +166,7 @@ void BMW_512::copy_out(byte output[])
0xAAAAAAAAAAAAAAAC, 0xAAAAAAAAAAAAAAAD,
0xAAAAAAAAAAAAAAAE, 0xAAAAAAAAAAAAAAAF };
- BMW_512_compress(final, H, Q);
+ BMW_512_compress(final, &H[0], &Q[0]);
for(u32bit i = 0; i != OUTPUT_LENGTH; i += 8)
store_le(final[8 + i/8], output + i);
diff --git a/src/kdf/kdf2/kdf2.cpp b/src/kdf/kdf2/kdf2.cpp
index b9e785942..8106ba07d 100644
--- a/src/kdf/kdf2/kdf2.cpp
+++ b/src/kdf/kdf2/kdf2.cpp
@@ -29,7 +29,7 @@ SecureVector<byte> KDF2::derive(u32bit out_len,
SecureVector<byte> hash_result = hash->final();
u32bit added = std::min<u32bit>(hash_result.size(), out_len);
- output.append(hash_result, added);
+ output.append(&hash_result[0], added);
out_len -= added;
++counter;
diff --git a/src/kdf/ssl_prf/prf_ssl3.cpp b/src/kdf/ssl_prf/prf_ssl3.cpp
index 2b67644d2..1d896a63c 100644
--- a/src/kdf/ssl_prf/prf_ssl3.cpp
+++ b/src/kdf/ssl_prf/prf_ssl3.cpp
@@ -39,7 +39,7 @@ OctetString next_hash(u32bit where, u32bit want,
md5.update(sha1_hash);
SecureVector<byte> md5_hash = md5.final();
- return OctetString(md5_hash, want);
+ return OctetString(&md5_hash[0], want);
}
}
diff --git a/src/kdf/tls_prf/prf_tls.cpp b/src/kdf/tls_prf/prf_tls.cpp
index 7345f11c5..fa4552474 100644
--- a/src/kdf/tls_prf/prf_tls.cpp
+++ b/src/kdf/tls_prf/prf_tls.cpp
@@ -18,7 +18,7 @@ namespace {
/*
* TLS PRF P_hash function
*/
-void P_hash(byte output[], u32bit output_len,
+void P_hash(MemoryRegion<byte>& output,
MessageAuthenticationCode* mac,
const byte secret[], u32bit secret_len,
const byte seed[], u32bit seed_len)
@@ -27,10 +27,12 @@ void P_hash(byte output[], u32bit output_len,
SecureVector<byte> A(seed, seed_len);
- while(output_len)
+ u32bit offset = 0;
+
+ while(offset != output.size())
{
const u32bit this_block_len =
- std::min(mac->OUTPUT_LENGTH, output_len);
+ std::min<u32bit>(mac->OUTPUT_LENGTH, output.size() - offset);
A = mac->process(A);
@@ -38,9 +40,8 @@ void P_hash(byte output[], u32bit output_len,
mac->update(seed, seed_len);
SecureVector<byte> block = mac->final();
- xor_buf(output, &block[0], this_block_len);
- output_len -= this_block_len;
- output += this_block_len;
+ xor_buf(&output[offset], &block[0], this_block_len);
+ offset += this_block_len;
}
}
@@ -75,8 +76,8 @@ SecureVector<byte> TLS_PRF::derive(u32bit key_len,
const byte* S1 = secret;
const byte* S2 = secret + (secret_len - S2_len);
- P_hash(output, key_len, hmac_md5, S1, S1_len, seed, seed_len);
- P_hash(output, key_len, hmac_sha1, S2, S2_len, seed, seed_len);
+ P_hash(output, hmac_md5, S1, S1_len, seed, seed_len);
+ P_hash(output, hmac_sha1, S2, S2_len, seed, seed_len);
return output;
}
@@ -100,7 +101,7 @@ SecureVector<byte> TLS_12_PRF::derive(u32bit key_len,
{
SecureVector<byte> output(key_len);
- P_hash(output, key_len, hmac, secret, secret_len, seed, seed_len);
+ P_hash(output, hmac, secret, secret_len, seed, seed_len);
return output;
}
diff --git a/src/math/bigint/big_code.cpp b/src/math/bigint/big_code.cpp
index a8272390d..1e35edcc9 100644
--- a/src/math/bigint/big_code.cpp
+++ b/src/math/bigint/big_code.cpp
@@ -22,7 +22,7 @@ void BigInt::encode(byte output[], const BigInt& n, Base base)
else if(base == Hexadecimal)
{
SecureVector<byte> binary(n.encoded_size(Binary));
- n.binary_encode(binary);
+ n.binary_encode(&binary[0]);
hex_encode(reinterpret_cast<char*>(output),
&binary[0], binary.size());
@@ -62,7 +62,7 @@ void BigInt::encode(byte output[], const BigInt& n, Base base)
SecureVector<byte> BigInt::encode(const BigInt& n, Base base)
{
SecureVector<byte> output(n.encoded_size(base));
- encode(output, n, base);
+ encode(&output[0], n, base);
if(base != Binary)
for(u32bit j = 0; j != output.size(); ++j)
if(output[j] == 0)
@@ -82,7 +82,7 @@ SecureVector<byte> BigInt::encode_1363(const BigInt& n, u32bit bytes)
const u32bit leading_0s = bytes - n_bytes;
SecureVector<byte> output(bytes);
- encode(output + leading_0s, n, Binary);
+ encode(&output[leading_0s], n, Binary);
return output;
}
@@ -91,7 +91,7 @@ SecureVector<byte> BigInt::encode_1363(const BigInt& n, u32bit bytes)
*/
BigInt BigInt::decode(const MemoryRegion<byte>& buf, Base base)
{
- return BigInt::decode(buf, buf.size(), base);
+ return BigInt::decode(&buf[0], buf.size(), base);
}
/*
@@ -121,7 +121,7 @@ BigInt BigInt::decode(const byte buf[], u32bit length, Base base)
binary = hex_decode(reinterpret_cast<const char*>(buf),
length, false);
- r.binary_decode(binary, binary.size());
+ r.binary_decode(&binary[0], binary.size());
}
else if(base == Decimal || base == Octal)
{
diff --git a/src/math/bigint/big_rand.cpp b/src/math/bigint/big_rand.cpp
index 84ad02587..29fdf1de6 100644
--- a/src/math/bigint/big_rand.cpp
+++ b/src/math/bigint/big_rand.cpp
@@ -40,7 +40,7 @@ void BigInt::randomize(RandomNumberGenerator& rng,
if(bitsize % 8)
array[0] &= 0xFF >> (8 - (bitsize % 8));
array[0] |= 0x80 >> ((bitsize % 8) ? (8 - bitsize % 8) : 0);
- binary_decode(array, array.size());
+ binary_decode(&array[0], array.size());
}
}
diff --git a/src/pbe/pbes1/pbes1.cpp b/src/pbe/pbes1/pbes1.cpp
index 701e61464..c1d34f9e3 100644
--- a/src/pbe/pbes1/pbes1.cpp
+++ b/src/pbe/pbes1/pbes1.cpp
@@ -68,7 +68,7 @@ void PBE_PKCS5v15::flush_pipe(bool safe_to_skip)
SecureVector<byte> buffer(DEFAULT_BUFFERSIZE);
while(pipe.remaining())
{
- u32bit got = pipe.read(buffer, buffer.size());
+ u32bit got = pipe.read(&buffer[0], buffer.size());
send(buffer, got);
}
}
diff --git a/src/pbe/pbes2/pbes2.cpp b/src/pbe/pbes2/pbes2.cpp
index 55b3a781a..0e8b3fb86 100644
--- a/src/pbe/pbes2/pbes2.cpp
+++ b/src/pbe/pbes2/pbes2.cpp
@@ -75,7 +75,7 @@ void PBE_PKCS5v20::flush_pipe(bool safe_to_skip)
SecureVector<byte> buffer(DEFAULT_BUFFERSIZE);
while(pipe.remaining())
{
- u32bit got = pipe.read(buffer, buffer.size());
+ u32bit got = pipe.read(&buffer[0], buffer.size());
send(buffer, got);
}
}
diff --git a/src/pbkdf/pbkdf1/pbkdf1.cpp b/src/pbkdf/pbkdf1/pbkdf1.cpp
index d9bdf1b1f..20875ebc2 100644
--- a/src/pbkdf/pbkdf1/pbkdf1.cpp
+++ b/src/pbkdf/pbkdf1/pbkdf1.cpp
@@ -31,10 +31,10 @@ OctetString PKCS5_PBKDF1::derive_key(u32bit key_len,
for(u32bit j = 1; j != iterations; ++j)
{
hash->update(key);
- hash->final(key);
+ hash->final(&key[0]);
}
- return OctetString(key, std::min<u32bit>(key_len, key.size()));
+ return OctetString(&key[0], std::min<u32bit>(key_len, key.size()));
}
}
diff --git a/src/pubkey/nr/nr.cpp b/src/pubkey/nr/nr.cpp
index 3c5b71ad2..244a397ee 100644
--- a/src/pubkey/nr/nr.cpp
+++ b/src/pubkey/nr/nr.cpp
@@ -104,8 +104,8 @@ NR_Signature_Operation::sign(const byte msg[], u32bit msg_len,
}
SecureVector<byte> output(2*q.bytes());
- c.binary_encode(output + (output.size() / 2 - c.bytes()));
- d.binary_encode(output + (output.size() - d.bytes()));
+ c.binary_encode(&output[output.size() / 2 - c.bytes()]);
+ d.binary_encode(&output[output.size() - d.bytes()]);
return output;
}
diff --git a/src/pubkey/pkcs8.cpp b/src/pubkey/pkcs8.cpp
index 5eed776be..415aed790 100644
--- a/src/pubkey/pkcs8.cpp
+++ b/src/pubkey/pkcs8.cpp
@@ -101,7 +101,7 @@ SecureVector<byte> PKCS8_decode(DataSource& source, const User_Interface& ui,
pbe->set_key(passphrase);
Pipe decryptor(pbe.release());
- decryptor.process_msg(key_data, key_data.size());
+ decryptor.process_msg(key_data);
key = decryptor.read_all();
}
diff --git a/src/rng/hmac_rng/hmac_rng.cpp b/src/rng/hmac_rng/hmac_rng.cpp
index ff7326336..6abdc66ce 100644
--- a/src/rng/hmac_rng/hmac_rng.cpp
+++ b/src/rng/hmac_rng/hmac_rng.cpp
@@ -20,11 +20,11 @@ void hmac_prf(MessageAuthenticationCode* prf,
u32bit& counter,
const std::string& label)
{
- prf->update(K, K.size());
+ prf->update(K);
prf->update(label);
for(u32bit i = 0; i != 4; ++i)
prf->update(get_byte(i, counter));
- prf->final(K);
+ prf->final(&K[0]);
++counter;
}
@@ -104,7 +104,7 @@ void HMAC_RNG::reseed(u32bit poll_bits)
// Now generate a new PRF output to use as the XTS extractor salt
hmac_prf(prf, K, counter, "xts");
- extractor->set_key(K, K.size());
+ extractor->set_key(K);
// Reset state
zeroise(K);
diff --git a/src/rng/randpool/randpool.cpp b/src/rng/randpool/randpool.cpp
index 713b5b416..bce3f8ac3 100644
--- a/src/rng/randpool/randpool.cpp
+++ b/src/rng/randpool/randpool.cpp
@@ -55,7 +55,7 @@ void Randpool::update_buffer()
break;
mac->update(static_cast<byte>(GEN_OUTPUT));
- mac->update(counter, counter.size());
+ mac->update(counter);
SecureVector<byte> mac_val = mac->final();
for(u32bit i = 0; i != mac_val.size(); ++i)
@@ -74,19 +74,19 @@ void Randpool::mix_pool()
const u32bit BLOCK_SIZE = cipher->BLOCK_SIZE;
mac->update(static_cast<byte>(MAC_KEY));
- mac->update(pool, pool.size());
+ mac->update(pool);
mac->set_key(mac->final());
mac->update(static_cast<byte>(CIPHER_KEY));
- mac->update(pool, pool.size());
+ mac->update(pool);
cipher->set_key(mac->final());
xor_buf(pool, buffer, BLOCK_SIZE);
cipher->encrypt(pool);
for(u32bit i = 1; i != POOL_BLOCKS; ++i)
{
- const byte* previous_block = pool + BLOCK_SIZE*(i-1);
- byte* this_block = pool + BLOCK_SIZE*i;
+ const byte* previous_block = &pool[BLOCK_SIZE*(i-1)];
+ byte* this_block = &pool[BLOCK_SIZE*i];
xor_buf(this_block, previous_block, BLOCK_SIZE);
cipher->encrypt(this_block);
}
diff --git a/src/ssl/rec_wri.cpp b/src/ssl/rec_wri.cpp
index d983fd363..607fe7b01 100644
--- a/src/ssl/rec_wri.cpp
+++ b/src/ssl/rec_wri.cpp
@@ -140,7 +140,7 @@ void Record_Writer::send(byte type, const byte input[], u32bit length)
buffer.copy(buf_pos, input, length);
if(buf_pos + length >= BUFFER_SIZE)
{
- send_record(buf_type, buffer, length);
+ send_record(buf_type, &buffer[0], length);
input += (BUFFER_SIZE - buf_pos);
length -= (BUFFER_SIZE - buf_pos);
while(length >= BUFFER_SIZE)
@@ -237,7 +237,7 @@ void Record_Writer::send_record(byte type, const byte buf[], u32bit length)
SecureVector<byte> output = cipher.read_all(Pipe::LAST_MESSAGE);
- send_record(type, major, minor, output, output.size());
+ send_record(type, major, minor, &output[0], output.size());
seq_no++;
}
diff --git a/src/ssl/s_kex.cpp b/src/ssl/s_kex.cpp
index 9fe37d490..220ef2e0b 100644
--- a/src/ssl/s_kex.cpp
+++ b/src/ssl/s_kex.cpp
@@ -118,7 +118,7 @@ void Server_Key_Exchange::deserialize(const MemoryRegion<byte>& buf)
if(len + so_far > buf.size())
throw Decoding_Error("Server_Key_Exchange: Packet corrupted");
- values[j].set(buf + so_far, len);
+ values[j].set(&buf[so_far], len);
so_far += len;
if(j == 2 && so_far == buf.size())
diff --git a/src/ssl/tls_client.cpp b/src/ssl/tls_client.cpp
index 3b63b2119..79ca842d9 100644
--- a/src/ssl/tls_client.cpp
+++ b/src/ssl/tls_client.cpp
@@ -276,7 +276,7 @@ void TLS_Client::state_machine()
else if(rec_type == APPLICATION_DATA)
{
if(active)
- read_buf.write(record, record.size());
+ read_buf.write(&record[0], record.size());
else
throw Unexpected_Message("Application data before handshake done");
}
@@ -312,7 +312,7 @@ void TLS_Client::read_handshake(byte rec_type,
const MemoryRegion<byte>& rec_buf)
{
if(rec_type == HANDSHAKE)
- state->queue.write(rec_buf, rec_buf.size());
+ state->queue.write(&rec_buf[0], rec_buf.size());
while(true)
{
@@ -333,7 +333,7 @@ void TLS_Client::read_handshake(byte rec_type,
type = static_cast<Handshake_Type>(head[0]);
contents.resize(length);
state->queue.read(head, 4);
- state->queue.read(contents, contents.size());
+ state->queue.read(&contents[0], contents.size());
}
}
}
diff --git a/src/ssl/tls_server.cpp b/src/ssl/tls_server.cpp
index 2a84fa063..8d9cc1b43 100644
--- a/src/ssl/tls_server.cpp
+++ b/src/ssl/tls_server.cpp
@@ -239,7 +239,7 @@ void TLS_Server::state_machine()
else if(rec_type == APPLICATION_DATA)
{
if(active)
- read_buf.write(record, record.size());
+ read_buf.write(&record[0], record.size());
else
throw Unexpected_Message("Application data before handshake done");
}
@@ -273,7 +273,7 @@ void TLS_Server::read_handshake(byte rec_type,
{
if(!state)
state = new Handshake_State;
- state->queue.write(rec_buf, rec_buf.size());
+ state->queue.write(&rec_buf[0], rec_buf.size());
}
while(true)
@@ -295,7 +295,7 @@ void TLS_Server::read_handshake(byte rec_type,
type = static_cast<Handshake_Type>(head[0]);
contents.resize(length);
state->queue.read(head, 4);
- state->queue.read(contents, contents.size());
+ state->queue.read(&contents[0], contents.size());
}
}
}
diff --git a/src/stream/ctr/ctr.cpp b/src/stream/ctr/ctr.cpp
index 66af28a15..bf546da9a 100644
--- a/src/stream/ctr/ctr.cpp
+++ b/src/stream/ctr/ctr.cpp
@@ -108,7 +108,7 @@ void CTR_BE::set_iv(const byte iv[], u32bit iv_len)
break;
}
- permutation->encrypt_n(counter, buffer, PARALLEL_BLOCKS);
+ permutation->encrypt_n(&counter[0], &buffer[0], PARALLEL_BLOCKS);
position = 0;
}
@@ -134,7 +134,7 @@ void CTR_BE::increment_counter()
this_ctr[permutation->BLOCK_SIZE-1] = last_byte;
}
- permutation->encrypt_n(counter, buffer, PARALLEL_BLOCKS);
+ permutation->encrypt_n(&counter[0], &buffer[0], PARALLEL_BLOCKS);
position = 0;
}