WvStreams
wvblowfish.h
1/* -*- Mode: C++ -*-
2 * Worldvisions Tunnel Vision Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4 *
5 * Blowfish cryptography abstractions.
6 */
7#ifndef __WVBLOWFISH_H
8#define __WVBLOWFISH_H
9
10#include "wvencoder.h"
11#include "wvencoderstream.h"
12
13struct bf_key_st;
14
22{
23public:
30
38 WvBlowfishEncoder(Mode mode, const void *key, size_t keysize);
39 virtual ~WvBlowfishEncoder();
40
48 void setkey(const void *key, size_t keysize);
49
55 void setiv(const void *iv);
56
58 bool is_encrypting() const {
59 return (mode == ECBEncrypt || mode == CFBEncrypt);
60 }
61
62protected:
63 virtual bool _encode(WvBuf &in, WvBuf &out, bool flush);
64 virtual bool _reset(); // supported: restores most recently set
65 // key and initialization vector
66
67 Mode mode;
68 size_t keysize;
69 unsigned char *key;
70 struct bf_key_st *bfkey;
71 unsigned char ivec[8]; // initialization vector
72 int ivecoff; // current offset into initvec
73
74 void preparekey();
75};
76
77
88{
89public:
91 const void *key, size_t _keysize,
94 virtual ~WvBlowfishStream() { }
95};
96
97#endif // __WVBLOWFISH_H
An encoder implementing the Blowfish encryption method.
Definition wvblowfish.h:22
virtual bool _reset()
Template method implementation of reset().
Definition wvblowfish.cc:29
virtual bool _encode(WvBuf &in, WvBuf &out, bool flush)
Template method implementation of encode().
Definition wvblowfish.cc:63
void setiv(const void *iv)
Sets the current Blowfish initialization vector.
Definition wvblowfish.cc:46
bool is_encrypting() const
Return true if mode is encrypting or false if decrypting.
Definition wvblowfish.h:58
void setkey(const void *key, size_t keysize)
Sets the current Blowfish key and resets the initialization vector to all nulls.
Definition wvblowfish.cc:36
A crypto stream implementing Blowfish encryption.
Definition wvblowfish.h:88
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
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
Definition wvstream.h:25