1 | // sosemanuk.h - written and placed in the public domain by Wei Dai |
---|
2 | |
---|
3 | //! \file sosemanuk.h |
---|
4 | //! \brief Classes for Sosemanuk stream cipher |
---|
5 | |
---|
6 | #ifndef CRYPTOPP_SOSEMANUK_H |
---|
7 | #define CRYPTOPP_SOSEMANUK_H |
---|
8 | |
---|
9 | #include "strciphr.h" |
---|
10 | #include "secblock.h" |
---|
11 | |
---|
12 | // Clang due to "Inline assembly operands don't work with .intel_syntax" |
---|
13 | // https://llvm.org/bugs/show_bug.cgi?id=24232 |
---|
14 | #if CRYPTOPP_BOOL_X32 || defined(CRYPTOPP_DISABLE_INTEL_ASM) |
---|
15 | # define CRYPTOPP_DISABLE_SOSEMANUK_ASM |
---|
16 | #endif |
---|
17 | |
---|
18 | NAMESPACE_BEGIN(CryptoPP) |
---|
19 | |
---|
20 | //! algorithm info |
---|
21 | struct SosemanukInfo : public VariableKeyLength<16, 1, 32, 1, SimpleKeyingInterface::UNIQUE_IV, 16> |
---|
22 | { |
---|
23 | CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "Sosemanuk";} |
---|
24 | }; |
---|
25 | |
---|
26 | //! _ |
---|
27 | class SosemanukPolicy : public AdditiveCipherConcretePolicy<word32, 20>, public SosemanukInfo |
---|
28 | { |
---|
29 | protected: |
---|
30 | void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length); |
---|
31 | void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount); |
---|
32 | void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length); |
---|
33 | bool CipherIsRandomAccess() const {return false;} |
---|
34 | #if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) && !defined(CRYPTOPP_DISABLE_SOSEMANUK_ASM) |
---|
35 | unsigned int GetAlignment() const; |
---|
36 | unsigned int GetOptimalBlockSize() const; |
---|
37 | #endif |
---|
38 | |
---|
39 | FixedSizeSecBlock<word32, 25*4> m_key; |
---|
40 | FixedSizeAlignedSecBlock<word32, 12> m_state; |
---|
41 | }; |
---|
42 | |
---|
43 | //! <a href="http://www.cryptolounge.org/wiki/Sosemanuk">Sosemanuk</a> |
---|
44 | struct Sosemanuk : public SosemanukInfo, public SymmetricCipherDocumentation |
---|
45 | { |
---|
46 | typedef SymmetricCipherFinal<ConcretePolicyHolder<SosemanukPolicy, AdditiveCipherTemplate<> >, SosemanukInfo> Encryption; |
---|
47 | typedef Encryption Decryption; |
---|
48 | }; |
---|
49 | |
---|
50 | NAMESPACE_END |
---|
51 | |
---|
52 | #endif |
---|