Commit 201e2dea authored by vvaltman's avatar vvaltman

generate random_id with secure_random

parent 7147cf13
...@@ -1570,7 +1570,9 @@ static void send_part (struct send_file *f, void *callback, void *callback_extra ...@@ -1570,7 +1570,9 @@ static void send_part (struct send_file *f, void *callback, void *callback_extra
out_string ("audio"); out_string ("audio");
} }
out_long (-lrand48 () * (1ll << 32) - lrand48 ()); long long r;
tglt_secure_random (&r, 8);
out_long (r);
tglq_send_query (tgl_state.DC_working, packet_ptr - packet_buffer, packet_buffer, &send_file_methods, 0, callback, callback_extra); tglq_send_query (tgl_state.DC_working, packet_ptr - packet_buffer, packet_buffer, &send_file_methods, 0, callback, callback_extra);
} else { } else {
struct tgl_message *M = talloc0 (sizeof (*M)); struct tgl_message *M = talloc0 (sizeof (*M));
...@@ -1581,7 +1583,8 @@ static void send_part (struct send_file *f, void *callback, void *callback_extra ...@@ -1581,7 +1583,8 @@ static void send_part (struct send_file *f, void *callback, void *callback_extra
tgl_peer_t *P = tgl_peer_get (f->to_id); tgl_peer_t *P = tgl_peer_get (f->to_id);
assert (P); assert (P);
out_long (P->encr_chat.access_hash); out_long (P->encr_chat.access_hash);
long long r = -lrand48 () * (1ll << 32) - lrand48 (); long long r;
tglt_secure_random (&r, 8);
out_long (r); out_long (r);
encr_start (); encr_start ();
out_int (CODE_decrypted_message); out_int (CODE_decrypted_message);
...@@ -1715,7 +1718,7 @@ void _tgl_do_send_photo (enum tgl_message_media_type type, tgl_peer_id_t to_id, ...@@ -1715,7 +1718,7 @@ void _tgl_do_send_photo (enum tgl_message_media_type type, tgl_peer_id_t to_id,
return; return;
} }
f->id = lrand48 () * (1ll << 32) + lrand48 (); tglt_secure_random (&f->id, 8);
f->to_id = to_id; f->to_id = to_id;
switch (type) { switch (type) {
case tgl_message_media_photo: case tgl_message_media_photo:
...@@ -1821,7 +1824,9 @@ void tgl_do_forward_message (tgl_peer_id_t id, int n, void (*callback)(void *cal ...@@ -1821,7 +1824,9 @@ void tgl_do_forward_message (tgl_peer_id_t id, int n, void (*callback)(void *cal
out_int (CODE_messages_forward_message); out_int (CODE_messages_forward_message);
out_peer_id (id); out_peer_id (id);
out_int (n); out_int (n);
out_long (lrand48 () * (1ll << 32) + lrand48 ()); long long r;
tglt_secure_random (&r, 8);
out_long (r);
tglq_send_query (tgl_state.DC_working, packet_ptr - packet_buffer, packet_buffer, &fwd_msg_methods, 0, callback, callback_extra); tglq_send_query (tgl_state.DC_working, packet_ptr - packet_buffer, packet_buffer, &fwd_msg_methods, 0, callback, callback_extra);
} }
/* }}} */ /* }}} */
...@@ -2414,7 +2419,9 @@ void tgl_do_add_contact (const char *phone, int phone_len, const char *first_nam ...@@ -2414,7 +2419,9 @@ void tgl_do_add_contact (const char *phone, int phone_len, const char *first_nam
out_int (CODE_vector); out_int (CODE_vector);
out_int (1); out_int (1);
out_int (CODE_input_phone_contact); out_int (CODE_input_phone_contact);
out_long (lrand48 () * (1ll << 32) + lrand48 ()); long long r;
tglt_secure_random (&r, 8);
out_long (r);
out_cstring (phone, phone_len); out_cstring (phone, phone_len);
out_cstring (first_name, first_name_len); out_cstring (first_name, first_name_len);
out_cstring (last_name, last_name_len); out_cstring (last_name, last_name_len);
......
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