Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

wvcountermode.h

Go to the documentation of this file.
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 00012 /** A counter mode encryption encoder. */ 00013 class WvCounterModeEncoder : public WvEncoder 00014 { 00015 public: 00016 WvEncoder *keycrypt; 00017 00018 /** 00019 * Create a new counter mode encoder / decoder. 00020 * _keycrypt : the underlying encoder for generating the keystream 00021 * (note: takes ownership of this encoder) 00022 * _counter : the initial counter value 00023 * _countersize : the counter size, must equal crypto block size 00024 */ 00025 WvCounterModeEncoder(WvEncoder *_keycrypt, 00026 const void *_counter, size_t _countersize); 00027 virtual ~WvCounterModeEncoder(); 00028 00029 /** 00030 * Sets the Counter mode auto-incrementing counter. 00031 * counter : the counter 00032 * countersize : the new counter size, must equal crypto block size 00033 */ 00034 void setcounter(const void *counter, size_t countersize); 00035 00036 /** 00037 * Stores the current counter in the supplied buffer. 00038 * counter : the array that receives the counter 00039 */ 00040 void getcounter(void *counter) const; 00041 00042 /** Returns the counter size. */ 00043 size_t getcountersize() const 00044 { return countersize; } 00045 00046 /** Increments the counter. */ 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

Generated on Tue Oct 5 01:09:20 2004 for WvStreams by doxygen 1.3.7