From 6f60ed5818300927ad83af33841684a806151f6c Mon Sep 17 00:00:00 2001 From: Vysheng Date: Tue, 23 Sep 2014 18:59:28 +0400 Subject: [PATCH] mtproto-client: fixed bad bignum pad --- mtproto-client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mtproto-client.c b/mtproto-client.c index f2aff8a..12ac336 100644 --- a/mtproto-client.c +++ b/mtproto-client.c @@ -506,7 +506,7 @@ int tglmp_check_g (unsigned char p[256], BIGNUM *g) { static unsigned char s[256]; memset (s, 0, 256); assert (BN_num_bytes (g) <= 256); - BN_bn2bin (g, s); + BN_bn2bin (g, s + (256 - BN_num_bytes (g))); int ok = 0; int i; for (i = 0; i < 64; i++) { @@ -541,7 +541,7 @@ int tglmp_check_g (unsigned char p[256], BIGNUM *g) { int tglmp_check_g_bn (BIGNUM *p, BIGNUM *g) { static unsigned char s[256]; memset (s, 0, 256); - assert (BN_num_bytes (p) <= 256); + assert (BN_num_bytes (p) == 256); BN_bn2bin (p, s); return tglmp_check_g (s, g); }