Botan 2.1.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

## Detailed Description

Definition at line 56 of file tls_seq_numbers.h.

## Constructor & Destructor Documentation

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

Definition at line 59 of file tls_seq_numbers.h.

59 { m_write_seqs[0] = 0; }

## 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 84 of file tls_seq_numbers.h.

85 {
86 const size_t window_size = sizeof(m_window_bits) * 8;
87
88 if(sequence > m_window_highest)
89 return false;
90
91 const uint64_t offset = m_window_highest - sequence;
92
93 if(offset >= window_size)
94 return true; // really old?
95
96 return (((m_window_bits >> offset) & 1) == 1);
97 }

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

Implements Botan::TLS::Connection_Sequence_Numbers.

Definition at line 69 of file tls_seq_numbers.h.

69 { 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 70 of file tls_seq_numbers.h.

70 { 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 61 of file tls_seq_numbers.h.

61 { m_read_epoch += 1; }

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

Implements Botan::TLS::Connection_Sequence_Numbers.

Definition at line 63 of file tls_seq_numbers.h.

64 {
65 m_write_epoch += 1;
66 m_write_seqs[m_write_epoch] = 0;
67 }

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

Implements Botan::TLS::Connection_Sequence_Numbers.

Definition at line 79 of file tls_seq_numbers.h.

80 {
81 throw Exception("DTLS uses explicit sequence numbers");
82 }

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 72 of file tls_seq_numbers.h.

References BOTAN_ASSERT.

73 {
74 auto i = m_write_seqs.find(epoch);
75 BOTAN_ASSERT(i != m_write_seqs.end(), "Found epoch");
76 return (static_cast<uint64_t>(epoch) << 48) | i->second++;
77 }
BOTAN_ASSERT
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:27

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

Implements Botan::TLS::Connection_Sequence_Numbers.

Definition at line 99 of file tls_seq_numbers.h.

100 {
101 const size_t window_size = sizeof(m_window_bits) * 8;
102
103 if(sequence > m_window_highest)
104 {
105 const size_t offset = sequence - m_window_highest;
106 m_window_highest += offset;
107
108 if(offset >= window_size)
109 m_window_bits = 0;
110 else
111 m_window_bits <<= offset;
112
113 m_window_bits |= 0x01;
114 }
115 else
116 {
117 const uint64_t offset = m_window_highest - sequence;
118 m_window_bits |= (static_cast<uint64_t>(1) << offset);
119 }
120 }

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

- src/lib/tls/tls_seq_numbers.h