Botan 2.13.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
Botan::TLS::Datagram_Sequence_Numbers Class Referencefinal

`#include <tls_seq_numbers.h>`

Inheritance diagram for Botan::TLS::Datagram_Sequence_Numbers:

## Public Member Functions
bool | already_seen (uint64_t sequence) const override
uint16_t | current_read_epoch () const override
uint16_t | current_write_epoch () const override
| Datagram_Sequence_Numbers ()
void | new_read_cipher_state () override
void | new_write_cipher_state () override
uint64_t | next_read_sequence () override
uint64_t | next_write_sequence (uint16_t epoch) override
void | read_accept (uint64_t sequence) override
void | reset () override

## Detailed Description

Definition at line 70 of file tls_seq_numbers.h.

## Constructor & Destructor Documentation

Botan::TLS::Datagram_Sequence_Numbers::Datagram_Sequence_Numbers | ( |  | ) |
| inline

Definition at line 73 of file tls_seq_numbers.h.

References reset().

73 { Datagram_Sequence_Numbers::reset(); }
Botan::TLS::Datagram_Sequence_Numbers::reset
void reset() override
Definition: tls_seq_numbers.h:75

## Member Function Documentation

bool Botan::TLS::Datagram_Sequence_Numbers::already_seen | ( | uint64_t | sequence | ) | const
| inline override virtual

Implements Botan::TLS::Connection_Sequence_Numbers.

Definition at line 108 of file tls_seq_numbers.h.

109 {
110 const size_t window_size = sizeof(m_window_bits) * 8;
111
112 if(sequence > m_window_highest)
113 {
114 return false;
115 }
116
117 const uint64_t offset = m_window_highest - sequence;
118
119 if(offset >= window_size)
120 {
121 return true; // really old?
122 }
123
124 return (((m_window_bits >> offset) & 1) == 1);
125 }

uint16_t Botan::TLS::Datagram_Sequence_Numbers::current_read_epoch | ( |  | ) | const
| inline override virtual

Implements Botan::TLS::Connection_Sequence_Numbers.

Definition at line 93 of file tls_seq_numbers.h.

93 { return m_read_epoch; }

uint16_t Botan::TLS::Datagram_Sequence_Numbers::current_write_epoch | ( |  | ) | const
| inline override virtual

Implements Botan::TLS::Connection_Sequence_Numbers.

Definition at line 94 of file tls_seq_numbers.h.

94 { return m_write_epoch; }

void Botan::TLS::Datagram_Sequence_Numbers::new_read_cipher_state | ( |  | ) |
| inline override virtual

Implements Botan::TLS::Connection_Sequence_Numbers.

Definition at line 85 of file tls_seq_numbers.h.

85 { m_read_epoch++; }

void Botan::TLS::Datagram_Sequence_Numbers::new_write_cipher_state | ( |  | ) |
| inline override virtual

Implements Botan::TLS::Connection_Sequence_Numbers.

Definition at line 87 of file tls_seq_numbers.h.

88 {
89 m_write_epoch++;
90 m_write_seqs[m_write_epoch] = 0;
91 }

uint64_t Botan::TLS::Datagram_Sequence_Numbers::next_read_sequence | ( |  | ) |
| inline override virtual

Implements Botan::TLS::Connection_Sequence_Numbers.

Definition at line 103 of file tls_seq_numbers.h.

104 {
105 throw Invalid_State("DTLS uses explicit sequence numbers");
106 }

uint64_t Botan::TLS::Datagram_Sequence_Numbers::next_write_sequence | ( | uint16_t | epoch | ) |
| inline override virtual

Implements Botan::TLS::Connection_Sequence_Numbers.

Definition at line 96 of file tls_seq_numbers.h.

References BOTAN_ASSERT.

97 {
98 auto i = m_write_seqs.find(epoch);
99 BOTAN_ASSERT(i != m_write_seqs.end(), "Found epoch");
100 return (static_cast<uint64_t>(epoch) << 48) | i->second++;
101 }
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:55

void Botan::TLS::Datagram_Sequence_Numbers::read_accept | ( | uint64_t | sequence | ) |
| inline override virtual

Implements Botan::TLS::Connection_Sequence_Numbers.

Definition at line 127 of file tls_seq_numbers.h.

128 {
129 const size_t window_size = sizeof(m_window_bits) * 8;
130
131 if(sequence > m_window_highest)
132 {
133 const uint64_t offset = sequence - m_window_highest;
134 m_window_highest += offset;
135
136 if(offset >= window_size)
137 m_window_bits = 0;
138 else
139 m_window_bits <<= offset;
140
141 m_window_bits |= 0x01;
142 }
143 else
144 {
145 const uint64_t offset = m_window_highest - sequence;
146 m_window_bits |= (static_cast<uint64_t>(1) << offset);
147 }
148 }

void Botan::TLS::Datagram_Sequence_Numbers::reset | ( |  | ) |
| inline override virtual

Implements Botan::TLS::Connection_Sequence_Numbers.

Definition at line 75 of file tls_seq_numbers.h.

Referenced by Datagram_Sequence_Numbers().

76 {
77 m_write_seqs.clear();
78 m_write_seqs[0] = 0;
79 m_write_epoch = 0;
80 m_read_epoch = 0;
81 m_window_highest = 0;
82 m_window_bits = 0;
83 }

The documentation for this class was generated from the following file:

- src/lib/tls/tls_seq_numbers.h