Botan: Botan::TLS_Data_Reader Class Reference

Botan 1.10.16

Public Member Functions | List of all members
Botan::TLS_Data_Reader Class Reference

`#include <tls_reader.h>`

## Public Member Functions
void | discard_next (size_t bytes)
byte | get_byte ()
template<typename T , typename Container >
Container | get_elem (size_t num_elems)
template<typename T >
SecureVector< T > | get_fixed (size_t size)
template<typename T >
SecureVector< T > | get_range (size_t len_bytes, size_t min_elems, size_t max_elems)
template<typename T >
std::vector< T > | get_range_vector (size_t len_bytes, size_t min_elems, size_t max_elems)
u16bit | get_u16bit ()
bool | has_remaining () const
size_t | remaining_bytes () const
| TLS_Data_Reader (const MemoryRegion< byte > &buf_in)

## Detailed Description

Helper class for decoding TLS protocol messages

Definition at line 19 of file tls_reader.h.

## Constructor & Destructor Documentation

## ◆ TLS_Data_Reader()

Botan::TLS_Data_Reader::TLS_Data_Reader | ( | const MemoryRegion< byte > & | buf_in | ) |
| inline

Definition at line 22 of file tls_reader.h.

22 :
23 buf(buf_in), offset(0) {}

## Member Function Documentation

## ◆ discard_next()

void Botan::TLS_Data_Reader::discard_next | ( | size_t | bytes | ) |
| inline

Definition at line 35 of file tls_reader.h.

36 {
37 assert_at_least(bytes);
38 offset += bytes;
39 }

## ◆ get_byte()

byte Botan::TLS_Data_Reader::get_byte | ( |  | ) |
| inline

Definition at line 49 of file tls_reader.h.

Referenced by Botan::append_tls_length_value(), and get_fixed().

50 {
51 assert_at_least(1);
52 byte result = buf[offset];
53 offset += 1;
54 return result;
55 }
Botan::byte
unsigned char byte
Definition: types.h:22

## ◆ get_elem()

template<typename T , typename Container >

Container Botan::TLS_Data_Reader::get_elem | ( | size_t | num_elems | ) |
| inline

Definition at line 58 of file tls_reader.h.

59 {
60 assert_at_least(num_elems * sizeof(T));
61
62 Container result(num_elems);
63
64 for(size_t i = 0; i != num_elems; ++i)
65 result[i] = load_be<T>(&buf[offset], i);
66
67 offset += num_elems * sizeof(T);
68
69 return result;
70 }

## ◆ get_fixed()

template<typename T >

SecureVector<T> Botan::TLS_Data_Reader::get_fixed | ( | size_t | size | ) |
| inline

Definition at line 95 of file tls_reader.h.

References get_byte(), and get_u16bit().

96 {
97 return get_elem<T, SecureVector<T> >(size);
98 }

## ◆ get_range()

template<typename T >

SecureVector<T> Botan::TLS_Data_Reader::get_range | ( | size_t | len_bytes,
|  | size_t | min_elems,
|  | size_t | max_elems
| ) |  |
| inline

Definition at line 73 of file tls_reader.h.

Referenced by Botan::Client_Key_Exchange::Client_Key_Exchange().

76 {
77 const size_t num_elems =
78 get_num_elems(len_bytes, sizeof(T), min_elems, max_elems);
79
80 return get_elem<T, SecureVector<T> >(num_elems);
81 }

## ◆ get_range_vector()

template<typename T >

std::vector<T> Botan::TLS_Data_Reader::get_range_vector | ( | size_t | len_bytes,
|  | size_t | min_elems,
|  | size_t | max_elems
| ) |  |
| inline

Definition at line 84 of file tls_reader.h.

87 {
88 const size_t num_elems =
89 get_num_elems(len_bytes, sizeof(T), min_elems, max_elems);
90
91 return get_elem<T, std::vector<T> >(num_elems);
92 }

## ◆ get_u16bit()

u16bit Botan::TLS_Data_Reader::get_u16bit | ( |  | ) |
| inline

Definition at line 41 of file tls_reader.h.

References Botan::make_u16bit().

Referenced by get_fixed().

42 {
43 assert_at_least(2);
44 u16bit result = make_u16bit(buf[offset], buf[offset+1]);
45 offset += 2;
46 return result;
47 }
Botan::u16bit
unsigned short u16bit
Definition: types.h:27
Botan::make_u16bit
u16bit make_u16bit(byte i0, byte i1)
Definition: loadstor.h:47

## ◆ has_remaining()

bool Botan::TLS_Data_Reader::has_remaining | ( |  | ) | const
| inline

Definition at line 30 of file tls_reader.h.

References remaining_bytes().

31 {
32 return (remaining_bytes() > 0);
33 }
Botan::TLS_Data_Reader::remaining_bytes
size_t remaining_bytes() const
Definition: tls_reader.h:25

## ◆ remaining_bytes()

size_t Botan::TLS_Data_Reader::remaining_bytes | ( |  | ) | const
| inline

Definition at line 25 of file tls_reader.h.

References Botan::MemoryRegion< T >::size().

Referenced by has_remaining().

26 {
27 return buf.size() - offset;
28 }
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29

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

- src/ssl/tls_reader.h