wake.h

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 &params, const byte *key, size_t length);
00042         // CFB
00043         byte * GetRegisterBegin() {return (byte *)&r6;}
00044         void Iterate(byte *output, const byte *input, CipherDir dir, size_t iterationCount);
00045         // OFB
00046         void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
00047         bool IsRandomAccess() const {return false;}
00048 };
00049 
00050 namespace Weak {
00051 //! <a href="http://www.cryptolounge.org/wiki/WAKE">WAKE-CFB-BE</a>
00052 template <class B = BigEndian>
00053 struct WAKE_CFB : public WAKE_CFB_Info<B>, public SymmetricCipherDocumentation
00054 {
00055         typedef SymmetricCipherFinal<ConcretePolicyHolder<WAKE_Policy<B>, CFB_EncryptionTemplate<> >,  WAKE_CFB_Info<B> > Encryption;
00056         typedef SymmetricCipherFinal<ConcretePolicyHolder<WAKE_Policy<B>, CFB_DecryptionTemplate<> >,  WAKE_CFB_Info<B> > Decryption;
00057 };
00058 }
00059 
00060 //! WAKE-OFB
00061 template <class B = BigEndian>
00062 struct WAKE_OFB : public WAKE_OFB_Info<B>, public SymmetricCipherDocumentation
00063 {
00064         typedef SymmetricCipherFinal<ConcretePolicyHolder<WAKE_Policy<B>, AdditiveCipherTemplate<> >,  WAKE_OFB_Info<B> > Encryption;
00065         typedef Encryption Decryption;
00066 };
00067 
00068 /*
00069 template <class B = BigEndian>
00070 class WAKE_ROFB_Policy : public WAKE_Policy<B>
00071 {
00072 protected:
00073         void Iterate(KeystreamOperation operation, byte *output, const byte *input, unsigned int iterationCount);
00074 };
00075 
00076 template <class B = BigEndian>
00077 struct WAKE_ROFB : public WAKE_Info<B>
00078 {
00079         typedef SymmetricCipherTemplate<ConcretePolicyHolder<AdditiveCipherTemplate<>, WAKE_ROFB_Policy<B> > > Encryption;
00080         typedef Encryption Decryption;
00081 };
00082 */
00083 
00084 NAMESPACE_END
00085 
00086 #endif

Generated on Fri Jun 1 11:11:25 2007 for Crypto++ by  doxygen 1.5.2