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

« back to all changes in this revision

Viewing changes to include/filters.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
 
* Filters Header File                            *
3
 
* (C) 1999-2007 The Botan Project                *
4
 
*************************************************/
5
 
 
6
 
#ifndef BOTAN_FILTERS_H__
7
 
#define BOTAN_FILTERS_H__
8
 
 
9
 
#include <botan/pipe.h>
10
 
#include <botan/basefilt.h>
11
 
#include <botan/data_snk.h>
12
 
#include <botan/pk_filts.h>
13
 
#include <botan/base64.h>
14
 
#include <botan/hex.h>
15
 
 
16
 
namespace Botan {
17
 
 
18
 
/*************************************************
19
 
* Stream Cipher Filter                           *
20
 
*************************************************/
21
 
class StreamCipher_Filter : public Keyed_Filter
22
 
   {
23
 
   public:
24
 
      void seek(u32bit position) { cipher->seek(position); }
25
 
      bool supports_resync() const { return (cipher->IV_LENGTH != 0); }
26
 
 
27
 
      void set_iv(const InitializationVector&);
28
 
      void write(const byte[], u32bit);
29
 
 
30
 
      StreamCipher_Filter(const std::string&);
31
 
      StreamCipher_Filter(const std::string&, const SymmetricKey&);
32
 
      ~StreamCipher_Filter() { delete cipher; }
33
 
   private:
34
 
      SecureVector<byte> buffer;
35
 
      StreamCipher* cipher;
36
 
   };
37
 
 
38
 
/*************************************************
39
 
* Hash Filter                                    *
40
 
*************************************************/
41
 
class Hash_Filter : public Filter
42
 
   {
43
 
   public:
44
 
      void write(const byte input[], u32bit len) { hash->update(input, len); }
45
 
      void end_msg();
46
 
 
47
 
      Hash_Filter(const std::string&, u32bit = 0);
48
 
      ~Hash_Filter() { delete hash; }
49
 
   private:
50
 
      const u32bit OUTPUT_LENGTH;
51
 
      HashFunction* hash;
52
 
   };
53
 
 
54
 
/*************************************************
55
 
* MessageAuthenticationCode Filter               *
56
 
*************************************************/
57
 
class MAC_Filter : public Keyed_Filter
58
 
   {
59
 
   public:
60
 
      void write(const byte input[], u32bit len) { mac->update(input, len); }
61
 
      void end_msg();
62
 
 
63
 
      MAC_Filter(const std::string&, u32bit = 0);
64
 
      MAC_Filter(const std::string&, const SymmetricKey&, u32bit = 0);
65
 
      ~MAC_Filter() { delete mac; }
66
 
   private:
67
 
      const u32bit OUTPUT_LENGTH;
68
 
      MessageAuthenticationCode* mac;
69
 
   };
70
 
 
71
 
}
72
 
 
73
 
#endif