ChipMaster's trial hacks on C++CMS starting with v1.2.1. Not sure I'll follow on with the v2 since it looks to be breaking and mostly frivolous.
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.
 
 
 
 
 
 

47 lines
1.4 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
  4. //
  5. // See accompanying file COPYING.TXT file for licensing details.
  6. //
  7. ///////////////////////////////////////////////////////////////////////////////
  8. #ifndef CPPCMS_HMAC_ENCRYPTOR_H
  9. #define CPPCMS_HMAC_ENCRYPTOR_H
  10. #include <cppcms/session_cookies.h>
  11. #include <cppcms/crypto.h>
  12. #include <cppcms/config.h>
  13. #include <booster/thread.h>
  14. namespace cppcms {
  15. namespace sessions {
  16. namespace impl {
  17. class CPPCMS_API hmac_factory : public encryptor_factory {
  18. public:
  19. virtual std::auto_ptr<encryptor> get();
  20. hmac_factory(std::string const &algo,crypto::key const &k);
  21. virtual ~hmac_factory() {}
  22. private:
  23. std::string algo_;
  24. crypto::key key_;
  25. };
  26. class CPPCMS_API hmac_cipher : public cppcms::sessions::encryptor {
  27. public:
  28. hmac_cipher(std::string const &hash_name,crypto::key const &key);
  29. virtual std::string encrypt(std::string const &plain);
  30. virtual bool decrypt(std::string const &cipher,std::string &plain);
  31. static bool equal(void const *a,void const *b,size_t n);
  32. private:
  33. crypto::key key_;
  34. std::string hash_;
  35. };
  36. } // impl
  37. } // sessions
  38. } // cppcms
  39. #endif