engines/ccgost/gost2001_keyx.c:51: error: BUFFER_OVERRUN_L3
  Offset: [-10, +oo] Size: 64 by call to `store_bignum`.
Showing all 7 steps of the trace


engines/ccgost/gost2001_keyx.c:24:1: Array declaration
22.   
23.   /* Implementation of CryptoPro VKO 34.10-2001 algorithm */
24. > static int VKO_compute_key(unsigned char *shared_key,size_t shared_key_size,const EC_POINT *pub_key,EC_KEY *priv_key,const unsigned char *ukm)
25.   	{
26.   	unsigned char ukm_be[8],databuf[64],hashbuf[64];

engines/ccgost/gost2001_keyx.c:51:2: Call
49.   	/*Serialize elliptic curve point same way as we do it when saving
50.   	 * key */
51.   	store_bignum(Y,databuf,32);
       ^
52.   	store_bignum(X,databuf+32,32);
53.    	/* And reverse byte order of whole buffer */

engines/ccgost/gost_sign.c:314:1: Parameter `len`
  312.   /* Pack bignum into byte buffer of given size, filling all leading bytes
  313.    * by zeros */
  314. > int store_bignum(BIGNUM *bn, unsigned char *buf,int len)
  315.   	{
  316.   	int bytes = BN_num_bytes(bn);

engines/ccgost/gost_sign.c:319:2: Call
  317.   	if (bytes>len) return 0;
  318.   	memset(buf,0,len);
  319.   	BN_bn2bin(bn,buf+len-bytes);
          ^
  320.   	return 1;
  321.   	}	

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

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

crypto/bn/bn_lib.c:651:3: Array access: Offset: [-10, +oo] Size: 64 by call to `store_bignum` 
    649.   		{
    650.   		l=a->d[i/BN_BYTES];
    651.   		*(to++)=(unsigned char)(l>>(8*(i%BN_BYTES)))&0xff;
             ^
    652.   		}
    653.   	return(n);

int BN_bn2bin(const BIGNUM *a, unsigned char *to)
	{
	int n,i;
	BN_ULONG l;
	bn_check_top(a);
	n=i=BN_num_bytes(a);
	while (i--)
		{
		l=a->d[i/BN_BYTES];
		*(to++)=(unsigned char)(l>>(8*(i%BN_BYTES)))&0xff;
		}
	return(n);
	}
['static int VKO_compute_key(unsigned char *shared_key,size_t shared_key_size,const EC_POINT *pub_key,EC_KEY *priv_key,const unsigned char *ukm)\n\t{\n\tunsigned char ukm_be[8],databuf[64],hashbuf[64];\n\tBIGNUM *UKM=NULL,*p=NULL,*order=NULL,*X=NULL,*Y=NULL;\n\tconst BIGNUM* key=EC_KEY_get0_private_key(priv_key);\n\tEC_POINT *pnt=EC_POINT_new(EC_KEY_get0_group(priv_key));\n\tint i;\n\tgost_hash_ctx hash_ctx;\n\tBN_CTX *ctx = BN_CTX_new();\n\tfor (i=0;i<8;i++)\n\t\t{\n\t\tukm_be[7-i]=ukm[i];\n\t\t}\n\tBN_CTX_start(ctx);\n\tUKM=getbnfrombuf(ukm_be,8);\n\tp=BN_CTX_get(ctx);\n\torder = BN_CTX_get(ctx);\n\tX=BN_CTX_get(ctx);\n\tY=BN_CTX_get(ctx);\n\tEC_GROUP_get_order(EC_KEY_get0_group(priv_key),order,ctx);\n\tBN_mod_mul(p,key,UKM,order,ctx);\n\tEC_POINT_mul(EC_KEY_get0_group(priv_key),pnt,NULL,pub_key,p,ctx);\n\tEC_POINT_get_affine_coordinates_GFp(EC_KEY_get0_group(priv_key),\n\t\tpnt,X,Y,ctx);\n\tstore_bignum(Y,databuf,32);\n\tstore_bignum(X,databuf+32,32);\n\tfor (i=0;i<64;i++)\n\t\t{\n\t\thashbuf[63-i]=databuf[i];\n\t\t}\n\tinit_gost_hash_ctx(&hash_ctx,&GostR3411_94_CryptoProParamSet);\n\tstart_hash(&hash_ctx);\n\thash_block(&hash_ctx,hashbuf,64);\n\tfinish_hash(&hash_ctx,shared_key);\n\tdone_gost_hash_ctx(&hash_ctx);\n\tBN_free(UKM);\n\tBN_CTX_end(ctx);\n\tBN_CTX_free(ctx);\n\tEC_POINT_free(pnt);\n\treturn 32;\n\t}', 'int store_bignum(BIGNUM *bn, unsigned char *buf,int len)\n\t{\n\tint bytes = BN_num_bytes(bn);\n\tif (bytes>len) return 0;\n\tmemset(buf,0,len);\n\tBN_bn2bin(bn,buf+len-bytes);\n\treturn 1;\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}']