diff --git a/binlog.c b/binlog.c index beb7aa3..a71b4a7 100644 --- a/binlog.c +++ b/binlog.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "binlog.h" #include "mtproto-common.h" @@ -525,6 +526,7 @@ void replay_log_event (void) { memcpy (encr_prime, rptr, 256); rptr += 64; encr_param_version = *(rptr ++); + } break; case CODE_binlog_encr_chat_init: diff --git a/mtproto-client.h b/mtproto-client.h index 2a7d7e8..2b603d5 100644 --- a/mtproto-client.h +++ b/mtproto-client.h @@ -20,9 +20,12 @@ #ifndef __MTPROTO_CLIENT_H__ #define __MTPROTO_CLIENT_H__ #include "net.h" +#include void on_start (void); long long encrypt_send_message (struct connection *c, int *msg, int msg_ints, int useful); void dc_authorize (struct dc *DC); void work_update (struct connection *c, long long msg_id); void work_update_binlog (void); +int check_g (BIGNUM *g); +int check_DH_params (BIGNUM *p, int g); #endif diff --git a/queries.c b/queries.c index d42c448..41c5025 100644 --- a/queries.c +++ b/queries.c @@ -2270,6 +2270,7 @@ void do_send_accept_encr_chat (struct secret_chat *E, unsigned char *random) { assert (b); BIGNUM *g_a = BN_bin2bn (E->g_key, 256, 0); assert (g_a); + assert (check_g (g_a) >= 0); if (!ctx) { ctx = BN_CTX_new (); BN_CTX_init (ctx); @@ -2315,6 +2316,7 @@ void do_create_keys_end (struct secret_chat *U) { assert (encr_prime); BIGNUM *g_b = BN_bin2bn (U->g_key, 256, 0); assert (g_b); + assert (check_g (g_b) >= 0); if (!ctx) { ctx = BN_CTX_new (); BN_CTX_init (ctx);