crypto/pkcs7/pk7_doit.c:691: error: BUFFER_OVERRUN_L3
  Offset: [1, +oo] Size: [0, +oo] by call to `PKCS7_signatureVerify`.
Showing all 25 steps of the trace


crypto/pkcs7/pk7_doit.c:683:4: Call
681.   	/* Lets verify */
682.   	X509_STORE_CTX_init(ctx,cert_store,x509,cert);
683.   	i=X509_verify_cert(ctx);
          ^
684.   	if (i <= 0) 
685.   		{

crypto/x509/x509_vfy.c:197:32: Call
  195.   			 */
  196.   			ok=X509_STORE_get_by_subject(ctx,X509_LU_X509,xn,&obj);
  197.   			if ((ok != X509_LU_X509) || X509_cmp(x, obj.data.x509)) 
                                        ^
  198.   				{
  199.   				ctx->error=X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT;

crypto/x509/x509_cmp.c:142:1: Parameter `*b->cert_info->version->data`
    140.    * this to work.
    141.    */
    142. > int X509_cmp(X509 *a, X509 *b)
    143.   {
    144.   	/* ensure hash is valid */

crypto/x509/x509_cmp.c:146:2: Call
    144.   	/* ensure hash is valid */
    145.   	X509_check_purpose(a, -1, 0);
    146.   	X509_check_purpose(b, -1, 0);
            ^
    147.   	return memcmp(a->sha1_hash, b->sha1_hash, SHA_DIGEST_LENGTH);
    148.   }

crypto/x509v3/v3_purp.c:97:1: Parameter `*x->cert_info->version->data`
      95.   }
      96.   
      97. > int X509_check_purpose(X509 *x, int id, int ca)
      98.   {
      99.   	int idx;

crypto/x509/x509_vfy.c:243:5: Call
  241.   			if (ok == X509_LU_RETRY)
  242.   				{
  243.   				X509_OBJECT_free_contents(&obj);
             ^
  244.   				X509err(X509_F_X509_VERIFY_CERT,X509_R_SHOULD_RETRY);
  245.   				return(ok);

crypto/x509/x509_lu.c:341:1: Parameter `a->data.x509->aux->other->value.ptr->data`
    339.   	}
    340.   
    341. > void X509_OBJECT_free_contents(X509_OBJECT *a)
    342.   	{
    343.   	switch (a->type)

crypto/pkcs7/pk7_doit.c:691:9: Call
689.   	X509_STORE_CTX_cleanup(ctx);
690.   
691.   	return PKCS7_signatureVerify(bio, p7, si, x509);
               ^
692.   	err:
693.   	return ret;

crypto/pkcs7/pk7_doit.c:696:1: Parameter `*x509->cert_info->key->algor->parameter->value.sequence->data`
  694.   	}
  695.   
  696. > int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,
  697.   								X509 *x509)
  698.   	{

crypto/pkcs7/pk7_doit.c:792:9: Call
  790.   
  791.   	os=si->enc_digest;
  792.   	pkey = X509_get_pubkey(x509);
                 ^
  793.   	if(pkey->type == EVP_PKEY_DSA) mdc_tmp.digest=EVP_dss1();
  794.   

crypto/x509/x509_cmp.c:250:1: Parameter `*x->cert_info->key->algor->parameter->value.sequence->data`
    248.   	}
    249.   
    250. > EVP_PKEY *X509_get_pubkey(X509 *x)
    251.   	{
    252.   	if ((x == NULL) || (x->cert_info == NULL))

crypto/x509/x509_cmp.c:254:9: Call
    252.   	if ((x == NULL) || (x->cert_info == NULL))
    253.   		return(NULL);
    254.   	return(X509_PUBKEY_get(x->cert_info->key));
                   ^
    255.   	}
    256.   

crypto/asn1/x_pubkey.c:201:1: Parameter `*key->algor->parameter->value.sequence->data`
      199.   	}
      200.   
      201. > EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)
      202.   	{
      203.   	EVP_PKEY *ret=NULL;

crypto/asn1/x_pubkey.c:238:4: Assignment
      236.   			{
      237.   			ret->pkey.dsa->write_params=0;
      238.   			p=a->parameter->value.sequence->data;
                ^
      239.   			j=a->parameter->value.sequence->length;
      240.   			if (!d2i_DSAparams(&ret->pkey.dsa,&p,(long)j))

crypto/asn1/x_pubkey.c:240:9: Call
      238.   			p=a->parameter->value.sequence->data;
      239.   			j=a->parameter->value.sequence->length;
      240.   			if (!d2i_DSAparams(&ret->pkey.dsa,&p,(long)j))
                     ^
      241.   				goto err;
      242.   			}

crypto/asn1/d2i_dsap.c:71:1: Parameter `**pp`
        69.   #endif
        70.   
        71. > DSA *d2i_DSAparams(DSA **a, unsigned char **pp, long length)
        72.   	{
        73.   	int i=ERR_R_NESTED_ASN1_ERROR;

crypto/asn1/d2i_dsap.c:77:2: Assignment
        75.   	M_ASN1_D2I_vars(a,DSA *,DSA_new);
        76.   
        77.   	M_ASN1_D2I_Init();
               ^
        78.   	M_ASN1_D2I_start_sequence();
        79.   	M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);

crypto/asn1/d2i_dsap.c:78:2: Call
        76.   
        77.   	M_ASN1_D2I_Init();
        78.   	M_ASN1_D2I_start_sequence();
               ^
        79.   	M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
        80.   	if ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL) goto err_bn;

