diff --git a/mtproto-client.c b/mtproto-client.c index 811ba56..d4521e5 100644 --- a/mtproto-client.c +++ b/mtproto-client.c @@ -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 (); diff --git a/queries.c b/queries.c index 8ec160d..747c07b 100644 --- a/queries.c +++ b/queries.c @@ -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);