void *value);
static ASN1_TYPE *get_attribute(STACK_OF(X509_ATTRIBUTE) *sk, int nid);
+static int PKCS7_type_is_other(PKCS7* p7)
+ {
+ int isOther=1;
+
+ int nid=OBJ_obj2nid(p7->type);
+
+ switch( nid )
+ {
+ case NID_pkcs7_data:
+ case NID_pkcs7_signed:
+ case NID_pkcs7_enveloped:
+ case NID_pkcs7_signedAndEnveloped:
+ case NID_pkcs7_digest:
+ case NID_pkcs7_encrypted:
+ isOther=0;
+ break;
+ default:
+ isOther=1;
+ }
+
+ return isOther;
+
+ }
+
+static int PKCS7_type_is_octet_string(PKCS7* p7)
+ {
+ if ( 0==PKCS7_type_is_other(p7) )
+ return 0;
+
+ return (V_ASN1_OCTET_STRING==p7->d.other->type) ? 1 : 0;
+ }
+
BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
{
int i,j;
if (PKCS7_is_detached(p7))
bio=BIO_new(BIO_s_null());
else {
- if (PKCS7_type_is_signed(p7) &&
- PKCS7_type_is_data(p7->d.sign->contents)) {
- ASN1_OCTET_STRING *os;
- os=p7->d.sign->contents->d.data;
- if (os->length > 0) bio =
- BIO_new_mem_buf(os->data, os->length);
- }
+ if (PKCS7_type_is_signed(p7) ) {
+ if ( PKCS7_type_is_data(p7->d.sign->contents)) {
+ ASN1_OCTET_STRING *os;
+ os=p7->d.sign->contents->d.data;
+ if (os->length > 0)
+ bio = BIO_new_mem_buf(os->data, os->length);
+ }
+ else if ( PKCS7_type_is_octet_string(p7->d.sign->contents) ) {
+ ASN1_OCTET_STRING *os;
+ os=p7->d.sign->contents->d.other->value.octet_string;
+ if (os->length > 0)
+ bio = BIO_new_mem_buf(os->data, os->length);
+ }
+ }
if(bio == NULL) {
bio=BIO_new(BIO_s_mem());
BIO_set_mem_eof_return(bio,0);
STACK_OF(PKCS7_SIGNER_INFO) *si_sk=NULL;
ASN1_OCTET_STRING *os=NULL;
+ EVP_MD_CTX_init(&ctx_tmp);
i=OBJ_obj2nid(p7->type);
p7->state=PKCS7_S_HEADER;
/* We now have the EVP_MD_CTX, lets do the
* signing. */
- EVP_MD_CTX_init(&ctx_tmp);
EVP_MD_CTX_copy_ex(&ctx_tmp,mdc);
if (!BUF_MEM_grow(buf,EVP_PKEY_size(si->pkey)))
{
if (si->pkey->type == EVP_PKEY_DSA)
ctx_tmp.digest=EVP_dss1();
#endif
+#ifndef OPENSSL_NO_ECDSA
+ if (si->pkey->type == EVP_PKEY_ECDSA)
+ ctx_tmp.digest=EVP_ecdsa();
+#endif
if (!EVP_SignFinal(&ctx_tmp,(unsigned char *)buf->data,
(unsigned int *)&buf->length,si->pkey))
#ifndef OPENSSL_NO_DSA
if(pkey->type == EVP_PKEY_DSA) mdc_tmp.digest=EVP_dss1();
#endif
+#ifndef OPENSSL_NO_ECDSA
+ if (pkey->type == EVP_PKEY_ECDSA) mdc_tmp.digest=EVP_ecdsa();
+#endif
i=EVP_VerifyFinal(&mdc_tmp,os->data,os->length, pkey);
EVP_PKEY_free(pkey);