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, 4>
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 protected:
00019 void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length);
00020 void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
00021 void CipherGetNextIV(byte *IV) {UnalignedPutWord(BIG_ENDIAN_ORDER, IV, m_outsideCounter+1);}
00022 void CipherResynchronize(byte *keystreamBuffer, const byte *IV);
00023 bool IsRandomAccess() const {return true;}
00024 void SeekToIteration(lword iterationCount);
00025
00026 private:
00027 FixedSizeSecBlock<word32, 512> m_T;
00028 FixedSizeSecBlock<word32, 256> m_S;
00029 SecBlock<word32> m_R;
00030
00031 word32 m_startCount, m_iterationsPerCount;
00032 word32 m_outsideCounter, m_insideCounter;
00033 };
00034
00035
00036 template <class B = BigEndian>
00037 struct SEAL : public SEAL_Info<B>, public SymmetricCipherDocumentation
00038 {
00039 typedef SymmetricCipherFinal<ConcretePolicyHolder<SEAL_Policy<B>, AdditiveCipherTemplate<> >, SEAL_Info<B> > Encryption;
00040 typedef Encryption Decryption;
00041 };
00042
00043 NAMESPACE_END
00044
00045 #endif