00001 #ifndef CRYPTOPP_WAKE_H
00002 #define CRYPTOPP_WAKE_H
00003
00004 #include "seckey.h"
00005 #include "secblock.h"
00006 #include "strciphr.h"
00007
00008 NAMESPACE_BEGIN(CryptoPP)
00009
00010 template <class B = BigEndian>
00011 struct WAKE_Info : public FixedKeyLength<32>
00012 {
00013 static const char *StaticAlgorithmName() {return B::ToEnum() == LITTLE_ENDIAN_ORDER ? "WAKE-CFB-LE" : "WAKE-CFB-BE";}
00014 };
00015
00016 class WAKE_Base
00017 {
00018 protected:
00019 word32 M(word32 x, word32 y);
00020 void GenKey(word32 k0, word32 k1, word32 k2, word32 k3);
00021
00022 word32 t[257];
00023 word32 r3, r4, r5, r6;
00024 };
00025
00026 template <class B = BigEndian>
00027 class WAKE_Policy : public WAKE_Info<B>
00028 , public CFB_CipherConcretePolicy<word32, 1>
00029 , public AdditiveCipherConcretePolicy<word32, 1, 64>
00030 , protected WAKE_Base
00031 {
00032 protected:
00033 void CipherSetKey(const NameValuePairs ¶ms, const byte *key, unsigned int length);
00034
00035 byte * GetRegisterBegin() {return (byte *)&r6;}
00036 void Iterate(byte *output, const byte *input, CipherDir dir, unsigned int iterationCount);
00037
00038 void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, unsigned int iterationCount);
00039 bool IsRandomAccess() const {return false;}
00040 };
00041
00042
00043 template <class B = BigEndian>
00044 struct WAKE_CFB : public WAKE_Info<B>, public SymmetricCipherDocumentation
00045 {
00046 typedef SymmetricCipherFinalTemplate<ConcretePolicyHolder<WAKE_Policy<B>, CFB_EncryptionTemplate<> > > Encryption;
00047 typedef SymmetricCipherFinalTemplate<ConcretePolicyHolder<WAKE_Policy<B>, CFB_DecryptionTemplate<> > > Decryption;
00048 };
00049
00050
00051 template <class B = BigEndian>
00052 struct WAKE_OFB : public WAKE_Info<B>, public SymmetricCipherDocumentation
00053 {
00054 typedef SymmetricCipherFinalTemplate<ConcretePolicyHolder<WAKE_Policy<B>, AdditiveCipherTemplate<> > > Encryption;
00055 typedef Encryption Decryption;
00056 };
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 NAMESPACE_END
00075
00076 #endif