salsa.h

00001 // salsa.h - written and placed in the public domain by Wei Dai
00002 
00003 #ifndef CRYPTOPP_SALSA_H
00004 #define CRYPTOPP_SALSA_H
00005 
00006 #include "strciphr.h"
00007 
00008 NAMESPACE_BEGIN(CryptoPP)
00009 
00010 //! _
00011 struct Salsa20_Info : public VariableKeyLength<32, 16, 32, 16, SimpleKeyingInterface::STRUCTURED_IV, 8>
00012 {
00013         static const char *StaticAlgorithmName() {return "Salsa20";}
00014 };
00015 
00016 class CRYPTOPP_NO_VTABLE Salsa20_Policy : public AdditiveCipherConcretePolicy<word32, 16>, public Salsa20_Info
00017 {
00018 protected:
00019         void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length);
00020         void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
00021         void CipherGetNextIV(byte *IV);
00022         void CipherResynchronize(byte *keystreamBuffer, const byte *IV);
00023         bool IsRandomAccess() const {return true;}
00024         void SeekToIteration(lword iterationCount);
00025 
00026 private:
00027         int m_rounds;
00028         FixedSizeSecBlock<word32, 16> m_state;
00029 };
00030 
00031 //! Salsa20, variable rounds: 8, 12 or 20 (default 20)
00032 struct Salsa20 : public Salsa20_Info, public SymmetricCipherDocumentation
00033 {
00034         typedef SymmetricCipherFinal<ConcretePolicyHolder<Salsa20_Policy, AdditiveCipherTemplate<> >, Salsa20_Info> Encryption;
00035         typedef Encryption Decryption;
00036 };
00037 
00038 NAMESPACE_END
00039 
00040 #endif

Generated on Sat Dec 23 02:07:10 2006 for Crypto++ by  doxygen 1.5.1-p1