Botan 3.9.0
Crypto and TLS for C&
filters.h
Go to the documentation of this file.
1/*
2* Common Filters
3* (C) 1999-2007,2015 Jack Lloyd
4* (C) 2013 Joel Low
5*
6* Botan is released under the Simplified BSD License (see license.txt)
7*/
8
9#ifndef BOTAN_FILTERS_H_
10#define BOTAN_FILTERS_H_
11
12#include <botan/cipher_mode.h>
13#include <botan/data_snk.h>
14#include <botan/pipe.h>
15#include <botan/secmem.h>
16#include <botan/symkey.h>
17
18#if defined(BOTAN_TARGET_OS_HAS_THREADS)
19 #include <thread>
20#endif
21
22#if defined(BOTAN_HAS_STREAM_CIPHER)
23 #include <botan/stream_cipher.h>
24#endif
25
26#if defined(BOTAN_HAS_HASH)
27 #include <botan/hash.h>
28#endif
29
30#if defined(BOTAN_HAS_MAC)
31 #include <botan/mac.h>
32#endif
33
34namespace Botan {
35
36/**
37* Filter mixin that breaks input into blocks, useful for
38* cipher modes
39*/
40class BOTAN_PUBLIC_API(2, 0) Buffered_Filter /* NOLINT(*-special-member-functions) */ {
41 public:
42 /**
43 * Write bytes into the buffered filter, which will them emit them
44 * in calls to buffered_block in the subclass
45 * @param in the input bytes
46 * @param length of in in bytes
47 */
48 void write(const uint8_t in[], size_t length);
49
50 template <typename Alloc>
51 void write(const std::vector<uint8_t, Alloc>& in, size_t length) {
52 write(in.data(), length);
53 }
54
55 /**
56 * Finish a message, emitting to buffered_block and buffered_final
57 * Will throw an exception if less than final_minimum bytes were
58 * written into the filter.
59 */
60 void end_msg();
61
62 /**
63 * Initialize a Buffered_Filter
64 * @param block_size the function buffered_block will be called
65 * with inputs which are a multiple of this size
66 * @param final_minimum the function buffered_final will be called
67 * with at least this many bytes.
68 */
69 Buffered_Filter(size_t block_size, size_t final_minimum);
70
71 virtual ~Buffered_Filter() = default;
72
73 protected:
74 /**
75 * The block processor, implemented by subclasses
76 * @param input some input bytes
77 * @param length the size of input, guaranteed to be a multiple
78 * of block_size
79 */
80 virtual void buffered_block(const uint8_t input[], size_t length) = 0;
81
82 /**
83 * The final block, implemented by subclasses
84 * @param input some input bytes
85 * @param length the size of input, guaranteed to be at least
86 * final_minimum bytes
87 */
88 virtual void buffered_final(const uint8_t input[], size_t length) = 0;
89
90 /**
91 * @return block size of inputs
92 */
93 size_t buffered_block_size() const { return m_main_block_mod; }
94
95 /**
96 * @return current position in the buffer
97 */
98 size_t current_position() const { return m_buffer_pos; }
99
100 /**
101 * Reset the buffer position
102 */
103 void buffer_reset() { m_buffer_pos = 0; }
104
105 private:
106 size_t m_main_block_mod, m_final_minimum;
107
108 secure_vector<uint8_t> m_buffer;
109 size_t m_buffer_pos;
110};
111
112/**
113* This class represents keyed filters, i.e. filters that have to be
114* fed with a key in order to function.
115*/
117 public:
118 /**
119 * Set the key of this filter
120 * @param key the key to use
121 */
122 virtual void set_key(const SymmetricKey& key) = 0;
123
124 /**
125 * Set the initialization vector of this filter. Note: you should
126 * call set_iv() only after you have called set_key()
127 * @param iv the initialization vector to use
128 */
129 virtual void set_iv(const InitializationVector& iv) {
130 if(!iv.empty()) {
131 throw Invalid_IV_Length(name(), iv.length());
132 }
133 }
134
135 /**
136 * Check whether a key length is valid for this filter
137 * @param length the key length to be checked for validity
138 * @return true if the key length is valid, false otherwise
139 */
140 bool valid_keylength(size_t length) const { return key_spec().valid_keylength(length); }
141
142 /**
143 * @return object describing limits on key size
144 */
146
147 /**
148 * Check whether an IV length is valid for this filter
149 * @param length the IV length to be checked for validity
150 * @return true if the IV length is valid, false otherwise
151 */
152 virtual bool valid_iv_length(size_t length) const { return (length == 0); }
153};
154
155/**
156* Filter interface for cipher modes
157*/
159 private Buffered_Filter {
160 public:
161 explicit Cipher_Mode_Filter(Cipher_Mode* t);
162
163 explicit Cipher_Mode_Filter(std::unique_ptr<Cipher_Mode> t) : Cipher_Mode_Filter(t.release()) {}
164
165 void set_iv(const InitializationVector& iv) override;
166
167 void set_key(const SymmetricKey& key) override;
168
169 Key_Length_Specification key_spec() const override;
170
171 bool valid_iv_length(size_t length) const override;
172
173 std::string name() const override;
174
175 private:
176 void write(const uint8_t input[], size_t input_length) override;
177 void start_msg() override;
178 void end_msg() override;
179
180 void buffered_block(const uint8_t input[], size_t input_length) override;
181 void buffered_final(const uint8_t input[], size_t input_length) override;
182
183 std::unique_ptr<Cipher_Mode> m_mode;
184 std::vector<uint8_t> m_nonce;
185 secure_vector<uint8_t> m_buffer;
186};
187
188/*
189* Get a cipher object
190*/
191
192/**
193* Factory method for general symmetric cipher filters. No key will be
194* set in the filter.
195*
196* @param algo_spec the name of the desired cipher
197* @param direction determines whether the filter will be an encrypting or
198* decrypting filter
199* @return pointer to the encryption or decryption filter
200*/
201inline Keyed_Filter* get_cipher(std::string_view algo_spec, Cipher_Dir direction) {
202 auto c = Cipher_Mode::create_or_throw(algo_spec, direction);
203 // NOLINTNEXTLINE(*-owning-memory)
204 return new Cipher_Mode_Filter(c.release());
205}
206
207/**
208* Factory method for general symmetric cipher filters.
209* @param algo_spec the name of the desired cipher
210* @param key the key to be used for encryption/decryption performed by
211* the filter
212* @param direction determines whether the filter will be an encrypting
213* or decrypting filter
214* @return pointer to the encryption or decryption filter
215*/
216inline Keyed_Filter* get_cipher(std::string_view algo_spec, const SymmetricKey& key, Cipher_Dir direction) {
217 Keyed_Filter* cipher = get_cipher(algo_spec, direction);
218 cipher->set_key(key);
219 return cipher;
220}
221
222/**
223* Factory method for general symmetric cipher filters.
224* @param algo_spec the name of the desired cipher
225* @param key the key to be used for encryption/decryption performed by
226* the filter
227* @param iv the initialization vector to be used
228* @param direction determines whether the filter will be an encrypting
229* or decrypting filter
230* @return pointer to newly allocated encryption or decryption filter
231*/
232inline Keyed_Filter* get_cipher(std::string_view algo_spec,
233 const SymmetricKey& key,
234 const InitializationVector& iv,
235 Cipher_Dir direction) {
236 Keyed_Filter* cipher = get_cipher(algo_spec, key, direction);
237 if(!iv.empty()) {
238 cipher->set_iv(iv);
239 }
240 return cipher;
241}
242
243#if defined(BOTAN_HAS_STREAM_CIPHER)
244
245/**
246* Stream Cipher Filter
247*/
248class BOTAN_PUBLIC_API(2, 0) StreamCipher_Filter final : public Keyed_Filter {
249 public:
250 std::string name() const override { return m_cipher->name(); }
251
252 /**
253 * Write input data
254 * @param input data
255 * @param input_len length of input in bytes
256 */
257 void write(const uint8_t input[], size_t input_len) override;
258
259 bool valid_iv_length(size_t iv_len) const override { return m_cipher->valid_iv_length(iv_len); }
260
261 /**
262 * Set the initialization vector for this filter.
263 * @param iv the initialization vector to set
264 */
265 void set_iv(const InitializationVector& iv) override { m_cipher->set_iv(iv.begin(), iv.length()); }
266
267 /**
268 * Set the key of this filter.
269 * @param key the key to set
270 */
271 void set_key(const SymmetricKey& key) override { m_cipher->set_key(key); }
272
273 Key_Length_Specification key_spec() const override { return m_cipher->key_spec(); }
274
275 /**
276 * Construct a stream cipher filter.
277 * @param cipher a cipher object to use
278 */
279 explicit StreamCipher_Filter(StreamCipher* cipher);
280
281 /**
282 * Construct a stream cipher filter.
283 * @param cipher a cipher object to use
284 * @param key the key to use inside this filter
285 */
286 StreamCipher_Filter(StreamCipher* cipher, const SymmetricKey& key);
287
288 /**
289 * Construct a stream cipher filter.
290 * @param cipher the name of the desired cipher
291 */
292 explicit StreamCipher_Filter(std::string_view cipher);
293
294 /**
295 * Construct a stream cipher filter.
296 * @param cipher the name of the desired cipher
297 * @param key the key to use inside this filter
298 */
299 StreamCipher_Filter(std::string_view cipher, const SymmetricKey& key);
300
301 private:
302 std::unique_ptr<StreamCipher> m_cipher;
303 secure_vector<uint8_t> m_buffer;
304};
305#endif
306
307#if defined(BOTAN_HAS_HASH)
308
309/**
310* Hash Filter.
311*/
312class BOTAN_PUBLIC_API(2, 0) Hash_Filter final : public Filter {
313 public:
314 void write(const uint8_t input[], size_t len) override { m_hash->update(input, len); }
315
316 void end_msg() override;
317
318 std::string name() const override { return m_hash->name(); }
319
320 /**
321 * Construct a hash filter.
322 * @param hash the hash function to use
323 * @param len the output length of this filter. Leave the default
324 * value 0 if you want to use the full output of the hashfunction
325 * hash. Otherwise, specify a smaller value here so that the
326 * output of the hash algorithm will be cut off.
327 */
328 BOTAN_FUTURE_EXPLICIT Hash_Filter(HashFunction* hash, size_t len = 0) : m_hash(hash), m_out_len(len) {}
329
330 /**
331 * Construct a hash filter.
332 * @param request the name of the hash algorithm to use
333 * @param len the output length of this filter. Leave the default
334 * value 0 if you want to use the full output of the hashfunction
335 * hash. Otherwise, specify a smaller value here so that the
336 * output of the hash algorithm will be cut off.
337 */
338 BOTAN_FUTURE_EXPLICIT Hash_Filter(std::string_view request, size_t len = 0);
339
340 private:
341 std::unique_ptr<HashFunction> m_hash;
342 const size_t m_out_len;
343};
344#endif
345
346#if defined(BOTAN_HAS_MAC)
347
348/**
349* MessageAuthenticationCode Filter.
350*/
351class BOTAN_PUBLIC_API(2, 0) MAC_Filter final : public Keyed_Filter {
352 public:
353 void write(const uint8_t input[], size_t len) override { m_mac->update(input, len); }
354
355 void end_msg() override;
356
357 std::string name() const override { return m_mac->name(); }
358
359 /**
360 * Set the key of this filter.
361 * @param key the key to set
362 */
363 void set_key(const SymmetricKey& key) override { m_mac->set_key(key); }
364
365 Key_Length_Specification key_spec() const override { return m_mac->key_spec(); }
366
367 /**
368 * Construct a MAC filter. The MAC key will be left empty.
369 * @param mac the MAC to use
370 * @param out_len the output length of this filter. Leave the default
371 * value 0 if you want to use the full output of the
372 * MAC. Otherwise, specify a smaller value here so that the
373 * output of the MAC will be cut off.
374 */
375 BOTAN_FUTURE_EXPLICIT MAC_Filter(MessageAuthenticationCode* mac, size_t out_len = 0) :
376 m_mac(mac), m_out_len(out_len) {}
377
378 /**
379 * Construct a MAC filter.
380 * @param mac the MAC to use
381 * @param key the MAC key to use
382 * @param out_len the output length of this filter. Leave the default
383 * value 0 if you want to use the full output of the
384 * MAC. Otherwise, specify a smaller value here so that the
385 * output of the MAC will be cut off.
386 */
387 MAC_Filter(MessageAuthenticationCode* mac, const SymmetricKey& key, size_t out_len = 0) :
388 m_mac(mac), m_out_len(out_len) {
389 m_mac->set_key(key);
390 }
391
392 /**
393 * Construct a MAC filter. The MAC key will be left empty.
394 * @param mac the name of the MAC to use
395 * @param len the output length of this filter. Leave the default
396 * value 0 if you want to use the full output of the
397 * MAC. Otherwise, specify a smaller value here so that the
398 * output of the MAC will be cut off.
399 */
400 BOTAN_FUTURE_EXPLICIT MAC_Filter(std::string_view mac, size_t len = 0);
401
402 /**
403 * Construct a MAC filter.
404 * @param mac the name of the MAC to use
405 * @param key the MAC key to use
406 * @param len the output length of this filter. Leave the default
407 * value 0 if you want to use the full output of the
408 * MAC. Otherwise, specify a smaller value here so that the
409 * output of the MAC will be cut off.
410 */
411 MAC_Filter(std::string_view mac, const SymmetricKey& key, size_t len = 0);
412
413 private:
414 std::unique_ptr<MessageAuthenticationCode> m_mac;
415 const size_t m_out_len;
416};
417#endif
418
419#if defined(BOTAN_HAS_COMPRESSION)
420
423
424/**
425* Filter interface for compression
426*/
427class BOTAN_PUBLIC_API(2, 0) Compression_Filter final : public Filter {
428 public:
429 void start_msg() override;
430 void write(const uint8_t input[], size_t input_length) override;
431 void end_msg() override;
432
433 void flush();
434
435 std::string name() const override;
436
437 Compression_Filter(std::string_view type, size_t compression_level, size_t buffer_size = 4096);
438
439 ~Compression_Filter() override;
440
441 Compression_Filter(const Compression_Filter& other) = delete;
442 Compression_Filter(Compression_Filter&& other) = delete;
443 Compression_Filter& operator=(const Compression_Filter& other) = delete;
444 Compression_Filter& operator=(Compression_Filter&& other) = delete;
445
446 private:
447 std::unique_ptr<Compression_Algorithm> m_comp;
448 size_t m_buffersize, m_level;
449 secure_vector<uint8_t> m_buffer;
450};
451
452/**
453* Filter interface for decompression
454*/
455class BOTAN_PUBLIC_API(2, 0) Decompression_Filter final : public Filter {
456 public:
457 void start_msg() override;
458 void write(const uint8_t input[], size_t input_length) override;
459 void end_msg() override;
460
461 std::string name() const override;
462
463 BOTAN_FUTURE_EXPLICIT Decompression_Filter(std::string_view type, size_t buffer_size = 4096);
464
465 ~Decompression_Filter() override;
466
467 Decompression_Filter(const Decompression_Filter& other) = delete;
468 Decompression_Filter(Decompression_Filter&& other) = delete;
469 Decompression_Filter& operator=(const Decompression_Filter& other) = delete;
470 Decompression_Filter& operator=(Decompression_Filter&& other) = delete;
471
472 private:
473 std::unique_ptr<Decompression_Algorithm> m_comp;
474 std::size_t m_buffersize;
475 secure_vector<uint8_t> m_buffer;
476};
477
478#endif
479
480/**
481* This class represents a Base64 encoder.
482*/
483class BOTAN_PUBLIC_API(2, 0) Base64_Encoder final : public Filter {
484 public:
485 std::string name() const override { return "Base64_Encoder"; }
486
487 /**
488 * Input a part of a message to the encoder.
489 * @param input the message to input as a byte array
490 * @param length the length of the byte array input
491 */
492 void write(const uint8_t input[], size_t length) override;
493
494 /**
495 * Inform the Encoder that the current message shall be closed.
496 */
497 void end_msg() override;
498
499 /**
500 * Create a base64 encoder.
501 * @param line_breaks whether to use line breaks in the output
502 * @param line_length the length of the lines of the output
503 * @param trailing_newline whether to use a trailing newline
504 */
505 BOTAN_FUTURE_EXPLICIT Base64_Encoder(bool line_breaks = false,
506 size_t line_length = 72,
507 bool trailing_newline = false);
508
509 private:
510 void encode_and_send(const uint8_t input[], size_t length, bool final_inputs = false);
511 void do_output(const uint8_t output[], size_t length);
512
513 const size_t m_line_length;
514 const bool m_trailing_newline;
515 std::vector<uint8_t> m_in, m_out;
516 size_t m_position = 0;
517 size_t m_out_position = 0;
518};
519
520/**
521* This object represents a Base64 decoder.
522*/
523class BOTAN_PUBLIC_API(2, 0) Base64_Decoder final : public Filter {
524 public:
525 std::string name() const override { return "Base64_Decoder"; }
526
527 /**
528 * Input a part of a message to the decoder.
529 * @param input the message to input as a byte array
530 * @param length the length of the byte array input
531 */
532 void write(const uint8_t input[], size_t length) override;
533
534 /**
535 * Finish up the current message
536 */
537 void end_msg() override;
538
539 /**
540 * Create a base64 decoder.
541 * @param checking the type of checking that shall be performed by
542 * the decoder
543 */
544 explicit Base64_Decoder(Decoder_Checking checking = NONE);
545
546 private:
547 const Decoder_Checking m_checking;
548 std::vector<uint8_t> m_in;
549 std::vector<uint8_t> m_out;
550 size_t m_position = 0;
551};
552
553/**
554* Converts arbitrary binary data to hex strings, optionally with
555* newlines inserted
556*/
557class BOTAN_PUBLIC_API(2, 0) Hex_Encoder final : public Filter {
558 public:
559 /**
560 * Whether to use uppercase or lowercase letters for the encoded string.
561 */
562 enum Case : uint8_t { Uppercase, Lowercase };
563
564 std::string name() const override { return "Hex_Encoder"; }
565
566 void write(const uint8_t in[], size_t length) override;
567 void end_msg() override;
568
569 /**
570 * Create a hex encoder.
571 * @param the_case the case to use in the encoded strings.
572 */
573 explicit Hex_Encoder(Case the_case);
574
575 /**
576 * Create a hex encoder.
577 * @param newlines should newlines be used
578 * @param line_length if newlines are used, how long are lines
579 * @param the_case the case to use in the encoded strings
580 */
581 BOTAN_FUTURE_EXPLICIT Hex_Encoder(bool newlines = false, size_t line_length = 72, Case the_case = Uppercase);
582
583 private:
584 void encode_and_send(const uint8_t input[], size_t length);
585
586 const Case m_casing;
587 const size_t m_line_length;
588 std::vector<uint8_t> m_in;
589 std::vector<uint8_t> m_out;
590 size_t m_position = 0;
591 size_t m_counter = 0;
592};
593
594/**
595* Converts hex strings to bytes
596*/
597class BOTAN_PUBLIC_API(2, 0) Hex_Decoder final : public Filter {
598 public:
599 std::string name() const override { return "Hex_Decoder"; }
600
601 void write(const uint8_t input[], size_t length) override;
602 void end_msg() override;
603
604 /**
605 * Construct a Hex Decoder using the specified
606 * character checking.
607 * @param checking the checking to use during decoding.
608 */
609 explicit Hex_Decoder(Decoder_Checking checking = NONE);
610
611 private:
612 const Decoder_Checking m_checking;
613 std::vector<uint8_t> m_in, m_out;
614 size_t m_position = 0;
615};
616
617/**
618* BitBucket is a filter which simply discards all inputs
619*/
620class BOTAN_PUBLIC_API(2, 0) BitBucket final : public Filter {
621 public:
622 void write(const uint8_t /*input*/[], size_t /*length*/) override { /* discard */
623 }
624
625 std::string name() const override { return "BitBucket"; }
626};
627
628/**
629* This class represents Filter chains. A Filter chain is an ordered
630* concatenation of Filters, the input to a Chain sequentially passes
631* through all the Filters contained in the Chain.
632*/
633
634class BOTAN_PUBLIC_API(2, 0) Chain final : public Fanout_Filter {
635 public:
636 void write(const uint8_t input[], size_t length) override { send(input, length); }
637
638 std::string name() const override { return "Chain"; }
639
640 /**
641 * Construct a chain of up to four filters. The filters are set
642 * up in the same order as the arguments.
643 */
644 BOTAN_FUTURE_EXPLICIT Chain(Filter* f1 = nullptr,
645 Filter* f2 = nullptr,
646 Filter* f3 = nullptr,
647 Filter* f4 = nullptr);
648
649 /**
650 * Construct a chain from range of filters
651 * @param filter_arr the list of filters
652 * @param length how many filters
653 */
654 Chain(Filter* filter_arr[], size_t length);
655};
656
657/**
658* This class represents a fork filter, whose purpose is to fork the
659* flow of data. It causes an input message to result in n messages at
660* the end of the filter, where n is the number of forks.
661*/
662class BOTAN_PUBLIC_API(2, 0) Fork : public Fanout_Filter {
663 public:
664 void write(const uint8_t input[], size_t length) override { send(input, length); }
665
666 void set_port(size_t n) { Fanout_Filter::set_port(n); }
667
668 std::string name() const override { return "Fork"; }
669
670 /**
671 * Construct a Fork filter with up to four forks.
672 */
673 Fork(Filter* f1, Filter* f2, Filter* f3 = nullptr, Filter* f4 = nullptr);
674
675 /**
676 * Construct a Fork from range of filters
677 * @param filter_arr the list of filters
678 * @param length how many filters
679 */
680 Fork(Filter* filter_arr[], size_t length);
681};
682
683#if defined(BOTAN_HAS_THREAD_UTILS)
684
685/**
686* This class is a threaded version of the Fork filter. While this uses
687* threads, the class itself is NOT thread-safe. This is meant as a drop-
688* in replacement for Fork where performance gains are possible.
689*/
690class BOTAN_PUBLIC_API(2, 0) Threaded_Fork final : public Fork {
691 public:
692 std::string name() const override;
693
694 /**
695 * Construct a Threaded_Fork filter with up to four forks.
696 */
697 Threaded_Fork(Filter* f1, Filter* f2, Filter* f3 = nullptr, Filter* f4 = nullptr);
698
699 /**
700 * Construct a Threaded_Fork from range of filters
701 * @param filter_arr the list of filters
702 * @param length how many filters
703 */
704 Threaded_Fork(Filter* filter_arr[], size_t length);
705
706 ~Threaded_Fork() override;
707
708 Threaded_Fork(const Threaded_Fork& other) = delete;
709 Threaded_Fork(Threaded_Fork&& other) = delete;
710 Threaded_Fork& operator=(const Threaded_Fork& other) = delete;
711 Threaded_Fork& operator=(Threaded_Fork&& other) = delete;
712
713 private:
714 void set_next(Filter* f[], size_t n);
715 void send(const uint8_t in[], size_t length) override;
716 void thread_delegate_work(const uint8_t input[], size_t length);
717 void thread_entry(Filter* filter);
718
719 std::vector<std::shared_ptr<std::thread>> m_threads;
720 std::unique_ptr<struct Threaded_Fork_Data> m_thread_data;
721};
722#endif
723
724} // namespace Botan
725
726#endif
#define BOTAN_PUBLIC_API(maj, min)
Definition api.h:21
#define BOTAN_FUTURE_EXPLICIT
Definition api.h:52
Base64_Decoder(Decoder_Checking checking=NONE)
Definition b64_filt.cpp:105
std::string name() const override
Definition filters.h:525
std::string name() const override
Definition filters.h:485
BOTAN_FUTURE_EXPLICIT Base64_Encoder(bool line_breaks=false, size_t line_length=72, bool trailing_newline=false)
Definition b64_filt.cpp:20
std::string name() const override
Definition filters.h:625
void write(const uint8_t[], size_t) override
Definition filters.h:622
virtual ~Buffered_Filter()=default
void write(const std::vector< uint8_t, Alloc > &in, size_t length)
Definition filters.h:51
size_t current_position() const
Definition filters.h:98
virtual void buffered_block(const uint8_t input[], size_t length)=0
Buffered_Filter(size_t block_size, size_t final_minimum)
Definition buf_filt.cpp:18
virtual void buffered_final(const uint8_t input[], size_t length)=0
size_t buffered_block_size() const
Definition filters.h:93
void write(const uint8_t in[], size_t length)
Definition buf_filt.cpp:34
void write(const uint8_t input[], size_t length) override
Definition filters.h:636
BOTAN_FUTURE_EXPLICIT Chain(Filter *f1=nullptr, Filter *f2=nullptr, Filter *f3=nullptr, Filter *f4=nullptr)
Definition basefilt.cpp:14
std::string name() const override
Definition filters.h:638
Cipher_Mode_Filter(std::unique_ptr< Cipher_Mode > t)
Definition filters.h:163
Cipher_Mode_Filter(Cipher_Mode *t)
static std::unique_ptr< Cipher_Mode > create_or_throw(std::string_view algo, Cipher_Dir direction, std::string_view provider="")
void set_port(size_t n)
Definition filter.h:154
Filter(const Filter &)=delete
virtual void send(const uint8_t in[], size_t length)
Definition filter.cpp:30
virtual std::string name() const =0
std::string name() const override
Definition filters.h:668
void set_port(size_t n)
Definition filters.h:666
void write(const uint8_t input[], size_t length) override
Definition filters.h:664
Fork(Filter *f1, Filter *f2, Filter *f3=nullptr, Filter *f4=nullptr)
Definition basefilt.cpp:48
Hex_Decoder(Decoder_Checking checking=NONE)
Definition hex_filt.cpp:99
std::string name() const override
Definition filters.h:599
std::string name() const override
Definition filters.h:564
Hex_Encoder(Case the_case)
Definition hex_filt.cpp:33
virtual void set_key(const SymmetricKey &key)=0
bool valid_keylength(size_t length) const
Definition filters.h:140
virtual void set_iv(const InitializationVector &iv)
Definition filters.h:129
virtual bool valid_iv_length(size_t length) const
Definition filters.h:152
virtual Key_Length_Specification key_spec() const =0
size_t length() const
Definition symkey.h:27
bool empty() const
Definition symkey.h:31
OctetString SymmetricKey
Definition symkey.h:140
Decoder_Checking
Definition filter.h:167
@ NONE
Definition filter.h:167
OctetString InitializationVector
Definition symkey.h:145
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:69
Keyed_Filter * get_cipher(std::string_view algo_spec, Cipher_Dir direction)
Definition filters.h:201