crypto/asn1/asn1_lib.c:277:1: Parameter `*c->p`
          275.   	}
          276.   
          277. > int asn1_GetSequence(ASN1_CTX *c, long *length)
          278.   	{
          279.   	unsigned char *q;

crypto/asn1/asn1_lib.c:282:9: Call
          280.   
          281.   	q=c->p;
          282.   	c->inf=ASN1_get_object(&(c->p),&(c->slen),&(c->tag),&(c->xclass),
                         ^
          283.   		*length);
          284.   	if (c->inf & 0x80)

crypto/asn1/asn1_lib.c:83:1: <Length trace>
81.   
82.   
83. > int ASN1_get_object(unsigned char **pp, long *plength, int *ptag, int *pclass,
84.   	     long omax)
85.   	{

crypto/asn1/asn1_lib.c:83:1: Parameter `**pp`
            81.   
            82.   
            83. > int ASN1_get_object(unsigned char **pp, long *plength, int *ptag, int *pclass,
            84.   	     long omax)
            85.   	{

crypto/asn1/asn1_lib.c:88:2: Assignment
            86.   	int i,ret;
            87.   	long l;
            88.   	unsigned char *p= *pp;
                   ^
            89.   	int tag,xclass,inf;
            90.   	long max=omax;

crypto/asn1/asn1_lib.c:98:3: Assignment
            96.   	if (i == V_ASN1_PRIMITIVE_TAG)
            97.   		{		/* high-tag */
            98.   		p++;
                     ^
            99.   		if (--max == 0) goto err;
            100.   		l=0;

crypto/asn1/asn1_lib.c:101:10: Array access: Offset: [1, +oo] Size: [0, +oo] by call to `PKCS7_signatureVerify` 
            99.   		if (--max == 0) goto err;
            100.   		l=0;
            101.   		while (*p&0x80)
                            ^
            102.   			{
            103.   			l<<=7L;

int ASN1_get_object(unsigned char **pp, long *plength, int *ptag, int *pclass,
	     long omax)
	{
	int i,ret;
	long l;
	unsigned char *p= *pp;
	int tag,xclass,inf;
	long max=omax;
	if (!max) goto err;
	ret=(*p&V_ASN1_CONSTRUCTED);
	xclass=(*p&V_ASN1_PRIVATE);
	i= *p&V_ASN1_PRIMITIVE_TAG;
	if (i == V_ASN1_PRIMITIVE_TAG)
		{
		p++;
		if (--max == 0) goto err;
		l=0;
		while (*p&0x80)
			{
			l<<=7L;
			l|= *(p++)&0x7f;
			if (--max == 0) goto err;
			}
		l<<=7L;
		l|= *(p++)&0x7f;
		tag=(int)l;
		}
	else
		{
		tag=i;
		p++;
		if (--max == 0) goto err;
		}
	*ptag=tag;
	*pclass=xclass;
	if (!asn1_get_length(&p,&inf,plength,(int)max)) goto err;
#if 0
	fprintf(stderr,"p=%d + *plength=%ld > omax=%ld + *pp=%d  (%d > %d)\n",
		(int)p,*plength,omax,(int)*pp,(int)(p+ *plength),
		(int)(omax+ *pp));
#endif
#if 0
	if ((p+ *plength) > (omax+ *pp))
		{
		ASN1err(ASN1_F_ASN1_GET_OBJECT,ASN1_R_TOO_LONG);
		ret|=0x80;
		}
#endif
	*pp=p;
	return(ret|inf);
err:
	ASN1err(ASN1_F_ASN1_GET_OBJECT,ASN1_R_HEADER_TOO_LONG);
	return(0x80);
	}
['int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx, BIO *bio,\n\t     PKCS7 *p7, PKCS7_SIGNER_INFO *si)\n\t{\n\tPKCS7_ISSUER_AND_SERIAL *ias;\n\tint ret=0,i;\n\tSTACK_OF(X509) *cert;\n\tX509 *x509;\n\tif (PKCS7_type_is_signed(p7))\n\t\t{\n\t\tcert=p7->d.sign->cert;\n\t\t}\n\telse if (PKCS7_type_is_signedAndEnveloped(p7))\n\t\t{\n\t\tcert=p7->d.signed_and_enveloped->cert;\n\t\t}\n\telse\n\t\t{\n\t\tPKCS7err(PKCS7_F_PKCS7_DATAVERIFY,PKCS7_R_WRONG_PKCS7_TYPE);\n\t\tgoto err;\n\t\t}\n\tias=si->issuer_and_serial;\n\tx509=X509_find_by_issuer_and_serial(cert,ias->issuer,ias->serial);\n\tif (x509 == NULL)\n\t\t{\n\t\tPKCS7err(PKCS7_F_PKCS7_DATAVERIFY,PKCS7_R_UNABLE_TO_FIND_CERTIFICATE);\n\t\tgoto err;\n\t\t}\n\tX509_STORE_CTX_init(ctx,cert_store,x509,cert);\n\ti=X509_verify_cert(ctx);\n\tif (i <= 0)\n\t\t{\n\t\tPKCS7err(PKCS7_F_PKCS7_DATAVERIFY,ERR_R_X509_LIB);\n\t\tgoto err;\n\t\t}\n\tX509_STORE_CTX_cleanup(ctx);\n\treturn PKCS7_signatureVerify(bio, p7, si, x509);\n\terr:\n\treturn ret;\n\t}', 'int X509_verify_cert(X509_STORE_CTX *ctx)\n\t{\n\tX509 *x,*xtmp,*chain_ss=NULL;\n\tX509_NAME *xn;\n\tX509_OBJECT obj;\n\tint depth,i,ok=0;\n\tint num;\n\tint (*cb)();\n\tSTACK_OF(X509) *sktmp=NULL;\n\tif (ctx->cert == NULL)\n\t\t{\n\t\tX509err(X509_F_X509_VERIFY_CERT,X509_R_NO_CERT_SET_FOR_US_TO_VERIFY);\n\t\treturn(-1);\n\t\t}\n\tcb=ctx->ctx->verify_cb;\n\tif (cb == NULL) cb=null_callback;\n\tif (ctx->chain == NULL)\n\t\t{\n\t\tif (\t((ctx->chain=sk_X509_new_null()) == NULL) ||\n\t\t\t(!sk_X509_push(ctx->chain,ctx->cert)))\n\t\t\t{\n\t\t\tX509err(X509_F_X509_VERIFY_CERT,ERR_R_MALLOC_FAILURE);\n\t\t\tgoto end;\n\t\t\t}\n\t\tCRYPTO_add(&ctx->cert->references,1,CRYPTO_LOCK_X509);\n\t\tctx->last_untrusted=1;\n\t\t}\n\tif (ctx->untrusted != NULL\n\t    && (sktmp=sk_X509_dup(ctx->untrusted)) == NULL)\n\t\t{\n\t\tX509err(X509_F_X509_VERIFY_CERT,ERR_R_MALLOC_FAILURE);\n\t\tgoto end;\n\t\t}\n\tnum=sk_X509_num(ctx->chain);\n\tx=sk_X509_value(ctx->chain,num-1);\n\tdepth=ctx->depth;\n\tfor (;;)\n\t\t{\n\t\tif (depth < num) break;\n\t\txn=X509_get_issuer_name(x);\n\t\tif (X509_NAME_cmp(X509_get_subject_name(x),xn) == 0)\n\t\t\tbreak;\n\t\tif (ctx->untrusted != NULL)\n\t\t\t{\n\t\t\txtmp=X509_find_by_subject(sktmp,xn);\n\t\t\tif (xtmp != NULL)\n\t\t\t\t{\n\t\t\t\tif (!sk_X509_push(ctx->chain,xtmp))\n\t\t\t\t\t{\n\t\t\t\t\tX509err(X509_F_X509_VERIFY_CERT,ERR_R_MALLOC_FAILURE);\n\t\t\t\t\tgoto end;\n\t\t\t\t\t}\n\t\t\t\tCRYPTO_add(&xtmp->references,1,CRYPTO_LOCK_X509);\n\t\t\t\tsk_X509_delete_ptr(sktmp,xtmp);\n\t\t\t\tctx->last_untrusted++;\n\t\t\t\tx=xtmp;\n\t\t\t\tnum++;\n\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\tbreak;\n\t\t}\n\ti=sk_X509_num(ctx->chain);\n\tx=sk_X509_value(ctx->chain,i-1);\n\txn = X509_get_subject_name(x);\n\tif (X509_NAME_cmp(xn,X509_get_issuer_name(x))\n\t\t== 0)\n\t\t{\n\t\tif (sk_X509_num(ctx->chain) == 1)\n\t\t\t{\n\t\t\tok=X509_STORE_get_by_subject(ctx,X509_LU_X509,xn,&obj);\n\t\t\tif ((ok != X509_LU_X509) || X509_cmp(x, obj.data.x509))\n\t\t\t\t{\n\t\t\t\tctx->error=X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT;\n\t\t\t\tctx->current_cert=x;\n\t\t\t\tctx->error_depth=i-1;\n\t\t\t\tif(ok == X509_LU_X509) X509_OBJECT_free_contents(&obj);\n\t\t\t\tok=cb(0,ctx);\n\t\t\t\tif (!ok) goto end;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tX509_free(x);\n\t\t\t\tx = obj.data.x509;\n\t\t\t\tsk_X509_set(ctx->chain, i - 1, x);\n\t\t\t\tctx->last_untrusted=0;\n\t\t\t\t}\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tchain_ss=sk_X509_pop(ctx->chain);\n\t\t\tctx->last_untrusted--;\n\t\t\tnum--;\n\t\t\tx=sk_X509_value(ctx->chain,num-1);\n\t\t\t}\n\t\t}\n\tfor (;;)\n\t\t{\n\t\tif (depth < num) break;\n\t\txn=X509_get_issuer_name(x);\n\t\tif (X509_NAME_cmp(X509_get_subject_name(x),xn) == 0)\n\t\t\tbreak;\n\t\tok=X509_STORE_get_by_subject(ctx,X509_LU_X509,xn,&obj);\n\t\tif (ok != X509_LU_X509)\n\t\t\t{\n\t\t\tif (ok == X509_LU_RETRY)\n\t\t\t\t{\n\t\t\t\tX509_OBJECT_free_contents(&obj);\n\t\t\t\tX509err(X509_F_X509_VERIFY_CERT,X509_R_SHOULD_RETRY);\n\t\t\t\treturn(ok);\n\t\t\t\t}\n\t\t\telse if (ok != X509_LU_FAIL)\n\t\t\t\t{\n\t\t\t\tX509_OBJECT_free_contents(&obj);\n\t\t\t\treturn(ok);\n\t\t\t\t}\n\t\t\tbreak;\n\t\t\t}\n\t\tx=obj.data.x509;\n\t\tif (!sk_X509_push(ctx->chain,obj.data.x509))\n\t\t\t{\n\t\t\tX509_OBJECT_free_contents(&obj);\n\t\t\tX509err(X509_F_X509_VERIFY_CERT,ERR_R_MALLOC_FAILURE);\n\t\t\treturn(0);\n\t\t\t}\n\t\tnum++;\n\t\t}\n\txn=X509_get_issuer_name(x);\n\tif (X509_NAME_cmp(X509_get_subject_name(x),xn) != 0)\n\t\t{\n\t\tif ((chain_ss == NULL) || (X509_NAME_cmp(X509_get_subject_name(chain_ss),xn) != 0))\n\t\t\t{\n\t\t\tif (ctx->last_untrusted >= num)\n\t\t\t\tctx->error=X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY;\n\t\t\telse\n\t\t\t\tctx->error=X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT;\n\t\t\tctx->current_cert=x;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tsk_X509_push(ctx->chain,chain_ss);\n\t\t\tnum++;\n\t\t\tctx->last_untrusted=num;\n\t\t\tctx->current_cert=chain_ss;\n\t\t\tctx->error=X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN;\n\t\t\tchain_ss=NULL;\n\t\t\t}\n\t\tctx->error_depth=num-1;\n\t\tok=cb(0,ctx);\n\t\tif (!ok) goto end;\n\t\t}\n\tX509_get_pubkey_parameters(NULL,ctx->chain);\n\tif (ctx->ctx->verify != NULL)\n\t\tok=ctx->ctx->verify(ctx);\n\telse\n\t\tok=internal_verify(ctx);\n\tif (0)\n\t\t{\nend:\n\t\tX509_get_pubkey_parameters(NULL,ctx->chain);\n\t\t}\n\tif (sktmp != NULL) sk_X509_free(sktmp);\n\tif (chain_ss != NULL) X509_free(chain_ss);\n\treturn(ok);\n\t}', 'int X509_cmp(X509 *a, X509 *b)\n{\n\tX509_check_purpose(a, -1, 0);\n\tX509_check_purpose(b, -1, 0);\n\treturn memcmp(a->sha1_hash, b->sha1_hash, SHA_DIGEST_LENGTH);\n}', 'int X509_check_purpose(X509 *x, int id, int ca)\n{\n\tint idx;\n\tX509_PURPOSE *pt;\n\tif(!(x->ex_flags & EXFLAG_SET)) {\n\t\tCRYPTO_w_lock(CRYPTO_LOCK_X509);\n\t\tx509v3_cache_extensions(x);\n\t\tCRYPTO_w_unlock(CRYPTO_LOCK_X509);\n\t}\n\tif(id == -1) return 1;\n\tidx = x509_purpose_get_idx(id);\n\tif(idx == -1) return -1;\n\tpt = sk_X509_PURPOSE_value(xptable, idx);\n\treturn pt->check_purpose(pt, x,ca);\n}', 'void X509_OBJECT_free_contents(X509_OBJECT *a)\n\t{\n\tswitch (a->type)\n\t\t{\n\tcase X509_LU_X509:\n\t\tX509_free(a->data.x509);\n\t\tbreak;\n\tcase X509_LU_CRL:\n\t\tX509_CRL_free(a->data.crl);\n\t\tbreak;\n\t\t}\n\t}', 'int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,\n\t\t\t\t\t\t\t\tX509 *x509)\n\t{\n\tASN1_OCTET_STRING *os;\n\tEVP_MD_CTX mdc_tmp,*mdc;\n\tunsigned char *pp,*p;\n\tint ret=0,i;\n\tint md_type;\n\tSTACK_OF(X509_ATTRIBUTE) *sk;\n\tBIO *btmp;\n\tEVP_PKEY *pkey;\n\tif (!PKCS7_type_is_signed(p7) &&\n\t\t\t\t!PKCS7_type_is_signedAndEnveloped(p7)) {\n\t\tPKCS7err(PKCS7_F_PKCS7_SIGNATUREVERIFY,\n\t\t\t\t\t\tPKCS7_R_WRONG_PKCS7_TYPE);\n\t\tgoto err;\n\t}\n\tmd_type=OBJ_obj2nid(si->digest_alg->algorithm);\n\tbtmp=bio;\n\tfor (;;)\n\t\t{\n\t\tif ((btmp == NULL) ||\n\t\t\t((btmp=BIO_find_type(btmp,BIO_TYPE_MD)) == NULL))\n\t\t\t{\n\t\t\tPKCS7err(PKCS7_F_PKCS7_SIGNATUREVERIFY,\n\t\t\t\t\tPKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST);\n\t\t\tgoto err;\n\t\t\t}\n\t\tBIO_get_md_ctx(btmp,&mdc);\n\t\tif (mdc == NULL)\n\t\t\t{\n\t\t\tPKCS7err(PKCS7_F_PKCS7_SIGNATUREVERIFY,\n\t\t\t\t\t\t\tPKCS7_R_INTERNAL_ERROR);\n\t\t\tgoto err;\n\t\t\t}\n\t\tif (EVP_MD_type(EVP_MD_CTX_type(mdc)) == md_type)\n\t\t\tbreak;\n\t\tbtmp=btmp->next_bio;\n\t\t}\n\tmemcpy(&mdc_tmp,mdc,sizeof(mdc_tmp));\n\tsk=si->auth_attr;\n\tif ((sk != NULL) && (sk_X509_ATTRIBUTE_num(sk) != 0))\n\t\t{\n\t\tunsigned char md_dat[EVP_MAX_MD_SIZE];\n                unsigned int md_len;\n\t\tASN1_OCTET_STRING *message_digest;\n\t\tEVP_DigestFinal(&mdc_tmp,md_dat,&md_len);\n\t\tmessage_digest=PKCS7_digest_from_attributes(sk);\n\t\tif (!message_digest)\n\t\t\t{\n\t\t\tPKCS7err(PKCS7_F_PKCS7_SIGNATUREVERIFY,\n\t\t\t\t\tPKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST);\n\t\t\tgoto err;\n\t\t\t}\n\t\tif ((message_digest->length != (int)md_len) ||\n\t\t\t(memcmp(message_digest->data,md_dat,md_len)))\n\t\t\t{\n#if 0\n{\nint ii;\nfor (ii=0; ii<message_digest->length; ii++)\n\tprintf("%02X",message_digest->data[ii]); printf(" sent\\n");\nfor (ii=0; ii<md_len; ii++) printf("%02X",md_dat[ii]); printf(" calc\\n");\n}\n#endif\n\t\t\tPKCS7err(PKCS7_F_PKCS7_SIGNATUREVERIFY,\n\t\t\t\t\t\t\tPKCS7_R_DIGEST_FAILURE);\n\t\t\tret= -1;\n\t\t\tgoto err;\n\t\t\t}\n\t\tEVP_VerifyInit(&mdc_tmp,EVP_get_digestbynid(md_type));\n\t\ti=i2d_ASN1_SET_OF_X509_ATTRIBUTE(sk,NULL,i2d_X509_ATTRIBUTE,\n\t\t\tV_ASN1_SET,V_ASN1_UNIVERSAL, IS_SEQUENCE);\n\t\tpp=Malloc(i);\n\t\tp=pp;\n\t\ti2d_ASN1_SET_OF_X509_ATTRIBUTE(sk,&p,i2d_X509_ATTRIBUTE,\n\t\t\tV_ASN1_SET,V_ASN1_UNIVERSAL, IS_SEQUENCE);\n\t\tEVP_VerifyUpdate(&mdc_tmp,pp,i);\n\t\tFree(pp);\n\t\t}\n\tos=si->enc_digest;\n\tpkey = X509_get_pubkey(x509);\n\tif(pkey->type == EVP_PKEY_DSA) mdc_tmp.digest=EVP_dss1();\n\ti=EVP_VerifyFinal(&mdc_tmp,os->data,os->length, pkey);\n\tEVP_PKEY_free(pkey);\n\tif (i <= 0)\n\t\t{\n\t\tPKCS7err(PKCS7_F_PKCS7_SIGNATUREVERIFY,\n\t\t\t\t\t\tPKCS7_R_SIGNATURE_FAILURE);\n\t\tret= -1;\n\t\tgoto err;\n\t\t}\n\telse\n\t\tret=1;\nerr:\n\treturn(ret);\n\t}', 'EVP_PKEY *X509_get_pubkey(X509 *x)\n\t{\n\tif ((x == NULL) || (x->cert_info == NULL))\n\t\treturn(NULL);\n\treturn(X509_PUBKEY_get(x->cert_info->key));\n\t}', 'EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)\n\t{\n\tEVP_PKEY *ret=NULL;\n\tlong j;\n\tint type;\n\tunsigned char *p;\n#ifndef NO_DSA\n\tX509_ALGOR *a;\n#endif\n\tif (key == NULL) goto err;\n\tif (key->pkey != NULL)\n\t    {\n\t    CRYPTO_add(&key->pkey->references,1,CRYPTO_LOCK_EVP_PKEY);\n\t    return(key->pkey);\n\t    }\n\tif (key->public_key == NULL) goto err;\n\ttype=OBJ_obj2nid(key->algor->algorithm);\n\tp=key->public_key->data;\n        j=key->public_key->length;\n        if ((ret=d2i_PublicKey(type,NULL,&p,(long)j)) == NULL)\n\t\t{\n\t\tX509err(X509_F_X509_PUBKEY_GET,X509_R_ERR_ASN1_LIB);\n\t\tgoto err;\n\t\t}\n\tret->save_parameters=0;\n#ifndef NO_DSA\n\ta=key->algor;\n\tif (ret->type == EVP_PKEY_DSA)\n\t\t{\n\t\tif (a->parameter->type == V_ASN1_SEQUENCE)\n\t\t\t{\n\t\t\tret->pkey.dsa->write_params=0;\n\t\t\tp=a->parameter->value.sequence->data;\n\t\t\tj=a->parameter->value.sequence->length;\n\t\t\tif (!d2i_DSAparams(&ret->pkey.dsa,&p,(long)j))\n\t\t\t\tgoto err;\n\t\t\t}\n\t\tret->save_parameters=1;\n\t\t}\n#endif\n\tkey->pkey=ret;\n\tCRYPTO_add(&ret->references,1,CRYPTO_LOCK_EVP_PKEY);\n\treturn(ret);\nerr:\n\tif (ret != NULL)\n\t\tEVP_PKEY_free(ret);\n\treturn(NULL);\n\t}', 'DSA *d2i_DSAparams(DSA **a, unsigned char **pp, long length)\n\t{\n\tint i=ERR_R_NESTED_ASN1_ERROR;\n\tASN1_INTEGER *bs=NULL;\n\tM_ASN1_D2I_vars(a,DSA *,DSA_new);\n\tM_ASN1_D2I_Init();\n\tM_ASN1_D2I_start_sequence();\n\tM_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);\n\tif ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL) goto err_bn;\n\tM_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);\n\tif ((ret->q=BN_bin2bn(bs->data,bs->length,ret->q)) == NULL) goto err_bn;\n\tM_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);\n\tif ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL) goto err_bn;\n\tM_ASN1_BIT_STRING_free(bs);\n\tM_ASN1_D2I_Finish_2(a);\nerr_bn:\n\ti=ERR_R_BN_LIB;\nerr:\n\tASN1err(ASN1_F_D2I_DSAPARAMS,i);\n\tif ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret);\n\tif (bs != NULL) M_ASN1_BIT_STRING_free(bs);\n\treturn(NULL);\n\t}', 'int asn1_GetSequence(ASN1_CTX *c, long *length)\n\t{\n\tunsigned char *q;\n\tq=c->p;\n\tc->inf=ASN1_get_object(&(c->p),&(c->slen),&(c->tag),&(c->xclass),\n\t\t*length);\n\tif (c->inf & 0x80)\n\t\t{\n\t\tc->error=ERR_R_BAD_GET_ASN1_OBJECT_CALL;\n\t\treturn(0);\n\t\t}\n\tif (c->tag != V_ASN1_SEQUENCE)\n\t\t{\n\t\tc->error=ERR_R_EXPECTING_AN_ASN1_SEQUENCE;\n\t\treturn(0);\n\t\t}\n\t(*length)-=(c->p-q);\n\tif (c->max && (*length < 0))\n\t\t{\n\t\tc->error=ERR_R_ASN1_LENGTH_MISMATCH;\n\t\treturn(0);\n\t\t}\n\tif (c->inf == (1|V_ASN1_CONSTRUCTED))\n\t\tc->slen= *length+ *(c->pp)-c->p;\n\tc->eos=0;\n\treturn(1);\n\t}', 'int ASN1_get_object(unsigned char **pp, long *plength, int *ptag, int *pclass,\n\t     long omax)\n\t{\n\tint i,ret;\n\tlong l;\n\tunsigned char *p= *pp;\n\tint tag,xclass,inf;\n\tlong max=omax;\n\tif (!max) goto err;\n\tret=(*p&V_ASN1_CONSTRUCTED);\n\txclass=(*p&V_ASN1_PRIVATE);\n\ti= *p&V_ASN1_PRIMITIVE_TAG;\n\tif (i == V_ASN1_PRIMITIVE_TAG)\n\t\t{\n\t\tp++;\n\t\tif (--max == 0) goto err;\n\t\tl=0;\n\t\twhile (*p&0x80)\n\t\t\t{\n\t\t\tl<<=7L;\n\t\t\tl|= *(p++)&0x7f;\n\t\t\tif (--max == 0) goto err;\n\t\t\t}\n\t\tl<<=7L;\n\t\tl|= *(p++)&0x7f;\n\t\ttag=(int)l;\n\t\t}\n\telse\n\t\t{\n\t\ttag=i;\n\t\tp++;\n\t\tif (--max == 0) goto err;\n\t\t}\n\t*ptag=tag;\n\t*pclass=xclass;\n\tif (!asn1_get_length(&p,&inf,plength,(int)max)) goto err;\n#if 0\n\tfprintf(stderr,"p=%d + *plength=%ld > omax=%ld + *pp=%d  (%d > %d)\\n",\n\t\t(int)p,*plength,omax,(int)*pp,(int)(p+ *plength),\n\t\t(int)(omax+ *pp));\n#endif\n#if 0\n\tif ((p+ *plength) > (omax+ *pp))\n\t\t{\n\t\tASN1err(ASN1_F_ASN1_GET_OBJECT,ASN1_R_TOO_LONG);\n\t\tret|=0x80;\n\t\t}\n#endif\n\t*pp=p;\n\treturn(ret|inf);\nerr:\n\tASN1err(ASN1_F_ASN1_GET_OBJECT,ASN1_R_HEADER_TOO_LONG);\n\treturn(0x80);\n\t}']