aboutsummaryrefslogtreecommitdiffstats
path: root/src/ssl
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-10-15 13:19:18 +0000
committerlloyd <[email protected]>2010-10-15 13:19:18 +0000
commit8f90feb2418bd54b4f818ca6e9303c4562abf88d (patch)
tree3eeffb59870b39a0eaa2a27ec0c7c75b97b87be5 /src/ssl
parentf7b299b7ecc684754da2959366d8895ab621d430 (diff)
More size_t
Diffstat (limited to 'src/ssl')
-rw-r--r--src/ssl/rec_read.cpp20
-rw-r--r--src/ssl/rec_wri.cpp24
-rw-r--r--src/ssl/tls_record.h16
3 files changed, 30 insertions, 30 deletions
diff --git a/src/ssl/rec_read.cpp b/src/ssl/rec_read.cpp
index 29e2ca4c7..0886a688f 100644
--- a/src/ssl/rec_read.cpp
+++ b/src/ssl/rec_read.cpp
@@ -100,7 +100,7 @@ void Record_Reader::set_keys(const CipherSuite& suite, const SessionKeys& keys,
throw Invalid_Argument("Record_Reader: Unknown hash " + mac_algo);
}
-void Record_Reader::add_input(const byte input[], u32bit input_size)
+void Record_Reader::add_input(const byte input[], size_t input_size)
{
input_queue.write(input, input_size);
}
@@ -108,12 +108,12 @@ void Record_Reader::add_input(const byte input[], u32bit input_size)
/*
* Retrieve the next record
*/
-u32bit Record_Reader::get_record(byte& msg_type,
+size_t Record_Reader::get_record(byte& msg_type,
MemoryRegion<byte>& output)
{
byte header[5] = { 0 };
- const u32bit have_in_queue = input_queue.size();
+ const size_t have_in_queue = input_queue.size();
if(have_in_queue < sizeof(header))
return (sizeof(header) - have_in_queue);
@@ -126,7 +126,7 @@ u32bit Record_Reader::get_record(byte& msg_type,
// SSLv2-format client hello?
if(header[0] & 0x80 && header[2] == 1 && header[3] == 3)
{
- u32bit record_len = make_u16bit(header[0], header[1]) & 0x7FFF;
+ size_t record_len = make_u16bit(header[0], header[1]) & 0x7FFF;
if(have_in_queue < record_len + 2)
return (record_len + 2 - have_in_queue);
@@ -184,7 +184,7 @@ u32bit Record_Reader::get_record(byte& msg_type,
cipher.process_msg(buffer);
SecureVector<byte> plaintext = cipher.read_all(Pipe::LAST_MESSAGE);
- u32bit pad_size = 0;
+ size_t pad_size = 0;
if(block_size)
{
@@ -206,7 +206,7 @@ u32bit Record_Reader::get_record(byte& msg_type,
}
else
{
- for(u32bit j = 0; j != pad_size; j++)
+ for(size_t j = 0; j != pad_size; j++)
if(plaintext[plaintext.size()-j-1] != pad_value)
pad_size = 0;
}
@@ -215,22 +215,22 @@ u32bit Record_Reader::get_record(byte& msg_type,
if(plaintext.size() < mac_size + pad_size + iv_size)
throw Decoding_Error("Record_Reader: Record truncated");
- const u32bit mac_offset = plaintext.size() - (mac_size + pad_size);
+ const size_t mac_offset = plaintext.size() - (mac_size + pad_size);
SecureVector<byte> recieved_mac(&plaintext[mac_offset],
mac_size);
const u16bit plain_length = plaintext.size() - (mac_size + pad_size + iv_size);
mac.start_msg();
- for(u32bit j = 0; j != 8; j++)
+ for(size_t j = 0; j != 8; j++)
mac.write(get_byte(j, seq_no));
mac.write(header[0]); // msg_type
if(version != SSL_V3)
- for(u32bit j = 0; j != 2; j++)
+ for(size_t j = 0; j != 2; j++)
mac.write(get_byte(j, version));
- for(u32bit j = 0; j != 2; j++)
+ for(size_t j = 0; j != 2; j++)
mac.write(get_byte(j, plain_length));
mac.write(&plaintext[iv_size], plain_length);
mac.end_msg();
diff --git a/src/ssl/rec_wri.cpp b/src/ssl/rec_wri.cpp
index bf0577bd1..addb159ef 100644
--- a/src/ssl/rec_wri.cpp
+++ b/src/ssl/rec_wri.cpp
@@ -127,12 +127,12 @@ void Record_Writer::send(byte type, byte input)
/**
* Send one or more records to the other side
*/
-void Record_Writer::send(byte type, const byte input[], u32bit length)
+void Record_Writer::send(byte type, const byte input[], size_t length)
{
if(type != buf_type)
flush();
- const u32bit BUFFER_SIZE = buffer.size();
+ const size_t BUFFER_SIZE = buffer.size();
buf_type = type;
// FIXME: compression right here
@@ -161,11 +161,11 @@ void Record_Writer::send(byte type, const byte input[], u32bit length)
void Record_Writer::flush()
{
const byte* buf_ptr = &buffer[0];
- u32bit offset = 0;
+ size_t offset = 0;
while(offset != buf_pos)
{
- u32bit record_size = buf_pos - offset;
+ size_t record_size = buf_pos - offset;
if(record_size > MAX_PLAINTEXT_SIZE)
record_size = MAX_PLAINTEXT_SIZE;
@@ -179,7 +179,7 @@ void Record_Writer::flush()
/**
* Encrypt and send the record
*/
-void Record_Writer::send_record(byte type, const byte buf[], u32bit length)
+void Record_Writer::send_record(byte type, const byte buf[], size_t length)
{
if(length >= MAX_COMPRESSED_SIZE)
throw TLS_Exception(INTERNAL_ERROR,
@@ -190,7 +190,7 @@ void Record_Writer::send_record(byte type, const byte buf[], u32bit length)
else
{
mac.start_msg();
- for(u32bit j = 0; j != 8; j++)
+ for(size_t j = 0; j != 8; j++)
mac.write(get_byte(j, seq_no));
mac.write(type);
@@ -200,8 +200,8 @@ void Record_Writer::send_record(byte type, const byte buf[], u32bit length)
mac.write(minor);
}
- mac.write(get_byte(2, length));
- mac.write(get_byte(3, length));
+ mac.write(get_byte<u16bit>(0, length));
+ mac.write(get_byte<u16bit>(1, length));
mac.write(buf, length);
mac.end_msg();
@@ -227,10 +227,10 @@ void Record_Writer::send_record(byte type, const byte buf[], u32bit length)
if(block_size)
{
- u32bit pad_val =
+ size_t pad_val =
(block_size - (1 + length + buf_mac.size())) % block_size;
- for(u32bit j = 0; j != pad_val + 1; j++)
+ for(size_t j = 0; j != pad_val + 1; j++)
cipher.write(pad_val);
}
cipher.end_msg();
@@ -247,14 +247,14 @@ void Record_Writer::send_record(byte type, const byte buf[], u32bit length)
* Send a final record packet
*/
void Record_Writer::send_record(byte type, byte major, byte minor,
- const byte out[], u32bit length)
+ const byte out[], size_t length)
{
if(length >= MAX_CIPHERTEXT_SIZE)
throw TLS_Exception(INTERNAL_ERROR,
"Record_Writer: Record is too big");
byte header[5] = { type, major, minor, 0 };
- for(u32bit j = 0; j != 2; j++)
+ for(size_t j = 0; j != 2; j++)
header[j+3] = get_byte<u16bit>(j, length);
socket.write(header, 5);
diff --git a/src/ssl/tls_record.h b/src/ssl/tls_record.h
index 7ea7f3cc8..d39f1b557 100644
--- a/src/ssl/tls_record.h
+++ b/src/ssl/tls_record.h
@@ -23,7 +23,7 @@ namespace Botan {
class BOTAN_DLL Record_Writer
{
public:
- void send(byte, const byte[], u32bit);
+ void send(byte, const byte[], size_t);
void send(byte, byte);
void flush();
@@ -38,15 +38,15 @@ class BOTAN_DLL Record_Writer
Record_Writer(Socket& socket);
private:
- void send_record(byte, const byte[], u32bit);
- void send_record(byte, byte, byte, const byte[], u32bit);
+ void send_record(byte, const byte[], size_t);
+ void send_record(byte, byte, byte, const byte[], size_t);
Socket& socket;
Pipe cipher, mac;
SecureVector<byte> buffer;
- u32bit buf_pos;
+ size_t buf_pos;
- u32bit block_size, mac_size, iv_size;
+ size_t block_size, mac_size, iv_size;
u64bit seq_no;
byte major, minor, buf_type;
@@ -58,14 +58,14 @@ class BOTAN_DLL Record_Writer
class BOTAN_DLL Record_Reader
{
public:
- void add_input(const byte input[], u32bit input_size);
+ void add_input(const byte input[], size_t input_size);
/**
* @param msg_type (output variable)
* @param buffer (output variable)
* @return Number of bytes still needed (minimum), or 0 if success
*/
- u32bit get_record(byte& msg_type,
+ size_t get_record(byte& msg_type,
MemoryRegion<byte>& buffer);
SecureVector<byte> get_record(byte& msg_type);
@@ -83,7 +83,7 @@ class BOTAN_DLL Record_Reader
SecureQueue input_queue;
Pipe cipher, mac;
- u32bit block_size, mac_size, iv_size;
+ size_t block_size, mac_size, iv_size;
u64bit seq_no;
byte major, minor;
};