monotone

monotone Mtn Source Tree

Root/botan/filters.h

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
16namespace Botan {
17
18/*************************************************
19* Stream Cipher Filter *
20*************************************************/
21class 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*************************************************/
41class 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*************************************************/
57class 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

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status