Lines Matching refs:cms

29 static int cms_get_enveloped_type_simple(const CMS_ContentInfo *cms)  in cms_get_enveloped_type_simple()  argument
31 int nid = OBJ_obj2nid(cms->contentType); in cms_get_enveloped_type_simple()
45 static int cms_get_enveloped_type(const CMS_ContentInfo *cms) in cms_get_enveloped_type() argument
47 int ret = cms_get_enveloped_type_simple(cms); in cms_get_enveloped_type()
54 CMS_EnvelopedData *ossl_cms_get0_enveloped(CMS_ContentInfo *cms) in ossl_cms_get0_enveloped() argument
56 if (OBJ_obj2nid(cms->contentType) != NID_pkcs7_enveloped) { in ossl_cms_get0_enveloped()
60 return cms->d.envelopedData; in ossl_cms_get0_enveloped()
63 CMS_AuthEnvelopedData *ossl_cms_get0_auth_enveloped(CMS_ContentInfo *cms) in ossl_cms_get0_auth_enveloped() argument
65 if (OBJ_obj2nid(cms->contentType) != NID_id_smime_ct_authEnvelopedData) { in ossl_cms_get0_auth_enveloped()
69 return cms->d.authEnvelopedData; in ossl_cms_get0_auth_enveloped()
72 static CMS_EnvelopedData *cms_enveloped_data_init(CMS_ContentInfo *cms) in cms_enveloped_data_init() argument
74 if (cms->d.other == NULL) { in cms_enveloped_data_init()
75 cms->d.envelopedData = M_ASN1_new_of(CMS_EnvelopedData); in cms_enveloped_data_init()
76 if (cms->d.envelopedData == NULL) { in cms_enveloped_data_init()
80 cms->d.envelopedData->version = 0; in cms_enveloped_data_init()
81 cms->d.envelopedData->encryptedContentInfo->contentType = in cms_enveloped_data_init()
83 ASN1_OBJECT_free(cms->contentType); in cms_enveloped_data_init()
84 cms->contentType = OBJ_nid2obj(NID_pkcs7_enveloped); in cms_enveloped_data_init()
85 return cms->d.envelopedData; in cms_enveloped_data_init()
87 return ossl_cms_get0_enveloped(cms); in cms_enveloped_data_init()
91 cms_auth_enveloped_data_init(CMS_ContentInfo *cms) in cms_auth_enveloped_data_init() argument
93 if (cms->d.other == NULL) { in cms_auth_enveloped_data_init()
94 cms->d.authEnvelopedData = M_ASN1_new_of(CMS_AuthEnvelopedData); in cms_auth_enveloped_data_init()
95 if (cms->d.authEnvelopedData == NULL) { in cms_auth_enveloped_data_init()
100 cms->d.authEnvelopedData->version = 0; in cms_auth_enveloped_data_init()
101 cms->d.authEnvelopedData->authEncryptedContentInfo->contentType = in cms_auth_enveloped_data_init()
103 ASN1_OBJECT_free(cms->contentType); in cms_auth_enveloped_data_init()
104 cms->contentType = OBJ_nid2obj(NID_id_smime_ct_authEnvelopedData); in cms_auth_enveloped_data_init()
105 return cms->d.authEnvelopedData; in cms_auth_enveloped_data_init()
107 return ossl_cms_get0_auth_enveloped(cms); in cms_auth_enveloped_data_init()
149 CMS_EncryptedContentInfo *ossl_cms_get0_env_enc_content(const CMS_ContentInfo *cms) in ossl_cms_get0_env_enc_content() argument
151 switch (cms_get_enveloped_type(cms)) { in ossl_cms_get0_env_enc_content()
153 return cms->d.envelopedData == NULL ? NULL in ossl_cms_get0_env_enc_content()
154 : cms->d.envelopedData->encryptedContentInfo; in ossl_cms_get0_env_enc_content()
157 return cms->d.authEnvelopedData == NULL ? NULL in ossl_cms_get0_env_enc_content()
158 : cms->d.authEnvelopedData->authEncryptedContentInfo; in ossl_cms_get0_env_enc_content()
165 STACK_OF(CMS_RecipientInfo) *CMS_get0_RecipientInfos(CMS_ContentInfo *cms) in STACK_OF()
167 switch (cms_get_enveloped_type(cms)) { in STACK_OF()
169 return cms->d.envelopedData->recipientInfos; in STACK_OF()
172 return cms->d.authEnvelopedData->recipientInfos; in STACK_OF()
179 void ossl_cms_RecipientInfos_set_cmsctx(CMS_ContentInfo *cms) in ossl_cms_RecipientInfos_set_cmsctx() argument
183 const CMS_CTX *ctx = ossl_cms_get0_cmsctx(cms); in ossl_cms_RecipientInfos_set_cmsctx()
184 STACK_OF(CMS_RecipientInfo) *rinfos = CMS_get0_RecipientInfos(cms); in ossl_cms_RecipientInfos_set_cmsctx()
230 CMS_ContentInfo *cms; in CMS_EnvelopedData_create_ex() local
233 cms = CMS_ContentInfo_new_ex(libctx, propq); in CMS_EnvelopedData_create_ex()
234 if (cms == NULL) in CMS_EnvelopedData_create_ex()
236 env = cms_enveloped_data_init(cms); in CMS_EnvelopedData_create_ex()
241 0, ossl_cms_get0_cmsctx(cms))) in CMS_EnvelopedData_create_ex()
243 return cms; in CMS_EnvelopedData_create_ex()
245 CMS_ContentInfo_free(cms); in CMS_EnvelopedData_create_ex()
299 CMS_ContentInfo *cms; in CMS_AuthEnvelopedData_create_ex() local
302 cms = CMS_ContentInfo_new_ex(libctx, propq); in CMS_AuthEnvelopedData_create_ex()
303 if (cms == NULL) in CMS_AuthEnvelopedData_create_ex()
305 aenv = cms_auth_enveloped_data_init(cms); in CMS_AuthEnvelopedData_create_ex()
310 ossl_cms_get0_cmsctx(cms))) in CMS_AuthEnvelopedData_create_ex()
312 return cms; in CMS_AuthEnvelopedData_create_ex()
314 CMS_ContentInfo_free(cms); in CMS_AuthEnvelopedData_create_ex()
383 CMS_RecipientInfo *CMS_add1_recipient(CMS_ContentInfo *cms, X509 *recip, in CMS_add1_recipient() argument
390 const CMS_CTX *ctx = ossl_cms_get0_cmsctx(cms); in CMS_add1_recipient()
392 ris = CMS_get0_RecipientInfos(cms); in CMS_add1_recipient()
441 CMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms, X509 *recip, in CMS_add1_recipient_cert() argument
444 return CMS_add1_recipient(cms, recip, NULL, NULL, flags); in CMS_add1_recipient_cert()
506 static int cms_RecipientInfo_ktri_encrypt(const CMS_ContentInfo *cms, in cms_RecipientInfo_ktri_encrypt() argument
514 const CMS_CTX *ctx = ossl_cms_get0_cmsctx(cms); in cms_RecipientInfo_ktri_encrypt()
523 ec = ossl_cms_get0_env_enc_content(cms); in cms_RecipientInfo_ktri_encrypt()
565 static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, in cms_RecipientInfo_ktri_decrypt() argument
577 const CMS_CTX *ctx = ossl_cms_get0_cmsctx(cms); in cms_RecipientInfo_ktri_decrypt()
581 ec = ossl_cms_get0_env_enc_content(cms); in cms_RecipientInfo_ktri_decrypt()
588 if (cms->d.envelopedData->encryptedContentInfo->havenocert in cms_RecipientInfo_ktri_decrypt()
589 && !cms->d.envelopedData->encryptedContentInfo->debug) { in cms_RecipientInfo_ktri_decrypt()
688 CMS_RecipientInfo *CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid, in CMS_add0_recipient_key() argument
697 STACK_OF(CMS_RecipientInfo) *ris = CMS_get0_RecipientInfos(cms); in CMS_add0_recipient_key()
865 static int cms_RecipientInfo_kekri_encrypt(const CMS_ContentInfo *cms, in cms_RecipientInfo_kekri_encrypt() argument
876 const CMS_CTX *cms_ctx = ossl_cms_get0_cmsctx(cms); in cms_RecipientInfo_kekri_encrypt()
878 ec = ossl_cms_get0_env_enc_content(cms); in cms_RecipientInfo_kekri_encrypt()
934 static int cms_RecipientInfo_kekri_decrypt(CMS_ContentInfo *cms, in cms_RecipientInfo_kekri_decrypt() argument
945 const CMS_CTX *cms_ctx = ossl_cms_get0_cmsctx(cms); in cms_RecipientInfo_kekri_decrypt()
947 ec = ossl_cms_get0_env_enc_content(cms); in cms_RecipientInfo_kekri_decrypt()
1012 int CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) in CMS_RecipientInfo_decrypt() argument
1016 return cms_RecipientInfo_ktri_decrypt(cms, ri); in CMS_RecipientInfo_decrypt()
1019 return cms_RecipientInfo_kekri_decrypt(cms, ri); in CMS_RecipientInfo_decrypt()
1022 return ossl_cms_RecipientInfo_pwri_crypt(cms, ri, 0); in CMS_RecipientInfo_decrypt()
1030 int CMS_RecipientInfo_encrypt(const CMS_ContentInfo *cms, CMS_RecipientInfo *ri) in CMS_RecipientInfo_encrypt() argument
1034 return cms_RecipientInfo_ktri_encrypt(cms, ri); in CMS_RecipientInfo_encrypt()
1037 return ossl_cms_RecipientInfo_kari_encrypt(cms, ri); in CMS_RecipientInfo_encrypt()
1040 return cms_RecipientInfo_kekri_encrypt(cms, ri); in CMS_RecipientInfo_encrypt()
1043 return ossl_cms_RecipientInfo_pwri_crypt(cms, ri, 1); in CMS_RecipientInfo_encrypt()
1114 static int cms_env_encrypt_content_key(const CMS_ContentInfo *cms, in cms_env_encrypt_content_key() argument
1122 if (CMS_RecipientInfo_encrypt(cms, ri) <= 0) in cms_env_encrypt_content_key()
1136 static BIO *cms_EnvelopedData_Decryption_init_bio(CMS_ContentInfo *cms) in cms_EnvelopedData_Decryption_init_bio() argument
1138 CMS_EncryptedContentInfo *ec = cms->d.envelopedData->encryptedContentInfo; in cms_EnvelopedData_Decryption_init_bio()
1140 ossl_cms_get0_cmsctx(cms)); in cms_EnvelopedData_Decryption_init_bio()
1158 cms->d.envelopedData->unprotectedAttrs) <= 0) { in cms_EnvelopedData_Decryption_init_bio()
1165 static BIO *cms_EnvelopedData_Encryption_init_bio(CMS_ContentInfo *cms) in cms_EnvelopedData_Encryption_init_bio() argument
1171 CMS_EnvelopedData *env = cms->d.envelopedData; in cms_EnvelopedData_Encryption_init_bio()
1176 ret = ossl_cms_EncryptedContent_init_bio(ec, ossl_cms_get0_cmsctx(cms)); in cms_EnvelopedData_Encryption_init_bio()
1184 if (cms_env_encrypt_content_key(cms, rinfos) < 0) { in cms_EnvelopedData_Encryption_init_bio()
1202 BIO *ossl_cms_EnvelopedData_init_bio(CMS_ContentInfo *cms) in ossl_cms_EnvelopedData_init_bio() argument
1204 if (cms->d.envelopedData->encryptedContentInfo->cipher != NULL) { in ossl_cms_EnvelopedData_init_bio()
1206 return cms_EnvelopedData_Encryption_init_bio(cms); in ossl_cms_EnvelopedData_init_bio()
1210 return cms_EnvelopedData_Decryption_init_bio(cms); in ossl_cms_EnvelopedData_init_bio()
1213 BIO *ossl_cms_AuthEnvelopedData_init_bio(CMS_ContentInfo *cms) in ossl_cms_AuthEnvelopedData_init_bio() argument
1219 CMS_AuthEnvelopedData *aenv = cms->d.authEnvelopedData; in ossl_cms_AuthEnvelopedData_init_bio()
1228 ret = ossl_cms_EncryptedContent_init_bio(ec, ossl_cms_get0_cmsctx(cms)); in ossl_cms_AuthEnvelopedData_init_bio()
1236 if (cms_env_encrypt_content_key(cms, rinfos) < 0) { in ossl_cms_AuthEnvelopedData_init_bio()
1254 int ossl_cms_EnvelopedData_final(CMS_ContentInfo *cms, BIO *chain) in ossl_cms_EnvelopedData_final() argument
1260 env = ossl_cms_get0_enveloped(cms); in ossl_cms_EnvelopedData_final()
1292 cms_env_set_version(cms->d.envelopedData); in ossl_cms_EnvelopedData_final()
1296 int ossl_cms_AuthEnvelopedData_final(CMS_ContentInfo *cms, BIO *cmsbio) in ossl_cms_AuthEnvelopedData_final() argument
1320 if (!ASN1_OCTET_STRING_set(cms->d.authEnvelopedData->mac, tag, taglen)) in ossl_cms_AuthEnvelopedData_final()