summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/pkcs7
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/pkcs7')
-rw-r--r--src/lib/libcrypto/pkcs7/Makefile.ssl3
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_doit.c13
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_mime.c6
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_smime.c13
4 files changed, 21 insertions, 14 deletions
diff --git a/src/lib/libcrypto/pkcs7/Makefile.ssl b/src/lib/libcrypto/pkcs7/Makefile.ssl
index 6cd18b671e..37b72f0890 100644
--- a/src/lib/libcrypto/pkcs7/Makefile.ssl
+++ b/src/lib/libcrypto/pkcs7/Makefile.ssl
@@ -58,7 +58,8 @@ verify: verify.o example.o lib
58 58
59lib: $(LIBOBJ) 59lib: $(LIBOBJ)
60 $(AR) $(LIB) $(LIBOBJ) 60 $(AR) $(LIB) $(LIBOBJ)
61 $(RANLIB) $(LIB) 61 @echo You may get an error following this line. Please ignore.
62 - $(RANLIB) $(LIB)
62 @touch lib 63 @touch lib
63 64
64files: 65files:
diff --git a/src/lib/libcrypto/pkcs7/pk7_doit.c b/src/lib/libcrypto/pkcs7/pk7_doit.c
index 099e9651c1..bf43d030ad 100644
--- a/src/lib/libcrypto/pkcs7/pk7_doit.c
+++ b/src/lib/libcrypto/pkcs7/pk7_doit.c
@@ -370,7 +370,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
370 if (ri == NULL) { 370 if (ri == NULL) {
371 PKCS7err(PKCS7_F_PKCS7_DATADECODE, 371 PKCS7err(PKCS7_F_PKCS7_DATADECODE,
372 PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE); 372 PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE);
373 return(NULL); 373 goto err;
374 } 374 }
375 375
376 jj=EVP_PKEY_size(pkey); 376 jj=EVP_PKEY_size(pkey);
@@ -393,7 +393,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
393 BIO_get_cipher_ctx(etmp,&evp_ctx); 393 BIO_get_cipher_ctx(etmp,&evp_ctx);
394 EVP_CipherInit(evp_ctx,evp_cipher,NULL,NULL,0); 394 EVP_CipherInit(evp_ctx,evp_cipher,NULL,NULL,0);
395 if (EVP_CIPHER_asn1_to_param(evp_ctx,enc_alg->parameter) < 0) 395 if (EVP_CIPHER_asn1_to_param(evp_ctx,enc_alg->parameter) < 0)
396 return(NULL); 396 goto err;
397 397
398 if (jj != EVP_CIPHER_CTX_key_length(evp_ctx)) { 398 if (jj != EVP_CIPHER_CTX_key_length(evp_ctx)) {
399 /* Some S/MIME clients don't use the same key 399 /* Some S/MIME clients don't use the same key
@@ -588,8 +588,10 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
588 pp=NULL; 588 pp=NULL;
589 } 589 }
590 590
591#ifndef NO_DSA
591 if (si->pkey->type == EVP_PKEY_DSA) 592 if (si->pkey->type == EVP_PKEY_DSA)
592 ctx_tmp.digest=EVP_dss1(); 593 ctx_tmp.digest=EVP_dss1();
594#endif
593 595
594 if (!EVP_SignFinal(&ctx_tmp,(unsigned char *)buf->data, 596 if (!EVP_SignFinal(&ctx_tmp,(unsigned char *)buf->data,
595 (unsigned int *)&buf->length,si->pkey)) 597 (unsigned int *)&buf->length,si->pkey))
@@ -783,7 +785,14 @@ for (ii=0; ii<md_len; ii++) printf("%02X",md_dat[ii]); printf(" calc\n");
783 785
784 os=si->enc_digest; 786 os=si->enc_digest;
785 pkey = X509_get_pubkey(x509); 787 pkey = X509_get_pubkey(x509);
788 if (!pkey)
789 {
790 ret = -1;
791 goto err;
792 }
793#ifndef NO_DSA
786 if(pkey->type == EVP_PKEY_DSA) mdc_tmp.digest=EVP_dss1(); 794 if(pkey->type == EVP_PKEY_DSA) mdc_tmp.digest=EVP_dss1();
795#endif
787 796
788 i=EVP_VerifyFinal(&mdc_tmp,os->data,os->length, pkey); 797 i=EVP_VerifyFinal(&mdc_tmp,os->data,os->length, pkey);
789 EVP_PKEY_free(pkey); 798 EVP_PKEY_free(pkey);
diff --git a/src/lib/libcrypto/pkcs7/pk7_mime.c b/src/lib/libcrypto/pkcs7/pk7_mime.c
index 994473c0bd..086d394270 100644
--- a/src/lib/libcrypto/pkcs7/pk7_mime.c
+++ b/src/lib/libcrypto/pkcs7/pk7_mime.c
@@ -165,9 +165,9 @@ int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags)
165 } 165 }
166 bound[32] = 0; 166 bound[32] = 0;
167 BIO_printf(bio, "MIME-Version: 1.0\n"); 167 BIO_printf(bio, "MIME-Version: 1.0\n");
168 BIO_printf(bio, "Content-Type: multipart/signed ; "); 168 BIO_printf(bio, "Content-Type: multipart/signed;");
169 BIO_printf(bio, "protocol=\"application/x-pkcs7-signature\" ; "); 169 BIO_printf(bio, " protocol=\"application/x-pkcs7-signature\";");
170 BIO_printf(bio, "micalg=sha1 ; boundary=\"----%s\"\n\n", bound); 170 BIO_printf(bio, " micalg=sha1; boundary=\"----%s\"\n\n", bound);
171 BIO_printf(bio, "This is an S/MIME signed message\n\n"); 171 BIO_printf(bio, "This is an S/MIME signed message\n\n");
172 /* Now write out the first part */ 172 /* Now write out the first part */
173 BIO_printf(bio, "------%s\n", bound); 173 BIO_printf(bio, "------%s\n", bound);
diff --git a/src/lib/libcrypto/pkcs7/pk7_smime.c b/src/lib/libcrypto/pkcs7/pk7_smime.c
index d716f9faeb..3d3214f5ee 100644
--- a/src/lib/libcrypto/pkcs7/pk7_smime.c
+++ b/src/lib/libcrypto/pkcs7/pk7_smime.c
@@ -153,7 +153,7 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
153 PKCS7_SIGNER_INFO *si; 153 PKCS7_SIGNER_INFO *si;
154 X509_STORE_CTX cert_ctx; 154 X509_STORE_CTX cert_ctx;
155 char buf[4096]; 155 char buf[4096];
156 int i, j=0, k; 156 int i, j=0, k, ret = 0;
157 BIO *p7bio; 157 BIO *p7bio;
158 BIO *tmpout; 158 BIO *tmpout;
159 159
@@ -258,18 +258,15 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
258 } 258 }
259 } 259 }
260 260
261 sk_X509_free(signers); 261 ret = 1;
262 if(indata) BIO_pop(p7bio);
263 BIO_free_all(p7bio);
264
265 return 1;
266 262
267 err: 263 err:
268 264
265 if(indata) BIO_pop(p7bio);
266 BIO_free_all(p7bio);
269 sk_X509_free(signers); 267 sk_X509_free(signers);
270 BIO_free(p7bio);
271 268
272 return 0; 269 return ret;
273} 270}
274 271
275STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags) 272STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags)