1 // sosemanuk.h - originally written and placed in the public domain by Wei Dai 2 3 /// \file sosemanuk.h 4 /// \brief Classes for Sosemanuk stream cipher 5 /// \since Crypto++ 5.5 6 7 #ifndef CRYPTOPP_SOSEMANUK_H 8 #define CRYPTOPP_SOSEMANUK_H 9 10 #include "strciphr.h" 11 #include "secblock.h" 12 13 // Clang 3.3 integrated assembler crash on Linux. Clang 3.4 due to compiler 14 // error with .intel_syntax, http://llvm.org/bugs/show_bug.cgi?id=24232 15 #if CRYPTOPP_BOOL_X32 || defined(CRYPTOPP_DISABLE_MIXED_ASM) 16 # define CRYPTOPP_DISABLE_SOSEMANUK_ASM 1 17 #endif 18 19 NAMESPACE_BEGIN(CryptoPP) 20 21 /// \brief Sosemanuk stream cipher information 22 /// \since Crypto++ 5.5 23 struct SosemanukInfo : public VariableKeyLength<16, 1, 32, 1, SimpleKeyingInterface::UNIQUE_IV, 16> 24 { StaticAlgorithmNameSosemanukInfo25 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "Sosemanuk";} 26 }; 27 28 /// \brief Sosemanuk stream cipher implementation 29 /// \since Crypto++ 5.5 30 class SosemanukPolicy : public AdditiveCipherConcretePolicy<word32, 20>, public SosemanukInfo 31 { 32 protected: 33 std::string AlgorithmProvider() const; 34 void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length); 35 void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount); 36 void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length); CipherIsRandomAccess()37 bool CipherIsRandomAccess() const {return false;} 38 #if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) 39 unsigned int GetAlignment() const; 40 unsigned int GetOptimalBlockSize() const; 41 #endif 42 43 FixedSizeSecBlock<word32, 25*4> m_key; 44 FixedSizeAlignedSecBlock<word32, 12> m_state; 45 }; 46 47 /// \brief Sosemanuk stream cipher 48 /// \details is a stream cipher developed by Come Berbain, Olivier Billet, Anne Canteaut, Nicolas Courtois, 49 /// Henri Gilbert, Louis Goubin, Aline Gouget, Louis Granboulan, Cédric Lauradoux, Marine Minier, Thomas 50 /// Pornin and Hervé Sibert. Sosemanuk is one of the final four Profile 1 (software) ciphers selected for 51 /// the eSTREAM Portfolio. 52 /// \sa <a href="http://www.cryptolounge.org/wiki/Sosemanuk">Sosemanuk</a> 53 /// \since Crypto++ 5.5 54 struct Sosemanuk : public SosemanukInfo, public SymmetricCipherDocumentation 55 { 56 typedef SymmetricCipherFinal<ConcretePolicyHolder<SosemanukPolicy, AdditiveCipherTemplate<> >, SosemanukInfo> Encryption; 57 typedef Encryption Decryption; 58 }; 59 60 NAMESPACE_END 61 62 #endif 63