aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2013-09-06 21:49:18 +0000
committerlloyd <[email protected]>2013-09-06 21:49:18 +0000
commitc032dd416d182adbf43ffeba51529e7d6890a4d6 (patch)
tree566ed3760497e80d0816089bd733d074e81da846 /src
parent183c1a131ef5cb6b80d440880d2ef78b1c8f5f4c (diff)
Don't pass Record struct to handshake parser
Diffstat (limited to 'src')
-rw-r--r--src/tls/tls_channel.cpp2
-rw-r--r--src/tls/tls_handshake_io.cpp21
-rw-r--r--src/tls/tls_handshake_io.h13
3 files changed, 22 insertions, 14 deletions
diff --git a/src/tls/tls_channel.cpp b/src/tls/tls_channel.cpp
index 20d882a40..c00970c49 100644
--- a/src/tls/tls_channel.cpp
+++ b/src/tls/tls_channel.cpp
@@ -318,7 +318,7 @@ size_t Channel::received_data(const byte input[], size_t input_size)
sequence_numbers().read_accept(record.sequence());
}
- m_pending_state->handshake_io().add_record(record);
+ m_pending_state->handshake_io().add_record(record.contents(), record.type(), record.sequence());
while(auto pending = m_pending_state.get())
{
diff --git a/src/tls/tls_handshake_io.cpp b/src/tls/tls_handshake_io.cpp
index c685c80ef..38def13a2 100644
--- a/src/tls/tls_handshake_io.cpp
+++ b/src/tls/tls_handshake_io.cpp
@@ -39,15 +39,16 @@ Protocol_Version Stream_Handshake_IO::initial_record_version() const
return Protocol_Version::TLS_V10;
}
-void Stream_Handshake_IO::add_record(const Record& record)
+void Stream_Handshake_IO::add_record(const std::vector<byte>& record,
+ Record_Type record_type, u64bit)
{
- if(record.type() == HANDSHAKE)
+ if(record_type == HANDSHAKE)
{
- m_queue.insert(m_queue.end(), record.bits(), record.bits() + record.size());
+ m_queue.insert(m_queue.end(), record.begin(), record.end());
}
- else if(record.type() == CHANGE_CIPHER_SPEC)
+ else if(record_type == CHANGE_CIPHER_SPEC)
{
- if(record.size() != 1 || record.bits()[0] != 1)
+ if(record.size() != 1 || record[0] != 1)
throw Decoding_Error("Invalid ChangeCipherSpec");
// Pretend it's a regular handshake message of zero length
@@ -118,11 +119,13 @@ Protocol_Version Datagram_Handshake_IO::initial_record_version() const
return Protocol_Version::DTLS_V10;
}
-void Datagram_Handshake_IO::add_record(const Record& record)
+void Datagram_Handshake_IO::add_record(const std::vector<byte>& record,
+ Record_Type record_type,
+ u64bit record_sequence)
{
- const u16bit epoch = static_cast<u16bit>(record.sequence() >> 48);
+ const u16bit epoch = static_cast<u16bit>(record_sequence >> 48);
- if(record.type() == CHANGE_CIPHER_SPEC)
+ if(record_type == CHANGE_CIPHER_SPEC)
{
m_ccs_epochs.insert(epoch);
return;
@@ -130,7 +133,7 @@ void Datagram_Handshake_IO::add_record(const Record& record)
const size_t DTLS_HANDSHAKE_HEADER_LEN = 12;
- const byte* record_bits = record.bits();
+ const byte* record_bits = &record[0];
size_t record_size = record.size();
while(record_size)
diff --git a/src/tls/tls_handshake_io.h b/src/tls/tls_handshake_io.h
index 82d1a8e7e..36c605c30 100644
--- a/src/tls/tls_handshake_io.h
+++ b/src/tls/tls_handshake_io.h
@@ -24,7 +24,6 @@ namespace Botan {
namespace TLS {
class Handshake_Message;
-class Record;
/**
* Handshake IO Interface
@@ -40,7 +39,9 @@ class Handshake_IO
const std::vector<byte>& handshake_msg,
Handshake_Type handshake_type) const = 0;
- virtual void add_record(const Record& record) = 0;
+ virtual void add_record(const std::vector<byte>& record,
+ Record_Type type,
+ u64bit sequence_number) = 0;
/**
* Returns (HANDSHAKE_NONE, std::vector<>()) if no message currently available
@@ -74,7 +75,9 @@ class Stream_Handshake_IO : public Handshake_IO
const std::vector<byte>& handshake_msg,
Handshake_Type handshake_type) const override;
- void add_record(const Record& record) override;
+ void add_record(const std::vector<byte>& record,
+ Record_Type type,
+ u64bit sequence_number) override;
std::pair<Handshake_Type, std::vector<byte>>
get_next_record(bool expecting_ccs) override;
@@ -101,7 +104,9 @@ class Datagram_Handshake_IO : public Handshake_IO
const std::vector<byte>& handshake_msg,
Handshake_Type handshake_type) const override;
- void add_record(const Record& record) override;
+ void add_record(const std::vector<byte>& record,
+ Record_Type type,
+ u64bit sequence_number) override;
std::pair<Handshake_Type, std::vector<byte>>
get_next_record(bool expecting_ccs) override;