00001 #ifndef CRYPTOPP_SEAL_H
00002 #define CRYPTOPP_SEAL_H
00003
00004 #include "strciphr.h"
00005
00006 NAMESPACE_BEGIN(CryptoPP)
00007
00008
00009 template <class B = BigEndian>
00010 struct SEAL_Info : public FixedKeyLength<20, SimpleKeyingInterface::INTERNALLY_GENERATED_IV>
00011 {
00012 static const char *StaticAlgorithmName() {return B::ToEnum() == LITTLE_ENDIAN_ORDER ? "SEAL-3.0-LE" : "SEAL-3.0-BE";}
00013 };
00014
00015 template <class B = BigEndian>
00016 class CRYPTOPP_NO_VTABLE SEAL_Policy : public AdditiveCipherConcretePolicy<word32, 256>, public SEAL_Info<B>
00017 {
00018 public:
00019 unsigned int IVSize() const {return 4;}
00020 void GetNextIV(byte *IV) const {UnalignedPutWord(BIG_ENDIAN_ORDER, IV, m_outsideCounter+1);}
00021
00022 protected:
00023 void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length);
00024 void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
00025 void CipherResynchronize(byte *keystreamBuffer, const byte *IV);
00026 bool IsRandomAccess() const {return true;}
00027 void SeekToIteration(lword iterationCount);
00028
00029 private:
00030 FixedSizeSecBlock<word32, 512> m_T;
00031 FixedSizeSecBlock<word32, 256> m_S;
00032 SecBlock<word32> m_R;
00033
00034 word32 m_startCount, m_iterationsPerCount;
00035 word32 m_outsideCounter, m_insideCounter;
00036 };
00037
00038
00039 template <class B = BigEndian>
00040 struct SEAL : public SEAL_Info<B>, public SymmetricCipherDocumentation
00041 {
00042 typedef SymmetricCipherFinal<ConcretePolicyHolder<SEAL_Policy<B>, AdditiveCipherTemplate<> >, SEAL_Info<B> > Encryption;
00043 typedef Encryption Decryption;
00044 };
00045
00046 NAMESPACE_END
00047
00048 #endif