Counter Strike : Global Offensive Source Code
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.

49 lines
1.9 KiB

  1. #ifndef CRYPTOPP_AUTHENC_H
  2. #define CRYPTOPP_AUTHENC_H
  3. #include "cryptlib.h"
  4. #include "secblock.h"
  5. NAMESPACE_BEGIN(CryptoPP)
  6. //! .
  7. class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE AuthenticatedSymmetricCipherBase : public AuthenticatedSymmetricCipher
  8. {
  9. public:
  10. AuthenticatedSymmetricCipherBase() : m_state(State_Start) {}
  11. bool IsRandomAccess() const {return false;}
  12. bool IsSelfInverting() const {return true;}
  13. void UncheckedSetKey(const byte *,unsigned int,const CryptoPP::NameValuePairs &) {assert(false);}
  14. void SetKey(const byte *userKey, size_t keylength, const NameValuePairs &params);
  15. void Restart() {if (m_state > State_KeySet) m_state = State_KeySet;}
  16. void Resynchronize(const byte *iv, int length=-1);
  17. void Update(const byte *input, size_t length);
  18. void ProcessData(byte *outString, const byte *inString, size_t length);
  19. void TruncatedFinal(byte *mac, size_t macSize);
  20. protected:
  21. void AuthenticateData(const byte *data, size_t len);
  22. const SymmetricCipher & GetSymmetricCipher() const {return const_cast<AuthenticatedSymmetricCipherBase *>(this)->AccessSymmetricCipher();};
  23. virtual SymmetricCipher & AccessSymmetricCipher() =0;
  24. virtual bool AuthenticationIsOnPlaintext() const =0;
  25. virtual unsigned int AuthenticationBlockSize() const =0;
  26. virtual void SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs &params) =0;
  27. virtual void Resync(const byte *iv, size_t len) =0;
  28. virtual size_t AuthenticateBlocks(const byte *data, size_t len) =0;
  29. virtual void AuthenticateLastHeaderBlock() =0;
  30. virtual void AuthenticateLastConfidentialBlock() {}
  31. virtual void AuthenticateLastFooterBlock(byte *mac, size_t macSize) =0;
  32. enum State {State_Start, State_KeySet, State_IVSet, State_AuthUntransformed, State_AuthTransformed, State_AuthFooter};
  33. State m_state;
  34. unsigned int m_bufferedDataLength;
  35. lword m_totalHeaderLength, m_totalMessageLength, m_totalFooterLength;
  36. AlignedSecByteBlock m_buffer;
  37. };
  38. NAMESPACE_END
  39. #endif