WvStreams
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
15struct rsa_st;
16
27{
28public:
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
67private:
68 bool priv;
69 mutable WvLog debug;
70};
71
72
84class WvRSAEncoder : public WvEncoder
85{
86public:
93
101 WvRSAEncoder(Mode mode, const WvRSAKey &key);
102 virtual ~WvRSAEncoder();
103
104protected:
105 virtual bool _encode(WvBuf &in, WvBuf &out, bool flush);
106 virtual bool _reset(); // supported
107
108private:
109 Mode mode;
110 WvRSAKey key;
111 size_t rsasize;
112};
113
114
124{
125public:
126 WvRSAStream(WvStream *_cloned,
127 const WvRSAKey &_my_key, const WvRSAKey &_their_key,
130 virtual ~WvRSAStream() { }
131};
132
133
134#endif // __WVRSA_H
WvEncoderStream chains a series of encoders on the input and output ports of the underlying stream to...
The base encoder class.
Definition wvencoder.h:68
bool flush(WvBuf &inbuf, WvBuf &outbuf, bool finish=false)
Flushes the encoder and optionally finishes it.
Definition wvencoder.h:163
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
Definition wvstring.h:94
A WvLog stream accepts log messages from applications and forwards them to all registered WvLogRcv's.
Definition wvlog.h:57
An encoder implementing the RSA public key encryption method.
Definition wvrsa.h:85
virtual bool _encode(WvBuf &in, WvBuf &out, bool flush)
Template method implementation of encode().
Definition wvrsa.cc:242
@ SignEncrypt
Definition wvrsa.h:90
@ SignDecrypt
Definition wvrsa.h:91
virtual bool _reset()
Template method implementation of reset().
Definition wvrsa.cc:236
An RSA public key or public/private key pair that can be used for encryption.
Definition wvrsa.h:27
virtual WvString encode(const DumpMode mode) const
Return the information requested by mode.
Definition wvrsa.cc:86
DumpMode
Type for the encode() and decode() methods.
Definition wvrsa.h:36
virtual void decode(const DumpMode mode, WvStringParm encoded)
Load the information from the format requested by mode into the class - this overwrites the certifica...
Definition wvrsa.cc:147
A crypto stream implementing RSA public key encryption.
Definition wvrsa.h:124
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
Definition wvstream.h:25
WvString is an implementation of a simple and efficient printable-string class.
Definition wvstring.h:330