9#ifndef BOTAN_DATA_SRC_H_
10#define BOTAN_DATA_SRC_H_
12#include <botan/secmem.h>
34 [[nodiscard]]
virtual size_t read(uint8_t out[],
size_t length) = 0;
49 [[nodiscard]]
virtual size_t peek(uint8_t out[],
size_t length,
size_t peek_offset)
const = 0;
61 virtual std::string
id()
const {
return ""; }
69 size_t read_byte(uint8_t& out);
77 size_t peek_byte(uint8_t& out)
const;
84 size_t discard_next(
size_t N);
102 size_t read(uint8_t[],
size_t)
override;
103 size_t peek(uint8_t[],
size_t,
size_t)
const override;
104 bool check_available(
size_t n)
override;
105 bool end_of_data()
const override;
118 DataSource_Memory(
const uint8_t in[],
size_t length) : m_source(in, in + length), m_offset(0) {}
130 explicit DataSource_Memory(std::span<const uint8_t> in) : m_source(in.begin(), in.end()), m_offset(0) {}
136 explicit DataSource_Memory(
const std::vector<uint8_t>& in) : m_source(in.begin(), in.end()), m_offset(0) {}
150 size_t read(uint8_t[],
size_t)
override;
151 size_t peek(uint8_t[],
size_t,
size_t)
const override;
152 bool check_available(
size_t n)
override;
153 bool end_of_data()
const override;
154 std::string id()
const override;
158#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
176 const std::string m_identifier;
178 std::unique_ptr<std::istream> m_source_memory;
179 std::istream& m_source;
DataSource_Memory(const std::vector< uint8_t > &in)
DataSource_Memory(secure_vector< uint8_t > in)
DataSource_Memory(std::span< const uint8_t > in)
DataSource_Memory(const uint8_t in[], size_t length)
size_t get_bytes_read() const override
~DataSource_Stream() override
size_t get_bytes_read() const override
DataSource_Stream(const DataSource_Stream &)=delete
DataSource_Stream & operator=(const DataSource_Stream &)=delete
virtual std::string id() const
DataSource(const DataSource &)=delete
virtual size_t get_bytes_read() const =0
virtual ~DataSource()=default
virtual size_t peek(uint8_t out[], size_t length, size_t peek_offset) const =0
virtual size_t read(uint8_t out[], size_t length)=0
virtual bool check_available(size_t n)=0
virtual bool end_of_data() const =0
DataSource & operator=(const DataSource &)=delete
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
std::vector< T, secure_allocator< T > > secure_vector