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
00011 template <class B = BigEndian>
00012 struct WAKE_CFB_Info : public FixedKeyLength<32>
00013 {
00014 static const char *StaticAlgorithmName() {return B::ToEnum() == LITTLE_ENDIAN_ORDER ? "WAKE-CFB-LE" : "WAKE-CFB-BE";}
00015 };
00016
00017
00018 template <class B = BigEndian>
00019 struct WAKE_OFB_Info : public FixedKeyLength<32>
00020 {
00021 static const char *StaticAlgorithmName() {return B::ToEnum() == LITTLE_ENDIAN_ORDER ? "WAKE-OFB-LE" : "WAKE-OFB-BE";}
00022 };
00023
00024 class CRYPTOPP_NO_VTABLE WAKE_Base
00025 {
00026 protected:
00027 word32 M(word32 x, word32 y);
00028 void GenKey(word32 k0, word32 k1, word32 k2, word32 k3);
00029
00030 word32 t[257];
00031 word32 r3, r4, r5, r6;
00032 };
00033
00034 template <class B = BigEndian>
00035 class CRYPTOPP_NO_VTABLE WAKE_Policy
00036 : public CFB_CipherConcretePolicy<word32, 1>
00037 , public AdditiveCipherConcretePolicy<word32, 1, 64>
00038 , protected WAKE_Base
00039 {
00040 protected:
00041 void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length);
00042
00043 byte * GetRegisterBegin() {return (byte *)&r6;}
00044 void Iterate(byte *output, const byte *input, CipherDir dir, size_t iterationCount);
00045
00046 void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
00047 bool IsRandomAccess() const {return false;}
00048 };
00049
00050
00051 template <class B = BigEndian>
00052 struct WAKE_CFB : public WAKE_CFB_Info<B>, public SymmetricCipherDocumentation
00053 {
00054 typedef SymmetricCipherFinal<ConcretePolicyHolder<WAKE_Policy<B>, CFB_EncryptionTemplate<> >, WAKE_CFB_Info<B> > Encryption;
00055 typedef SymmetricCipherFinal<ConcretePolicyHolder<WAKE_Policy<B>, CFB_DecryptionTemplate<> >, WAKE_CFB_Info<B> > Decryption;
00056 };
00057
00058
00059 template <class B = BigEndian>
00060 struct WAKE_OFB : public WAKE_OFB_Info<B>, public SymmetricCipherDocumentation
00061 {
00062 typedef SymmetricCipherFinal<ConcretePolicyHolder<WAKE_Policy<B>, AdditiveCipherTemplate<> >, WAKE_OFB_Info<B> > Encryption;
00063 typedef Encryption Decryption;
00064 };
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 NAMESPACE_END
00083
00084 #endif