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.
 
 
 
 
 
 

55 lines
1.6 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_AES_ENCRYPTOR_H
  9. #define CPPCMS_AES_ENCRYPTOR_H
  10. #include <string>
  11. #include <cppcms/session_cookies.h>
  12. #include <cppcms/crypto.h>
  13. namespace cppcms {
  14. namespace sessions {
  15. namespace impl {
  16. class CPPCMS_API aes_factory : public encryptor_factory {
  17. public:
  18. aes_factory(std::string const &cbc,crypto::key const &cbc_key,std::string const &hmac,crypto::key const &hmac_key);
  19. aes_factory(std::string const &algo,crypto::key const &k);
  20. virtual std::auto_ptr<encryptor> get();
  21. virtual ~aes_factory() {}
  22. private:
  23. std::string cbc_;
  24. crypto::key cbc_key_;
  25. std::string hmac_;
  26. crypto::key hmac_key_;
  27. };
  28. class CPPCMS_API aes_cipher : public cppcms::sessions::encryptor {
  29. public:
  30. aes_cipher(std::string const &cbc_name,std::string const &md_name,crypto::key const &cbc_key,crypto::key const &md_key);
  31. ~aes_cipher();
  32. virtual std::string encrypt(std::string const &plain);
  33. virtual bool decrypt(std::string const &cipher,std::string &plain);
  34. private:
  35. void load();
  36. std::auto_ptr<crypto::cbc> cbc_;
  37. std::auto_ptr<crypto::message_digest> digest_;
  38. std::string cbc_name_,md_name_;
  39. crypto::key cbc_key_;
  40. crypto::key mac_key_;
  41. };
  42. } // impl
  43. } // sessions
  44. } // cppcms
  45. #endif