Botan  2.12.1
Crypto and TLS for C++11
secqueue.h
Go to the documentation of this file.
1 /*
2 * SecureQueue
3 * (C) 1999-2007 Jack Lloyd
4 * 2012 Markus Wanner
5 *
6 * Botan is released under the Simplified BSD License (see license.txt)
7 */
8 
9 #ifndef BOTAN_SECURE_QUEUE_H_
10 #define BOTAN_SECURE_QUEUE_H_
11 
12 #include <botan/data_src.h>
13 #include <botan/filter.h>
14 
16 
17 namespace Botan {
18 
19 /**
20 * A queue that knows how to zeroize itself
21 */
23  {
24  public:
25  std::string name() const override { return "Queue"; }
26 
27  void write(const uint8_t[], size_t) override;
28 
29  size_t read(uint8_t[], size_t) override;
30  size_t peek(uint8_t[], size_t, size_t = 0) const override;
31  size_t get_bytes_read() const override;
32 
33  bool end_of_data() const override;
34 
35  bool empty() const;
36 
37  bool check_available(size_t n) override { return n <= size(); }
38 
39  /**
40  * @return number of bytes available in the queue
41  */
42  size_t size() const;
43 
44  bool attachable() override { return false; }
45 
46  /**
47  * SecureQueue assignment
48  * @param other the queue to copy
49  */
50  SecureQueue& operator=(const SecureQueue& other);
51 
52  /**
53  * SecureQueue default constructor (creates empty queue)
54  */
55  SecureQueue();
56 
57  /**
58  * SecureQueue copy constructor
59  * @param other the queue to copy
60  */
61  SecureQueue(const SecureQueue& other);
62 
63  ~SecureQueue() { destroy(); }
64 
65  private:
66  void destroy();
67  size_t m_bytes_read;
68  class SecureQueueNode* m_head;
69  class SecureQueueNode* m_tail;
70  };
71 
72 }
73 
74 #endif
DataSource & operator=(const DataSource &)=delete
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
virtual void write(const uint8_t input[], size_t length)=0
std::string name() const override
Definition: secqueue.h:25
virtual size_t peek(uint8_t out[], size_t length, size_t peek_offset) const BOTAN_WARN_UNUSED_RESULT=0
virtual bool end_of_data() const =0
virtual size_t read(uint8_t out[], size_t length) BOTAN_WARN_UNUSED_RESULT=0
Definition: alg_id.cpp:13
virtual size_t get_bytes_read() const =0
bool attachable() override
Definition: secqueue.h:44
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:139
bool check_available(size_t n) override
Definition: secqueue.h:37