Commit 664e6e15 authored by Vysheng's avatar Vysheng

Support for g!=2 in DH

parent be596ed9
......@@ -441,7 +441,7 @@ int process_dh_answer (struct connection *c, char *packet, int len) {
assert (decrypt_buffer[5] == (int)CODE_server_DH_inner_data);
assert (!memcmp (decrypt_buffer + 6, nonce, 16));
assert (!memcmp (decrypt_buffer + 10, server_nonce, 16));
assert (decrypt_buffer[14] == 2);
int g = decrypt_buffer[14];
in_ptr = decrypt_buffer + 15;
in_end = decrypt_buffer + (l >> 2);
BN_init (&dh_prime);
......@@ -469,7 +469,7 @@ int process_dh_answer (struct connection *c, char *packet, int len) {
out_long (0LL);
BN_init (&dh_g);
BN_set_word (&dh_g, 2);
BN_set_word (&dh_g, g);
assert (RAND_pseudo_bytes ((unsigned char *)s_power, 256) >= 0);
BIGNUM *dh_power = BN_new ();
......
......@@ -302,8 +302,8 @@ extern struct dc *DC_list[];
extern struct dc *DC_working;
void out_random (int n) {
assert (n <= 16);
static char buf[16];
assert (n <= 32);
static char buf[32];
int i;
for (i = 0; i < n; i++) {
buf[i] = lrand48 () & 255;
......@@ -1375,7 +1375,7 @@ void send_part (struct send_file *f) {
encr_start ();
out_int (CODE_decrypted_message);
out_long (r);
out_random (16);
out_random (15 + 4 * (lrand48 () % 3));
out_string ("");
if (f->media_type == CODE_input_media_uploaded_photo) {
out_int (CODE_decrypted_message_media_photo);
......
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