Lines Matching refs:p7
20 long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg)
25 nid = OBJ_obj2nid(p7->type);
31 ret = p7->detached = (int)larg;
32 if (ret && PKCS7_type_is_data(p7->d.sign->contents)) {
34 os = p7->d.sign->contents->d.data;
36 p7->d.sign->contents->d.data = NULL;
46 if (p7->d.sign == NULL || p7->d.sign->contents->d.ptr == NULL)
51 p7->detached = ret;
66 int PKCS7_content_new(PKCS7 *p7, int type)
74 if (!PKCS7_set_content(p7, ret))
83 int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data)
87 i = OBJ_obj2nid(p7->type);
90 PKCS7_free(p7->d.sign->contents);
91 p7->d.sign->contents = p7_data;
94 PKCS7_free(p7->d.digest->contents);
95 p7->d.digest->contents = p7_data;
110 int PKCS7_set_type(PKCS7 *p7, int type)
115 * PKCS7_content_free(p7);
121 p7->type = obj;
122 if ((p7->d.sign = PKCS7_SIGNED_new()) == NULL)
124 if (!ASN1_INTEGER_set(p7->d.sign->version, 1)) {
125 PKCS7_SIGNED_free(p7->d.sign);
126 p7->d.sign = NULL;
131 p7->type = obj;
132 if ((p7->d.data = ASN1_OCTET_STRING_new()) == NULL)
136 p7->type = obj;
137 if ((p7->d.signed_and_enveloped = PKCS7_SIGN_ENVELOPE_new())
140 if (!ASN1_INTEGER_set(p7->d.signed_and_enveloped->version, 1))
142 p7->d.signed_and_enveloped->enc_data->content_type
146 p7->type = obj;
147 if ((p7->d.enveloped = PKCS7_ENVELOPE_new())
150 if (!ASN1_INTEGER_set(p7->d.enveloped->version, 0))
152 p7->d.enveloped->enc_data->content_type = OBJ_nid2obj(NID_pkcs7_data);
155 p7->type = obj;
156 if ((p7->d.encrypted = PKCS7_ENCRYPT_new())
159 if (!ASN1_INTEGER_set(p7->d.encrypted->version, 0))
161 p7->d.encrypted->enc_data->content_type = OBJ_nid2obj(NID_pkcs7_data);
165 p7->type = obj;
166 if ((p7->d.digest = PKCS7_DIGEST_new())
169 if (!ASN1_INTEGER_set(p7->d.digest->version, 0))
181 int PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other)
183 p7->type = OBJ_nid2obj(type);
184 p7->d.other = other;
188 int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *psi)
196 i = OBJ_obj2nid(p7->type);
199 signer_sk = p7->d.sign->signer_info;
200 md_sk = p7->d.sign->md_algs;
203 signer_sk = p7->d.signed_and_enveloped->signer_info;
204 md_sk = p7->d.signed_and_enveloped->md_algs;
245 psi->ctx = ossl_pkcs7_get0_ctx(p7);
251 int PKCS7_add_certificate(PKCS7 *p7, X509 *x509)
256 i = OBJ_obj2nid(p7->type);
259 sk = &(p7->d.sign->cert);
262 sk = &(p7->d.signed_and_enveloped->cert);
272 int PKCS7_add_crl(PKCS7 *p7, X509_CRL *crl)
277 i = OBJ_obj2nid(p7->type);
280 sk = &(p7->d.sign->crl);
283 sk = &(p7->d.signed_and_enveloped->crl);
387 PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509, EVP_PKEY *pkey,
407 if (!PKCS7_add_signer(p7, si))
415 static STACK_OF(X509) *pkcs7_get_signer_certs(const PKCS7 *p7)
417 if (p7->d.ptr == NULL)
419 if (PKCS7_type_is_signed(p7))
420 return p7->d.sign->cert;
421 if (PKCS7_type_is_signedAndEnveloped(p7))
422 return p7->d.signed_and_enveloped->cert;
426 static STACK_OF(PKCS7_RECIP_INFO) *pkcs7_get_recipient_info(const PKCS7 *p7)
428 if (p7->d.ptr == NULL)
430 if (PKCS7_type_is_signedAndEnveloped(p7))
431 return p7->d.signed_and_enveloped->recipientinfo;
432 if (PKCS7_type_is_enveloped(p7))
433 return p7->d.enveloped->recipientinfo;
441 void ossl_pkcs7_resolve_libctx(PKCS7 *p7)
444 const PKCS7_CTX *ctx = ossl_pkcs7_get0_ctx(p7);
451 if (ctx == NULL || p7->d.ptr == NULL)
454 rinfos = pkcs7_get_recipient_info(p7);
455 sinfos = PKCS7_get_signer_info(p7);
456 certs = pkcs7_get_signer_certs(p7);
475 const PKCS7_CTX *ossl_pkcs7_get0_ctx(const PKCS7 *p7)
477 return p7 != NULL ? &p7->ctx : NULL;
480 void ossl_pkcs7_set0_libctx(PKCS7 *p7, OSSL_LIB_CTX *ctx)
482 p7->ctx.libctx = ctx;
485 int ossl_pkcs7_set1_propq(PKCS7 *p7, const char *propq)
487 if (p7->ctx.propq != NULL) {
488 OPENSSL_free(p7->ctx.propq);
489 p7->ctx.propq = NULL;
492 p7->ctx.propq = OPENSSL_strdup(propq);
493 if (p7->ctx.propq == NULL) {
520 int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md)
522 if (PKCS7_type_is_digest(p7)) {
523 if ((p7->d.digest->md->parameter = ASN1_TYPE_new()) == NULL) {
527 p7->d.digest->md->parameter->type = V_ASN1_NULL;
528 p7->d.digest->md->algorithm = OBJ_nid2obj(EVP_MD_nid(md));
536 STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7)
538 if (p7 == NULL || p7->d.ptr == NULL)
540 if (PKCS7_type_is_signed(p7)) {
541 return p7->d.sign->signer_info;
542 } else if (PKCS7_type_is_signedAndEnveloped(p7)) {
543 return p7->d.signed_and_enveloped->signer_info;
565 PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509)
573 if (!PKCS7_add_recipient_info(p7, ri))
575 ri->ctx = ossl_pkcs7_get0_ctx(p7);
582 int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri)
587 i = OBJ_obj2nid(p7->type);
590 sk = p7->d.signed_and_enveloped->recipientinfo;
593 sk = p7->d.enveloped->recipientinfo;
670 X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si)
672 if (PKCS7_type_is_signed(p7))
673 return (X509_find_by_issuer_and_serial(p7->d.sign->cert,
681 int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher)
686 i = OBJ_obj2nid(p7->type);
689 ec = p7->d.signed_and_enveloped->enc_data;
692 ec = p7->d.enveloped->enc_data;
707 ec->ctx = ossl_pkcs7_get0_ctx(p7);
712 int PKCS7_stream(unsigned char ***boundary, PKCS7 *p7)
716 switch (OBJ_obj2nid(p7->type)) {
718 os = p7->d.data;
722 os = p7->d.signed_and_enveloped->enc_data->enc_data;
725 p7->d.signed_and_enveloped->enc_data->enc_data = os;
730 os = p7->d.enveloped->enc_data->enc_data;
733 p7->d.enveloped->enc_data->enc_data = os;
738 os = p7->d.sign->contents->d.data;