1#ifndef CRYPTOPP_WAKE_H
2#define CRYPTOPP_WAKE_H
3
4#include "seckey.h"
5#include "secblock.h"
6#include "strciphr.h"
7
8NAMESPACE_BEGIN(CryptoPP)
9
10//! _
11template <class B = BigEndian>
12struct WAKE_CFB_Info : public FixedKeyLength<32>
13{
14	static const char *StaticAlgorithmName() {return B::ToEnum() == LITTLE_ENDIAN_ORDER ? "WAKE-CFB-LE" : "WAKE-CFB-BE";}
15};
16
17//! _
18template <class B = BigEndian>
19struct WAKE_OFB_Info : public FixedKeyLength<32>
20{
21	static const char *StaticAlgorithmName() {return B::ToEnum() == LITTLE_ENDIAN_ORDER ? "WAKE-OFB-LE" : "WAKE-OFB-BE";}
22};
23
24class CRYPTOPP_NO_VTABLE WAKE_Base
25{
26protected:
27	word32 M(word32 x, word32 y);
28	void GenKey(word32 k0, word32 k1, word32 k2, word32 k3);
29
30	word32 t[257];
31	word32 r3, r4, r5, r6;
32};
33
34template <class B = BigEndian>
35class CRYPTOPP_NO_VTABLE WAKE_Policy
36				: public CFB_CipherConcretePolicy<word32, 1>
37				, public AdditiveCipherConcretePolicy<word32, 1, 64>
38				, protected WAKE_Base
39{
40protected:
41	void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length);
42	// CFB
43	byte * GetRegisterBegin() {return (byte *)&r6;}
44	void Iterate(byte *output, const byte *input, CipherDir dir, size_t iterationCount);
45	// OFB
46	void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
47	bool CipherIsRandomAccess() const {return false;}
48};
49
50namespace Weak {
51//! <a href="http://www.cryptolounge.org/wiki/WAKE">WAKE-CFB-BE</a>
52template <class B = BigEndian>
53struct WAKE_CFB : public WAKE_CFB_Info<B>, public SymmetricCipherDocumentation
54{
55	typedef SymmetricCipherFinal<ConcretePolicyHolder<WAKE_Policy<B>, CFB_EncryptionTemplate<> >,  WAKE_CFB_Info<B> > Encryption;
56	typedef SymmetricCipherFinal<ConcretePolicyHolder<WAKE_Policy<B>, CFB_DecryptionTemplate<> >,  WAKE_CFB_Info<B> > Decryption;
57};
58}
59
60//! WAKE-OFB
61template <class B = BigEndian>
62struct WAKE_OFB : public WAKE_OFB_Info<B>, public SymmetricCipherDocumentation
63{
64	typedef SymmetricCipherFinal<ConcretePolicyHolder<WAKE_Policy<B>, AdditiveCipherTemplate<> >,  WAKE_OFB_Info<B> > Encryption;
65	typedef Encryption Decryption;
66};
67
68/*
69template <class B = BigEndian>
70class WAKE_ROFB_Policy : public WAKE_Policy<B>
71{
72protected:
73	void Iterate(KeystreamOperation operation, byte *output, const byte *input, unsigned int iterationCount);
74};
75
76template <class B = BigEndian>
77struct WAKE_ROFB : public WAKE_Info<B>
78{
79	typedef SymmetricCipherTemplate<ConcretePolicyHolder<AdditiveCipherTemplate<>, WAKE_ROFB_Policy<B> > > Encryption;
80	typedef Encryption Decryption;
81};
82*/
83
84NAMESPACE_END
85
86#endif
87