encrypt.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. const int aes_key_optimize=1; //if enabled,once you used a key for aes,you cant change it anymore
  8. int my_encrypt(const char *data,char *output,int &len,char * key);
  9. int my_decrypt(const char *data,char *output,int &len,char * key);
  10. int my_encrypt_pesudo_header(uint8_t *data,uint8_t *output,int &len,uint8_t * key,uint8_t *header,int hlen);
  11. int my_decrypt_pesudo_header(uint8_t *data,uint8_t *output,int &len,uint8_t * key,uint8_t *header,int hlen);
  12. unsigned short csum(const unsigned short *ptr,int nbytes) ;
  13. enum auth_mode_t {auth_none=0,auth_md5,auth_crc32,auth_simple,auth_end};
  14. enum cipher_mode_t {cipher_none=0,cipher_aes128cbc,cipher_xor,cipher_end};
  15. extern auth_mode_t auth_mode;
  16. extern cipher_mode_t cipher_mode;
  17. extern unordered_map<int, const char *> auth_mode_tostring;
  18. extern unordered_map<int, const char *> cipher_mode_tostring;
  19. int cipher_decrypt(const char *data,char *output,int &len,char * key);//internal interface ,exposed for test only
  20. int cipher_encrypt(const char *data,char *output,int &len,char * key);//internal interface ,exposed for test only
  21. #endif