Commit 484e1c30 authored by vysheng's avatar vysheng

Fixed secure random.

parent 7a5fa39f
...@@ -1505,16 +1505,11 @@ void do_send_photo (int type, peer_id_t to_id, char *file_name) { ...@@ -1505,16 +1505,11 @@ void do_send_photo (int type, peer_id_t to_id, char *file_name) {
if (get_peer_type (f->to_id) == PEER_ENCR_CHAT) { if (get_peer_type (f->to_id) == PEER_ENCR_CHAT) {
f->encr = 1; f->encr = 1;
f->iv = malloc (32); f->iv = malloc (32);
int i; secure_random (f->iv, 32);
for (i = 0; i < 8; i++) {
((int *)f->iv)[i] = mrand48 ();
}
f->init_iv = malloc (32); f->init_iv = malloc (32);
memcpy (f->init_iv, f->iv, 32); memcpy (f->init_iv, f->iv, 32);
f->key = malloc (32); f->key = malloc (32);
for (i = 0; i < 8; i++) { secure_random (f->key, 32);
((int *)f->key)[i] = mrand48 ();
}
} }
if (f->part_size > (512 << 10)) { if (f->part_size > (512 << 10)) {
close (fd); close (fd);
...@@ -2362,8 +2357,10 @@ void do_create_keys_end (struct secret_chat *U) { ...@@ -2362,8 +2357,10 @@ void do_create_keys_end (struct secret_chat *U) {
void do_send_create_encr_chat (void *x, unsigned char *random) { void do_send_create_encr_chat (void *x, unsigned char *random) {
int user_id = (long)x; int user_id = (long)x;
int i; int i;
for (i = 0; i < 64; i++) { unsigned char random_here[256];
*(((int *)random) + i) ^= mrand48 (); secure_random (random_here, 256);
for (i = 0; i < 256; i++) {
random[i] ^= random_here[i];
} }
if (!ctx) { if (!ctx) {
ctx = BN_CTX_new (); ctx = BN_CTX_new ();
......
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