aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/tls/tls_seq_numbers.h
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-12-11 15:28:38 -0500
committerJack Lloyd <[email protected]>2016-12-18 16:48:24 -0500
commitf3cb3edb512bdcab498d825886c3366c341b3f78 (patch)
tree645c73ec295a5a34f25d99903b6d9fa9751e86d3 /src/lib/tls/tls_seq_numbers.h
parentc1dd21253c1f3188ff45d3ad47698efd08235ae8 (diff)
Convert to using standard uintN_t integer types
Renames a couple of functions for somewhat better name consistency, eg make_u32bit becomes make_uint32. The old typedefs remain for now since probably lots of application code uses them.
Diffstat (limited to 'src/lib/tls/tls_seq_numbers.h')
-rw-r--r--src/lib/tls/tls_seq_numbers.h62
1 files changed, 31 insertions, 31 deletions
diff --git a/src/lib/tls/tls_seq_numbers.h b/src/lib/tls/tls_seq_numbers.h
index aa0cfe1f4..ece329494 100644
--- a/src/lib/tls/tls_seq_numbers.h
+++ b/src/lib/tls/tls_seq_numbers.h
@@ -22,14 +22,14 @@ class Connection_Sequence_Numbers
virtual void new_read_cipher_state() = 0;
virtual void new_write_cipher_state() = 0;
- virtual u16bit current_read_epoch() const = 0;
- virtual u16bit current_write_epoch() const = 0;
+ virtual uint16_t current_read_epoch() const = 0;
+ virtual uint16_t current_write_epoch() const = 0;
- virtual u64bit next_write_sequence(u16bit) = 0;
- virtual u64bit next_read_sequence() = 0;
+ virtual uint64_t next_write_sequence(uint16_t) = 0;
+ virtual uint64_t next_read_sequence() = 0;
- virtual bool already_seen(u64bit seq) const = 0;
- virtual void read_accept(u64bit seq) = 0;
+ virtual bool already_seen(uint64_t seq) const = 0;
+ virtual void read_accept(uint64_t seq) = 0;
};
class Stream_Sequence_Numbers final : public Connection_Sequence_Numbers
@@ -38,19 +38,19 @@ class Stream_Sequence_Numbers final : public Connection_Sequence_Numbers
void new_read_cipher_state() override { m_read_seq_no = 0; m_read_epoch += 1; }
void new_write_cipher_state() override { m_write_seq_no = 0; m_write_epoch += 1; }
- u16bit current_read_epoch() const override { return m_read_epoch; }
- u16bit current_write_epoch() const override { return m_write_epoch; }
+ uint16_t current_read_epoch() const override { return m_read_epoch; }
+ uint16_t current_write_epoch() const override { return m_write_epoch; }
- u64bit next_write_sequence(u16bit) override { return m_write_seq_no++; }
- u64bit next_read_sequence() override { return m_read_seq_no; }
+ uint64_t next_write_sequence(uint16_t) override { return m_write_seq_no++; }
+ uint64_t next_read_sequence() override { return m_read_seq_no; }
- bool already_seen(u64bit) const override { return false; }
- void read_accept(u64bit) override { m_read_seq_no++; }
+ bool already_seen(uint64_t) const override { return false; }
+ void read_accept(uint64_t) override { m_read_seq_no++; }
private:
- u64bit m_write_seq_no = 0;
- u64bit m_read_seq_no = 0;
- u16bit m_read_epoch = 0;
- u16bit m_write_epoch = 0;
+ uint64_t m_write_seq_no = 0;
+ uint64_t m_read_seq_no = 0;
+ uint16_t m_read_epoch = 0;
+ uint16_t m_write_epoch = 0;
};
class Datagram_Sequence_Numbers final : public Connection_Sequence_Numbers
@@ -66,29 +66,29 @@ class Datagram_Sequence_Numbers final : public Connection_Sequence_Numbers
m_write_seqs[m_write_epoch] = 0;
}
- u16bit current_read_epoch() const override { return m_read_epoch; }
- u16bit current_write_epoch() const override { return m_write_epoch; }
+ uint16_t current_read_epoch() const override { return m_read_epoch; }
+ uint16_t current_write_epoch() const override { return m_write_epoch; }
- u64bit next_write_sequence(u16bit epoch) override
+ uint64_t next_write_sequence(uint16_t epoch) override
{
auto i = m_write_seqs.find(epoch);
BOTAN_ASSERT(i != m_write_seqs.end(), "Found epoch");
- return (static_cast<u64bit>(epoch) << 48) | i->second++;
+ return (static_cast<uint64_t>(epoch) << 48) | i->second++;
}
- u64bit next_read_sequence() override
+ uint64_t next_read_sequence() override
{
throw Exception("DTLS uses explicit sequence numbers");
}
- bool already_seen(u64bit sequence) const override
+ bool already_seen(uint64_t sequence) const override
{
const size_t window_size = sizeof(m_window_bits) * 8;
if(sequence > m_window_highest)
return false;
- const u64bit offset = m_window_highest - sequence;
+ const uint64_t offset = m_window_highest - sequence;
if(offset >= window_size)
return true; // really old?
@@ -96,7 +96,7 @@ class Datagram_Sequence_Numbers final : public Connection_Sequence_Numbers
return (((m_window_bits >> offset) & 1) == 1);
}
- void read_accept(u64bit sequence) override
+ void read_accept(uint64_t sequence) override
{
const size_t window_size = sizeof(m_window_bits) * 8;
@@ -114,17 +114,17 @@ class Datagram_Sequence_Numbers final : public Connection_Sequence_Numbers
}
else
{
- const u64bit offset = m_window_highest - sequence;
- m_window_bits |= (static_cast<u64bit>(1) << offset);
+ const uint64_t offset = m_window_highest - sequence;
+ m_window_bits |= (static_cast<uint64_t>(1) << offset);
}
}
private:
- std::map<u16bit, u64bit> m_write_seqs;
- u16bit m_write_epoch = 0;
- u16bit m_read_epoch = 0;
- u64bit m_window_highest = 0;
- u64bit m_window_bits = 0;
+ std::map<uint16_t, uint64_t> m_write_seqs;
+ uint16_t m_write_epoch = 0;
+ uint16_t m_read_epoch = 0;
+ uint64_t m_window_highest = 0;
+ uint64_t m_window_bits = 0;
};
}