diff options
Diffstat (limited to 'src/lib/libcrypto/pkcs7')
-rw-r--r-- | src/lib/libcrypto/pkcs7/Makefile.ssl | 91 | ||||
-rw-r--r-- | src/lib/libcrypto/pkcs7/bio_ber.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/pkcs7/pk7_attr.c | 30 | ||||
-rw-r--r-- | src/lib/libcrypto/pkcs7/pk7_doit.c | 57 | ||||
-rw-r--r-- | src/lib/libcrypto/pkcs7/pk7_mime.c | 138 | ||||
-rw-r--r-- | src/lib/libcrypto/pkcs7/pk7_smime.c | 24 | ||||
-rw-r--r-- | src/lib/libcrypto/pkcs7/pkcs7.h | 43 |
7 files changed, 205 insertions, 182 deletions
diff --git a/src/lib/libcrypto/pkcs7/Makefile.ssl b/src/lib/libcrypto/pkcs7/Makefile.ssl index 0e508386e8..6cd18b671e 100644 --- a/src/lib/libcrypto/pkcs7/Makefile.ssl +++ b/src/lib/libcrypto/pkcs7/Makefile.ssl | |||
@@ -99,12 +99,14 @@ clean: | |||
99 | 99 | ||
100 | pk7_attr.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 100 | pk7_attr.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
101 | pk7_attr.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | 101 | pk7_attr.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h |
102 | pk7_attr.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | 102 | pk7_attr.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h |
103 | pk7_attr.o: ../../include/openssl/des.h ../../include/openssl/dh.h | 103 | pk7_attr.o: ../../include/openssl/crypto.h ../../include/openssl/des.h |
104 | pk7_attr.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | 104 | pk7_attr.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h |
105 | pk7_attr.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 105 | pk7_attr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h |
106 | pk7_attr.o: ../../include/openssl/idea.h ../../include/openssl/md2.h | 106 | pk7_attr.o: ../../include/openssl/evp.h ../../include/openssl/idea.h |
107 | pk7_attr.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | 107 | pk7_attr.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h |
108 | pk7_attr.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
109 | pk7_attr.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
108 | pk7_attr.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | 110 | pk7_attr.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h |
109 | pk7_attr.o: ../../include/openssl/opensslv.h ../../include/openssl/pem.h | 111 | pk7_attr.o: ../../include/openssl/opensslv.h ../../include/openssl/pem.h |
110 | pk7_attr.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h | 112 | pk7_attr.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h |
@@ -112,26 +114,29 @@ pk7_attr.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | |||
112 | pk7_attr.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | 114 | pk7_attr.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h |
113 | pk7_attr.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | 115 | pk7_attr.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h |
114 | pk7_attr.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | 116 | pk7_attr.o: ../../include/openssl/sha.h ../../include/openssl/stack.h |
115 | pk7_attr.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | 117 | pk7_attr.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h |
118 | pk7_attr.o: ../../include/openssl/x509_vfy.h | ||
116 | pk7_doit.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 119 | pk7_doit.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
117 | pk7_doit.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | 120 | pk7_doit.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h |
118 | pk7_doit.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | 121 | pk7_doit.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h |
119 | pk7_doit.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h | 122 | pk7_doit.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h |
120 | pk7_doit.o: ../../include/openssl/des.h ../../include/openssl/dh.h | 123 | pk7_doit.o: ../../include/openssl/des.h ../../include/openssl/dh.h |
121 | pk7_doit.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h | 124 | pk7_doit.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h |
122 | pk7_doit.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | 125 | pk7_doit.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h |
123 | pk7_doit.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | 126 | pk7_doit.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
124 | pk7_doit.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | 127 | pk7_doit.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h |
128 | pk7_doit.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
125 | pk7_doit.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | 129 | pk7_doit.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h |
126 | pk7_doit.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | 130 | pk7_doit.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
131 | pk7_doit.o: ../../include/openssl/opensslconf.h | ||
127 | pk7_doit.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h | 132 | pk7_doit.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h |
128 | pk7_doit.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h | 133 | pk7_doit.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h |
129 | pk7_doit.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | 134 | pk7_doit.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h |
130 | pk7_doit.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | 135 | pk7_doit.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h |
131 | pk7_doit.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | 136 | pk7_doit.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h |
132 | pk7_doit.o: ../../include/openssl/stack.h ../../include/openssl/x509.h | 137 | pk7_doit.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
133 | pk7_doit.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h | 138 | pk7_doit.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h |
134 | pk7_doit.o: ../cryptlib.h | 139 | pk7_doit.o: ../../include/openssl/x509v3.h ../cryptlib.h |
135 | pk7_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 140 | pk7_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
136 | pk7_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | 141 | pk7_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h |
137 | pk7_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | 142 | pk7_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h |
@@ -139,14 +144,16 @@ pk7_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | |||
139 | pk7_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | 144 | pk7_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h |
140 | pk7_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h | 145 | pk7_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h |
141 | pk7_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 146 | pk7_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
142 | pk7_lib.o: ../../include/openssl/idea.h ../../include/openssl/md2.h | 147 | pk7_lib.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h |
148 | pk7_lib.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
143 | pk7_lib.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | 149 | pk7_lib.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h |
144 | pk7_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | 150 | pk7_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
145 | pk7_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h | 151 | pk7_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
146 | pk7_lib.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | 152 | pk7_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h |
147 | pk7_lib.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | 153 | pk7_lib.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h |
148 | pk7_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | 154 | pk7_lib.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h |
149 | pk7_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | 155 | pk7_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h |
156 | pk7_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
150 | pk7_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | 157 | pk7_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h |
151 | pk7_lib.o: ../cryptlib.h | 158 | pk7_lib.o: ../cryptlib.h |
152 | pk7_mime.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 159 | pk7_mime.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
@@ -156,47 +163,55 @@ pk7_mime.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | |||
156 | pk7_mime.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | 163 | pk7_mime.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h |
157 | pk7_mime.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h | 164 | pk7_mime.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h |
158 | pk7_mime.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 165 | pk7_mime.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
159 | pk7_mime.o: ../../include/openssl/idea.h ../../include/openssl/md2.h | 166 | pk7_mime.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h |
167 | pk7_mime.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
160 | pk7_mime.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | 168 | pk7_mime.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h |
161 | pk7_mime.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | 169 | pk7_mime.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
170 | pk7_mime.o: ../../include/openssl/opensslconf.h | ||
162 | pk7_mime.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h | 171 | pk7_mime.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h |
163 | pk7_mime.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h | 172 | pk7_mime.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h |
164 | pk7_mime.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | 173 | pk7_mime.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h |
165 | pk7_mime.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | 174 | pk7_mime.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h |
166 | pk7_mime.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | 175 | pk7_mime.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h |
167 | pk7_mime.o: ../../include/openssl/stack.h ../../include/openssl/x509.h | 176 | pk7_mime.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
168 | pk7_mime.o: ../../include/openssl/x509_vfy.h ../cryptlib.h | 177 | pk7_mime.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h |
178 | pk7_mime.o: ../cryptlib.h | ||
169 | pk7_smime.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 179 | pk7_smime.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
170 | pk7_smime.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | 180 | pk7_smime.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h |
171 | pk7_smime.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | 181 | pk7_smime.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h |
172 | pk7_smime.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h | 182 | pk7_smime.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h |
173 | pk7_smime.o: ../../include/openssl/des.h ../../include/openssl/dh.h | 183 | pk7_smime.o: ../../include/openssl/des.h ../../include/openssl/dh.h |
174 | pk7_smime.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h | 184 | pk7_smime.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h |
175 | pk7_smime.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | 185 | pk7_smime.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h |
176 | pk7_smime.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | 186 | pk7_smime.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
177 | pk7_smime.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | 187 | pk7_smime.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h |
188 | pk7_smime.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
178 | pk7_smime.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | 189 | pk7_smime.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h |
179 | pk7_smime.o: ../../include/openssl/objects.h | 190 | pk7_smime.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
180 | pk7_smime.o: ../../include/openssl/opensslconf.h | 191 | pk7_smime.o: ../../include/openssl/opensslconf.h |
181 | pk7_smime.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h | 192 | pk7_smime.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h |
182 | pk7_smime.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | 193 | pk7_smime.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h |
183 | pk7_smime.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | 194 | pk7_smime.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h |
184 | pk7_smime.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | 195 | pk7_smime.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h |
185 | pk7_smime.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | 196 | pk7_smime.o: ../../include/openssl/sha.h ../../include/openssl/stack.h |
186 | pk7_smime.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | 197 | pk7_smime.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h |
187 | pk7_smime.o: ../../include/openssl/x509v3.h ../cryptlib.h | 198 | pk7_smime.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h |
199 | pk7_smime.o: ../cryptlib.h | ||
188 | pkcs7err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 200 | pkcs7err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
189 | pkcs7err.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | 201 | pkcs7err.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h |
190 | pkcs7err.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | 202 | pkcs7err.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h |
191 | pkcs7err.o: ../../include/openssl/des.h ../../include/openssl/dh.h | 203 | pkcs7err.o: ../../include/openssl/crypto.h ../../include/openssl/des.h |
192 | pkcs7err.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | 204 | pkcs7err.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h |
193 | pkcs7err.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 205 | pkcs7err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h |
194 | pkcs7err.o: ../../include/openssl/idea.h ../../include/openssl/md2.h | 206 | pkcs7err.o: ../../include/openssl/evp.h ../../include/openssl/idea.h |
195 | pkcs7err.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | 207 | pkcs7err.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h |
208 | pkcs7err.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
209 | pkcs7err.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
196 | pkcs7err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | 210 | pkcs7err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h |
197 | pkcs7err.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h | 211 | pkcs7err.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h |
198 | pkcs7err.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | 212 | pkcs7err.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h |
199 | pkcs7err.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | 213 | pkcs7err.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h |
200 | pkcs7err.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | 214 | pkcs7err.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h |
201 | pkcs7err.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | 215 | pkcs7err.o: ../../include/openssl/sha.h ../../include/openssl/stack.h |
202 | pkcs7err.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | 216 | pkcs7err.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h |
217 | pkcs7err.o: ../../include/openssl/x509_vfy.h | ||
diff --git a/src/lib/libcrypto/pkcs7/bio_ber.c b/src/lib/libcrypto/pkcs7/bio_ber.c index 4803966fd2..5447e69818 100644 --- a/src/lib/libcrypto/pkcs7/bio_ber.c +++ b/src/lib/libcrypto/pkcs7/bio_ber.c | |||
@@ -128,7 +128,7 @@ static int ber_new(BIO *bi) | |||
128 | { | 128 | { |
129 | BIO_BER_CTX *ctx; | 129 | BIO_BER_CTX *ctx; |
130 | 130 | ||
131 | ctx=(BIO_BER_CTX *)Malloc(sizeof(BIO_BER_CTX)); | 131 | ctx=(BIO_BER_CTX *)OPENSSL_malloc(sizeof(BIO_BER_CTX)); |
132 | if (ctx == NULL) return(0); | 132 | if (ctx == NULL) return(0); |
133 | 133 | ||
134 | memset((char *)ctx,0,sizeof(BIO_BER_CTX)); | 134 | memset((char *)ctx,0,sizeof(BIO_BER_CTX)); |
@@ -146,7 +146,7 @@ static int ber_free(BIO *a) | |||
146 | if (a == NULL) return(0); | 146 | if (a == NULL) return(0); |
147 | b=(BIO_BER_CTX *)a->ptr; | 147 | b=(BIO_BER_CTX *)a->ptr; |
148 | memset(a->ptr,0,sizeof(BIO_BER_CTX)); | 148 | memset(a->ptr,0,sizeof(BIO_BER_CTX)); |
149 | Free(a->ptr); | 149 | OPENSSL_free(a->ptr); |
150 | a->ptr=NULL; | 150 | a->ptr=NULL; |
151 | a->init=0; | 151 | a->init=0; |
152 | a->flags=0; | 152 | a->flags=0; |
diff --git a/src/lib/libcrypto/pkcs7/pk7_attr.c b/src/lib/libcrypto/pkcs7/pk7_attr.c index 3b9c0fe3f2..6ae264cbf9 100644 --- a/src/lib/libcrypto/pkcs7/pk7_attr.c +++ b/src/lib/libcrypto/pkcs7/pk7_attr.c | |||
@@ -12,22 +12,24 @@ | |||
12 | #include <openssl/asn1.h> | 12 | #include <openssl/asn1.h> |
13 | #include <openssl/pem.h> | 13 | #include <openssl/pem.h> |
14 | #include <openssl/pkcs7.h> | 14 | #include <openssl/pkcs7.h> |
15 | #include <openssl/x509.h> | ||
15 | #include <openssl/err.h> | 16 | #include <openssl/err.h> |
16 | 17 | ||
17 | int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, STACK *cap) | 18 | int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, STACK_OF(X509_ALGOR) *cap) |
18 | { | 19 | { |
19 | ASN1_STRING *seq; | 20 | ASN1_STRING *seq; |
20 | unsigned char *p, *pp; | 21 | unsigned char *p, *pp; |
21 | int len; | 22 | int len; |
22 | len=i2d_ASN1_SET(cap,NULL,i2d_X509_ALGOR, V_ASN1_SEQUENCE, | 23 | len=i2d_ASN1_SET_OF_X509_ALGOR(cap,NULL,i2d_X509_ALGOR, |
23 | V_ASN1_UNIVERSAL, IS_SEQUENCE); | 24 | V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, |
24 | if(!(pp=(unsigned char *)Malloc(len))) { | 25 | IS_SEQUENCE); |
26 | if(!(pp=(unsigned char *)OPENSSL_malloc(len))) { | ||
25 | PKCS7err(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP,ERR_R_MALLOC_FAILURE); | 27 | PKCS7err(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP,ERR_R_MALLOC_FAILURE); |
26 | return 0; | 28 | return 0; |
27 | } | 29 | } |
28 | p=pp; | 30 | p=pp; |
29 | i2d_ASN1_SET(cap,&p,i2d_X509_ALGOR, V_ASN1_SEQUENCE, | 31 | i2d_ASN1_SET_OF_X509_ALGOR(cap,&p,i2d_X509_ALGOR, V_ASN1_SEQUENCE, |
30 | V_ASN1_UNIVERSAL, IS_SEQUENCE); | 32 | V_ASN1_UNIVERSAL, IS_SEQUENCE); |
31 | if(!(seq = ASN1_STRING_new())) { | 33 | if(!(seq = ASN1_STRING_new())) { |
32 | PKCS7err(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP,ERR_R_MALLOC_FAILURE); | 34 | PKCS7err(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP,ERR_R_MALLOC_FAILURE); |
33 | return 0; | 35 | return 0; |
@@ -36,27 +38,29 @@ int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, STACK *cap) | |||
36 | PKCS7err(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP,ERR_R_MALLOC_FAILURE); | 38 | PKCS7err(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP,ERR_R_MALLOC_FAILURE); |
37 | return 0; | 39 | return 0; |
38 | } | 40 | } |
39 | Free (pp); | 41 | OPENSSL_free (pp); |
40 | return PKCS7_add_signed_attribute(si, NID_SMIMECapabilities, | 42 | return PKCS7_add_signed_attribute(si, NID_SMIMECapabilities, |
41 | V_ASN1_SEQUENCE, seq); | 43 | V_ASN1_SEQUENCE, seq); |
42 | } | 44 | } |
43 | 45 | ||
44 | STACK *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si) | 46 | STACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si) |
45 | { | 47 | { |
46 | ASN1_TYPE *cap; | 48 | ASN1_TYPE *cap; |
47 | unsigned char *p; | 49 | unsigned char *p; |
48 | cap = PKCS7_get_signed_attribute(si, NID_SMIMECapabilities); | 50 | cap = PKCS7_get_signed_attribute(si, NID_SMIMECapabilities); |
49 | if (!cap) return NULL; | 51 | if (!cap) return NULL; |
50 | p = cap->value.sequence->data; | 52 | p = cap->value.sequence->data; |
51 | return d2i_ASN1_SET (NULL, &p, cap->value.sequence->length, | 53 | return d2i_ASN1_SET_OF_X509_ALGOR(NULL, &p, |
52 | (char *(*)())d2i_X509_ALGOR, X509_ALGOR_free, V_ASN1_SEQUENCE, | 54 | cap->value.sequence->length, |
53 | V_ASN1_UNIVERSAL); | 55 | d2i_X509_ALGOR, X509_ALGOR_free, |
56 | V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL); | ||
54 | } | 57 | } |
55 | 58 | ||
56 | /* Basic smime-capabilities OID and optional integer arg */ | 59 | /* Basic smime-capabilities OID and optional integer arg */ |
57 | int PKCS7_simple_smimecap(STACK *sk, int nid, int arg) | 60 | int PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg) |
58 | { | 61 | { |
59 | X509_ALGOR *alg; | 62 | X509_ALGOR *alg; |
63 | |||
60 | if(!(alg = X509_ALGOR_new())) { | 64 | if(!(alg = X509_ALGOR_new())) { |
61 | PKCS7err(PKCS7_F_PKCS7_SIMPLE_SMIMECAP,ERR_R_MALLOC_FAILURE); | 65 | PKCS7err(PKCS7_F_PKCS7_SIMPLE_SMIMECAP,ERR_R_MALLOC_FAILURE); |
62 | return 0; | 66 | return 0; |
@@ -80,6 +84,6 @@ int PKCS7_simple_smimecap(STACK *sk, int nid, int arg) | |||
80 | alg->parameter->value.integer = nbit; | 84 | alg->parameter->value.integer = nbit; |
81 | alg->parameter->type = V_ASN1_INTEGER; | 85 | alg->parameter->type = V_ASN1_INTEGER; |
82 | } | 86 | } |
83 | sk_push (sk, (char *)alg); | 87 | sk_X509_ALGOR_push (sk, alg); |
84 | return 1; | 88 | return 1; |
85 | } | 89 | } |
diff --git a/src/lib/libcrypto/pkcs7/pk7_doit.c b/src/lib/libcrypto/pkcs7/pk7_doit.c index 4ab24a86f5..099e9651c1 100644 --- a/src/lib/libcrypto/pkcs7/pk7_doit.c +++ b/src/lib/libcrypto/pkcs7/pk7_doit.c | |||
@@ -189,7 +189,7 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio) | |||
189 | EVP_PKEY_free(pkey); | 189 | EVP_PKEY_free(pkey); |
190 | if (max < jj) max=jj; | 190 | if (max < jj) max=jj; |
191 | } | 191 | } |
192 | if ((tmp=(unsigned char *)Malloc(max)) == NULL) | 192 | if ((tmp=(unsigned char *)OPENSSL_malloc(max)) == NULL) |
193 | { | 193 | { |
194 | PKCS7err(PKCS7_F_PKCS7_DATAINIT,ERR_R_MALLOC_FAILURE); | 194 | PKCS7err(PKCS7_F_PKCS7_DATAINIT,ERR_R_MALLOC_FAILURE); |
195 | goto err; | 195 | goto err; |
@@ -203,12 +203,12 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio) | |||
203 | if (jj <= 0) | 203 | if (jj <= 0) |
204 | { | 204 | { |
205 | PKCS7err(PKCS7_F_PKCS7_DATAINIT,ERR_R_EVP_LIB); | 205 | PKCS7err(PKCS7_F_PKCS7_DATAINIT,ERR_R_EVP_LIB); |
206 | Free(tmp); | 206 | OPENSSL_free(tmp); |
207 | goto err; | 207 | goto err; |
208 | } | 208 | } |
209 | M_ASN1_OCTET_STRING_set(ri->enc_key,tmp,jj); | 209 | M_ASN1_OCTET_STRING_set(ri->enc_key,tmp,jj); |
210 | } | 210 | } |
211 | Free(tmp); | 211 | OPENSSL_free(tmp); |
212 | memset(key, 0, keylen); | 212 | memset(key, 0, keylen); |
213 | 213 | ||
214 | if (out == NULL) | 214 | if (out == NULL) |
@@ -265,13 +265,6 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert) | |||
265 | STACK_OF(PKCS7_RECIP_INFO) *rsk=NULL; | 265 | STACK_OF(PKCS7_RECIP_INFO) *rsk=NULL; |
266 | X509_ALGOR *xalg=NULL; | 266 | X509_ALGOR *xalg=NULL; |
267 | PKCS7_RECIP_INFO *ri=NULL; | 267 | PKCS7_RECIP_INFO *ri=NULL; |
268 | #ifndef NO_RC2 | ||
269 | char is_rc2 = 0; | ||
270 | #endif | ||
271 | /* EVP_PKEY *pkey; */ | ||
272 | #if 0 | ||
273 | X509_STORE_CTX s_ctx; | ||
274 | #endif | ||
275 | 268 | ||
276 | i=OBJ_obj2nid(p7->type); | 269 | i=OBJ_obj2nid(p7->type); |
277 | p7->state=PKCS7_S_HEADER; | 270 | p7->state=PKCS7_S_HEADER; |
@@ -312,16 +305,6 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert) | |||
312 | goto err; | 305 | goto err; |
313 | } | 306 | } |
314 | 307 | ||
315 | if(EVP_CIPHER_nid(evp_cipher) == NID_rc2_cbc) | ||
316 | { | ||
317 | #ifndef NO_RC2 | ||
318 | is_rc2 = 1; | ||
319 | #else | ||
320 | PKCS7err(PKCS7_F_PKCS7_DATADECODE,PKCS7_R_UNSUPPORTED_CIPHER_TYPE); | ||
321 | goto err; | ||
322 | #endif | ||
323 | } | ||
324 | |||
325 | /* We will be checking the signature */ | 308 | /* We will be checking the signature */ |
326 | if (md_sk != NULL) | 309 | if (md_sk != NULL) |
327 | { | 310 | { |
@@ -391,7 +374,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert) | |||
391 | } | 374 | } |
392 | 375 | ||
393 | jj=EVP_PKEY_size(pkey); | 376 | jj=EVP_PKEY_size(pkey); |
394 | tmp=(unsigned char *)Malloc(jj+10); | 377 | tmp=(unsigned char *)OPENSSL_malloc(jj+10); |
395 | if (tmp == NULL) | 378 | if (tmp == NULL) |
396 | { | 379 | { |
397 | PKCS7err(PKCS7_F_PKCS7_DATADECODE,ERR_R_MALLOC_FAILURE); | 380 | PKCS7err(PKCS7_F_PKCS7_DATADECODE,ERR_R_MALLOC_FAILURE); |
@@ -413,24 +396,18 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert) | |||
413 | return(NULL); | 396 | return(NULL); |
414 | 397 | ||
415 | if (jj != EVP_CIPHER_CTX_key_length(evp_ctx)) { | 398 | if (jj != EVP_CIPHER_CTX_key_length(evp_ctx)) { |
416 | /* HACK: some S/MIME clients don't use the same key | 399 | /* Some S/MIME clients don't use the same key |
417 | * and effective key length. The key length is | 400 | * and effective key length. The key length is |
418 | * determined by the size of the decrypted RSA key. | 401 | * determined by the size of the decrypted RSA key. |
419 | * So we hack things to manually set the RC2 key | ||
420 | * because we currently can't do this with the EVP | ||
421 | * interface. | ||
422 | */ | 402 | */ |
423 | #ifndef NO_RC2 | 403 | if(!EVP_CIPHER_CTX_set_key_length(evp_ctx, jj)) |
424 | if(is_rc2) RC2_set_key(&(evp_ctx->c.rc2_ks),jj, tmp, | ||
425 | EVP_CIPHER_CTX_key_length(evp_ctx)*8); | ||
426 | else | ||
427 | #endif | ||
428 | { | 404 | { |
429 | PKCS7err(PKCS7_F_PKCS7_DATADECODE, | 405 | PKCS7err(PKCS7_F_PKCS7_DATADECODE, |
430 | PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH); | 406 | PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH); |
431 | goto err; | 407 | goto err; |
432 | } | 408 | } |
433 | } else EVP_CipherInit(evp_ctx,NULL,tmp,NULL,0); | 409 | } |
410 | EVP_CipherInit(evp_ctx,NULL,tmp,NULL,0); | ||
434 | 411 | ||
435 | memset(tmp,0,jj); | 412 | memset(tmp,0,jj); |
436 | 413 | ||
@@ -479,7 +456,7 @@ err: | |||
479 | out=NULL; | 456 | out=NULL; |
480 | } | 457 | } |
481 | if (tmp != NULL) | 458 | if (tmp != NULL) |
482 | Free(tmp); | 459 | OPENSSL_free(tmp); |
483 | return(out); | 460 | return(out); |
484 | } | 461 | } |
485 | 462 | ||
@@ -557,7 +534,7 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio) | |||
557 | if (EVP_MD_CTX_type(mdc) == j) | 534 | if (EVP_MD_CTX_type(mdc) == j) |
558 | break; | 535 | break; |
559 | else | 536 | else |
560 | btmp=btmp->next_bio; | 537 | btmp=BIO_next(btmp); |
561 | } | 538 | } |
562 | 539 | ||
563 | /* We now have the EVP_MD_CTX, lets do the | 540 | /* We now have the EVP_MD_CTX, lets do the |
@@ -601,13 +578,13 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio) | |||
601 | x=i2d_ASN1_SET_OF_X509_ATTRIBUTE(sk,NULL, | 578 | x=i2d_ASN1_SET_OF_X509_ATTRIBUTE(sk,NULL, |
602 | i2d_X509_ATTRIBUTE, | 579 | i2d_X509_ATTRIBUTE, |
603 | V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET); | 580 | V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET); |
604 | pp=(unsigned char *)Malloc(x); | 581 | pp=(unsigned char *)OPENSSL_malloc(x); |
605 | p=pp; | 582 | p=pp; |
606 | i2d_ASN1_SET_OF_X509_ATTRIBUTE(sk,&p, | 583 | i2d_ASN1_SET_OF_X509_ATTRIBUTE(sk,&p, |
607 | i2d_X509_ATTRIBUTE, | 584 | i2d_X509_ATTRIBUTE, |
608 | V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET); | 585 | V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET); |
609 | EVP_SignUpdate(&ctx_tmp,pp,x); | 586 | EVP_SignUpdate(&ctx_tmp,pp,x); |
610 | Free(pp); | 587 | OPENSSL_free(pp); |
611 | pp=NULL; | 588 | pp=NULL; |
612 | } | 589 | } |
613 | 590 | ||
@@ -650,7 +627,7 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio) | |||
650 | (unsigned char *)buf_mem->data,buf_mem->length); | 627 | (unsigned char *)buf_mem->data,buf_mem->length); |
651 | #endif | 628 | #endif |
652 | } | 629 | } |
653 | if (pp != NULL) Free(pp); | 630 | if (pp != NULL) OPENSSL_free(pp); |
654 | pp=NULL; | 631 | pp=NULL; |
655 | 632 | ||
656 | ret=1; | 633 | ret=1; |
@@ -749,7 +726,7 @@ int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si, | |||
749 | } | 726 | } |
750 | if (EVP_MD_CTX_type(mdc) == md_type) | 727 | if (EVP_MD_CTX_type(mdc) == md_type) |
751 | break; | 728 | break; |
752 | btmp=btmp->next_bio; | 729 | btmp=BIO_next(btmp); |
753 | } | 730 | } |
754 | 731 | ||
755 | /* mdc is the digest ctx that we want, unless there are attributes, | 732 | /* mdc is the digest ctx that we want, unless there are attributes, |
@@ -795,13 +772,13 @@ for (ii=0; ii<md_len; ii++) printf("%02X",md_dat[ii]); printf(" calc\n"); | |||
795 | */ | 772 | */ |
796 | i=i2d_ASN1_SET_OF_X509_ATTRIBUTE(sk,NULL,i2d_X509_ATTRIBUTE, | 773 | i=i2d_ASN1_SET_OF_X509_ATTRIBUTE(sk,NULL,i2d_X509_ATTRIBUTE, |
797 | V_ASN1_SET,V_ASN1_UNIVERSAL, IS_SEQUENCE); | 774 | V_ASN1_SET,V_ASN1_UNIVERSAL, IS_SEQUENCE); |
798 | pp=Malloc(i); | 775 | pp=OPENSSL_malloc(i); |
799 | p=pp; | 776 | p=pp; |
800 | i2d_ASN1_SET_OF_X509_ATTRIBUTE(sk,&p,i2d_X509_ATTRIBUTE, | 777 | i2d_ASN1_SET_OF_X509_ATTRIBUTE(sk,&p,i2d_X509_ATTRIBUTE, |
801 | V_ASN1_SET,V_ASN1_UNIVERSAL, IS_SEQUENCE); | 778 | V_ASN1_SET,V_ASN1_UNIVERSAL, IS_SEQUENCE); |
802 | EVP_VerifyUpdate(&mdc_tmp,pp,i); | 779 | EVP_VerifyUpdate(&mdc_tmp,pp,i); |
803 | 780 | ||
804 | Free(pp); | 781 | OPENSSL_free(pp); |
805 | } | 782 | } |
806 | 783 | ||
807 | os=si->enc_digest; | 784 | os=si->enc_digest; |
@@ -932,7 +909,7 @@ static int add_attribute(STACK_OF(X509_ATTRIBUTE) **sk, int nid, int atrtype, | |||
932 | 909 | ||
933 | if (*sk == NULL) | 910 | if (*sk == NULL) |
934 | { | 911 | { |
935 | *sk = sk_X509_ATTRIBUTE_new(NULL); | 912 | *sk = sk_X509_ATTRIBUTE_new_null(); |
936 | new_attrib: | 913 | new_attrib: |
937 | attr=X509_ATTRIBUTE_create(nid,atrtype,value); | 914 | attr=X509_ATTRIBUTE_create(nid,atrtype,value); |
938 | sk_X509_ATTRIBUTE_push(*sk,attr); | 915 | sk_X509_ATTRIBUTE_push(*sk,attr); |
diff --git a/src/lib/libcrypto/pkcs7/pk7_mime.c b/src/lib/libcrypto/pkcs7/pk7_mime.c index 734643be28..994473c0bd 100644 --- a/src/lib/libcrypto/pkcs7/pk7_mime.c +++ b/src/lib/libcrypto/pkcs7/pk7_mime.c | |||
@@ -70,16 +70,21 @@ | |||
70 | */ | 70 | */ |
71 | 71 | ||
72 | typedef struct { | 72 | typedef struct { |
73 | char *name; /* Name of line e.g. "content-type" */ | ||
74 | char *value; /* Value of line e.g. "text/plain" */ | ||
75 | STACK /* MIME_PARAM */ *params; /* Zero or more parameters */ | ||
76 | } MIME_HEADER; | ||
77 | |||
78 | typedef struct { | ||
79 | char *param_name; /* Param name e.g. "micalg" */ | 73 | char *param_name; /* Param name e.g. "micalg" */ |
80 | char *param_value; /* Param value e.g. "sha1" */ | 74 | char *param_value; /* Param value e.g. "sha1" */ |
81 | } MIME_PARAM; | 75 | } MIME_PARAM; |
82 | 76 | ||
77 | DECLARE_STACK_OF(MIME_PARAM) | ||
78 | IMPLEMENT_STACK_OF(MIME_PARAM) | ||
79 | |||
80 | typedef struct { | ||
81 | char *name; /* Name of line e.g. "content-type" */ | ||
82 | char *value; /* Value of line e.g. "text/plain" */ | ||
83 | STACK_OF(MIME_PARAM) *params; /* Zero or more parameters */ | ||
84 | } MIME_HEADER; | ||
85 | |||
86 | DECLARE_STACK_OF(MIME_HEADER) | ||
87 | IMPLEMENT_STACK_OF(MIME_HEADER) | ||
83 | 88 | ||
84 | static int B64_write_PKCS7(BIO *bio, PKCS7 *p7); | 89 | static int B64_write_PKCS7(BIO *bio, PKCS7 *p7); |
85 | static PKCS7 *B64_read_PKCS7(BIO *bio); | 90 | static PKCS7 *B64_read_PKCS7(BIO *bio); |
@@ -88,14 +93,16 @@ static char * strip_start(char *name); | |||
88 | static char * strip_end(char *name); | 93 | static char * strip_end(char *name); |
89 | static MIME_HEADER *mime_hdr_new(char *name, char *value); | 94 | static MIME_HEADER *mime_hdr_new(char *name, char *value); |
90 | static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value); | 95 | static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value); |
91 | static STACK *mime_parse_hdr(BIO *bio); | 96 | static STACK_OF(MIME_HEADER) *mime_parse_hdr(BIO *bio); |
92 | static int mime_hdr_cmp(MIME_HEADER **a, MIME_HEADER **b); | 97 | static int mime_hdr_cmp(const MIME_HEADER * const *a, |
93 | static int mime_param_cmp(MIME_PARAM **a, MIME_PARAM **b); | 98 | const MIME_HEADER * const *b); |
99 | static int mime_param_cmp(const MIME_PARAM * const *a, | ||
100 | const MIME_PARAM * const *b); | ||
94 | static void mime_param_free(MIME_PARAM *param); | 101 | static void mime_param_free(MIME_PARAM *param); |
95 | static int mime_bound_check(char *line, int linelen, char *bound, int blen); | 102 | static int mime_bound_check(char *line, int linelen, char *bound, int blen); |
96 | static int multi_split(BIO *bio, char *bound, STACK **ret); | 103 | static int multi_split(BIO *bio, char *bound, STACK_OF(BIO) **ret); |
97 | static int iscrlf(char c); | 104 | static int iscrlf(char c); |
98 | static MIME_HEADER *mime_hdr_find(STACK *hdrs, char *name); | 105 | static MIME_HEADER *mime_hdr_find(STACK_OF(MIME_HEADER) *hdrs, char *name); |
99 | static MIME_PARAM *mime_param_find(MIME_HEADER *hdr, char *name); | 106 | static MIME_PARAM *mime_param_find(MIME_HEADER *hdr, char *name); |
100 | static void mime_hdr_free(MIME_HEADER *hdr); | 107 | static void mime_hdr_free(MIME_HEADER *hdr); |
101 | 108 | ||
@@ -163,7 +170,7 @@ int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags) | |||
163 | BIO_printf(bio, "micalg=sha1 ; boundary=\"----%s\"\n\n", bound); | 170 | BIO_printf(bio, "micalg=sha1 ; boundary=\"----%s\"\n\n", bound); |
164 | BIO_printf(bio, "This is an S/MIME signed message\n\n"); | 171 | BIO_printf(bio, "This is an S/MIME signed message\n\n"); |
165 | /* Now write out the first part */ | 172 | /* Now write out the first part */ |
166 | BIO_printf(bio, "------%s\r\n", bound); | 173 | BIO_printf(bio, "------%s\n", bound); |
167 | if(flags & PKCS7_TEXT) BIO_printf(bio, "Content-Type: text/plain\n\n"); | 174 | if(flags & PKCS7_TEXT) BIO_printf(bio, "Content-Type: text/plain\n\n"); |
168 | while((i = BIO_read(data, linebuf, MAX_SMLEN)) > 0) | 175 | while((i = BIO_read(data, linebuf, MAX_SMLEN)) > 0) |
169 | BIO_write(bio, linebuf, i); | 176 | BIO_write(bio, linebuf, i); |
@@ -196,8 +203,8 @@ int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags) | |||
196 | PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont) | 203 | PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont) |
197 | { | 204 | { |
198 | BIO *p7in; | 205 | BIO *p7in; |
199 | STACK *headers = NULL; | 206 | STACK_OF(MIME_HEADER) *headers = NULL; |
200 | STACK *parts = NULL; | 207 | STACK_OF(BIO) *parts = NULL; |
201 | MIME_HEADER *hdr; | 208 | MIME_HEADER *hdr; |
202 | MIME_PARAM *prm; | 209 | MIME_PARAM *prm; |
203 | PKCS7 *p7; | 210 | PKCS7 *p7; |
@@ -211,7 +218,7 @@ PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont) | |||
211 | } | 218 | } |
212 | 219 | ||
213 | if(!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) { | 220 | if(!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) { |
214 | sk_pop_free(headers, mime_hdr_free); | 221 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); |
215 | PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_NO_CONTENT_TYPE); | 222 | PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_NO_CONTENT_TYPE); |
216 | return NULL; | 223 | return NULL; |
217 | } | 224 | } |
@@ -222,24 +229,24 @@ PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont) | |||
222 | /* Split into two parts */ | 229 | /* Split into two parts */ |
223 | prm = mime_param_find(hdr, "boundary"); | 230 | prm = mime_param_find(hdr, "boundary"); |
224 | if(!prm || !prm->param_value) { | 231 | if(!prm || !prm->param_value) { |
225 | sk_pop_free(headers, mime_hdr_free); | 232 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); |
226 | PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_NO_MULTIPART_BOUNDARY); | 233 | PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_NO_MULTIPART_BOUNDARY); |
227 | return NULL; | 234 | return NULL; |
228 | } | 235 | } |
229 | ret = multi_split(bio, prm->param_value, &parts); | 236 | ret = multi_split(bio, prm->param_value, &parts); |
230 | sk_pop_free(headers, mime_hdr_free); | 237 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); |
231 | if(!ret || (sk_num(parts) != 2) ) { | 238 | if(!ret || (sk_BIO_num(parts) != 2) ) { |
232 | PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_NO_MULTIPART_BODY_FAILURE); | 239 | PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_NO_MULTIPART_BODY_FAILURE); |
233 | sk_pop_free(parts, (stkfree)BIO_free); | 240 | sk_BIO_pop_free(parts, BIO_vfree); |
234 | return NULL; | 241 | return NULL; |
235 | } | 242 | } |
236 | 243 | ||
237 | /* Parse the signature piece */ | 244 | /* Parse the signature piece */ |
238 | p7in = (BIO *)sk_value(parts, 1); | 245 | p7in = sk_BIO_value(parts, 1); |
239 | 246 | ||
240 | if (!(headers = mime_parse_hdr(p7in))) { | 247 | if (!(headers = mime_parse_hdr(p7in))) { |
241 | PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_MIME_SIG_PARSE_ERROR); | 248 | PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_MIME_SIG_PARSE_ERROR); |
242 | sk_pop_free(parts, (stkfree)BIO_free); | 249 | sk_BIO_pop_free(parts, BIO_vfree); |
243 | return NULL; | 250 | return NULL; |
244 | } | 251 | } |
245 | 252 | ||
@@ -247,32 +254,32 @@ PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont) | |||
247 | 254 | ||
248 | if(!(hdr = mime_hdr_find(headers, "content-type")) || | 255 | if(!(hdr = mime_hdr_find(headers, "content-type")) || |
249 | !hdr->value) { | 256 | !hdr->value) { |
250 | sk_pop_free(headers, mime_hdr_free); | 257 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); |
251 | PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_NO_SIG_CONTENT_TYPE); | 258 | PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_NO_SIG_CONTENT_TYPE); |
252 | return NULL; | 259 | return NULL; |
253 | } | 260 | } |
254 | 261 | ||
255 | if(strcmp(hdr->value, "application/x-pkcs7-signature") && | 262 | if(strcmp(hdr->value, "application/x-pkcs7-signature") && |
256 | strcmp(hdr->value, "application/pkcs7-signature")) { | 263 | strcmp(hdr->value, "application/pkcs7-signature")) { |
257 | sk_pop_free(headers, mime_hdr_free); | 264 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); |
258 | PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_SIG_INVALID_MIME_TYPE); | 265 | PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_SIG_INVALID_MIME_TYPE); |
259 | ERR_add_error_data(2, "type: ", hdr->value); | 266 | ERR_add_error_data(2, "type: ", hdr->value); |
260 | sk_pop_free(parts, (stkfree)BIO_free); | 267 | sk_BIO_pop_free(parts, BIO_vfree); |
261 | return NULL; | 268 | return NULL; |
262 | } | 269 | } |
263 | sk_pop_free(headers, mime_hdr_free); | 270 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); |
264 | /* Read in PKCS#7 */ | 271 | /* Read in PKCS#7 */ |
265 | if(!(p7 = B64_read_PKCS7(p7in))) { | 272 | if(!(p7 = B64_read_PKCS7(p7in))) { |
266 | PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_PKCS7_SIG_PARSE_ERROR); | 273 | PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_PKCS7_SIG_PARSE_ERROR); |
267 | sk_pop_free(parts, (stkfree)BIO_free); | 274 | sk_BIO_pop_free(parts, BIO_vfree); |
268 | return NULL; | 275 | return NULL; |
269 | } | 276 | } |
270 | 277 | ||
271 | if(bcont) { | 278 | if(bcont) { |
272 | *bcont = (BIO *)sk_value(parts, 0); | 279 | *bcont = sk_BIO_value(parts, 0); |
273 | BIO_free(p7in); | 280 | BIO_free(p7in); |
274 | sk_free(parts); | 281 | sk_BIO_free(parts); |
275 | } else sk_pop_free(parts, (stkfree)BIO_free); | 282 | } else sk_BIO_pop_free(parts, BIO_vfree); |
276 | return p7; | 283 | return p7; |
277 | } | 284 | } |
278 | 285 | ||
@@ -282,11 +289,11 @@ PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont) | |||
282 | strcmp (hdr->value, "application/pkcs7-mime")) { | 289 | strcmp (hdr->value, "application/pkcs7-mime")) { |
283 | PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_INVALID_MIME_TYPE); | 290 | PKCS7err(PKCS7_F_SMIME_READ_PKCS7,PKCS7_R_INVALID_MIME_TYPE); |
284 | ERR_add_error_data(2, "type: ", hdr->value); | 291 | ERR_add_error_data(2, "type: ", hdr->value); |
285 | sk_pop_free(headers, mime_hdr_free); | 292 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); |
286 | return NULL; | 293 | return NULL; |
287 | } | 294 | } |
288 | 295 | ||
289 | sk_pop_free(headers, mime_hdr_free); | 296 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); |
290 | 297 | ||
291 | if(!(p7 = B64_read_PKCS7(bio))) { | 298 | if(!(p7 = B64_read_PKCS7(bio))) { |
292 | PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_PKCS7_PARSE_ERROR); | 299 | PKCS7err(PKCS7_F_SMIME_READ_PKCS7, PKCS7_R_PKCS7_PARSE_ERROR); |
@@ -325,24 +332,25 @@ int SMIME_text(BIO *in, BIO *out) | |||
325 | { | 332 | { |
326 | char iobuf[4096]; | 333 | char iobuf[4096]; |
327 | int len; | 334 | int len; |
328 | STACK *headers; | 335 | STACK_OF(MIME_HEADER) *headers; |
329 | MIME_HEADER *hdr; | 336 | MIME_HEADER *hdr; |
337 | |||
330 | if (!(headers = mime_parse_hdr(in))) { | 338 | if (!(headers = mime_parse_hdr(in))) { |
331 | PKCS7err(PKCS7_F_SMIME_TEXT,PKCS7_R_MIME_PARSE_ERROR); | 339 | PKCS7err(PKCS7_F_SMIME_TEXT,PKCS7_R_MIME_PARSE_ERROR); |
332 | return 0; | 340 | return 0; |
333 | } | 341 | } |
334 | if(!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) { | 342 | if(!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) { |
335 | PKCS7err(PKCS7_F_SMIME_TEXT,PKCS7_R_MIME_NO_CONTENT_TYPE); | 343 | PKCS7err(PKCS7_F_SMIME_TEXT,PKCS7_R_MIME_NO_CONTENT_TYPE); |
336 | sk_pop_free(headers, mime_hdr_free); | 344 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); |
337 | return 0; | 345 | return 0; |
338 | } | 346 | } |
339 | if (strcmp (hdr->value, "text/plain")) { | 347 | if (strcmp (hdr->value, "text/plain")) { |
340 | PKCS7err(PKCS7_F_SMIME_TEXT,PKCS7_R_INVALID_MIME_TYPE); | 348 | PKCS7err(PKCS7_F_SMIME_TEXT,PKCS7_R_INVALID_MIME_TYPE); |
341 | ERR_add_error_data(2, "type: ", hdr->value); | 349 | ERR_add_error_data(2, "type: ", hdr->value); |
342 | sk_pop_free(headers, mime_hdr_free); | 350 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); |
343 | return 0; | 351 | return 0; |
344 | } | 352 | } |
345 | sk_pop_free(headers, mime_hdr_free); | 353 | sk_MIME_HEADER_pop_free(headers, mime_hdr_free); |
346 | while ((len = BIO_read(in, iobuf, sizeof(iobuf))) > 0) | 354 | while ((len = BIO_read(in, iobuf, sizeof(iobuf))) > 0) |
347 | BIO_write(out, iobuf, len); | 355 | BIO_write(out, iobuf, len); |
348 | return 1; | 356 | return 1; |
@@ -352,18 +360,19 @@ int SMIME_text(BIO *in, BIO *out) | |||
352 | * canonical parts in a STACK of bios | 360 | * canonical parts in a STACK of bios |
353 | */ | 361 | */ |
354 | 362 | ||
355 | static int multi_split(BIO *bio, char *bound, STACK **ret) | 363 | static int multi_split(BIO *bio, char *bound, STACK_OF(BIO) **ret) |
356 | { | 364 | { |
357 | char linebuf[MAX_SMLEN]; | 365 | char linebuf[MAX_SMLEN]; |
358 | int len, blen; | 366 | int len, blen; |
359 | BIO *bpart = NULL; | 367 | BIO *bpart = NULL; |
360 | STACK *parts; | 368 | STACK_OF(BIO) *parts; |
361 | char state, part, first; | 369 | char state, part, first; |
370 | |||
362 | blen = strlen(bound); | 371 | blen = strlen(bound); |
363 | part = 0; | 372 | part = 0; |
364 | state = 0; | 373 | state = 0; |
365 | first = 1; | 374 | first = 1; |
366 | parts = sk_new(NULL); | 375 | parts = sk_BIO_new_null(); |
367 | *ret = parts; | 376 | *ret = parts; |
368 | while ((len = BIO_gets(bio, linebuf, MAX_SMLEN)) > 0) { | 377 | while ((len = BIO_gets(bio, linebuf, MAX_SMLEN)) > 0) { |
369 | state = mime_bound_check(linebuf, len, bound, blen); | 378 | state = mime_bound_check(linebuf, len, bound, blen); |
@@ -371,12 +380,12 @@ static int multi_split(BIO *bio, char *bound, STACK **ret) | |||
371 | first = 1; | 380 | first = 1; |
372 | part++; | 381 | part++; |
373 | } else if(state == 2) { | 382 | } else if(state == 2) { |
374 | sk_push(parts, (char *)bpart); | 383 | sk_BIO_push(parts, bpart); |
375 | return 1; | 384 | return 1; |
376 | } else if(part) { | 385 | } else if(part) { |
377 | if(first) { | 386 | if(first) { |
378 | first = 0; | 387 | first = 0; |
379 | if(bpart) sk_push(parts, (char *)bpart); | 388 | if(bpart) sk_BIO_push(parts, bpart); |
380 | bpart = BIO_new(BIO_s_mem()); | 389 | bpart = BIO_new(BIO_s_mem()); |
381 | 390 | ||
382 | } else BIO_write(bpart, "\r\n", 2); | 391 | } else BIO_write(bpart, "\r\n", 2); |
@@ -405,15 +414,16 @@ static int iscrlf(char c) | |||
405 | #define MIME_COMMENT 6 | 414 | #define MIME_COMMENT 6 |
406 | 415 | ||
407 | 416 | ||
408 | static STACK *mime_parse_hdr(BIO *bio) | 417 | static STACK_OF(MIME_HEADER) *mime_parse_hdr(BIO *bio) |
409 | { | 418 | { |
410 | char *p, *q, c; | 419 | char *p, *q, c; |
411 | char *ntmp; | 420 | char *ntmp; |
412 | char linebuf[MAX_SMLEN]; | 421 | char linebuf[MAX_SMLEN]; |
413 | MIME_HEADER *mhdr = NULL; | 422 | MIME_HEADER *mhdr = NULL; |
414 | STACK *headers; | 423 | STACK_OF(MIME_HEADER) *headers; |
415 | int len, state, save_state = 0; | 424 | int len, state, save_state = 0; |
416 | headers = sk_new(mime_hdr_cmp); | 425 | |
426 | headers = sk_MIME_HEADER_new(mime_hdr_cmp); | ||
417 | while ((len = BIO_gets(bio, linebuf, MAX_SMLEN)) > 0) { | 427 | while ((len = BIO_gets(bio, linebuf, MAX_SMLEN)) > 0) { |
418 | /* If whitespace at line start then continuation line */ | 428 | /* If whitespace at line start then continuation line */ |
419 | if(mhdr && isspace((unsigned char)linebuf[0])) state = MIME_NAME; | 429 | if(mhdr && isspace((unsigned char)linebuf[0])) state = MIME_NAME; |
@@ -441,7 +451,7 @@ static STACK *mime_parse_hdr(BIO *bio) | |||
441 | mime_debug("Found End Value\n"); | 451 | mime_debug("Found End Value\n"); |
442 | *p = 0; | 452 | *p = 0; |
443 | mhdr = mime_hdr_new(ntmp, strip_ends(q)); | 453 | mhdr = mime_hdr_new(ntmp, strip_ends(q)); |
444 | sk_push(headers, (char *)mhdr); | 454 | sk_MIME_HEADER_push(headers, mhdr); |
445 | ntmp = NULL; | 455 | ntmp = NULL; |
446 | q = p + 1; | 456 | q = p + 1; |
447 | state = MIME_NAME; | 457 | state = MIME_NAME; |
@@ -493,7 +503,7 @@ static STACK *mime_parse_hdr(BIO *bio) | |||
493 | 503 | ||
494 | if(state == MIME_TYPE) { | 504 | if(state == MIME_TYPE) { |
495 | mhdr = mime_hdr_new(ntmp, strip_ends(q)); | 505 | mhdr = mime_hdr_new(ntmp, strip_ends(q)); |
496 | sk_push(headers, (char *)mhdr); | 506 | sk_MIME_HEADER_push(headers, mhdr); |
497 | } else if(state == MIME_VALUE) | 507 | } else if(state == MIME_VALUE) |
498 | mime_hdr_addparam(mhdr, ntmp, strip_ends(q)); | 508 | mime_hdr_addparam(mhdr, ntmp, strip_ends(q)); |
499 | if(p == linebuf) break; /* Blank line means end of headers */ | 509 | if(p == linebuf) break; /* Blank line means end of headers */ |
@@ -569,11 +579,11 @@ static MIME_HEADER *mime_hdr_new(char *name, char *value) | |||
569 | } | 579 | } |
570 | } | 580 | } |
571 | } else tmpval = NULL; | 581 | } else tmpval = NULL; |
572 | mhdr = (MIME_HEADER *) Malloc(sizeof(MIME_HEADER)); | 582 | mhdr = (MIME_HEADER *) OPENSSL_malloc(sizeof(MIME_HEADER)); |
573 | if(!mhdr) return NULL; | 583 | if(!mhdr) return NULL; |
574 | mhdr->name = tmpname; | 584 | mhdr->name = tmpname; |
575 | mhdr->value = tmpval; | 585 | mhdr->value = tmpval; |
576 | if(!(mhdr->params = sk_new(mime_param_cmp))) return NULL; | 586 | if(!(mhdr->params = sk_MIME_PARAM_new(mime_param_cmp))) return NULL; |
577 | return mhdr; | 587 | return mhdr; |
578 | } | 588 | } |
579 | 589 | ||
@@ -598,34 +608,36 @@ static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value) | |||
598 | if(!tmpval) return 0; | 608 | if(!tmpval) return 0; |
599 | } else tmpval = NULL; | 609 | } else tmpval = NULL; |
600 | /* Parameter values are case sensitive so leave as is */ | 610 | /* Parameter values are case sensitive so leave as is */ |
601 | mparam = (MIME_PARAM *) Malloc(sizeof(MIME_PARAM)); | 611 | mparam = (MIME_PARAM *) OPENSSL_malloc(sizeof(MIME_PARAM)); |
602 | if(!mparam) return 0; | 612 | if(!mparam) return 0; |
603 | mparam->param_name = tmpname; | 613 | mparam->param_name = tmpname; |
604 | mparam->param_value = tmpval; | 614 | mparam->param_value = tmpval; |
605 | sk_push(mhdr->params, (char *)mparam); | 615 | sk_MIME_PARAM_push(mhdr->params, mparam); |
606 | return 1; | 616 | return 1; |
607 | } | 617 | } |
608 | 618 | ||
609 | static int mime_hdr_cmp(MIME_HEADER **a, MIME_HEADER **b) | 619 | static int mime_hdr_cmp(const MIME_HEADER * const *a, |
620 | const MIME_HEADER * const *b) | ||
610 | { | 621 | { |
611 | return(strcmp((*a)->name, (*b)->name)); | 622 | return(strcmp((*a)->name, (*b)->name)); |
612 | } | 623 | } |
613 | 624 | ||
614 | static int mime_param_cmp(MIME_PARAM **a, MIME_PARAM **b) | 625 | static int mime_param_cmp(const MIME_PARAM * const *a, |
626 | const MIME_PARAM * const *b) | ||
615 | { | 627 | { |
616 | return(strcmp((*a)->param_name, (*b)->param_name)); | 628 | return(strcmp((*a)->param_name, (*b)->param_name)); |
617 | } | 629 | } |
618 | 630 | ||
619 | /* Find a header with a given name (if possible) */ | 631 | /* Find a header with a given name (if possible) */ |
620 | 632 | ||
621 | static MIME_HEADER *mime_hdr_find(STACK *hdrs, char *name) | 633 | static MIME_HEADER *mime_hdr_find(STACK_OF(MIME_HEADER) *hdrs, char *name) |
622 | { | 634 | { |
623 | MIME_HEADER htmp; | 635 | MIME_HEADER htmp; |
624 | int idx; | 636 | int idx; |
625 | htmp.name = name; | 637 | htmp.name = name; |
626 | idx = sk_find(hdrs, (char *)&htmp); | 638 | idx = sk_MIME_HEADER_find(hdrs, &htmp); |
627 | if(idx < 0) return NULL; | 639 | if(idx < 0) return NULL; |
628 | return (MIME_HEADER *)sk_value(hdrs, idx); | 640 | return sk_MIME_HEADER_value(hdrs, idx); |
629 | } | 641 | } |
630 | 642 | ||
631 | static MIME_PARAM *mime_param_find(MIME_HEADER *hdr, char *name) | 643 | static MIME_PARAM *mime_param_find(MIME_HEADER *hdr, char *name) |
@@ -633,24 +645,24 @@ static MIME_PARAM *mime_param_find(MIME_HEADER *hdr, char *name) | |||
633 | MIME_PARAM param; | 645 | MIME_PARAM param; |
634 | int idx; | 646 | int idx; |
635 | param.param_name = name; | 647 | param.param_name = name; |
636 | idx = sk_find(hdr->params, (char *)¶m); | 648 | idx = sk_MIME_PARAM_find(hdr->params, ¶m); |
637 | if(idx < 0) return NULL; | 649 | if(idx < 0) return NULL; |
638 | return (MIME_PARAM *)sk_value(hdr->params, idx); | 650 | return sk_MIME_PARAM_value(hdr->params, idx); |
639 | } | 651 | } |
640 | 652 | ||
641 | static void mime_hdr_free(MIME_HEADER *hdr) | 653 | static void mime_hdr_free(MIME_HEADER *hdr) |
642 | { | 654 | { |
643 | if(hdr->name) Free(hdr->name); | 655 | if(hdr->name) OPENSSL_free(hdr->name); |
644 | if(hdr->value) Free(hdr->value); | 656 | if(hdr->value) OPENSSL_free(hdr->value); |
645 | if(hdr->params) sk_pop_free(hdr->params, mime_param_free); | 657 | if(hdr->params) sk_MIME_PARAM_pop_free(hdr->params, mime_param_free); |
646 | Free(hdr); | 658 | OPENSSL_free(hdr); |
647 | } | 659 | } |
648 | 660 | ||
649 | static void mime_param_free(MIME_PARAM *param) | 661 | static void mime_param_free(MIME_PARAM *param) |
650 | { | 662 | { |
651 | if(param->param_name) Free(param->param_name); | 663 | if(param->param_name) OPENSSL_free(param->param_name); |
652 | if(param->param_value) Free(param->param_value); | 664 | if(param->param_value) OPENSSL_free(param->param_value); |
653 | Free(param); | 665 | OPENSSL_free(param); |
654 | } | 666 | } |
655 | 667 | ||
656 | /* Check for a multipart boundary. Returns: | 668 | /* Check for a multipart boundary. Returns: |
diff --git a/src/lib/libcrypto/pkcs7/pk7_smime.c b/src/lib/libcrypto/pkcs7/pk7_smime.c index b41f42ed04..d716f9faeb 100644 --- a/src/lib/libcrypto/pkcs7/pk7_smime.c +++ b/src/lib/libcrypto/pkcs7/pk7_smime.c | |||
@@ -64,12 +64,12 @@ | |||
64 | #include <openssl/x509v3.h> | 64 | #include <openssl/x509v3.h> |
65 | 65 | ||
66 | PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, | 66 | PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, |
67 | BIO *data, int flags) | 67 | BIO *data, int flags) |
68 | { | 68 | { |
69 | PKCS7 *p7; | 69 | PKCS7 *p7; |
70 | PKCS7_SIGNER_INFO *si; | 70 | PKCS7_SIGNER_INFO *si; |
71 | BIO *p7bio; | 71 | BIO *p7bio; |
72 | STACK *smcap; | 72 | STACK_OF(X509_ALGOR) *smcap; |
73 | int i; | 73 | int i; |
74 | 74 | ||
75 | if(!X509_check_private_key(signcert, pkey)) { | 75 | if(!X509_check_private_key(signcert, pkey)) { |
@@ -109,7 +109,9 @@ PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, | |||
109 | PKCS7_add_signed_attribute(si, NID_pkcs9_contentType, | 109 | PKCS7_add_signed_attribute(si, NID_pkcs9_contentType, |
110 | V_ASN1_OBJECT, OBJ_nid2obj(NID_pkcs7_data)); | 110 | V_ASN1_OBJECT, OBJ_nid2obj(NID_pkcs7_data)); |
111 | /* Add SMIMECapabilities */ | 111 | /* Add SMIMECapabilities */ |
112 | if(!(smcap = sk_new(NULL))) { | 112 | if(!(flags & PKCS7_NOSMIMECAP)) |
113 | { | ||
114 | if(!(smcap = sk_X509_ALGOR_new_null())) { | ||
113 | PKCS7err(PKCS7_F_PKCS7_SIGN,ERR_R_MALLOC_FAILURE); | 115 | PKCS7err(PKCS7_F_PKCS7_SIGN,ERR_R_MALLOC_FAILURE); |
114 | return NULL; | 116 | return NULL; |
115 | } | 117 | } |
@@ -127,7 +129,8 @@ PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, | |||
127 | PKCS7_simple_smimecap (smcap, NID_rc2_cbc, 40); | 129 | PKCS7_simple_smimecap (smcap, NID_rc2_cbc, 40); |
128 | #endif | 130 | #endif |
129 | PKCS7_add_attrib_smimecap (si, smcap); | 131 | PKCS7_add_attrib_smimecap (si, smcap); |
130 | sk_pop_free(smcap, X509_ALGOR_free); | 132 | sk_X509_ALGOR_pop_free(smcap, X509_ALGOR_free); |
133 | } | ||
131 | } | 134 | } |
132 | 135 | ||
133 | if(flags & PKCS7_DETACHED)PKCS7_set_detached(p7, 1); | 136 | if(flags & PKCS7_DETACHED)PKCS7_set_detached(p7, 1); |
@@ -150,7 +153,7 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, | |||
150 | PKCS7_SIGNER_INFO *si; | 153 | PKCS7_SIGNER_INFO *si; |
151 | X509_STORE_CTX cert_ctx; | 154 | X509_STORE_CTX cert_ctx; |
152 | char buf[4096]; | 155 | char buf[4096]; |
153 | int i, j=0; | 156 | int i, j=0, k; |
154 | BIO *p7bio; | 157 | BIO *p7bio; |
155 | BIO *tmpout; | 158 | BIO *tmpout; |
156 | 159 | ||
@@ -169,12 +172,17 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, | |||
169 | PKCS7err(PKCS7_F_PKCS7_VERIFY,PKCS7_R_NO_CONTENT); | 172 | PKCS7err(PKCS7_F_PKCS7_VERIFY,PKCS7_R_NO_CONTENT); |
170 | return 0; | 173 | return 0; |
171 | } | 174 | } |
175 | #if 0 | ||
176 | /* NB: this test commented out because some versions of Netscape | ||
177 | * illegally include zero length content when signing data. | ||
178 | */ | ||
172 | 179 | ||
173 | /* Check for data and content: two sets of data */ | 180 | /* Check for data and content: two sets of data */ |
174 | if(!PKCS7_get_detached(p7) && indata) { | 181 | if(!PKCS7_get_detached(p7) && indata) { |
175 | PKCS7err(PKCS7_F_PKCS7_VERIFY,PKCS7_R_CONTENT_AND_DATA_PRESENT); | 182 | PKCS7err(PKCS7_F_PKCS7_VERIFY,PKCS7_R_CONTENT_AND_DATA_PRESENT); |
176 | return 0; | 183 | return 0; |
177 | } | 184 | } |
185 | #endif | ||
178 | 186 | ||
179 | sinfos = PKCS7_get_signer_info(p7); | 187 | sinfos = PKCS7_get_signer_info(p7); |
180 | 188 | ||
@@ -190,8 +198,8 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, | |||
190 | 198 | ||
191 | /* Now verify the certificates */ | 199 | /* Now verify the certificates */ |
192 | 200 | ||
193 | if (!(flags & PKCS7_NOVERIFY)) for (i = 0; i < sk_X509_num(signers); i++) { | 201 | if (!(flags & PKCS7_NOVERIFY)) for (k = 0; k < sk_X509_num(signers); k++) { |
194 | signer = sk_X509_value (signers, i); | 202 | signer = sk_X509_value (signers, k); |
195 | if (!(flags & PKCS7_NOCHAIN)) { | 203 | if (!(flags & PKCS7_NOCHAIN)) { |
196 | X509_STORE_CTX_init(&cert_ctx, store, signer, | 204 | X509_STORE_CTX_init(&cert_ctx, store, signer, |
197 | p7->d.sign->cert); | 205 | p7->d.sign->cert); |
@@ -282,7 +290,7 @@ STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags) | |||
282 | PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS,PKCS7_R_WRONG_CONTENT_TYPE); | 290 | PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS,PKCS7_R_WRONG_CONTENT_TYPE); |
283 | return NULL; | 291 | return NULL; |
284 | } | 292 | } |
285 | if(!(signers = sk_X509_new(NULL))) { | 293 | if(!(signers = sk_X509_new_null())) { |
286 | PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS,ERR_R_MALLOC_FAILURE); | 294 | PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS,ERR_R_MALLOC_FAILURE); |
287 | return NULL; | 295 | return NULL; |
288 | } | 296 | } |
diff --git a/src/lib/libcrypto/pkcs7/pkcs7.h b/src/lib/libcrypto/pkcs7/pkcs7.h index 3ec725d226..1b817e605d 100644 --- a/src/lib/libcrypto/pkcs7/pkcs7.h +++ b/src/lib/libcrypto/pkcs7/pkcs7.h | |||
@@ -59,15 +59,13 @@ | |||
59 | #ifndef HEADER_PKCS7_H | 59 | #ifndef HEADER_PKCS7_H |
60 | #define HEADER_PKCS7_H | 60 | #define HEADER_PKCS7_H |
61 | 61 | ||
62 | #ifdef __cplusplus | ||
63 | extern "C" { | ||
64 | #endif | ||
65 | |||
66 | #include <openssl/bio.h> | 62 | #include <openssl/bio.h> |
67 | #include <openssl/x509.h> | 63 | #include <openssl/x509.h> |
68 | 64 | ||
69 | #ifdef VMS | 65 | #include <openssl/symhacks.h> |
70 | #include <openssl/vms_idhacks.h> | 66 | |
67 | #ifdef __cplusplus | ||
68 | extern "C" { | ||
71 | #endif | 69 | #endif |
72 | 70 | ||
73 | #ifdef WIN32 | 71 | #ifdef WIN32 |
@@ -210,9 +208,16 @@ typedef struct pkcs7_st | |||
210 | 208 | ||
211 | /* NID_pkcs7_encrypted */ | 209 | /* NID_pkcs7_encrypted */ |
212 | PKCS7_ENCRYPT *encrypted; | 210 | PKCS7_ENCRYPT *encrypted; |
211 | |||
212 | /* Anything else */ | ||
213 | ASN1_TYPE *other; | ||
213 | } d; | 214 | } d; |
214 | } PKCS7; | 215 | } PKCS7; |
215 | 216 | ||
217 | DECLARE_STACK_OF(PKCS7) | ||
218 | DECLARE_ASN1_SET_OF(PKCS7) | ||
219 | DECLARE_PKCS12_STACK_OF(PKCS7) | ||
220 | |||
216 | #define PKCS7_OP_SET_DETACHED_SIGNATURE 1 | 221 | #define PKCS7_OP_SET_DETACHED_SIGNATURE 1 |
217 | #define PKCS7_OP_GET_DETACHED_SIGNATURE 2 | 222 | #define PKCS7_OP_GET_DETACHED_SIGNATURE 2 |
218 | 223 | ||
@@ -240,15 +245,16 @@ typedef struct pkcs7_st | |||
240 | 245 | ||
241 | /* S/MIME related flags */ | 246 | /* S/MIME related flags */ |
242 | 247 | ||
243 | #define PKCS7_TEXT 0x1 | 248 | #define PKCS7_TEXT 0x1 |
244 | #define PKCS7_NOCERTS 0x2 | 249 | #define PKCS7_NOCERTS 0x2 |
245 | #define PKCS7_NOSIGS 0x4 | 250 | #define PKCS7_NOSIGS 0x4 |
246 | #define PKCS7_NOCHAIN 0x8 | 251 | #define PKCS7_NOCHAIN 0x8 |
247 | #define PKCS7_NOINTERN 0x10 | 252 | #define PKCS7_NOINTERN 0x10 |
248 | #define PKCS7_NOVERIFY 0x20 | 253 | #define PKCS7_NOVERIFY 0x20 |
249 | #define PKCS7_DETACHED 0x40 | 254 | #define PKCS7_DETACHED 0x40 |
250 | #define PKCS7_BINARY 0x80 | 255 | #define PKCS7_BINARY 0x80 |
251 | #define PKCS7_NOATTR 0x100 | 256 | #define PKCS7_NOATTR 0x100 |
257 | #define PKCS7_NOSMIMECAP 0x200 | ||
252 | 258 | ||
253 | /* Flags: for compatibility with older code */ | 259 | /* Flags: for compatibility with older code */ |
254 | 260 | ||
@@ -402,9 +408,10 @@ PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, EVP_CIPHER *cipher, | |||
402 | int flags); | 408 | int flags); |
403 | int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags); | 409 | int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags); |
404 | 410 | ||
405 | int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, STACK *cap); | 411 | int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, |
406 | STACK *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si); | 412 | STACK_OF(X509_ALGOR) *cap); |
407 | int PKCS7_simple_smimecap(STACK *sk, int nid, int arg); | 413 | STACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si); |
414 | int PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg); | ||
408 | 415 | ||
409 | int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags); | 416 | int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags); |
410 | PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont); | 417 | PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont); |