Botan 3.11.0
Crypto and TLS for C&
tls_reader.cpp
Go to the documentation of this file.
1/*
2* (C) 2026 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#include <botan/internal/tls_reader.h>
8
9#include <botan/exceptn.h>
10#include <botan/internal/fmt.h>
11
12namespace Botan::TLS {
13
14void TLS_Data_Reader::assert_at_least(size_t n) const {
15 const size_t left = remaining_bytes();
16 if(left < n) {
17 throw_decode_error(fmt("Expected {} bytes remaining, only {} left", n, left));
18 }
19}
20
21void TLS_Data_Reader::throw_decode_error(std::string_view why) const {
22 throw Decoding_Error(fmt("Invalid {}: {}", m_typename, why));
23}
24
25} // namespace Botan::TLS
size_t remaining_bytes() const
Definition tls_reader.h:37
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53