WvStreams
wvcountermode.h
00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Tunnel Vision Software:
00003  *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
00004  *
00005  * A 'counter mode' cryptography engine abstraction.
00006  */
00007 #ifndef __WVCOUNTERMODE_H
00008 #define __WVCOUNTERMODE_H
00009 
00010 #include "wvencoder.h"
00011 
00013 class WvCounterModeEncoder : public WvEncoder
00014 {
00015 public:
00016     WvEncoder *keycrypt;
00017 
00025     WvCounterModeEncoder(WvEncoder *_keycrypt,
00026         const void *_counter, size_t _countersize);
00027     virtual ~WvCounterModeEncoder();
00028 
00034     void setcounter(const void *counter, size_t countersize);
00035 
00040     void getcounter(void *counter) const;
00041 
00043     size_t getcountersize() const
00044         { return countersize; }
00045     
00047     virtual void incrcounter();
00048     
00049 private:
00050     WvConstInPlaceBuf counterbuf;
00051 
00052 protected:
00053     unsigned char *counter; // auto-incrementing counter
00054     size_t countersize; // counter size in bytes
00055     
00056     virtual bool _encode(WvBuf &inbuf, WvBuf &outbuf, bool flush);
00057 };
00058 
00059 #endif // __WVCOUNTERMODE_H