WvStreams
debian/libwvstreams-dev/usr/include/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
87class WvBlowfishStream : public WvEncoderStream
88{
89public:
90 WvBlowfishStream(WvStream *_cloned,
91 const void *key, size_t _keysize,
94 virtual ~WvBlowfishStream() { }
95};
96
97#endif // __WVBLOWFISH_H
An encoder implementing the Blowfish encryption method.
WvBlowfishEncoder(Mode mode, const void *key, size_t keysize)
Creates a new Blowfish cipher encoder.
Definition wvblowfish.cc:14
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.
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
WvEncoderStream(WvStream *cloned)
Creates an encoder stream.
WvEncoder()
Creates a new WvEncoder.
Definition wvencoder.cc:11
bool flush(WvBuf &inbuf, WvBuf &outbuf, bool finish=false)
Flushes the encoder and optionally finishes it.
WvStream()
Basic constructor for just a do-nothing WvStream.
Definition wvstream.cc:249