From 7142dd018dcb4596a3d2d8667bfd6f2f911b0077 Mon Sep 17 00:00:00 2001 From: wangyu- Date: Sun, 18 Feb 2018 21:17:38 -0600 Subject: [PATCH] added some TODOs --- encrypt.cpp | 47 ++++++++++++++++++++++++++--------------------- encrypt.h | 3 --- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/encrypt.cpp b/encrypt.cpp index c159079..f92098b 100755 --- a/encrypt.cpp +++ b/encrypt.cpp @@ -17,23 +17,13 @@ static int8_t zero_iv[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0};//this prog ****/ char key[16];//generated from key_string by md5. -/* -TODO - -Change md5 to HMAC-md5 if necessary.Change padding to PKCS#7 style if necessary. - -Need someone with cryptography knowledge to help review the encryption method. - -Change them if necessary(I can do this by myself,if it turns out to be necessary). - -github issue: - -https://github.com/wangyu-/udp2raw-tunnel/issues/17 - -*/ +//TODO key derive function unordered_map auth_mode_tostring = {{auth_none, "none"}, {auth_md5, "md5"}, {auth_crc32, "crc32"},{auth_simple,"simple"}}; +//TODO HMAC-md5 ,HMAC-sha1 + unordered_map cipher_mode_tostring={{cipher_none,"none"},{cipher_aes128cbc,"aes128cbc"},{cipher_xor,"xor"}}; +//TODO aes-gcm auth_mode_t auth_mode=auth_md5; cipher_mode_t cipher_mode=cipher_aes128cbc; @@ -356,13 +346,28 @@ int my_decrypt(const char *data,char *output,int &len,char * key) return 0; } -int my_encrypt_pesudo_header(uint8_t *data,uint8_t *output,int &len,uint8_t * key,uint8_t *header,int hlen) +int encrypt_AE(const char *data,char *output,int &len,char * key) { - - return 0; -} -int my_decrypt_pesudo_header(uint8_t *data,uint8_t *output,int &len,uint8_t * key,uint8_t *header,int hlen) -{ - return 0; + //TODO + //use encrypt-then-MAC scheme + return -1; +} + +int decrypt_AE(const char *data,char *output,int &len,char * key) +{ + //TODO + return -1; +} + +int encrypt_AEAD(uint8_t *data,uint8_t *output,int &len,uint8_t * key,uint8_t *header,int hlen) +{ + //TODO + return -1; +} + +int decrypt_AEAD(uint8_t *data,uint8_t *output,int &len,uint8_t * key,uint8_t *header,int hlen) +{ + //TODO + return -1; } diff --git a/encrypt.h b/encrypt.h index ad8f6da..47a1f74 100755 --- a/encrypt.h +++ b/encrypt.h @@ -17,9 +17,6 @@ extern char key[16]; int my_encrypt(const char *data,char *output,int &len,char * key); int my_decrypt(const char *data,char *output,int &len,char * key); -int my_encrypt_pesudo_header(uint8_t *data,uint8_t *output,int &len,uint8_t * key,uint8_t *header,int hlen); -int my_decrypt_pesudo_header(uint8_t *data,uint8_t *output,int &len,uint8_t * key,uint8_t *header,int hlen); - unsigned short csum(const unsigned short *ptr,int nbytes) ;