Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.7 KiB

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