encrypt.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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,auth_md5,auth_crc32,auth_simple,auth_hmac_sha1,auth_end};
  15. enum cipher_mode_t {cipher_none=0,cipher_aes128cbc,cipher_xor,cipher_aes128cfb,cipher_end};
  16. extern auth_mode_t auth_mode;
  17. extern cipher_mode_t cipher_mode;
  18. extern unordered_map<int, const char *> auth_mode_tostring;
  19. extern unordered_map<int, const char *> cipher_mode_tostring;
  20. extern char gro_xor[256+100];
  21. int cipher_decrypt(const char *data,char *output,int &len,char * key);//internal interface ,exposed for test only
  22. int cipher_encrypt(const char *data,char *output,int &len,char * key);//internal interface ,exposed for test only
  23. void aes_ecb_encrypt(const char *data,char *output);
  24. void aes_ecb_decrypt(const char *data,char *output);
  25. void aes_ecb_encrypt1(char *data);
  26. void aes_ecb_decrypt1(char *data);
  27. #endif