engines/ccgost/gost_sign.c:170: error: INTEGER_OVERFLOW_L2
  ([0, `dsa->q->top`] - 1):unsigned64 by call to `BN_mod_exp`.
Showing all 21 steps of the trace


engines/ccgost/gost_sign.c:135:1: Parameter `dsa->q->top`
133.    */
134.   
135. > int gost_do_verify(const unsigned char *dgst, int dgst_len,
136.   	DSA_SIG *sig, DSA *dsa)
137.   	{

engines/ccgost/gost_sign.c:146:6: Call
144.   
145.   	BN_CTX_start(ctx);
146.   	if (BN_cmp(sig->s,dsa->q)>=1||
            ^
147.   		BN_cmp(sig->r,dsa->q)>=1)
148.   		{

crypto/bn/bn_lib.c:678:1: Parameter `a->top`
  676.   	}
  677.   
  678. > int BN_cmp(const BIGNUM *a, const BIGNUM *b)
  679.   	{
  680.   	int i;

engines/ccgost/gost_sign.c:147:3: Call
145.   	BN_CTX_start(ctx);
146.   	if (BN_cmp(sig->s,dsa->q)>=1||
147.   		BN_cmp(sig->r,dsa->q)>=1)
         ^
148.   		{
149.   		GOSTerr(GOST_F_GOST_DO_VERIFY,GOST_R_SIGNATURE_PARTS_GREATER_THAN_Q);

crypto/bn/bn_lib.c:678:1: Parameter `a->top`
  676.   	}
  677.   
  678. > int BN_cmp(const BIGNUM *a, const BIGNUM *b)
  679.   	{
  680.   	int i;

engines/ccgost/gost_sign.c:163:2: Call
161.   	u = BN_CTX_get(ctx);
162.   	
163.   	BN_mod(tmp,md,dsa->q,ctx);
        ^
164.   	if (BN_is_zero(tmp))
165.   		{

crypto/bn/bn_div.c:181:1: Parameter `divisor->top`
  179.   static int BN_div_no_branch(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num,
  180.           const BIGNUM *divisor, BN_CTX *ctx);
  181. > int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
  182.   	   BN_CTX *ctx)
  183.   	{

engines/ccgost/gost_sign.c:168:2: Call
166.   		BN_one(md);
167.   		}
168.   	BN_copy(q2,dsa->q);
        ^
169.   	BN_sub_word(q2,2);
170.   	BN_mod_exp(v,md,q2,dsa->q,ctx);

crypto/bn/bn_lib.c:497:1: Parameter `a->dmax`
  495.   	}
  496.   
  497. > BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
  498.   	{
  499.   	int i;

engines/ccgost/gost_sign.c:170:2: Call
168.   	BN_copy(q2,dsa->q);
169.   	BN_sub_word(q2,2);
170.   	BN_mod_exp(v,md,q2,dsa->q,ctx);
        ^
171.   	BN_mod_mul(z1,sig->s,v,dsa->q,ctx);
172.   	BN_sub(tmp,dsa->q,sig->r);

crypto/bn/bn_exp.c:163:1: Parameter `m->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/bn/bn_exp.c:228:9: Call
  226.   #endif
  227.   #ifdef RECP_MUL_MOD
  228.   		{ ret=BN_mod_exp_recp(r,a,p,m,ctx); }
                 ^
  229.   #else
  230.   		{ ret=BN_mod_exp_simple(r,a,p,m,ctx); }

crypto/bn/bn_exp.c:238:1: Parameter `m->top`
    236.   
    237.   
    238. > int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
    239.   		    const BIGNUM *m, BN_CTX *ctx)
    240.   	{

crypto/bn/bn_exp.c:278:7: Call
    276.   	else
    277.   		{
    278.   		if (BN_RECP_CTX_set(&recp,m,ctx) <= 0) goto err;
                 ^
    279.   		}
    280.   

crypto/bn/bn_recp.c:94:1: Parameter `d->top`
      92.   	}
      93.   
      94. > int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *d, BN_CTX *ctx)
      95.   	{
      96.   	if (!BN_copy(&(recp->N),d)) return 0;

crypto/bn/bn_recp.c:96:7: Call
      94.   int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *d, BN_CTX *ctx)
      95.   	{
      96.   	if (!BN_copy(&(recp->N),d)) return 0;
                  ^
      97.   	BN_zero(&(recp->Nr));
      98.   	recp->num_bits=BN_num_bits(d);

crypto/bn/bn_lib.c:497:1: Parameter `a->dmax`
        495.   	}
        496.   
        497. > BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
        498.   	{
        499.   	int i;

crypto/bn/bn_recp.c:98:17: Call
      96.   	if (!BN_copy(&(recp->N),d)) return 0;
      97.   	BN_zero(&(recp->Nr));
      98.   	recp->num_bits=BN_num_bits(d);
                             ^
      99.   	recp->shift=0;
      100.   	return(1);

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, dsa->q->top] - 1):unsigned64 by call to `BN_mod_exp` 
        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 gost_do_verify(const unsigned char *dgst, int dgst_len,\n\tDSA_SIG *sig, DSA *dsa)\n\t{\n\tBIGNUM *md, *tmp=NULL;\n\tBIGNUM *q2=NULL;\n\tBIGNUM *u=NULL,*v=NULL,*z1=NULL,*z2=NULL;\n\tBIGNUM *tmp2=NULL,*tmp3=NULL;\n\tint ok;\n\tBN_CTX *ctx = BN_CTX_new();\n\tBN_CTX_start(ctx);\n\tif (BN_cmp(sig->s,dsa->q)>=1||\n\t\tBN_cmp(sig->r,dsa->q)>=1)\n\t\t{\n\t\tGOSTerr(GOST_F_GOST_DO_VERIFY,GOST_R_SIGNATURE_PARTS_GREATER_THAN_Q);\n\t\treturn 0;\n\t\t}\n\tmd=hashsum2bn(dgst);\n\ttmp=BN_CTX_get(ctx);\n\tv=BN_CTX_get(ctx);\n\tq2=BN_CTX_get(ctx);\n\tz1=BN_CTX_get(ctx);\n\tz2=BN_CTX_get(ctx);\n\ttmp2=BN_CTX_get(ctx);\n\ttmp3=BN_CTX_get(ctx);\n\tu = BN_CTX_get(ctx);\n\tBN_mod(tmp,md,dsa->q,ctx);\n\tif (BN_is_zero(tmp))\n\t\t{\n\t\tBN_one(md);\n\t\t}\n\tBN_copy(q2,dsa->q);\n\tBN_sub_word(q2,2);\n\tBN_mod_exp(v,md,q2,dsa->q,ctx);\n\tBN_mod_mul(z1,sig->s,v,dsa->q,ctx);\n\tBN_sub(tmp,dsa->q,sig->r);\n\tBN_mod_mul(z2,tmp,v,dsa->p,ctx);\n\tBN_mod_exp(tmp,dsa->g,z1,dsa->p,ctx);\n\tBN_mod_exp(tmp2,dsa->pub_key,z2,dsa->p,ctx);\n\tBN_mod_mul(tmp3,tmp,tmp2,dsa->p,ctx);\n\tBN_mod(u,tmp3,dsa->q,ctx);\n\tok= BN_cmp(u,sig->r);\n\tBN_free(md);\n\tBN_CTX_end(ctx);\n\tBN_CTX_free(ctx);\n\tif (ok!=0)\n\t\t{\n\t\tGOSTerr(GOST_F_GOST_DO_VERIFY,GOST_R_SIGNATURE_MISMATCH);\n\t\t}\n\treturn (ok==0);\n\t}', 'int BN_cmp(const BIGNUM *a, const BIGNUM *b)\n\t{\n\tint i;\n\tint gt,lt;\n\tBN_ULONG t1,t2;\n\tif ((a == NULL) || (b == NULL))\n\t\t{\n\t\tif (a != NULL)\n\t\t\treturn(-1);\n\t\telse if (b != NULL)\n\t\t\treturn(1);\n\t\telse\n\t\t\treturn(0);\n\t\t}\n\tbn_check_top(a);\n\tbn_check_top(b);\n\tif (a->neg != b->neg)\n\t\t{\n\t\tif (a->neg)\n\t\t\treturn(-1);\n\t\telse\treturn(1);\n\t\t}\n\tif (a->neg == 0)\n\t\t{ gt=1; lt= -1; }\n\telse\t{ gt= -1; lt=1; }\n\tif (a->top > b->top) return(gt);\n\tif (a->top < b->top) return(lt);\n\tfor (i=a->top-1; i>=0; i--)\n\t\t{\n\t\tt1=a->d[i];\n\t\tt2=b->d[i];\n\t\tif (t1 > t2) return(gt);\n\t\tif (t1 < t2) return(lt);\n\t\t}\n\treturn(0);\n\t}', 'int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,\n\t   BN_CTX *ctx)\n\t{\n\tint norm_shift,i;\n\tsize_t loop;\n\tBIGNUM *tmp,wnum,*snum,*sdiv,*res;\n\tBN_ULONG *resp,*wnump;\n\tBN_ULONG d0,d1;\n\tsize_t num_n,div_n;\n\tif (num->top > 0 && num->d[num->top - 1] == 0)\n\t\t{\n\t\tBNerr(BN_F_BN_DIV,BN_R_NOT_INITIALIZED);\n\t\treturn 0;\n\t\t}\n\tbn_check_top(num);\n\tif ((BN_get_flags(num, BN_FLG_CONSTTIME) != 0) || (BN_get_flags(divisor, BN_FLG_CONSTTIME) != 0))\n\t\t{\n\t\treturn BN_div_no_branch(dv, rm, num, divisor, ctx);\n\t\t}\n\tbn_check_top(dv);\n\tbn_check_top(rm);\n\tbn_check_top(divisor);\n\tif (BN_is_zero(divisor))\n\t\t{\n\t\tBNerr(BN_F_BN_DIV,BN_R_DIV_BY_ZERO);\n\t\treturn(0);\n\t\t}\n\tif (BN_ucmp(num,divisor) < 0)\n\t\t{\n\t\tif (rm != NULL)\n\t\t\t{ if (BN_copy(rm,num) == NULL) return(0); }\n\t\tif (dv != NULL) BN_zero(dv);\n\t\treturn(1);\n\t\t}\n\tBN_CTX_start(ctx);\n\ttmp=BN_CTX_get(ctx);\n\tsnum=BN_CTX_get(ctx);\n\tsdiv=BN_CTX_get(ctx);\n\tif (dv == NULL)\n\t\tres=BN_CTX_get(ctx);\n\telse\tres=dv;\n\tif (sdiv == NULL || res == NULL) goto err;\n\tnorm_shift=BN_BITS2-((BN_num_bits(divisor))%BN_BITS2);\n\tif (!(BN_lshift(sdiv,divisor,norm_shift))) goto err;\n\tsdiv->neg=0;\n\tnorm_shift+=BN_BITS2;\n\tif (!(BN_lshift(snum,num,norm_shift))) goto err;\n\tsnum->neg=0;\n\tdiv_n=sdiv->top;\n\tnum_n=snum->top;\n\tloop=num_n-div_n;\n\twnum.neg   = 0;\n\twnum.d     = &(snum->d[loop]);\n\twnum.top   = div_n;\n\twnum.dmax  = snum->dmax - loop;\n\td0=sdiv->d[div_n-1];\n\td1=(div_n == 1)?0:sdiv->d[div_n-2];\n\twnump= &(snum->d[num_n-1]);\n\tres->neg= (num->neg^divisor->neg);\n\tif (!bn_wexpand(res,(loop+1))) goto err;\n\tres->top=loop;\n\tresp= &(res->d[loop-1]);\n\tif (!bn_wexpand(tmp, div_n+1)) goto err;\n\tif (BN_ucmp(&wnum,sdiv) >= 0)\n\t\t{\n\t\tbn_clear_top2max(&wnum);\n\t\tbn_sub_words(wnum.d, wnum.d, sdiv->d, div_n);\n\t\t*resp=1;\n\t\t}\n\telse\n\t\tres->top--;\n\tif (res->top == 0)\n\t\tres->neg = 0;\n\telse\n\t\tresp--;\n\tfor (i=0; i<loop-1; i++, wnump--, resp--)\n\t\t{\n\t\tBN_ULONG q,l0;\n#if defined(BN_DIV3W) && !defined(OPENSSL_NO_ASM)\n\t\tBN_ULONG bn_div_3_words(BN_ULONG*,BN_ULONG,BN_ULONG);\n\t\tq=bn_div_3_words(wnump,d1,d0);\n#else\n\t\tBN_ULONG n0,n1,rem=0;\n\t\tn0=wnump[0];\n\t\tn1=wnump[-1];\n\t\tif (n0 == d0)\n\t\t\tq=BN_MASK2;\n\t\telse\n\t\t\t{\n#ifdef BN_LLONG\n\t\t\tBN_ULLONG t2;\n#if defined(BN_LLONG) && defined(BN_DIV2W) && !defined(bn_div_words)\n\t\t\tq=(BN_ULONG)(((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0);\n#else\n\t\t\tq=bn_div_words(n0,n1,d0);\n#ifdef BN_DEBUG_LEVITTE\n\t\t\tfprintf(stderr,"DEBUG: bn_div_words(0x%08X,0x%08X,0x%08\\\nX) -> 0x%08X\\n",\n\t\t\t\tn0, n1, d0, q);\n#endif\n#endif\n#ifndef REMAINDER_IS_ALREADY_CALCULATED\n\t\t\trem=(n1-q*d0)&BN_MASK2;\n#endif\n\t\t\tt2=(BN_ULLONG)d1*q;\n\t\t\tfor (;;)\n\t\t\t\t{\n\t\t\t\tif (t2 <= ((((BN_ULLONG)rem)<<BN_BITS2)|wnump[-2]))\n\t\t\t\t\tbreak;\n\t\t\t\tq--;\n\t\t\t\trem += d0;\n\t\t\t\tif (rem < d0) break;\n\t\t\t\tt2 -= d1;\n\t\t\t\t}\n#else\n\t\t\tBN_ULONG t2l,t2h;\n\t\t\tq=bn_div_words(n0,n1,d0);\n#ifdef BN_DEBUG_LEVITTE\n\t\t\tfprintf(stderr,"DEBUG: bn_div_words(0x%08X,0x%08X,0x%08\\\nX) -> 0x%08X\\n",\n\t\t\t\tn0, n1, d0, q);\n#endif\n#ifndef REMAINDER_IS_ALREADY_CALCULATED\n\t\t\trem=(n1-q*d0)&BN_MASK2;\n#endif\n#if defined(BN_UMULT_LOHI)\n\t\t\tBN_UMULT_LOHI(t2l,t2h,d1,q);\n#elif defined(BN_UMULT_HIGH)\n\t\t\tt2l = d1 * q;\n\t\t\tt2h = BN_UMULT_HIGH(d1,q);\n#else\n\t\t\t{\n\t\t\tBN_ULONG ql, qh;\n\t\t\tt2l=LBITS(d1); t2h=HBITS(d1);\n\t\t\tql =LBITS(q);  qh =HBITS(q);\n\t\t\tmul64(t2l,t2h,ql,qh);\n\t\t\t}\n#endif\n\t\t\tfor (;;)\n\t\t\t\t{\n\t\t\t\tif ((t2h < rem) ||\n\t\t\t\t\t((t2h == rem) && (t2l <= wnump[-2])))\n\t\t\t\t\tbreak;\n\t\t\t\tq--;\n\t\t\t\trem += d0;\n\t\t\t\tif (rem < d0) break;\n\t\t\t\tif (t2l < d1) t2h--; t2l -= d1;\n\t\t\t\t}\n#endif\n\t\t\t}\n#endif\n\t\tl0=bn_mul_words(tmp->d,sdiv->d,div_n,q);\n\t\ttmp->d[div_n]=l0;\n\t\twnum.d--;\n\t\tif (bn_sub_words(wnum.d, wnum.d, tmp->d, div_n+1))\n\t\t\t{\n\t\t\tq--;\n\t\t\tif (bn_add_words(wnum.d, wnum.d, sdiv->d, div_n))\n\t\t\t\t(*wnump)++;\n\t\t\t}\n\t\t*resp = q;\n\t\t}\n\tbn_correct_top(snum);\n\tif (rm != NULL)\n\t\t{\n\t\tint neg = num->neg;\n\t\tBN_rshift(rm,snum,norm_shift);\n\t\tif (!BN_is_zero(rm))\n\t\t\trm->neg = neg;\n\t\tbn_check_top(rm);\n\t\t}\n\tBN_CTX_end(ctx);\n\treturn(1);\nerr:\n\tbn_check_top(rm);\n\tBN_CTX_end(ctx);\n\treturn(0);\n\t}', 'BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)\n\t{\n\tint i;\n\tBN_ULONG *A;\n\tconst BN_ULONG *B;\n\tbn_check_top(b);\n\tif (a == b) return(a);\n\tif (bn_wexpand(a,b->top) == NULL) return(NULL);\n#if 1\n\tA=a->d;\n\tB=b->d;\n\tfor (i=b->top>>2; i>0; i--,A+=4,B+=4)\n\t\t{\n\t\tBN_ULONG a0,a1,a2,a3;\n\t\ta0=B[0]; a1=B[1]; a2=B[2]; a3=B[3];\n\t\tA[0]=a0; A[1]=a1; A[2]=a2; A[3]=a3;\n\t\t}\n\tswitch (b->top&3)\n\t\t{\n\t\tcase 3: A[2]=B[2];\n\t\tcase 2: A[1]=B[1];\n\t\tcase 1: A[0]=B[0];\n\t\tcase 0: ;\n\t\t}\n#else\n\tmemcpy(a->d,b->d,sizeof(b->d[0])*b->top);\n#endif\n\ta->top=b->top;\n\ta->neg=b->neg;\n\tbn_check_top(a);\n\treturn(a);\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}', 'int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n\t\t    const BIGNUM *m, BN_CTX *ctx)\n\t{\n\tint i,j,bits,ret=0,wstart,wend,window,wvalue;\n\tint start=1;\n\tBIGNUM *aa;\n\tBIGNUM *val[TABLE_SIZE];\n\tBN_RECP_CTX recp;\n\tif (BN_get_flags(p, BN_FLG_CONSTTIME) != 0)\n\t\t{\n\t\tBNerr(BN_F_BN_MOD_EXP_RECP,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n\t\treturn -1;\n\t\t}\n\tbits=BN_num_bits(p);\n\tif (bits == 0)\n\t\t{\n\t\tret = BN_one(r);\n\t\treturn ret;\n\t\t}\n\tBN_CTX_start(ctx);\n\taa = BN_CTX_get(ctx);\n\tval[0] = BN_CTX_get(ctx);\n\tif(!aa || !val[0]) goto err;\n\tBN_RECP_CTX_init(&recp);\n\tif (m->neg)\n\t\t{\n\t\tif (!BN_copy(aa, m)) goto err;\n\t\taa->neg = 0;\n\t\tif (BN_RECP_CTX_set(&recp,aa,ctx) <= 0) goto err;\n\t\t}\n\telse\n\t\t{\n\t\tif (BN_RECP_CTX_set(&recp,m,ctx) <= 0) goto err;\n\t\t}\n\tif (!BN_nnmod(val[0],a,m,ctx)) goto err;\n\tif (BN_is_zero(val[0]))\n\t\t{\n\t\tBN_zero(r);\n\t\tret = 1;\n\t\tgoto err;\n\t\t}\n\twindow = BN_window_bits_for_exponent_size(bits);\n\tif (window > 1)\n\t\t{\n\t\tif (!BN_mod_mul_reciprocal(aa,val[0],val[0],&recp,ctx))\n\t\t\tgoto err;\n\t\tj=1<<(window-1);\n\t\tfor (i=1; i<j; i++)\n\t\t\t{\n\t\t\tif(((val[i] = BN_CTX_get(ctx)) == NULL) ||\n\t\t\t\t\t!BN_mod_mul_reciprocal(val[i],val[i-1],\n\t\t\t\t\t\taa,&recp,ctx))\n\t\t\t\tgoto err;\n\t\t\t}\n\t\t}\n\tstart=1;\n\twvalue=0;\n\twstart=bits-1;\n\twend=0;\n\tif (!BN_one(r)) goto err;\n\tfor (;;)\n\t\t{\n\t\tif (BN_is_bit_set(p,wstart) == 0)\n\t\t\t{\n\t\t\tif (!start)\n\t\t\t\tif (!BN_mod_mul_reciprocal(r,r,r,&recp,ctx))\n\t\t\t\tgoto err;\n\t\t\tif (wstart == 0) break;\n\t\t\twstart--;\n\t\t\tcontinue;\n\t\t\t}\n\t\tj=wstart;\n\t\twvalue=1;\n\t\twend=0;\n\t\tfor (i=1; i<window; i++)\n\t\t\t{\n\t\t\tif (wstart-i < 0) break;\n\t\t\tif (BN_is_bit_set(p,wstart-i))\n\t\t\t\t{\n\t\t\t\twvalue<<=(i-wend);\n\t\t\t\twvalue|=1;\n\t\t\t\twend=i;\n\t\t\t\t}\n\t\t\t}\n\t\tj=wend+1;\n\t\tif (!start)\n\t\t\tfor (i=0; i<j; i++)\n\t\t\t\t{\n\t\t\t\tif (!BN_mod_mul_reciprocal(r,r,r,&recp,ctx))\n\t\t\t\t\tgoto err;\n\t\t\t\t}\n\t\tif (!BN_mod_mul_reciprocal(r,r,val[wvalue>>1],&recp,ctx))\n\t\t\tgoto err;\n\t\twstart-=wend+1;\n\t\twvalue=0;\n\t\tstart=0;\n\t\tif (wstart < 0) break;\n\t\t}\n\tret=1;\nerr:\n\tBN_CTX_end(ctx);\n\tBN_RECP_CTX_free(&recp);\n\tbn_check_top(r);\n\treturn(ret);\n\t}', 'int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *d, BN_CTX *ctx)\n\t{\n\tif (!BN_copy(&(recp->N),d)) return 0;\n\tBN_zero(&(recp->Nr));\n\trecp->num_bits=BN_num_bits(d);\n\trecp->shift=0;\n\treturn(1);\n\t}', '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}']