blob: c3fd8426e51d3b266ab9b39837dc2af2a05f4388 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/*************************************************
* SWIG Interface for Botan *
* (C) 1999-2003 The Botan Project *
*************************************************/
#ifndef BOTAN_WRAP_BASE_H__
#define BOTAN_WRAP_BASE_H__
#include <botan/pipe.h>
#if !defined(SWIG)
#define OUTPUT
#define INOUT
#endif
/*************************************************
* Typedefs *
*************************************************/
typedef unsigned char byte;
typedef unsigned int u32bit;
/*************************************************
* Library Initalization/Shutdown Object *
*************************************************/
class LibraryInitializer
{
public:
LibraryInitializer(const char*);
~LibraryInitializer();
};
/*************************************************
* Symmetric Key Object *
*************************************************/
class SymmetricKey
{
public:
std::string as_string() const { return key->as_string(); }
u32bit length() const { return key->length(); }
SymmetricKey(u32bit = 0);
SymmetricKey(const std::string&);
~SymmetricKey();
private:
Botan::SymmetricKey* key;
};
/*************************************************
* Initialization Vector Object *
*************************************************/
class InitializationVector
{
public:
std::string as_string() const { return iv.as_string(); }
u32bit length() const { return iv.length(); }
InitializationVector(u32bit n = 0) { iv.change(n); }
InitializationVector(const std::string&);
private:
Botan::InitializationVector iv;
};
/*************************************************
* Filter Object *
*************************************************/
class Filter
{
public:
Filter(const char*);
//Filter(const char*, const SymmetricKey&);
//Filter(const char*, const SymmetricKey&, const InitializationVector&);
~Filter();
private:
friend class Pipe;
Botan::Filter* filter;
bool pipe_owns;
};
/*************************************************
* Pipe Object *
*************************************************/
class Pipe
{
public:
static const u32bit DEFAULT_MESSAGE = 0xFFFFFFFF;
void write_file(const char*);
void write_string(const char*);
u32bit read(byte*, u32bit, u32bit = DEFAULT_MESSAGE);
std::string read_all_as_string(u32bit = DEFAULT_MESSAGE);
u32bit remaining(u32bit = DEFAULT_MESSAGE);
void start_msg();
void end_msg();
Pipe(Filter* = 0, Filter* = 0, Filter* = 0, Filter* = 0);
~Pipe();
private:
Botan::Pipe* pipe;
};
#endif
|