~ubuntu-branches/debian/sid/botan/sid

« back to all changes in this revision

Viewing changes to src/lib/filters/secqueue.h

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2018-03-01 22:23:25 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20180301222325-7p7vc45gu3hta34d
Tags: 2.4.0-2
* Don't remove .doctrees from the manual if it doesn't exist.
* Don't specify parallel to debhelper.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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