8 #include <botan/hex_filt.h>
10 #include <botan/parsing.h>
11 #include <botan/charset.h>
12 #include <botan/exceptn.h>
26 casing(c), line_length(breaks ? length : 0)
28 in.
resize(HEX_CODEC_BUFFER_SIZE);
30 counter = position = 0;
38 in.
resize(HEX_CODEC_BUFFER_SIZE);
40 counter = position = 0;
46 void Hex_Encoder::encode_and_send(
const byte block[],
size_t length)
56 size_t remaining = 2*length, offset = 0;
59 size_t sent = std::min(line_length - counter, remaining);
60 send(&out[offset], sent);
64 if(counter == line_length)
78 in.
copy(position, input, length);
79 if(position + length >= in.
size())
81 encode_and_send(&in[0], in.
size());
82 input += (in.
size() - position);
83 length -= (in.
size() - position);
84 while(length >= in.
size())
86 encode_and_send(input, in.
size());
90 in.
copy(input, length);
101 encode_and_send(&in[0], position);
102 if(counter && line_length)
104 counter = position = 0;
112 in.
resize(HEX_CODEC_BUFFER_SIZE);
124 size_t to_copy = std::min<size_t>(length, in.
size() - position);
125 copy_mem(&in[position], input, to_copy);
130 reinterpret_cast<const char*>(&in[0]),
137 if(consumed != position)
139 copy_mem(&in[0], &in[consumed], position - consumed);
140 position = position - consumed;
157 reinterpret_cast<const char*>(&in[0]),
164 const bool not_full_bytes = consumed != position;
169 throw std::invalid_argument(
"Hex_Decoder: Input not full bytes");
size_t hex_decode(byte output[], const char input[], size_t input_length, size_t &input_consumed, bool ignore_ws)
const size_t HEX_CODEC_BUFFER_SIZE
Hex_Decoder(Decoder_Checking checking=NONE)
void copy(const T in[], size_t n)
void send(const byte in[], size_t length)
void copy_mem(T *out, const T *in, size_t n)
Hex_Encoder(Case the_case)
void write(const byte[], size_t)
void write(const byte in[], size_t length)
void hex_encode(char output[], const byte input[], size_t input_length, bool uppercase)