WvStreams
Main Page
Modules
Classes
Files
File List
File Members
include
wvrsa.h
1
/* -*- Mode: C++ -*-
2
* Worldvisions Tunnel Vision Software:
3
* Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4
*
5
* RSA cryptography abstractions.
6
*/
7
#ifndef __WVRSA_H
8
#define __WVRSA_H
9
10
#include "wverror.h"
11
#include "wvencoder.h"
12
#include "wvencoderstream.h"
13
#include "wvlog.h"
14
15
struct
rsa_st;
16
26
class
WvRSAKey
27
{
28
public
:
36
enum
DumpMode
{ RsaPEM, RsaPubPEM, RsaHex, RsaPubHex };
37
38
struct
rsa_st *rsa;
39
40
WvRSAKey
();
41
WvRSAKey
(
const
WvRSAKey
&k);
42
WvRSAKey
(
WvStringParm
keystr,
bool
priv);
43
WvRSAKey
(
struct
rsa_st *_rsa,
bool
priv);
// note: takes ownership
44
48
WvRSAKey
(
int
bits);
49
50
virtual
~
WvRSAKey
();
51
52
virtual
bool
isok()
const
;
53
57
virtual
WvString
encode
(
const
DumpMode
mode)
const
;
58
virtual
void
encode
(
const
DumpMode
mode,
WvBuf
&buf)
const
;
59
64
virtual
void
decode
(
const
DumpMode
mode,
WvStringParm
encoded);
65
virtual
void
decode
(
const
DumpMode
mode,
WvBuf
&encoded);
66
67
private
:
68
bool
priv;
69
mutable
WvLog
debug;
70
};
71
72
84
class
WvRSAEncoder
:
public
WvEncoder
85
{
86
public
:
87
enum
Mode
{
88
Encrypt
,
89
Decrypt
,
90
SignEncrypt
,
91
SignDecrypt
92
};
93
101
WvRSAEncoder
(
Mode
mode,
const
WvRSAKey
&key);
102
virtual
~
WvRSAEncoder
();
103
104
protected
:
105
virtual
bool
_encode
(
WvBuf
&in,
WvBuf
&out,
bool
flush
);
106
virtual
bool
_reset
();
// supported
107
108
private
:
109
Mode
mode;
110
WvRSAKey
key;
111
size_t
rsasize;
112
};
113
114
123
class
WvRSAStream
:
public
WvEncoderStream
124
{
125
public
:
126
WvRSAStream
(
WvStream
*_cloned,
127
const
WvRSAKey
&_my_key,
const
WvRSAKey
&_their_key,
128
WvRSAEncoder::Mode
readmode =
WvRSAEncoder::Decrypt
,
129
WvRSAEncoder::Mode
writemode =
WvRSAEncoder::Encrypt
);
130
virtual
~
WvRSAStream
() { }
131
};
132
133
134
#endif // __WVRSA_H
Generated on Thu Oct 31 2013 15:14:23 for WvStreams by
1.8.4