summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/cms/cms_io.c
diff options
context:
space:
mode:
authorjsing <>2019-08-11 10:15:30 +0000
committerjsing <>2019-08-11 10:15:30 +0000
commitaa695fbdbecb8a63a9f0f512222e04a0be2b9734 (patch)
treea038b26f2da29ed31383201d4852270882e9961e /src/lib/libcrypto/cms/cms_io.c
parentfa447988cd063cd304b8a827bbc5ad99dea4a159 (diff)
downloadopenbsd-aa695fbdbecb8a63a9f0f512222e04a0be2b9734.tar.gz
openbsd-aa695fbdbecb8a63a9f0f512222e04a0be2b9734.tar.bz2
openbsd-aa695fbdbecb8a63a9f0f512222e04a0be2b9734.zip
Expand ASN.1 macros.
Diffstat (limited to 'src/lib/libcrypto/cms/cms_io.c')
-rw-r--r--src/lib/libcrypto/cms/cms_io.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/src/lib/libcrypto/cms/cms_io.c b/src/lib/libcrypto/cms/cms_io.c
index 5528ca04be..6eba856867 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.9 2019/08/10 18:15:52 jsing Exp $ */ 1/* $OpenBSD: cms_io.c,v 1.10 2019/08/11 10:15:30 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.
@@ -82,22 +82,49 @@ CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms)
82CMS_ContentInfo * 82CMS_ContentInfo *
83d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms) 83d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms)
84{ 84{
85 return ASN1_item_d2i_bio(ASN1_ITEM_rptr(CMS_ContentInfo), bp, cms); 85 return ASN1_item_d2i_bio(&CMS_ContentInfo_it, bp, cms);
86} 86}
87 87
88int 88int
89i2d_CMS_bio(BIO *bp, CMS_ContentInfo *cms) 89i2d_CMS_bio(BIO *bp, CMS_ContentInfo *cms)
90{ 90{
91 return ASN1_item_i2d_bio(ASN1_ITEM_rptr(CMS_ContentInfo), bp, cms); 91 return ASN1_item_i2d_bio(&CMS_ContentInfo_it, bp, cms);
92} 92}
93 93
94IMPLEMENT_PEM_rw_const(CMS, CMS_ContentInfo, PEM_STRING_CMS, CMS_ContentInfo) 94
95CMS_ContentInfo *
96PEM_read_bio_CMS(BIO *bp, CMS_ContentInfo **x, pem_password_cb *cb, void *u)
97{
98 return PEM_ASN1_read_bio((d2i_of_void *)d2i_CMS_ContentInfo, PEM_STRING_CMS, bp,
99 (void **)x, cb, u);
100}
101
102CMS_ContentInfo *
103PEM_read_CMS(FILE *fp, CMS_ContentInfo **x, pem_password_cb *cb, void *u)
104{
105 return PEM_ASN1_read((d2i_of_void *)d2i_CMS_ContentInfo, PEM_STRING_CMS, fp,
106 (void **)x, cb, u);
107}
108
109int
110PEM_write_bio_CMS(BIO *bp, const CMS_ContentInfo *x)
111{
112 return PEM_ASN1_write_bio((i2d_of_void *)i2d_CMS_ContentInfo, PEM_STRING_CMS, bp,
113 (void *)x, NULL, NULL, 0, NULL, NULL);
114}
115
116int
117PEM_write_CMS(FILE *fp, const CMS_ContentInfo *x)
118{
119 return PEM_ASN1_write((i2d_of_void *)i2d_CMS_ContentInfo, PEM_STRING_CMS, fp,
120 (void *)x, NULL, NULL, 0, NULL, NULL);
121}
95 122
96BIO * 123BIO *
97BIO_new_CMS(BIO *out, CMS_ContentInfo *cms) 124BIO_new_CMS(BIO *out, CMS_ContentInfo *cms)
98{ 125{
99 return BIO_new_NDEF(out, (ASN1_VALUE *)cms, 126 return BIO_new_NDEF(out, (ASN1_VALUE *)cms,
100 ASN1_ITEM_rptr(CMS_ContentInfo)); 127 &CMS_ContentInfo_it);
101} 128}
102 129
103/* CMS wrappers round generalised stream and MIME routines */ 130/* CMS wrappers round generalised stream and MIME routines */
@@ -105,14 +132,14 @@ BIO_new_CMS(BIO *out, CMS_ContentInfo *cms)
105int i2d_CMS_bio_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags) 132int i2d_CMS_bio_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags)
106{ 133{
107 return i2d_ASN1_bio_stream(out, (ASN1_VALUE *)cms, in, flags, 134 return i2d_ASN1_bio_stream(out, (ASN1_VALUE *)cms, in, flags,
108 ASN1_ITEM_rptr(CMS_ContentInfo)); 135 &CMS_ContentInfo_it);
109} 136}
110 137
111int 138int
112PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags) 139PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags)
113{ 140{
114 return PEM_write_bio_ASN1_stream(out, (ASN1_VALUE *)cms, in, flags, 141 return PEM_write_bio_ASN1_stream(out, (ASN1_VALUE *)cms, in, flags,
115 "CMS", ASN1_ITEM_rptr(CMS_ContentInfo)); 142 "CMS", &CMS_ContentInfo_it);
116} 143}
117 144
118int 145int
@@ -128,12 +155,12 @@ SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags)
128 mdalgs = NULL; 155 mdalgs = NULL;
129 156
130 return SMIME_write_ASN1(bio, (ASN1_VALUE *)cms, data, flags, ctype_nid, 157 return SMIME_write_ASN1(bio, (ASN1_VALUE *)cms, data, flags, ctype_nid,
131 econt_nid, mdalgs, ASN1_ITEM_rptr(CMS_ContentInfo)); 158 econt_nid, mdalgs, &CMS_ContentInfo_it);
132} 159}
133 160
134CMS_ContentInfo * 161CMS_ContentInfo *
135SMIME_read_CMS(BIO *bio, BIO **bcont) 162SMIME_read_CMS(BIO *bio, BIO **bcont)
136{ 163{
137 return (CMS_ContentInfo *)SMIME_read_ASN1(bio, bcont, 164 return (CMS_ContentInfo *)SMIME_read_ASN1(bio, bcont,
138 ASN1_ITEM_rptr(CMS_ContentInfo)); 165 &CMS_ContentInfo_it);
139} 166}