Commit e0c65ac6 authored by vysheng's avatar vysheng

Merge branch 'master' of github.com:vysheng/tg

parents 408c51e5 eb54c5f0
...@@ -25,7 +25,7 @@ Install libs: readline openssl and (if you want to use config) libconfig and lub ...@@ -25,7 +25,7 @@ Install libs: readline openssl and (if you want to use config) libconfig and lub
If you do not want to use them pass options --disable-libconfig and --disable-liblua respectively If you do not want to use them pass options --disable-libconfig and --disable-liblua respectively
On ubuntu use: On ubuntu use:
$ sudo apt-get install libreadline-dev libconfig-dev libssl-dev lua5.2 lublua5.2-dev $ sudo apt-get install libreadline-dev libconfig-dev libssl-dev lua5.2 liblua5.2-dev
On gentoo: On gentoo:
$ sudo emerge -av sys-libs/readline dev-libs/libconfig dev-libs/openssl dev-lang/lua $ sudo emerge -av sys-libs/readline dev-libs/libconfig dev-libs/openssl dev-lang/lua
......
...@@ -347,6 +347,7 @@ void init_aes_unauth (const char server_nonce[16], const char hidden_client_nonc ...@@ -347,6 +347,7 @@ void init_aes_unauth (const char server_nonce[16], const char hidden_client_nonc
} else { } else {
AES_set_decrypt_key (aes_key_raw, 32*8, &aes_key); AES_set_decrypt_key (aes_key_raw, 32*8, &aes_key);
} }
memset (aes_key_raw, 0, sizeof (aes_key_raw));
} }
void init_aes_auth (char auth_key[192], char msg_key[16], int encrypt) { void init_aes_auth (char auth_key[192], char msg_key[16], int encrypt) {
...@@ -386,6 +387,7 @@ void init_aes_auth (char auth_key[192], char msg_key[16], int encrypt) { ...@@ -386,6 +387,7 @@ void init_aes_auth (char auth_key[192], char msg_key[16], int encrypt) {
} else { } else {
AES_set_decrypt_key (aes_key_raw, 32*8, &aes_key); AES_set_decrypt_key (aes_key_raw, 32*8, &aes_key);
} }
memset (aes_key_raw, 0, sizeof (aes_key_raw));
} }
int pad_aes_encrypt (char *from, int from_len, char *to, int size) { int pad_aes_encrypt (char *from, int from_len, char *to, int size) {
......
...@@ -746,6 +746,7 @@ char *encrypt_decrypted_message (struct secret_chat *E) { ...@@ -746,6 +746,7 @@ char *encrypt_decrypted_message (struct secret_chat *E) {
AES_KEY aes_key; AES_KEY aes_key;
AES_set_encrypt_key (key, 256, &aes_key); AES_set_encrypt_key (key, 256, &aes_key);
AES_ige_encrypt ((void *)encr_ptr, (void *)encr_ptr, 4 * (encr_end - encr_ptr), &aes_key, iv, 1); AES_ige_encrypt ((void *)encr_ptr, (void *)encr_ptr, 4 * (encr_end - encr_ptr), &aes_key, iv, 1);
memset (&aes_key, 0, sizeof (aes_key));
return (void *)msg_key; return (void *)msg_key;
} }
...@@ -1290,15 +1291,14 @@ void send_part (struct send_file *f) { ...@@ -1290,15 +1291,14 @@ void send_part (struct send_file *f) {
if (f->encr) { if (f->encr) {
if (x & 15) { if (x & 15) {
assert (f->offset == f->size); assert (f->offset == f->size);
if (x & 15) { secure_random (buf + x, (-x) & 15);
secure_random (buf + x, (-x) & 15); x = (x + 15) & ~15;
x = (x + 15) & ~15;
}
} }
AES_KEY aes_key; AES_KEY aes_key;
AES_set_encrypt_key (f->key, 256, &aes_key); AES_set_encrypt_key (f->key, 256, &aes_key);
AES_ige_encrypt ((void *)buf, (void *)buf, x, &aes_key, f->iv, 1); AES_ige_encrypt ((void *)buf, (void *)buf, x, &aes_key, f->iv, 1);
memset (&aes_key, 0, sizeof (aes_key));
} }
out_cstring (buf, x); out_cstring (buf, x);
if (verbosity >= 2) { if (verbosity >= 2) {
...@@ -1803,6 +1803,7 @@ int download_on_answer (struct query *q) { ...@@ -1803,6 +1803,7 @@ int download_on_answer (struct query *q) {
AES_KEY aes_key; AES_KEY aes_key;
AES_set_decrypt_key (D->key, 256, &aes_key); AES_set_decrypt_key (D->key, 256, &aes_key);
AES_ige_encrypt (ptr, ptr, len, &aes_key, D->iv, 0); AES_ige_encrypt (ptr, ptr, len, &aes_key, D->iv, 0);
memset (&aes_key, 0, sizeof (aes_key));
if (len > D->size - D->offset) { if (len > D->size - D->offset) {
len = D->size - D->offset; len = D->size - D->offset;
} }
......
...@@ -1376,6 +1376,7 @@ int decrypt_encrypted_message (struct secret_chat *E) { ...@@ -1376,6 +1376,7 @@ int decrypt_encrypted_message (struct secret_chat *E) {
AES_KEY aes_key; AES_KEY aes_key;
AES_set_decrypt_key (key, 256, &aes_key); AES_set_decrypt_key (key, 256, &aes_key);
AES_ige_encrypt ((void *)decr_ptr, (void *)decr_ptr, 4 * (decr_end - decr_ptr), &aes_key, iv, 0); AES_ige_encrypt ((void *)decr_ptr, (void *)decr_ptr, 4 * (decr_end - decr_ptr), &aes_key, iv, 0);
memset (&aes_key, 0, sizeof (aes_key));
int x = *(decr_ptr); int x = *(decr_ptr);
if (x < 0 || (x & 3)) { if (x < 0 || (x & 3)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment