1#ifndef CRYPTOPP_SEAL_H
2#define CRYPTOPP_SEAL_H
3
4#include "strciphr.h"
5
6NAMESPACE_BEGIN(CryptoPP)
7
8//! _
9template <class B = BigEndian>
10struct SEAL_Info : public FixedKeyLength<20, SimpleKeyingInterface::INTERNALLY_GENERATED_IV, 4>
11{
12	static const char *StaticAlgorithmName() {return B::ToEnum() == LITTLE_ENDIAN_ORDER ? "SEAL-3.0-LE" : "SEAL-3.0-BE";}
13};
14
15template <class B = BigEndian>
16class CRYPTOPP_NO_VTABLE SEAL_Policy : public AdditiveCipherConcretePolicy<word32, 256>, public SEAL_Info<B>
17{
18protected:
19	void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length);
20	void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
21	void CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length);
22	bool CipherIsRandomAccess() const {return true;}
23	void SeekToIteration(lword iterationCount);
24
25private:
26	FixedSizeSecBlock<word32, 512> m_T;
27	FixedSizeSecBlock<word32, 256> m_S;
28	SecBlock<word32> m_R;
29
30	word32 m_startCount, m_iterationsPerCount;
31	word32 m_outsideCounter, m_insideCounter;
32};
33
34//! <a href="http://www.weidai.com/scan-mirror/cs.html#SEAL-3.0-BE">SEAL</a>
35template <class B = BigEndian>
36struct SEAL : public SEAL_Info<B>, public SymmetricCipherDocumentation
37{
38	typedef SymmetricCipherFinal<ConcretePolicyHolder<SEAL_Policy<B>, AdditiveCipherTemplate<> >, SEAL_Info<B> > Encryption;
39	typedef Encryption Decryption;
40};
41
42NAMESPACE_END
43
44#endif
45