Botan
1.11.15
|
00001 /* 00002 * SecureQueue 00003 * (C) 1999-2007 Jack Lloyd 00004 * 2012 Markus Wanner 00005 * 00006 * Botan is released under the Simplified BSD License (see license.txt) 00007 */ 00008 00009 #ifndef BOTAN_SECURE_QUEUE_H__ 00010 #define BOTAN_SECURE_QUEUE_H__ 00011 00012 #include <botan/data_src.h> 00013 #include <botan/filter.h> 00014 00015 namespace Botan { 00016 00017 /** 00018 * A queue that knows how to zeroize itself 00019 */ 00020 class BOTAN_DLL SecureQueue : public Fanout_Filter, public DataSource 00021 { 00022 public: 00023 std::string name() const { return "Queue"; } 00024 00025 void write(const byte[], size_t); 00026 00027 size_t read(byte[], size_t); 00028 size_t peek(byte[], size_t, size_t = 0) const; 00029 size_t get_bytes_read() const; 00030 00031 bool end_of_data() const; 00032 00033 bool empty() const; 00034 00035 /** 00036 * @return number of bytes available in the queue 00037 */ 00038 size_t size() const; 00039 00040 bool attachable() { return false; } 00041 00042 /** 00043 * SecureQueue assignment 00044 * @param other the queue to copy 00045 */ 00046 SecureQueue& operator=(const SecureQueue& other); 00047 00048 /** 00049 * SecureQueue default constructor (creates empty queue) 00050 */ 00051 SecureQueue(); 00052 00053 /** 00054 * SecureQueue copy constructor 00055 * @param other the queue to copy 00056 */ 00057 SecureQueue(const SecureQueue& other); 00058 00059 ~SecureQueue() { destroy(); } 00060 private: 00061 size_t bytes_read; 00062 void destroy(); 00063 class SecureQueueNode* head; 00064 class SecureQueueNode* tail; 00065 }; 00066 00067 } 00068 00069 #endif