mirror of
https://github.com/wangyu-/udp2raw.git
synced 2025-01-19 14:29:34 +08:00
deleted my encrypt_old
This commit is contained in:
parent
7d306b2451
commit
d09e0c51aa
93
encrypt.cpp
93
encrypt.cpp
@ -327,99 +327,6 @@ int my_decrypt(const char *data,char *output,int &len,char * key)
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
int my_encrypt_old(const char *data0,char *output,int &len,char * key)
|
||||
{
|
||||
static const int disable_all=0;
|
||||
static const int disable_aes=0;
|
||||
|
||||
char data[buf_len];
|
||||
memcpy(data,data0,len);
|
||||
|
||||
if(disable_all)
|
||||
{
|
||||
memcpy(output,data,len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ori_len=len;
|
||||
|
||||
len=len+16;//md5
|
||||
len+=2;//length
|
||||
|
||||
if(len%16!=0)
|
||||
{
|
||||
len= (len/16)*16+16;
|
||||
}
|
||||
|
||||
if(len>max_data_len) return -1;
|
||||
|
||||
data[len-16-2]= (unsigned char)( (uint16_t(ori_len))>>8);
|
||||
data[len-16-1]=(unsigned char)( ((uint16_t(ori_len))<<8)>>8) ;
|
||||
|
||||
|
||||
//printf("%d %d\n",data[len-16-2],data[len-16-1]);
|
||||
md5((unsigned char *)data,len-16,(unsigned char *)(data+len-16));
|
||||
|
||||
|
||||
if(disable_aes)
|
||||
{
|
||||
memcpy(output,data,len);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
AESACC_CBC_encrypt_buffer((unsigned char *)output,(unsigned char *)data,len,(unsigned char *)key,(unsigned char *)zero_iv);
|
||||
//it doesnt allow over lap
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
int my_decrypt_old(const char *data0,char *output,int &len,char * key)
|
||||
{
|
||||
static const int disable_all=0;
|
||||
static const int disable_aes=0;
|
||||
|
||||
char data[buf_len];
|
||||
memcpy(data,data0,len);
|
||||
|
||||
if(disable_all)
|
||||
{
|
||||
memcpy(output,data,len);
|
||||
return 0;
|
||||
}
|
||||
uint8_t md5_res[16];
|
||||
if(len>max_data_len) return -1;
|
||||
if(len<32) return -1;
|
||||
if(len%16 !=0) return -1;
|
||||
|
||||
|
||||
if(disable_aes)
|
||||
{
|
||||
memcpy(output,data,len);
|
||||
}
|
||||
else
|
||||
{
|
||||
AESACC_CBC_decrypt_buffer((unsigned char *)output,(unsigned char *)data,len,(unsigned char *)key,(unsigned char *)zero_iv);
|
||||
}
|
||||
|
||||
|
||||
//printf("%d %d\n",data[len-16-2],data[len-16-1]);
|
||||
|
||||
//printf("<<%d>>",len);
|
||||
|
||||
md5((unsigned char *)output,len-16,(unsigned char *)md5_res);
|
||||
|
||||
if(memcmp(output+len-16,md5_res,16)!=0)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
len=((unsigned char)output[len-16-2])*256u+((unsigned char)output[len-16-1]); //this may be broken because of sign
|
||||
|
||||
return 0;
|
||||
}*/
|
||||
|
||||
int my_encrypt_pesudo_header(uint8_t *data,uint8_t *output,int &len,uint8_t * key,uint8_t *header,int hlen)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user