8#ifndef BOTAN_TLS_SEQ_NUMBERS_H_
9#define BOTAN_TLS_SEQ_NUMBERS_H_
11#include <botan/exceptn.h>
69 uint64_t m_write_seq_no;
70 uint64_t m_read_seq_no;
71 uint16_t m_read_epoch;
72 uint16_t m_write_epoch;
92 m_write_seqs[m_write_epoch] = 0;
100 auto i = m_write_seqs.find(epoch);
102 return (
static_cast<uint64_t
>(epoch) << 48) | i->second++;
108 const size_t window_size =
sizeof(m_window_bits) * 8;
110 if(sequence > m_window_highest) {
114 const uint64_t offset = m_window_highest - sequence;
116 if(offset >= window_size) {
120 return (((m_window_bits >> offset) & 1) == 1);
124 const size_t window_size =
sizeof(m_window_bits) * 8;
126 if(sequence > m_window_highest) {
128 const uint64_t offset = sequence - m_window_highest;
129 m_window_highest += offset;
131 if(offset >= window_size) {
134 m_window_bits <<= offset;
137 m_window_bits |= 0x01;
139 const uint64_t offset = m_window_highest - sequence;
141 if(offset < window_size) {
143 m_window_bits |= (
static_cast<uint64_t
>(1) << offset);
146 m_window_highest = sequence;
153 std::map<uint16_t, uint64_t> m_write_seqs;
154 uint16_t m_write_epoch = 0;
155 uint16_t m_read_epoch = 0;
156 uint64_t m_window_highest = 0;
157 uint64_t m_window_bits = 0;
#define BOTAN_ASSERT(expr, assertion_made)
virtual uint16_t current_read_epoch() const =0
virtual uint64_t next_read_sequence()=0
virtual ~Connection_Sequence_Numbers()=default
virtual void read_accept(uint64_t seq)=0
virtual uint16_t current_write_epoch() const =0
virtual void new_read_cipher_state()=0
virtual bool already_seen(uint64_t seq) const =0
virtual void new_write_cipher_state()=0
virtual uint64_t next_write_sequence(uint16_t)=0
uint64_t next_read_sequence() override
void read_accept(uint64_t sequence) override
uint16_t current_read_epoch() const override
void new_read_cipher_state() override
uint16_t current_write_epoch() const override
uint64_t next_write_sequence(uint16_t epoch) override
bool already_seen(uint64_t sequence) const override
void new_write_cipher_state() override
Datagram_Sequence_Numbers()
uint64_t next_write_sequence(uint16_t) override
uint64_t next_read_sequence() override
void read_accept(uint64_t) override
Stream_Sequence_Numbers()
void new_read_cipher_state() override
void new_write_cipher_state() override
uint16_t current_read_epoch() const override
bool already_seen(uint64_t) const override
uint16_t current_write_epoch() const override
int(* final)(unsigned char *, CTX *)