2017-09-01 17:40:55 -05:00
|
|
|
#ifndef UDP2RAW_ENCRYPTION_H_
|
|
|
|
#define UDP2RAW_ENCRYPTION_H_
|
2017-07-29 20:32:26 +08:00
|
|
|
|
2017-07-30 16:57:24 +08:00
|
|
|
|
|
|
|
|
|
|
|
//#include "aes.h"
|
|
|
|
//#include "md5.h"
|
2017-07-29 20:32:26 +08:00
|
|
|
#include "common.h"
|
|
|
|
|
2017-07-30 16:57:24 +08:00
|
|
|
|
|
|
|
//using namespace std;
|
2018-06-22 13:22:26 -05:00
|
|
|
//extern char key[16];
|
2017-09-18 07:29:12 -05:00
|
|
|
|
|
|
|
const int aes_key_optimize=1; //if enabled,once you used a key for aes,you cant change it anymore
|
|
|
|
|
2018-06-23 16:19:15 -05:00
|
|
|
int my_init_keys(const char *,int);
|
2018-06-22 13:22:26 -05:00
|
|
|
|
|
|
|
int my_encrypt(const char *data,char *output,int &len);
|
|
|
|
int my_decrypt(const char *data,char *output,int &len);
|
2017-07-22 23:39:35 +08:00
|
|
|
|
2017-07-25 00:04:49 +08:00
|
|
|
|
|
|
|
unsigned short csum(const unsigned short *ptr,int nbytes) ;
|
|
|
|
|
|
|
|
|
2018-06-22 13:22:26 -05:00
|
|
|
enum auth_mode_t {auth_none=0,auth_md5,auth_crc32,auth_simple,auth_hmac_sha1,auth_end};
|
2017-07-30 16:57:24 +08:00
|
|
|
|
2017-07-26 06:29:40 +08:00
|
|
|
|
2017-07-26 08:51:05 +08:00
|
|
|
enum cipher_mode_t {cipher_none=0,cipher_aes128cbc,cipher_xor,cipher_end};
|
2017-07-30 16:57:24 +08:00
|
|
|
|
2017-07-24 12:34:42 +08:00
|
|
|
|
2017-07-26 08:51:05 +08:00
|
|
|
extern auth_mode_t auth_mode;
|
|
|
|
extern cipher_mode_t cipher_mode;
|
2017-07-30 16:57:24 +08:00
|
|
|
|
|
|
|
extern unordered_map<int, const char *> auth_mode_tostring;
|
|
|
|
extern unordered_map<int, const char *> cipher_mode_tostring;
|
2017-07-24 12:34:42 +08:00
|
|
|
|
2017-09-18 06:34:03 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
2017-09-18 07:29:12 -05:00
|
|
|
int cipher_decrypt(const char *data,char *output,int &len,char * key);//internal interface ,exposed for test only
|
|
|
|
int cipher_encrypt(const char *data,char *output,int &len,char * key);//internal interface ,exposed for test only
|
2017-09-18 06:34:03 -05:00
|
|
|
|
2017-07-19 00:52:33 +08:00
|
|
|
#endif
|