WvStreams
wvxor.h
00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Tunnel Vision Software:
00003  *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
00004  *
00005  * XOR cryptography abstractions.
00006  * Could use this to implement short one time pads.
00007  */
00008 #ifndef __WVXOR_H
00009 #define __WVXOR_H
00010 
00011 #include "wvencoder.h"
00012 #include "wvencoderstream.h"
00013 
00018 class WvXOREncoder : public WvEncoder
00019 {
00020 public:
00026     WvXOREncoder(const void *_key, size_t _keylen);
00027     virtual ~WvXOREncoder();
00028     
00029 protected:
00030     bool _encode(WvBuf &in, WvBuf &out, bool flush);
00031 
00032 private:
00033     unsigned char *key;
00034     size_t keylen;
00035     int keyoff;
00036 };
00037 
00038 
00043 class WvXORStream : public WvEncoderStream
00044 {
00045 public:
00046     WvXORStream(WvStream *_cloned, const void *key, size_t _keysize);
00047     virtual ~WvXORStream() { }
00048 public:
00049     const char *wstype() const { return "WvXORStream"; }
00050 };
00051 
00052 #endif /// __WVXOR_H