aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-07-04 15:13:45 -0400
committerJack Lloyd <[email protected]>2019-07-04 15:13:45 -0400
commit24ef3c3bea9aaaf1fa0d50b57250b17552ee6949 (patch)
tree96f68bb38c6a487b0f1b0e14601c3fe93599df54
parentae37dd372bb7ccd9afb25866ecededa4de10a36a (diff)
Remove Record_Raw_Input
-rw-r--r--src/lib/tls/tls_channel.cpp8
-rw-r--r--src/lib/tls/tls_record.cpp33
-rw-r--r--src/lib/tls/tls_record.h32
3 files changed, 30 insertions, 43 deletions
diff --git a/src/lib/tls/tls_channel.cpp b/src/lib/tls/tls_channel.cpp
index a2f24dc69..e866d6436 100644
--- a/src/lib/tls/tls_channel.cpp
+++ b/src/lib/tls/tls_channel.cpp
@@ -312,11 +312,13 @@ size_t Channel::received_data(const uint8_t input[], size_t input_size)
size_t consumed = 0;
- Record_Raw_Input raw_input(input, input_size, consumed, m_is_datagram);
Record record(record_data, &record_sequence, &record_version, &record_type);
const size_t needed =
- read_record(m_readbuf,
- raw_input,
+ read_record(m_is_datagram,
+ m_readbuf,
+ input,
+ input_size,
+ consumed,
record,
m_sequence_numbers.get(),
[this](uint16_t epoch) { return read_cipher_state_epoch(epoch); });
diff --git a/src/lib/tls/tls_record.cpp b/src/lib/tls/tls_record.cpp
index 45a1603cf..86e60801d 100644
--- a/src/lib/tls/tls_record.cpp
+++ b/src/lib/tls/tls_record.cpp
@@ -308,7 +308,9 @@ void decrypt_record(secure_vector<uint8_t>& output,
}
size_t read_tls_record(secure_vector<uint8_t>& readbuf,
- Record_Raw_Input& raw_input,
+ const uint8_t input[],
+ size_t input_len,
+ size_t& consumed,
Record& rec,
Connection_Sequence_Numbers* sequence_numbers,
get_cipherstate_fn get_cipherstate)
@@ -316,7 +318,7 @@ size_t read_tls_record(secure_vector<uint8_t>& readbuf,
if(readbuf.size() < TLS_HEADER_SIZE) // header incomplete?
{
if(size_t needed = fill_buffer_to(readbuf,
- raw_input.get_data(), raw_input.get_size(), raw_input.get_consumed(),
+ input, input_len, consumed,
TLS_HEADER_SIZE))
return needed;
@@ -341,7 +343,7 @@ size_t read_tls_record(secure_vector<uint8_t>& readbuf,
"Received a completely empty record");
if(size_t needed = fill_buffer_to(readbuf,
- raw_input.get_data(), raw_input.get_size(), raw_input.get_consumed(),
+ input, input_len, consumed,
TLS_HEADER_SIZE + record_size))
return needed;
@@ -395,14 +397,16 @@ size_t read_tls_record(secure_vector<uint8_t>& readbuf,
}
size_t read_dtls_record(secure_vector<uint8_t>& readbuf,
- Record_Raw_Input& raw_input,
+ const uint8_t input[],
+ size_t input_len,
+ size_t& consumed,
Record& rec,
Connection_Sequence_Numbers* sequence_numbers,
get_cipherstate_fn get_cipherstate)
{
if(readbuf.size() < DTLS_HEADER_SIZE) // header incomplete?
{
- if(fill_buffer_to(readbuf, raw_input.get_data(), raw_input.get_size(), raw_input.get_consumed(), DTLS_HEADER_SIZE))
+ if(fill_buffer_to(readbuf, input, input_len, consumed, DTLS_HEADER_SIZE))
{
readbuf.clear();
return 0;
@@ -431,7 +435,7 @@ size_t read_dtls_record(secure_vector<uint8_t>& readbuf,
return 0;
}
- if(fill_buffer_to(readbuf, raw_input.get_data(), raw_input.get_size(), raw_input.get_consumed(), DTLS_HEADER_SIZE + record_size))
+ if(fill_buffer_to(readbuf, input, input_len, consumed, DTLS_HEADER_SIZE + record_size))
{
// Truncated packet?
readbuf.clear();
@@ -498,18 +502,21 @@ size_t read_dtls_record(secure_vector<uint8_t>& readbuf,
}
-size_t read_record(secure_vector<uint8_t>& readbuf,
- Record_Raw_Input& raw_input,
+size_t read_record(bool is_datagram,
+ secure_vector<uint8_t>& readbuf,
+ const uint8_t input[],
+ size_t input_len,
+ size_t& consumed,
Record& rec,
Connection_Sequence_Numbers* sequence_numbers,
get_cipherstate_fn get_cipherstate)
{
- if(raw_input.is_datagram())
- return read_dtls_record(readbuf, raw_input, rec,
- sequence_numbers, get_cipherstate);
+ if(is_datagram)
+ return read_dtls_record(readbuf, input, input_len, consumed,
+ rec, sequence_numbers, get_cipherstate);
else
- return read_tls_record(readbuf, raw_input, rec,
- sequence_numbers, get_cipherstate);
+ return read_tls_record(readbuf, input, input_len, consumed,
+ rec, sequence_numbers, get_cipherstate);
}
}
diff --git a/src/lib/tls/tls_record.h b/src/lib/tls/tls_record.h
index 3a29164b5..e3eab5239 100644
--- a/src/lib/tls/tls_record.h
+++ b/src/lib/tls/tls_record.h
@@ -105,31 +105,6 @@ class Record final
size_t m_size;
};
-class Record_Raw_Input final
- {
- public:
- Record_Raw_Input(const uint8_t* data, size_t size, size_t& consumed,
- bool is_datagram)
- : m_data(data), m_size(size), m_consumed(consumed),
- m_is_datagram(is_datagram) {}
-
- const uint8_t*& get_data() { return m_data; }
-
- size_t& get_size() { return m_size; }
-
- size_t& get_consumed() { return m_consumed; }
- void set_consumed(size_t consumed) { m_consumed = consumed; }
-
- bool is_datagram() { return m_is_datagram; }
-
- private:
- const uint8_t* m_data;
- size_t m_size;
- size_t& m_consumed;
- bool m_is_datagram;
- };
-
-
/**
* Create a TLS record
* @param write_buffer the output record is placed here
@@ -157,8 +132,11 @@ typedef std::function<std::shared_ptr<Connection_Cipher_State> (uint16_t)> get_c
* Decode a TLS record
* @return zero if full message, else number of bytes still needed
*/
-size_t read_record(secure_vector<uint8_t>& read_buffer,
- Record_Raw_Input& raw_input,
+size_t read_record(bool is_datagram,
+ secure_vector<uint8_t>& read_buffer,
+ const uint8_t input[],
+ size_t input_len,
+ size_t& consumed,
Record& rec,
Connection_Sequence_Numbers* sequence_numbers,
get_cipherstate_fn get_cipherstate);