do_rand () renamed to secure_random ()
This commit is contained in:
parent
b2ba81e761
commit
7a5fa39f84
@ -98,7 +98,7 @@ double get_utime (int clock_id) {
|
||||
return res;
|
||||
}
|
||||
|
||||
void do_rand (void *s, int l) {
|
||||
void secure_random (void *s, int l) {
|
||||
if (RAND_bytes (s, l) < 0) {
|
||||
if (allow_weak_random) {
|
||||
RAND_pseudo_bytes (s, l);
|
||||
@ -232,7 +232,7 @@ int rpc_send_message (struct connection *c, void *data, int len) {
|
||||
|
||||
int send_req_pq_packet (struct connection *c) {
|
||||
assert (c_state == st_init);
|
||||
do_rand (nonce, 16);
|
||||
secure_random (nonce, 16);
|
||||
unenc_msg_header.out_msg_id = 0;
|
||||
clear_packet ();
|
||||
out_int (CODE_req_pq);
|
||||
@ -380,7 +380,7 @@ int process_respq_answer (struct connection *c, char *packet, int len) {
|
||||
//out_int (0x0501); // q=5
|
||||
out_ints ((int *) nonce, 4);
|
||||
out_ints ((int *) server_nonce, 4);
|
||||
do_rand (new_nonce, 32);
|
||||
secure_random (new_nonce, 32);
|
||||
out_ints ((int *) new_nonce, 8);
|
||||
sha1 ((unsigned char *) (packet_buffer + 5), (packet_ptr - packet_buffer - 5) * 4, (unsigned char *) packet_buffer);
|
||||
|
||||
@ -573,7 +573,7 @@ int process_dh_answer (struct connection *c, char *packet, int len) {
|
||||
BN_init (&dh_g);
|
||||
BN_set_word (&dh_g, g);
|
||||
|
||||
do_rand (s_power, 256);
|
||||
secure_random (s_power, 256);
|
||||
BIGNUM *dh_power = BN_new ();
|
||||
assert (BN_bin2bn ((unsigned char *)s_power, 256, dh_power) == dh_power);
|
||||
|
||||
@ -692,7 +692,7 @@ void init_enc_msg (struct session *S, int useful) {
|
||||
// assert (DC->server_salt);
|
||||
enc_msg.server_salt = DC->server_salt;
|
||||
if (!S->session_id) {
|
||||
do_rand (&S->session_id, 8);
|
||||
secure_random (&S->session_id, 8);
|
||||
}
|
||||
enc_msg.session_id = S->session_id;
|
||||
//enc_msg.auth_key_id2 = auth_key_id;
|
||||
|
@ -29,5 +29,5 @@ void work_update_binlog (void);
|
||||
int check_g (unsigned char p[256], BIGNUM *g);
|
||||
int check_g_bn (BIGNUM *p, BIGNUM *g);
|
||||
int check_DH_params (BIGNUM *p, int g);
|
||||
void do_rand (void *s, int l);
|
||||
void secure_random (void *s, int l);
|
||||
#endif
|
||||
|
@ -2264,7 +2264,7 @@ void do_send_accept_encr_chat (struct secret_chat *E, unsigned char *random) {
|
||||
}
|
||||
if (ok) { return; } // Already generated key for this chat
|
||||
unsigned char random_here[256];
|
||||
do_rand (random_here, 256);
|
||||
secure_random (random_here, 256);
|
||||
for (i = 0; i < 256; i++) {
|
||||
random[i] ^= random_here[i];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user