Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:09

0001 // sosemanuk.h - originally written and placed in the public domain by Wei Dai

0002 
0003 /// \file sosemanuk.h

0004 /// \brief Classes for Sosemanuk stream cipher

0005 /// \since Crypto++ 5.5

0006 
0007 #ifndef CRYPTOPP_SOSEMANUK_H
0008 #define CRYPTOPP_SOSEMANUK_H
0009 
0010 #include "strciphr.h"
0011 #include "secblock.h"
0012 
0013 // Clang 3.3 integrated assembler crash on Linux. Clang 3.4 due to compiler

0014 // error with .intel_syntax, http://llvm.org/bugs/show_bug.cgi?id=24232

0015 #if CRYPTOPP_BOOL_X32 || defined(CRYPTOPP_DISABLE_MIXED_ASM)
0016 # define CRYPTOPP_DISABLE_SOSEMANUK_ASM 1
0017 #endif
0018 
0019 NAMESPACE_BEGIN(CryptoPP)
0020 
0021 /// \brief Sosemanuk stream cipher information

0022 /// \since Crypto++ 5.5

0023 struct SosemanukInfo : public VariableKeyLength<16, 1, 32, 1, SimpleKeyingInterface::UNIQUE_IV, 16>
0024 {
0025     CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "Sosemanuk";}
0026 };
0027 
0028 /// \brief Sosemanuk stream cipher implementation

0029 /// \since Crypto++ 5.5

0030 class SosemanukPolicy : public AdditiveCipherConcretePolicy<word32, 20>, public SosemanukInfo
0031 {
0032 protected:
0033     std::string AlgorithmProvider() const;
0034     void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length);
0035     void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
0036     void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length);
0037     bool CipherIsRandomAccess() const {return false;}
0038 #if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
0039     unsigned int GetAlignment() const;
0040     unsigned int GetOptimalBlockSize() const;
0041 #endif
0042 
0043     FixedSizeSecBlock<word32, 25*4> m_key;
0044     FixedSizeAlignedSecBlock<word32, 12> m_state;
0045 };
0046 
0047 /// \brief Sosemanuk stream cipher

0048 /// \details is a stream cipher developed by Come Berbain, Olivier Billet, Anne Canteaut, Nicolas Courtois,

0049 ///   Henri Gilbert, Louis Goubin, Aline Gouget, Louis Granboulan, Cédric Lauradoux, Marine Minier, Thomas

0050 ///   Pornin and Hervé Sibert. Sosemanuk is one of the final four Profile 1 (software) ciphers selected for

0051 ///   the eSTREAM Portfolio.

0052 /// \sa <a href="http://www.cryptolounge.org/wiki/Sosemanuk">Sosemanuk</a>

0053 /// \since Crypto++ 5.5

0054 struct Sosemanuk : public SosemanukInfo, public SymmetricCipherDocumentation
0055 {
0056     typedef SymmetricCipherFinal<ConcretePolicyHolder<SosemanukPolicy, AdditiveCipherTemplate<> >, SosemanukInfo> Encryption;
0057     typedef Encryption Decryption;
0058 };
0059 
0060 NAMESPACE_END
0061 
0062 #endif