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::UNIQUE_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 CipherResynchronize(byte *keystreamBuffer, const byte *IV);
00022         bool IsRandomAccess() const {return true;}
00023         void SeekToIteration(lword iterationCount);
00024 #if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X64
00025         unsigned int GetAlignment() const;
00026         unsigned int GetOptimalBlockSize() const;
00027 #endif
00028 
00029 private:
00030         FixedSizeAlignedSecBlock<word32, 16> m_state;
00031         int m_rounds;
00032 };
00033 
00034 /// <a href="http://www.cryptolounge.org/wiki/Salsa20">Salsa20</a>, variable rounds: 8, 12 or 20 (default 20)
00035 struct Salsa20 : public Salsa20_Info, public SymmetricCipherDocumentation
00036 {
00037         typedef SymmetricCipherFinal<ConcretePolicyHolder<Salsa20_Policy, AdditiveCipherTemplate<> >, Salsa20_Info> Encryption;
00038         typedef Encryption Decryption;
00039 };
00040 
00041 NAMESPACE_END
00042 
00043 #endif

Generated on Fri Jun 1 11:11:24 2007 for Crypto++ by  doxygen 1.5.2