aboutsummaryrefslogtreecommitdiffstats
path: root/src/tls/tls_record.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-01-05 23:01:06 +0000
committerlloyd <[email protected]>2012-01-05 23:01:06 +0000
commitf452ca334eeb469d13d816c43227a7ea2f49efeb (patch)
tree51b21923652a596d3d04f6e24ff601e32ff97eb6 /src/tls/tls_record.h
parent74226be019b1a66f8eae9a6516f2eb28a53fb9e2 (diff)
Make record reading faster (less copying, no queue at all), at the
expense of significant complexity. Needs careful testing for corner cases and malicious inputs, but seems to work well with randomly chosen segmentations in a correctly formatted stream at least.
Diffstat (limited to 'src/tls/tls_record.h')
-rw-r--r--src/tls/tls_record.h35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/tls/tls_record.h b/src/tls/tls_record.h
index 8e89b9f8a..f4f3e697f 100644
--- a/src/tls/tls_record.h
+++ b/src/tls/tls_record.h
@@ -59,6 +59,9 @@ class BOTAN_DLL Record_Writer
~Record_Writer() { delete m_mac; }
private:
+ Record_Writer(const Record_Writer&) {}
+ Record_Writer& operator=(const Record_Writer&) { return (*this); }
+
void send_record(byte type, const byte input[], size_t length);
std::tr1::function<void (const byte[], size_t)> m_output_fn;
@@ -80,17 +83,21 @@ class BOTAN_DLL Record_Writer
class BOTAN_DLL Record_Reader
{
public:
- 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
+ * @param input new input data (may be NULL if input_size == 0)
+ * @param input_size size of input in bytes
+ * @param input_consumed is set to the number of bytes of input
+ * that were consumed
+ * @param msg_type is set to the type of the message just read if
+ * this function returns 0
+ * @param msg is set to the contents of the record
+ * @return number of bytes still needed (minimum), or 0 if success
*/
- size_t get_record(byte& msg_type,
- MemoryVector<byte>& buffer);
-
- SecureVector<byte> get_record(byte& msg_type);
+ size_t add_input(const byte input[], size_t input_size,
+ size_t& input_consumed,
+ byte& msg_type,
+ MemoryVector<byte>& msg);
void activate(const TLS_Cipher_Suite& suite,
const SessionKeys& keys,
@@ -102,16 +109,22 @@ class BOTAN_DLL Record_Reader
void reset();
- bool currently_empty() const { return m_input_queue.size() == 0; }
-
void set_maximum_fragment_size(size_t max_fragment);
Record_Reader();
~Record_Reader() { delete m_mac; }
private:
+ Record_Reader(const Record_Reader&) {}
+ Record_Reader& operator=(const Record_Reader&) { return (*this); }
+
+ void consume_input(const byte*& input,
+ size_t& input_size,
+ size_t& input_consumed,
+ size_t desired);
+
MemoryVector<byte> m_readbuf;
- SecureQueue m_input_queue;
+ size_t m_readbuf_pos;
Pipe m_cipher;
MessageAuthenticationCode* m_mac;