wvdbusserver: implement NameHasOwner request.
[wvstreams.git] / include / wvcountermode.h
blob4a5d2b611cb769de0dab51af5998fec6926bfc38
1 /* -*- Mode: C++ -*-
2 * Worldvisions Tunnel Vision Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
5 * A 'counter mode' cryptography engine abstraction.
6 */
7 #ifndef __WVCOUNTERMODE_H
8 #define __WVCOUNTERMODE_H
10 #include "wvencoder.h"
12 /** A counter mode encryption encoder. */
13 class WvCounterModeEncoder : public WvEncoder
15 public:
16 WvEncoder *keycrypt;
18 /**
19 * Create a new counter mode encoder / decoder.
20 * _keycrypt : the underlying encoder for generating the keystream
21 * (note: takes ownership of this encoder)
22 * _counter : the initial counter value
23 * _countersize : the counter size, must equal crypto block size
25 WvCounterModeEncoder(WvEncoder *_keycrypt,
26 const void *_counter, size_t _countersize);
27 virtual ~WvCounterModeEncoder();
29 /**
30 * Sets the Counter mode auto-incrementing counter.
31 * counter : the counter
32 * countersize : the new counter size, must equal crypto block size
34 void setcounter(const void *counter, size_t countersize);
36 /**
37 * Stores the current counter in the supplied buffer.
38 * counter : the array that receives the counter
40 void getcounter(void *counter) const;
42 /** Returns the counter size. */
43 size_t getcountersize() const
44 { return countersize; }
46 /** Increments the counter. */
47 virtual void incrcounter();
49 private:
50 WvConstInPlaceBuf counterbuf;
52 protected:
53 unsigned char *counter; // auto-incrementing counter
54 size_t countersize; // counter size in bytes
56 virtual bool _encode(WvBuf &inbuf, WvBuf &outbuf, bool flush);
59 #endif // __WVCOUNTERMODE_H