~zooko/cryptopp/trunk

1 by weidai
Initial revision
1
#ifndef CRYPTOPP_WAKE_H
2
#define CRYPTOPP_WAKE_H
3
4
#include "seckey.h"
5
#include "secblock.h"
6
#include "strciphr.h"
7
8
NAMESPACE_BEGIN(CryptoPP)
9
173 by weidai
fix documentation, fix PanamaMAC, fix algorithm names
10
//! _
1 by weidai
Initial revision
11
template <class B = BigEndian>
173 by weidai
fix documentation, fix PanamaMAC, fix algorithm names
12
struct WAKE_CFB_Info : public FixedKeyLength<32>
1 by weidai
Initial revision
13
{
14
	static const char *StaticAlgorithmName() {return B::ToEnum() == LITTLE_ENDIAN_ORDER ? "WAKE-CFB-LE" : "WAKE-CFB-BE";}
15
};
16
173 by weidai
fix documentation, fix PanamaMAC, fix algorithm names
17
//! _
18
template <class B = BigEndian>
19
struct 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
57 by weidai
add CRYPTOPP_NO_VTABLE
24
class CRYPTOPP_NO_VTABLE WAKE_Base
1 by weidai
Initial revision
25
{
26
protected:
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
34
template <class B = BigEndian>
173 by weidai
fix documentation, fix PanamaMAC, fix algorithm names
35
class CRYPTOPP_NO_VTABLE WAKE_Policy
36
				: public CFB_CipherConcretePolicy<word32, 1>
1 by weidai
Initial revision
37
				, public AdditiveCipherConcretePolicy<word32, 1, 64>
38
				, protected WAKE_Base
39
{
40
protected:
184 by weidai
port to MSVC .NET 2005 beta 2
41
	void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length);
1 by weidai
Initial revision
42
	// CFB
43
	byte * GetRegisterBegin() {return (byte *)&r6;}
184 by weidai
port to MSVC .NET 2005 beta 2
44
	void Iterate(byte *output, const byte *input, CipherDir dir, size_t iterationCount);
1 by weidai
Initial revision
45
	// OFB
184 by weidai
port to MSVC .NET 2005 beta 2
46
	void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
1 by weidai
Initial revision
47
	bool IsRandomAccess() const {return false;}
48
};
49
267 by weidai
move MD2, MD4, MD5, PanamaHash, WAKE_CFB into the namespace 'Weak'
50
namespace Weak {
51
//! <a href="http://www.cryptolounge.org/wiki/WAKE">WAKE-CFB-BE</a>
1 by weidai
Initial revision
52
template <class B = BigEndian>
173 by weidai
fix documentation, fix PanamaMAC, fix algorithm names
53
struct WAKE_CFB : public WAKE_CFB_Info<B>, public SymmetricCipherDocumentation
1 by weidai
Initial revision
54
{
173 by weidai
fix documentation, fix PanamaMAC, fix algorithm names
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;
1 by weidai
Initial revision
57
};
267 by weidai
move MD2, MD4, MD5, PanamaHash, WAKE_CFB into the namespace 'Weak'
58
}
1 by weidai
Initial revision
59
60
//! WAKE-OFB
61
template <class B = BigEndian>
173 by weidai
fix documentation, fix PanamaMAC, fix algorithm names
62
struct WAKE_OFB : public WAKE_OFB_Info<B>, public SymmetricCipherDocumentation
1 by weidai
Initial revision
63
{
173 by weidai
fix documentation, fix PanamaMAC, fix algorithm names
64
	typedef SymmetricCipherFinal<ConcretePolicyHolder<WAKE_Policy<B>, AdditiveCipherTemplate<> >,  WAKE_OFB_Info<B> > Encryption;
1 by weidai
Initial revision
65
	typedef Encryption Decryption;
66
};
67
68
/*
69
template <class B = BigEndian>
70
class WAKE_ROFB_Policy : public WAKE_Policy<B>
71
{
72
protected:
73
	void Iterate(KeystreamOperation operation, byte *output, const byte *input, unsigned int iterationCount);
74
};
75
76
template <class B = BigEndian>
77
struct WAKE_ROFB : public WAKE_Info<B>
78
{
79
	typedef SymmetricCipherTemplate<ConcretePolicyHolder<AdditiveCipherTemplate<>, WAKE_ROFB_Policy<B> > > Encryption;
80
	typedef Encryption Decryption;
81
};
82
*/
83
84
NAMESPACE_END
85
86
#endif