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.

68 lines
1.8 KiB

  1. // wake.h - written and placed in the public domain by Wei Dai
  2. //! \file wake.h
  3. //! \brief Classes for WAKE stream cipher
  4. #ifndef CRYPTOPP_WAKE_H
  5. #define CRYPTOPP_WAKE_H
  6. #include "seckey.h"
  7. #include "secblock.h"
  8. #include "strciphr.h"
  9. NAMESPACE_BEGIN(CryptoPP)
  10. //! _
  11. template <class B = BigEndian>
  12. struct WAKE_OFB_Info : public FixedKeyLength<32>
  13. {
  14. static const char *StaticAlgorithmName() {return B::ToEnum() == LITTLE_ENDIAN_ORDER ? "WAKE-OFB-LE" : "WAKE-OFB-BE";}
  15. };
  16. class CRYPTOPP_NO_VTABLE WAKE_Base
  17. {
  18. protected:
  19. word32 M(word32 x, word32 y);
  20. void GenKey(word32 k0, word32 k1, word32 k2, word32 k3);
  21. word32 t[257];
  22. word32 r3, r4, r5, r6;
  23. };
  24. template <class B = BigEndian>
  25. class CRYPTOPP_NO_VTABLE WAKE_Policy : public AdditiveCipherConcretePolicy<word32, 1, 64>, protected WAKE_Base
  26. {
  27. protected:
  28. void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length);
  29. // OFB
  30. void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
  31. bool CipherIsRandomAccess() const {return false;}
  32. };
  33. //! WAKE-OFB
  34. template <class B = BigEndian>
  35. struct WAKE_OFB : public WAKE_OFB_Info<B>, public SymmetricCipherDocumentation
  36. {
  37. typedef SymmetricCipherFinal<ConcretePolicyHolder<WAKE_Policy<B>, AdditiveCipherTemplate<> >, WAKE_OFB_Info<B> > Encryption;
  38. typedef Encryption Decryption;
  39. };
  40. /*
  41. template <class B = BigEndian>
  42. class WAKE_ROFB_Policy : public WAKE_Policy<B>
  43. {
  44. protected:
  45. void Iterate(KeystreamOperation operation, byte *output, const byte *input, unsigned int iterationCount);
  46. };
  47. template <class B = BigEndian>
  48. struct WAKE_ROFB : public WAKE_Info<B>
  49. {
  50. typedef SymmetricCipherTemplate<ConcretePolicyHolder<AdditiveCipherTemplate<>, WAKE_ROFB_Policy<B> > > Encryption;
  51. typedef Encryption Decryption;
  52. };
  53. */
  54. NAMESPACE_END
  55. #endif