diff options
Diffstat (limited to 'src/lib/libcrypto/cms/cms_io.c')
-rw-r--r-- | src/lib/libcrypto/cms/cms_io.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/src/lib/libcrypto/cms/cms_io.c b/src/lib/libcrypto/cms/cms_io.c index 56d7cd68e1..5528ca04be 100644 --- a/src/lib/libcrypto/cms/cms_io.c +++ b/src/lib/libcrypto/cms/cms_io.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: cms_io.c,v 1.8 2019/08/10 16:42:20 jsing Exp $ */ | 1 | /* $OpenBSD: cms_io.c,v 1.9 2019/08/10 18:15:52 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
4 | * project. | 4 | * project. |
@@ -59,9 +59,11 @@ | |||
59 | #include <openssl/cms.h> | 59 | #include <openssl/cms.h> |
60 | #include "cms_lcl.h" | 60 | #include "cms_lcl.h" |
61 | 61 | ||
62 | int CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms) | 62 | int |
63 | CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms) | ||
63 | { | 64 | { |
64 | ASN1_OCTET_STRING **pos; | 65 | ASN1_OCTET_STRING **pos; |
66 | |||
65 | pos = CMS_get0_content(cms); | 67 | pos = CMS_get0_content(cms); |
66 | if (pos == NULL) | 68 | if (pos == NULL) |
67 | return 0; | 69 | return 0; |
@@ -77,22 +79,25 @@ int CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms) | |||
77 | return 0; | 79 | return 0; |
78 | } | 80 | } |
79 | 81 | ||
80 | CMS_ContentInfo *d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms) | 82 | CMS_ContentInfo * |
83 | d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms) | ||
81 | { | 84 | { |
82 | return ASN1_item_d2i_bio(ASN1_ITEM_rptr(CMS_ContentInfo), bp, cms); | 85 | return ASN1_item_d2i_bio(ASN1_ITEM_rptr(CMS_ContentInfo), bp, cms); |
83 | } | 86 | } |
84 | 87 | ||
85 | int i2d_CMS_bio(BIO *bp, CMS_ContentInfo *cms) | 88 | int |
89 | i2d_CMS_bio(BIO *bp, CMS_ContentInfo *cms) | ||
86 | { | 90 | { |
87 | return ASN1_item_i2d_bio(ASN1_ITEM_rptr(CMS_ContentInfo), bp, cms); | 91 | return ASN1_item_i2d_bio(ASN1_ITEM_rptr(CMS_ContentInfo), bp, cms); |
88 | } | 92 | } |
89 | 93 | ||
90 | IMPLEMENT_PEM_rw_const(CMS, CMS_ContentInfo, PEM_STRING_CMS, CMS_ContentInfo) | 94 | IMPLEMENT_PEM_rw_const(CMS, CMS_ContentInfo, PEM_STRING_CMS, CMS_ContentInfo) |
91 | 95 | ||
92 | BIO *BIO_new_CMS(BIO *out, CMS_ContentInfo *cms) | 96 | BIO * |
97 | BIO_new_CMS(BIO *out, CMS_ContentInfo *cms) | ||
93 | { | 98 | { |
94 | return BIO_new_NDEF(out, (ASN1_VALUE *)cms, | 99 | return BIO_new_NDEF(out, (ASN1_VALUE *)cms, |
95 | ASN1_ITEM_rptr(CMS_ContentInfo)); | 100 | ASN1_ITEM_rptr(CMS_ContentInfo)); |
96 | } | 101 | } |
97 | 102 | ||
98 | /* CMS wrappers round generalised stream and MIME routines */ | 103 | /* CMS wrappers round generalised stream and MIME routines */ |
@@ -103,31 +108,32 @@ int i2d_CMS_bio_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags) | |||
103 | ASN1_ITEM_rptr(CMS_ContentInfo)); | 108 | ASN1_ITEM_rptr(CMS_ContentInfo)); |
104 | } | 109 | } |
105 | 110 | ||
106 | int PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, | 111 | int |
107 | int flags) | 112 | PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags) |
108 | { | 113 | { |
109 | return PEM_write_bio_ASN1_stream(out, (ASN1_VALUE *)cms, in, flags, | 114 | return PEM_write_bio_ASN1_stream(out, (ASN1_VALUE *)cms, in, flags, |
110 | "CMS", ASN1_ITEM_rptr(CMS_ContentInfo)); | 115 | "CMS", ASN1_ITEM_rptr(CMS_ContentInfo)); |
111 | } | 116 | } |
112 | 117 | ||
113 | int SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags) | 118 | int |
119 | SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags) | ||
114 | { | 120 | { |
115 | STACK_OF(X509_ALGOR) *mdalgs; | 121 | STACK_OF(X509_ALGOR) *mdalgs; |
116 | int ctype_nid = OBJ_obj2nid(cms->contentType); | 122 | int ctype_nid = OBJ_obj2nid(cms->contentType); |
117 | int econt_nid = OBJ_obj2nid(CMS_get0_eContentType(cms)); | 123 | int econt_nid = OBJ_obj2nid(CMS_get0_eContentType(cms)); |
124 | |||
118 | if (ctype_nid == NID_pkcs7_signed) | 125 | if (ctype_nid == NID_pkcs7_signed) |
119 | mdalgs = cms->d.signedData->digestAlgorithms; | 126 | mdalgs = cms->d.signedData->digestAlgorithms; |
120 | else | 127 | else |
121 | mdalgs = NULL; | 128 | mdalgs = NULL; |
122 | 129 | ||
123 | return SMIME_write_ASN1(bio, (ASN1_VALUE *)cms, data, flags, | 130 | return SMIME_write_ASN1(bio, (ASN1_VALUE *)cms, data, flags, ctype_nid, |
124 | ctype_nid, econt_nid, mdalgs, | 131 | econt_nid, mdalgs, ASN1_ITEM_rptr(CMS_ContentInfo)); |
125 | ASN1_ITEM_rptr(CMS_ContentInfo)); | ||
126 | } | 132 | } |
127 | 133 | ||
128 | CMS_ContentInfo *SMIME_read_CMS(BIO *bio, BIO **bcont) | 134 | CMS_ContentInfo * |
135 | SMIME_read_CMS(BIO *bio, BIO **bcont) | ||
129 | { | 136 | { |
130 | return (CMS_ContentInfo *)SMIME_read_ASN1(bio, bcont, | 137 | return (CMS_ContentInfo *)SMIME_read_ASN1(bio, bcont, |
131 | ASN1_ITEM_rptr | 138 | ASN1_ITEM_rptr(CMS_ContentInfo)); |
132 | (CMS_ContentInfo)); | ||
133 | } | 139 | } |