WvStreams
wvcountermode.h
1 /* -*- Mode: C++ -*-
2  * Worldvisions Tunnel Vision Software:
3  * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4  *
5  * A 'counter mode' cryptography engine abstraction.
6  */
7 #ifndef __WVCOUNTERMODE_H
8 #define __WVCOUNTERMODE_H
9 
10 #include "wvencoder.h"
11 
14 {
15 public:
16  WvEncoder *keycrypt;
17 
26  const void *_counter, size_t _countersize);
27  virtual ~WvCounterModeEncoder();
28 
34  void setcounter(const void *counter, size_t countersize);
35 
40  void getcounter(void *counter) const;
41 
43  size_t getcountersize() const
44  { return countersize; }
45 
47  virtual void incrcounter();
48 
49 private:
50  WvConstInPlaceBuf counterbuf;
51 
52 protected:
53  unsigned char *counter; // auto-incrementing counter
54  size_t countersize; // counter size in bytes
55 
56  virtual bool _encode(WvBuf &inbuf, WvBuf &outbuf, bool flush);
57 };
58 
59 #endif // __WVCOUNTERMODE_H
WvEncoder
The base encoder class.
Definition: wvencoder.h:67
WvCounterModeEncoder::setcounter
void setcounter(const void *counter, size_t countersize)
Sets the Counter mode auto-incrementing counter.
Definition: wvcountermode.cc:25
WvCounterModeEncoder::getcounter
void getcounter(void *counter) const
Stores the current counter in the supplied buffer.
Definition: wvcountermode.cc:34
WvCounterModeEncoder::WvCounterModeEncoder
WvCounterModeEncoder(WvEncoder *_keycrypt, const void *_counter, size_t _countersize)
Create a new counter mode encoder / decoder.
Definition: wvcountermode.cc:10
WvCounterModeEncoder
A counter mode encryption encoder.
Definition: wvcountermode.h:13
WvCounterModeEncoder::incrcounter
virtual void incrcounter()
Increments the counter.
Definition: wvcountermode.cc:40
WvBufBase< unsigned char >
Specialization of WvBufBase for unsigned char type buffers intended for use with raw memory buffers.
Definition: wvbuf.h:22
WvCounterModeEncoder::getcountersize
size_t getcountersize() const
Returns the counter size.
Definition: wvcountermode.h:43
WvConstInPlaceBuf
The const in place raw memory buffer type.
Definition: wvbuf.h:187
WvEncoder::flush
bool flush(WvBuf &inbuf, WvBuf &outbuf, bool finish=false)
Flushes the encoder and optionally finishes it.
Definition: wvencoder.h:163
WvCounterModeEncoder::_encode
virtual bool _encode(WvBuf &inbuf, WvBuf &outbuf, bool flush)
Template method implementation of encode().
Definition: wvcountermode.cc:46