encrypt.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef UDP2RAW_ENCRYPTION_H_
  2. #define UDP2RAW_ENCRYPTION_H_
  3. //#include "aes.h"
  4. //#include "md5.h"
  5. #include "common.h"
  6. // using namespace std;
  7. // extern char key[16];
  8. const int aes_key_optimize = 1; // if enabled,once you used a key for aes,you cant change it anymore
  9. extern int aes128cfb_old;
  10. int my_init_keys(const char *, int);
  11. int my_encrypt(const char *data, char *output, int &len);
  12. int my_decrypt(const char *data, char *output, int &len);
  13. unsigned short csum(const unsigned short *ptr, int nbytes);
  14. enum auth_mode_t { auth_none = 0,
  15. auth_md5,
  16. auth_crc32,
  17. auth_simple,
  18. auth_hmac_sha1,
  19. auth_end };
  20. enum cipher_mode_t { cipher_none = 0,
  21. cipher_aes128cbc,
  22. cipher_xor,
  23. cipher_aes128cfb,
  24. cipher_end };
  25. extern auth_mode_t auth_mode;
  26. extern cipher_mode_t cipher_mode;
  27. extern unordered_map<int, const char *> auth_mode_tostring;
  28. extern unordered_map<int, const char *> cipher_mode_tostring;
  29. extern char gro_xor[256 + 100];
  30. int cipher_decrypt(const char *data, char *output, int &len, char *key); // internal interface ,exposed for test only
  31. int cipher_encrypt(const char *data, char *output, int &len, char *key); // internal interface ,exposed for test only
  32. void aes_ecb_encrypt(const char *data, char *output);
  33. void aes_ecb_decrypt(const char *data, char *output);
  34. void aes_ecb_encrypt1(char *data);
  35. void aes_ecb_decrypt1(char *data);
  36. #endif