Changes between 0.9.1c and 0.9.2
+ *) Add a bunch of fixes to the PKCS#7 stuff. It used to sometimes reorder
+ signed attributes when verifying signatures (this would break them),
+ the detached data encoding was wrong and public keys obtained using
+ X509_get_pubkey() weren't freed.
+ [Steve Henson]
+
*) Add text documentation for the BUFFER functions. Also added a work around
to a Win95 console bug. This was triggered by the password read stuff: the
last character typed gets carried over to the next fread(). If you were
}
pkey=X509_get_pubkey(ri->cert);
jj=EVP_PKEY_size(pkey);
+ EVP_PKEY_free(pkey);
if (max < jj) max=jj;
}
if ((tmp=(unsigned char *)Malloc(max)) == NULL)
ri=(PKCS7_RECIP_INFO *)sk_value(rsk,i);
pkey=X509_get_pubkey(ri->cert);
jj=EVP_PKEY_encrypt(tmp,key,keylen,pkey);
+ EVP_PKEY_free(pkey);
if (jj <= 0)
{
PKCS7err(PKCS7_F_PKCS7_DATAINIT,ERR_R_EVP_LIB);
case NID_pkcs7_signed:
si_sk=p7->d.sign->signer_info;
os=p7->d.sign->contents->d.data;
+ /* If detached data then the content is excluded */
+ if(p7->detached) {
+ ASN1_OCTET_STRING_free(os);
+ p7->d.sign->contents->d.data = NULL;
+ }
break;
}
}
}
- if (p7->detached)
- ASN1_OCTET_STRING_set(os,(unsigned char *)"",0);
- else
+ if (!p7->detached)
{
btmp=BIO_find_type(bio,BIO_TYPE_MEM);
if (btmp == NULL)
STACK *sk,*cert;
BIO *btmp;
X509 *x509;
+ EVP_PKEY *pkey;
if (PKCS7_type_is_signed(p7))
{
}
EVP_VerifyInit(&mdc_tmp,EVP_get_digestbynid(md_type));
+ /* Note: when forming the encoding of the attributes we
+ * shouldn't reorder them or this will break the signature.
+ * This is done by using the IS_SEQUENCE flag.
+ */
i=i2d_ASN1_SET(sk,NULL,i2d_X509_ATTRIBUTE,
- V_ASN1_SET,V_ASN1_UNIVERSAL, IS_SET);
+ V_ASN1_SET,V_ASN1_UNIVERSAL, IS_SEQUENCE);
pp=(unsigned char *)Malloc(i);
p=pp;
i2d_ASN1_SET(sk,&p,i2d_X509_ATTRIBUTE,
- V_ASN1_SET,V_ASN1_UNIVERSAL, IS_SET);
+ V_ASN1_SET,V_ASN1_UNIVERSAL, IS_SEQUENCE);
EVP_VerifyUpdate(&mdc_tmp,pp,i);
+
Free(pp);
}
os=si->enc_digest;
- if (X509_get_pubkey(x509)->type == EVP_PKEY_DSA)
- mdc_tmp.digest=EVP_dss1();
+ pkey = X509_get_pubkey(x509);
+ if(pkey->type == EVP_PKEY_DSA) mdc_tmp.digest=EVP_dss1();
- i=EVP_VerifyFinal(&mdc_tmp,os->data,os->length,
- X509_get_pubkey(x509));
+ i=EVP_VerifyFinal(&mdc_tmp,os->data,os->length, pkey);
+ EVP_PKEY_free(pkey);
if (i <= 0)
{
PKCS7err(PKCS7_F_PKCS7_DATAVERIFY,PKCS7_R_SIGNATURE_FAILURE);