crypto/jpake/jpake.c:295: error: INTEGER_OVERFLOW_L2
  ([0, `ctx->p.g->top`] - 1):unsigned64 by call to `verify_zkp`.
Showing all 25 steps of the trace


crypto/jpake/jpake.c:285:1: Parameter `ctx->p.g->top`
283.       }
284.   
285. > int JPAKE_STEP1_process(JPAKE_CTX *ctx, const JPAKE_STEP1 *received)
286.       {
287.      /* verify their ZKP(xc) */

crypto/jpake/jpake.c:288:9: Call
286.       {
287.      /* verify their ZKP(xc) */
288.       if(!verify_zkp(&received->p1, ctx->p.g, ctx))
               ^
289.   	{
290.   	JPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_VERIFY_X3_FAILED);

crypto/jpake/jpake.c:214:1: Parameter `zkpg->top`
  212.       }
  213.   
  214. > static int verify_zkp(const JPAKE_STEP_PART *p, const BIGNUM *zkpg,
  215.   		      JPAKE_CTX *ctx)
  216.       {

crypto/jpake/jpake.c:223:5: Call
  221.       int ret = 0;
  222.   
  223.       zkp_hash(h, zkpg, p, ctx->p.peer_name);
             ^
  224.   
  225.      /* t1 = g^b */

crypto/jpake/jpake.c:162:1: Parameter `zkpg->top`
    160.   
    161.   /* h=hash(g, g^r, g^x, name) */
    162. > static void zkp_hash(BIGNUM *h, const BIGNUM *zkpg, const JPAKE_STEP_PART *p,
    163.   		     const char *proof_name)
    164.       {

crypto/jpake/jpake.c:173:5: Call
    171.       */
    172.       SHA1_Init(&sha);
    173.       hashbn(&sha, zkpg);
               ^
    174.       OPENSSL_assert(!BN_is_zero(p->zkpx.gr));
    175.       hashbn(&sha, p->zkpx.gr);

crypto/jpake/jpake.c:150:1: Parameter `bn->top`
      148.       }
      149.   
      150. > static void hashbn(SHA_CTX *sha, const BIGNUM *bn)
      151.       {
      152.       size_t l = BN_num_bytes(bn);

crypto/jpake/jpake.c:152:16: Call
      150.   static void hashbn(SHA_CTX *sha, const BIGNUM *bn)
      151.       {
      152.       size_t l = BN_num_bytes(bn);
                            ^
      153.       unsigned char *bin = OPENSSL_malloc(l);
      154.   

crypto/bn/bn_lib.c:248:1: Parameter `a->top`
        246.   	}
        247.   
        248. > int BN_num_bits(const BIGNUM *a)
        249.   	{
        250.   	int i = a->top - 1;

crypto/jpake/jpake.c:156:5: Call
      154.   
      155.       hashlength(sha, l);
      156.       BN_bn2bin(bn, bin);
                 ^
      157.       SHA1_Update(sha, bin, l);
      158.       OPENSSL_free(bin);

crypto/bn/bn_lib.c:641:1: Parameter `a->top`
        639.   
        640.   /* ignore negative */
        641. > int BN_bn2bin(const BIGNUM *a, unsigned char *to)
        642.   	{
        643.   	int n,i;

crypto/bn/bn_lib.c:647:6: Call
        645.   
        646.   	bn_check_top(a);
        647.   	n=i=BN_num_bytes(a);
                    ^
        648.   	while (i--)
        649.   		{

crypto/bn/bn_lib.c:248:1: Parameter `a->top`
          246.   	}
          247.   
          248. > int BN_num_bits(const BIGNUM *a)
          249.   	{
          250.   	int i = a->top - 1;

crypto/jpake/jpake.c:226:5: Call
  224.   
  225.      /* t1 = g^b */
  226.       BN_mod_exp(t1, zkpg, p->zkpx.b, ctx->p.p, ctx->ctx);
             ^
  227.      /* t2 = (g^x)^h = g^{hx} */
  228.       BN_mod_exp(t2, p->gx, h, ctx->p.p, ctx->ctx);

crypto/bn/bn_exp.c:163:1: Parameter `a->top`
    161.   
    162.   
    163. > int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m,
    164.   	       BN_CTX *ctx)
    165.   	{

crypto/jpake/jpake.c:295:9: Call
293.   
294.      /* verify their ZKP(xd) */
295.       if(!verify_zkp(&received->p2, ctx->p.g, ctx))
               ^
296.   	{
297.   	JPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_VERIFY_X4_FAILED);

crypto/jpake/jpake.c:214:1: Parameter `zkpg->top`
  212.       }
  213.   
  214. > static int verify_zkp(const JPAKE_STEP_PART *p, const BIGNUM *zkpg,
  215.   		      JPAKE_CTX *ctx)
  216.       {

crypto/jpake/jpake.c:223:5: Call
  221.       int ret = 0;
  222.   
  223.       zkp_hash(h, zkpg, p, ctx->p.peer_name);
             ^
  224.   
  225.      /* t1 = g^b */

crypto/jpake/jpake.c:162:1: Parameter `zkpg->top`
    160.   
    161.   /* h=hash(g, g^r, g^x, name) */
    162. > static void zkp_hash(BIGNUM *h, const BIGNUM *zkpg, const JPAKE_STEP_PART *p,
    163.   		     const char *proof_name)
    164.       {

crypto/jpake/jpake.c:173:5: Call
    171.       */
    172.       SHA1_Init(&sha);
    173.       hashbn(&sha, zkpg);
               ^
    174.       OPENSSL_assert(!BN_is_zero(p->zkpx.gr));
    175.       hashbn(&sha, p->zkpx.gr);

crypto/jpake/jpake.c:150:1: Parameter `bn->top`
      148.       }
      149.   
      150. > static void hashbn(SHA_CTX *sha, const BIGNUM *bn)
      151.       {
      152.       size_t l = BN_num_bytes(bn);

crypto/jpake/jpake.c:152:16: Call
      150.   static void hashbn(SHA_CTX *sha, const BIGNUM *bn)
      151.       {
      152.       size_t l = BN_num_bytes(bn);
                            ^
      153.       unsigned char *bin = OPENSSL_malloc(l);
      154.   

crypto/bn/bn_lib.c:248:1: <LHS trace>
246.   	}
247.   
248. > int BN_num_bits(const BIGNUM *a)
249.   	{
250.   	int i = a->top - 1;

crypto/bn/bn_lib.c:248:1: Parameter `a->top`
        246.   	}
        247.   
        248. > int BN_num_bits(const BIGNUM *a)
        249.   	{
        250.   	int i = a->top - 1;

crypto/bn/bn_lib.c:250:2: Binary operation: ([0, ctx->p.g->top] - 1):unsigned64 by call to `verify_zkp` 
        248.   int BN_num_bits(const BIGNUM *a)
        249.   	{
        250.   	int i = a->top - 1;
                ^
        251.   	bn_check_top(a);
        252.   

int BN_num_bits(const BIGNUM *a)
	{
	int i = a->top - 1;
	bn_check_top(a);
	if (BN_is_zero(a)) return 0;
	return ((i*BN_BITS2) + BN_num_bits_word(a->d[i]));
	}
['int JPAKE_STEP1_process(JPAKE_CTX *ctx, const JPAKE_STEP1 *received)\n    {\n    if(!verify_zkp(&received->p1, ctx->p.g, ctx))\n\t{\n\tJPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_VERIFY_X3_FAILED);\n\treturn 0;\n\t}\n    if(!verify_zkp(&received->p2, ctx->p.g, ctx))\n\t{\n\tJPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_VERIFY_X4_FAILED);\n\treturn 0;\n\t}\n    if(BN_is_one(received->p2.gx))\n\t{\n\tJPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_G_TO_THE_X4_IS_ONE);\n\treturn 0;\n\t}\n    BN_copy(ctx->p.gxc, received->p1.gx);\n    BN_copy(ctx->p.gxd, received->p2.gx);\n    return 1;\n    }', 'static int verify_zkp(const JPAKE_STEP_PART *p, const BIGNUM *zkpg,\n\t\t      JPAKE_CTX *ctx)\n    {\n    BIGNUM *h = BN_new();\n    BIGNUM *t1 = BN_new();\n    BIGNUM *t2 = BN_new();\n    BIGNUM *t3 = BN_new();\n    int ret = 0;\n    zkp_hash(h, zkpg, p, ctx->p.peer_name);\n    BN_mod_exp(t1, zkpg, p->zkpx.b, ctx->p.p, ctx->ctx);\n    BN_mod_exp(t2, p->gx, h, ctx->p.p, ctx->ctx);\n    BN_mod_mul(t3, t1, t2, ctx->p.p, ctx->ctx);\n    if(BN_cmp(t3, p->zkpx.gr) == 0)\n\tret = 1;\n    else\n\tJPAKEerr(JPAKE_F_VERIFY_ZKP, JPAKE_R_ZKP_VERIFY_FAILED);\n    BN_free(t3);\n    BN_free(t2);\n    BN_free(t1);\n    BN_free(h);\n    return ret;\n    }', 'static void zkp_hash(BIGNUM *h, const BIGNUM *zkpg, const JPAKE_STEP_PART *p,\n\t\t     const char *proof_name)\n    {\n    unsigned char md[SHA_DIGEST_LENGTH];\n    SHA_CTX sha;\n    SHA1_Init(&sha);\n    hashbn(&sha, zkpg);\n    OPENSSL_assert(!BN_is_zero(p->zkpx.gr));\n    hashbn(&sha, p->zkpx.gr);\n    hashbn(&sha, p->gx);\n    hashstring(&sha, proof_name);\n    SHA1_Final(md, &sha);\n    BN_bin2bn(md, SHA_DIGEST_LENGTH, h);\n    }', 'static void hashbn(SHA_CTX *sha, const BIGNUM *bn)\n    {\n    size_t l = BN_num_bytes(bn);\n    unsigned char *bin = OPENSSL_malloc(l);\n    hashlength(sha, l);\n    BN_bn2bin(bn, bin);\n    SHA1_Update(sha, bin, l);\n    OPENSSL_free(bin);\n    }', 'int BN_num_bits(const BIGNUM *a)\n\t{\n\tint i = a->top - 1;\n\tbn_check_top(a);\n\tif (BN_is_zero(a)) return 0;\n\treturn ((i*BN_BITS2) + BN_num_bits_word(a->d[i]));\n\t}', 'int BN_bn2bin(const BIGNUM *a, unsigned char *to)\n\t{\n\tint n,i;\n\tBN_ULONG l;\n\tbn_check_top(a);\n\tn=i=BN_num_bytes(a);\n\twhile (i--)\n\t\t{\n\t\tl=a->d[i/BN_BYTES];\n\t\t*(to++)=(unsigned char)(l>>(8*(i%BN_BYTES)))&0xff;\n\t\t}\n\treturn(n);\n\t}', 'int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m,\n\t       BN_CTX *ctx)\n\t{\n\tint ret;\n\tbn_check_top(a);\n\tbn_check_top(p);\n\tbn_check_top(m);\n#define MONT_MUL_MOD\n#define MONT_EXP_WORD\n#define RECP_MUL_MOD\n#ifdef MONT_MUL_MOD\n\tif (BN_is_odd(m))\n\t\t{\n#  ifdef MONT_EXP_WORD\n\t\tif (a->top == 1 && !a->neg && (BN_get_flags(p, BN_FLG_CONSTTIME) == 0))\n\t\t\t{\n\t\t\tBN_ULONG A = a->d[0];\n\t\t\tret=BN_mod_exp_mont_word(r,A,p,m,ctx,NULL);\n\t\t\t}\n\t\telse\n#  endif\n\t\t\tret=BN_mod_exp_mont(r,a,p,m,ctx,NULL);\n\t\t}\n\telse\n#endif\n#ifdef RECP_MUL_MOD\n\t\t{ ret=BN_mod_exp_recp(r,a,p,m,ctx); }\n#else\n\t\t{ ret=BN_mod_exp_simple(r,a,p,m,ctx); }\n#endif\n\tbn_check_top(r);\n\treturn(ret);\n\t}']