int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
EVP_MD *dgst)
{
+ char is_dsa;
+ if (pkey->type == EVP_PKEY_DSA) is_dsa = 1;
+ else is_dsa = 0;
/* We now need to add another PKCS7_SIGNER_INFO entry */
ASN1_INTEGER_set(p7i->version,1);
X509_NAME_set(&p7i->issuer_and_serial->issuer,
p7i->pkey=pkey;
/* Set the algorithms */
- if (pkey->type == EVP_PKEY_DSA)
- p7i->digest_alg->algorithm=OBJ_nid2obj(NID_sha1);
+ if (is_dsa) p7i->digest_alg->algorithm=OBJ_nid2obj(NID_sha1);
else
p7i->digest_alg->algorithm=OBJ_nid2obj(EVP_MD_type(dgst));
if (p7i->digest_enc_alg->parameter != NULL)
ASN1_TYPE_free(p7i->digest_enc_alg->parameter);
- if ((p7i->digest_enc_alg->parameter=ASN1_TYPE_new()) == NULL)
- goto err;
- p7i->digest_enc_alg->parameter->type=V_ASN1_NULL;
+ if(is_dsa) p7i->digest_enc_alg->parameter = NULL;
+ else {
+ if (!(p7i->digest_enc_alg->parameter=ASN1_TYPE_new()))
+ goto err;
+ p7i->digest_enc_alg->parameter->type=V_ASN1_NULL;
+ }
return(1);
err:
int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher)
{
int i;
+ ASN1_OBJECT *objtmp;
PKCS7_ENC_CONTENT *ec;
i=OBJ_obj2nid(p7->type);
return(0);
}
- /* Setup cipher OID */
+ /* Check cipher OID exists and has data in it*/
+ i = EVP_CIPHER_type(cipher);
+ if(i == NID_undef) {
+ PKCS7err(PKCS7_F_PKCS7_SET_CIPHER,PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER);
+ return(0);
+ }
+ objtmp = OBJ_nid2obj(i);
ec->cipher = cipher;
return 1;