Lines Matching refs:cms
29 static int cms_get_enveloped_type(const CMS_ContentInfo *cms) in cms_get_enveloped_type() argument
31 int nid = OBJ_obj2nid(cms->contentType); in cms_get_enveloped_type()
46 CMS_EnvelopedData *ossl_cms_get0_enveloped(CMS_ContentInfo *cms) in ossl_cms_get0_enveloped() argument
48 if (OBJ_obj2nid(cms->contentType) != NID_pkcs7_enveloped) { in ossl_cms_get0_enveloped()
52 return cms->d.envelopedData; in ossl_cms_get0_enveloped()
55 CMS_AuthEnvelopedData *ossl_cms_get0_auth_enveloped(CMS_ContentInfo *cms) in ossl_cms_get0_auth_enveloped() argument
57 if (OBJ_obj2nid(cms->contentType) != NID_id_smime_ct_authEnvelopedData) { in ossl_cms_get0_auth_enveloped()
61 return cms->d.authEnvelopedData; in ossl_cms_get0_auth_enveloped()
64 static CMS_EnvelopedData *cms_enveloped_data_init(CMS_ContentInfo *cms) in cms_enveloped_data_init() argument
66 if (cms->d.other == NULL) { in cms_enveloped_data_init()
67 cms->d.envelopedData = M_ASN1_new_of(CMS_EnvelopedData); in cms_enveloped_data_init()
68 if (cms->d.envelopedData == NULL) { in cms_enveloped_data_init()
72 cms->d.envelopedData->version = 0; in cms_enveloped_data_init()
73 cms->d.envelopedData->encryptedContentInfo->contentType = in cms_enveloped_data_init()
75 ASN1_OBJECT_free(cms->contentType); in cms_enveloped_data_init()
76 cms->contentType = OBJ_nid2obj(NID_pkcs7_enveloped); in cms_enveloped_data_init()
77 return cms->d.envelopedData; in cms_enveloped_data_init()
79 return ossl_cms_get0_enveloped(cms); in cms_enveloped_data_init()
83 cms_auth_enveloped_data_init(CMS_ContentInfo *cms) in cms_auth_enveloped_data_init() argument
85 if (cms->d.other == NULL) { in cms_auth_enveloped_data_init()
86 cms->d.authEnvelopedData = M_ASN1_new_of(CMS_AuthEnvelopedData); in cms_auth_enveloped_data_init()
87 if (cms->d.authEnvelopedData == NULL) { in cms_auth_enveloped_data_init()
92 cms->d.authEnvelopedData->version = 0; in cms_auth_enveloped_data_init()
93 cms->d.authEnvelopedData->authEncryptedContentInfo->contentType = in cms_auth_enveloped_data_init()
95 ASN1_OBJECT_free(cms->contentType); in cms_auth_enveloped_data_init()
96 cms->contentType = OBJ_nid2obj(NID_id_smime_ct_authEnvelopedData); in cms_auth_enveloped_data_init()
97 return cms->d.authEnvelopedData; in cms_auth_enveloped_data_init()
99 return ossl_cms_get0_auth_enveloped(cms); in cms_auth_enveloped_data_init()
141 CMS_EncryptedContentInfo* ossl_cms_get0_env_enc_content(const CMS_ContentInfo *cms) in ossl_cms_get0_env_enc_content() argument
143 switch (cms_get_enveloped_type(cms)) { in ossl_cms_get0_env_enc_content()
145 return cms->d.envelopedData->encryptedContentInfo; in ossl_cms_get0_env_enc_content()
148 return cms->d.authEnvelopedData->authEncryptedContentInfo; in ossl_cms_get0_env_enc_content()
155 STACK_OF(CMS_RecipientInfo) *CMS_get0_RecipientInfos(CMS_ContentInfo *cms) in STACK_OF()
157 switch (cms_get_enveloped_type(cms)) { in STACK_OF()
159 return cms->d.envelopedData->recipientInfos; in STACK_OF()
162 return cms->d.authEnvelopedData->recipientInfos; in STACK_OF()
169 void ossl_cms_RecipientInfos_set_cmsctx(CMS_ContentInfo *cms) in ossl_cms_RecipientInfos_set_cmsctx() argument
173 const CMS_CTX *ctx = ossl_cms_get0_cmsctx(cms); in ossl_cms_RecipientInfos_set_cmsctx()
174 STACK_OF(CMS_RecipientInfo) *rinfos = CMS_get0_RecipientInfos(cms); in ossl_cms_RecipientInfos_set_cmsctx()
220 CMS_ContentInfo *cms; in CMS_EnvelopedData_create_ex() local
223 cms = CMS_ContentInfo_new_ex(libctx, propq); in CMS_EnvelopedData_create_ex()
224 if (cms == NULL) in CMS_EnvelopedData_create_ex()
226 env = cms_enveloped_data_init(cms); in CMS_EnvelopedData_create_ex()
231 0, ossl_cms_get0_cmsctx(cms))) in CMS_EnvelopedData_create_ex()
233 return cms; in CMS_EnvelopedData_create_ex()
235 CMS_ContentInfo_free(cms); in CMS_EnvelopedData_create_ex()
249 CMS_ContentInfo *cms; in CMS_AuthEnvelopedData_create_ex() local
252 cms = CMS_ContentInfo_new_ex(libctx, propq); in CMS_AuthEnvelopedData_create_ex()
253 if (cms == NULL) in CMS_AuthEnvelopedData_create_ex()
255 aenv = cms_auth_enveloped_data_init(cms); in CMS_AuthEnvelopedData_create_ex()
260 ossl_cms_get0_cmsctx(cms))) in CMS_AuthEnvelopedData_create_ex()
262 return cms; in CMS_AuthEnvelopedData_create_ex()
264 CMS_ContentInfo_free(cms); in CMS_AuthEnvelopedData_create_ex()
333 CMS_RecipientInfo *CMS_add1_recipient(CMS_ContentInfo *cms, X509 *recip, in CMS_add1_recipient() argument
340 const CMS_CTX *ctx = ossl_cms_get0_cmsctx(cms); in CMS_add1_recipient()
342 ris = CMS_get0_RecipientInfos(cms); in CMS_add1_recipient()
389 CMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms, X509 *recip, in CMS_add1_recipient_cert() argument
392 return CMS_add1_recipient(cms, recip, NULL, NULL, flags); in CMS_add1_recipient_cert()
454 static int cms_RecipientInfo_ktri_encrypt(const CMS_ContentInfo *cms, in cms_RecipientInfo_ktri_encrypt() argument
462 const CMS_CTX *ctx = ossl_cms_get0_cmsctx(cms); in cms_RecipientInfo_ktri_encrypt()
471 ec = ossl_cms_get0_env_enc_content(cms); in cms_RecipientInfo_ktri_encrypt()
516 static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, in cms_RecipientInfo_ktri_decrypt() argument
528 const CMS_CTX *ctx = ossl_cms_get0_cmsctx(cms); in cms_RecipientInfo_ktri_decrypt()
532 ec = ossl_cms_get0_env_enc_content(cms); in cms_RecipientInfo_ktri_decrypt()
539 if (cms->d.envelopedData->encryptedContentInfo->havenocert in cms_RecipientInfo_ktri_decrypt()
540 && !cms->d.envelopedData->encryptedContentInfo->debug) { in cms_RecipientInfo_ktri_decrypt()
647 CMS_RecipientInfo *CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid, in CMS_add0_recipient_key() argument
656 STACK_OF(CMS_RecipientInfo) *ris = CMS_get0_RecipientInfos(cms); in CMS_add0_recipient_key()
818 static int cms_RecipientInfo_kekri_encrypt(const CMS_ContentInfo *cms, in cms_RecipientInfo_kekri_encrypt() argument
829 const CMS_CTX *cms_ctx = ossl_cms_get0_cmsctx(cms); in cms_RecipientInfo_kekri_encrypt()
831 ec = ossl_cms_get0_env_enc_content(cms); in cms_RecipientInfo_kekri_encrypt()
889 static int cms_RecipientInfo_kekri_decrypt(CMS_ContentInfo *cms, in cms_RecipientInfo_kekri_decrypt() argument
900 const CMS_CTX *cms_ctx = ossl_cms_get0_cmsctx(cms); in cms_RecipientInfo_kekri_decrypt()
902 ec = ossl_cms_get0_env_enc_content(cms); in cms_RecipientInfo_kekri_decrypt()
969 int CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) in CMS_RecipientInfo_decrypt() argument
973 return cms_RecipientInfo_ktri_decrypt(cms, ri); in CMS_RecipientInfo_decrypt()
976 return cms_RecipientInfo_kekri_decrypt(cms, ri); in CMS_RecipientInfo_decrypt()
979 return ossl_cms_RecipientInfo_pwri_crypt(cms, ri, 0); in CMS_RecipientInfo_decrypt()
987 int CMS_RecipientInfo_encrypt(const CMS_ContentInfo *cms, CMS_RecipientInfo *ri) in CMS_RecipientInfo_encrypt() argument
991 return cms_RecipientInfo_ktri_encrypt(cms, ri); in CMS_RecipientInfo_encrypt()
994 return ossl_cms_RecipientInfo_kari_encrypt(cms, ri); in CMS_RecipientInfo_encrypt()
997 return cms_RecipientInfo_kekri_encrypt(cms, ri); in CMS_RecipientInfo_encrypt()
1000 return ossl_cms_RecipientInfo_pwri_crypt(cms, ri, 1); in CMS_RecipientInfo_encrypt()
1071 static int cms_env_encrypt_content_key(const CMS_ContentInfo *cms, in cms_env_encrypt_content_key() argument
1079 if (CMS_RecipientInfo_encrypt(cms, ri) <= 0) in cms_env_encrypt_content_key()
1093 static BIO *cms_EnvelopedData_Decryption_init_bio(CMS_ContentInfo *cms) in cms_EnvelopedData_Decryption_init_bio() argument
1095 CMS_EncryptedContentInfo *ec = cms->d.envelopedData->encryptedContentInfo; in cms_EnvelopedData_Decryption_init_bio()
1097 ossl_cms_get0_cmsctx(cms)); in cms_EnvelopedData_Decryption_init_bio()
1115 cms->d.envelopedData->unprotectedAttrs) <= 0) { in cms_EnvelopedData_Decryption_init_bio()
1122 static BIO *cms_EnvelopedData_Encryption_init_bio(CMS_ContentInfo *cms) in cms_EnvelopedData_Encryption_init_bio() argument
1128 CMS_EnvelopedData *env = cms->d.envelopedData; in cms_EnvelopedData_Encryption_init_bio()
1133 ret = ossl_cms_EncryptedContent_init_bio(ec, ossl_cms_get0_cmsctx(cms)); in cms_EnvelopedData_Encryption_init_bio()
1141 if (cms_env_encrypt_content_key(cms, rinfos) < 0) { in cms_EnvelopedData_Encryption_init_bio()
1159 BIO *ossl_cms_EnvelopedData_init_bio(CMS_ContentInfo *cms) in ossl_cms_EnvelopedData_init_bio() argument
1161 if (cms->d.envelopedData->encryptedContentInfo->cipher != NULL) { in ossl_cms_EnvelopedData_init_bio()
1163 return cms_EnvelopedData_Encryption_init_bio(cms); in ossl_cms_EnvelopedData_init_bio()
1167 return cms_EnvelopedData_Decryption_init_bio(cms); in ossl_cms_EnvelopedData_init_bio()
1170 BIO *ossl_cms_AuthEnvelopedData_init_bio(CMS_ContentInfo *cms) in ossl_cms_AuthEnvelopedData_init_bio() argument
1176 CMS_AuthEnvelopedData *aenv = cms->d.authEnvelopedData; in ossl_cms_AuthEnvelopedData_init_bio()
1185 ret = ossl_cms_EncryptedContent_init_bio(ec, ossl_cms_get0_cmsctx(cms)); in ossl_cms_AuthEnvelopedData_init_bio()
1193 if (cms_env_encrypt_content_key(cms, rinfos) < 0) { in ossl_cms_AuthEnvelopedData_init_bio()
1211 int ossl_cms_EnvelopedData_final(CMS_ContentInfo *cms, BIO *chain) in ossl_cms_EnvelopedData_final() argument
1217 env = ossl_cms_get0_enveloped(cms); in ossl_cms_EnvelopedData_final()
1249 cms_env_set_version(cms->d.envelopedData); in ossl_cms_EnvelopedData_final()
1253 int ossl_cms_AuthEnvelopedData_final(CMS_ContentInfo *cms, BIO *cmsbio) in ossl_cms_AuthEnvelopedData_final() argument
1277 if (!ASN1_OCTET_STRING_set(cms->d.authEnvelopedData->mac, tag, taglen)) in ossl_cms_AuthEnvelopedData_final()