00001 #ifndef CRYPTOPP_WAKE_H
00002 #define CRYPTOPP_WAKE_H
00003
00004 #include "cryptlib.h"
00005 #include "misc.h"
00006 #include "filters.h"
00007
00008 NAMESPACE_BEGIN(CryptoPP)
00009
00010 class WAKE
00011 {
00012 protected:
00013 inline word32 M(word32 x, word32 y);
00014 inline word32 enc(word32 V);
00015 inline word32 dec(word32 V);
00016 void genkey(word32 k0, word32 k1, word32 k2, word32 k3);
00017
00018 word32 t[257];
00019 word32 r3, r4, r5, r6;
00020 };
00021
00023 class WAKEEncryption : public Filter, protected WAKE, public FixedKeyLength<32>
00024 {
00025 public:
00027 WAKEEncryption(const byte *key, BufferedTransformation *outQueue = NULL);
00028
00029 void Put(byte inByte)
00030 {
00031 if (inbufSize==INBUFMAX)
00032 ProcessInbuf();
00033 inbuf[inbufSize++] = inByte;
00034 }
00035
00036 void Put(const byte *inString, unsigned int length);
00037 void MessageEnd(int propagation=-1);
00038
00039 protected:
00040 virtual void ProcessInbuf();
00041 enum {INBUFMAX=256};
00042 SecByteBlock inbuf;
00043 unsigned int inbufSize;
00044 };
00045
00047 class WAKEDecryption : public WAKEEncryption
00048 {
00049 public:
00051 WAKEDecryption(const byte *key, BufferedTransformation *outQueue = NULL)
00052 : WAKEEncryption(key, outQueue) {lastBlock=false;}
00053
00054 void MessageEnd(int propagation=-1);
00055
00056 protected:
00057 virtual void ProcessInbuf();
00058 bool lastBlock;
00059 };
00060
00061 NAMESPACE_END
00062
00063 #endif