Some other things changed to secure_random

This commit is contained in:
vysheng 2013-12-25 12:56:46 +04:00
parent 484e1c30e8
commit 874aace355

View File

@ -310,9 +310,7 @@ void out_random (int n) {
assert (n <= 32); assert (n <= 32);
static char buf[32]; static char buf[32];
int i; int i;
for (i = 0; i < n; i++) { secure_random (buf, n);
buf[i] = lrand48 () & 255;
}
out_cstring (buf, n); out_cstring (buf, n);
} }
@ -772,7 +770,7 @@ void encr_start (void) {
void encr_finish (struct secret_chat *E) { void encr_finish (struct secret_chat *E) {
int l = packet_ptr - (encr_extra + 8); int l = packet_ptr - (encr_extra + 8);
while (((packet_ptr - encr_extra) - 3) & 3) { while (((packet_ptr - encr_extra) - 3) & 3) {
out_int (mrand48 ()); out_rand (4);
} }
*encr_extra = ((packet_ptr - encr_extra) - 1) * 4 * 256 + 0xfe; *encr_extra = ((packet_ptr - encr_extra) - 1) * 4 * 256 + 0xfe;
@ -883,10 +881,7 @@ void do_send_encr_msg (struct message *M) {
out_int (CODE_decrypted_message); out_int (CODE_decrypted_message);
out_long (M->id); out_long (M->id);
static int buf[4]; static int buf[4];
int i; secure_random (buf, 16);
for (i = 0; i < 3; i++) {
buf[i] = mrand48 ();
}
out_cstring ((void *)buf, 16); out_cstring ((void *)buf, 16);
out_cstring ((void *)M->message, M->message_len); out_cstring ((void *)M->message, M->message_len);
out_int (CODE_decrypted_message_media_empty); out_int (CODE_decrypted_message_media_empty);
@ -1299,8 +1294,9 @@ 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);
while (x & 15) { if (x & 15) {
buf[x ++] = lrand48 () & 255; secure_random (buf + x, (-x) & 15);
x = (x + 15) & ~15;
} }
} }