Botan  2.7.0
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 
15 namespace Botan {
16 
17 /**
18 * A queue that knows how to zeroize itself
19 */
20 class BOTAN_PUBLIC_API(2,0) SecureQueue final : public Fanout_Filter, public DataSource
21  {
22  public:
23  std::string name() const override { return "Queue"; }
24 
25  void write(const uint8_t[], size_t) override;
26 
27  size_t read(uint8_t[], size_t) override;
28  size_t peek(uint8_t[], size_t, size_t = 0) const override;
29  size_t get_bytes_read() const override;
30 
31  bool end_of_data() const override;
32 
33  bool empty() const;
34 
35  bool check_available(size_t n) override { return n <= size(); }
36 
37  /**
38  * @return number of bytes available in the queue
39  */
40  size_t size() const;
41 
42  bool attachable() override { return false; }
43 
44  /**
45  * SecureQueue assignment
46  * @param other the queue to copy
47  */
48  SecureQueue& operator=(const SecureQueue& other);
49 
50  /**
51  * SecureQueue default constructor (creates empty queue)
52  */
53  SecureQueue();
54 
55  /**
56  * SecureQueue copy constructor
57  * @param other the queue to copy
58  */
59  SecureQueue(const SecureQueue& other);
60 
61  ~SecureQueue() { destroy(); }
62 
63  private:
64  void destroy();
65  size_t m_bytes_read;
66  class SecureQueueNode* m_head;
67  class SecureQueueNode* m_tail;
68  };
69 
70 }
71 
72 #endif
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
std::string name() const override
Definition: secqueue.h:23
Definition: alg_id.cpp:13
bool attachable() override
Definition: secqueue.h:42
bool check_available(size_t n) override
Definition: secqueue.h:35