diff options
Diffstat (limited to 'src/lib/libcrypto/pkcs7/pk7_mime.c')
-rw-r--r-- | src/lib/libcrypto/pkcs7/pk7_mime.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/lib/libcrypto/pkcs7/pk7_mime.c b/src/lib/libcrypto/pkcs7/pk7_mime.c index 5d2a97839d..927b88c3e7 100644 --- a/src/lib/libcrypto/pkcs7/pk7_mime.c +++ b/src/lib/libcrypto/pkcs7/pk7_mime.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * project 1999. | 3 | * project 1999. |
4 | */ | 4 | */ |
5 | /* ==================================================================== | 5 | /* ==================================================================== |
6 | * Copyright (c) 1999-2003 The OpenSSL Project. All rights reserved. | 6 | * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. |
7 | * | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions |
@@ -152,11 +152,12 @@ int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags) | |||
152 | { | 152 | { |
153 | char bound[33], c; | 153 | char bound[33], c; |
154 | int i; | 154 | int i; |
155 | char *mime_prefix, *mime_eol; | 155 | char *mime_prefix, *mime_eol, *msg_type=NULL; |
156 | if (flags & PKCS7_NOOLDMIMETYPE) | 156 | if (flags & PKCS7_NOOLDMIMETYPE) |
157 | mime_prefix = "application/pkcs7-"; | 157 | mime_prefix = "application/pkcs7-"; |
158 | else | 158 | else |
159 | mime_prefix = "application/x-pkcs7-"; | 159 | mime_prefix = "application/x-pkcs7-"; |
160 | |||
160 | if (flags & PKCS7_CRLFEOL) | 161 | if (flags & PKCS7_CRLFEOL) |
161 | mime_eol = "\r\n"; | 162 | mime_eol = "\r\n"; |
162 | else | 163 | else |
@@ -198,11 +199,30 @@ int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags) | |||
198 | mime_eol, mime_eol); | 199 | mime_eol, mime_eol); |
199 | return 1; | 200 | return 1; |
200 | } | 201 | } |
202 | |||
203 | /* Determine smime-type header */ | ||
204 | |||
205 | if (PKCS7_type_is_enveloped(p7)) | ||
206 | msg_type = "enveloped-data"; | ||
207 | else if (PKCS7_type_is_signed(p7)) | ||
208 | { | ||
209 | /* If we have any signers it is signed-data othewise | ||
210 | * certs-only. | ||
211 | */ | ||
212 | STACK_OF(PKCS7_SIGNER_INFO) *sinfos; | ||
213 | sinfos = PKCS7_get_signer_info(p7); | ||
214 | if (sk_PKCS7_SIGNER_INFO_num(sinfos) > 0) | ||
215 | msg_type = "signed-data"; | ||
216 | else | ||
217 | msg_type = "certs-only"; | ||
218 | } | ||
201 | /* MIME headers */ | 219 | /* MIME headers */ |
202 | BIO_printf(bio, "MIME-Version: 1.0%s", mime_eol); | 220 | BIO_printf(bio, "MIME-Version: 1.0%s", mime_eol); |
203 | BIO_printf(bio, "Content-Disposition: attachment;"); | 221 | BIO_printf(bio, "Content-Disposition: attachment;"); |
204 | BIO_printf(bio, " filename=\"smime.p7m\"%s", mime_eol); | 222 | BIO_printf(bio, " filename=\"smime.p7m\"%s", mime_eol); |
205 | BIO_printf(bio, "Content-Type: %smime;", mime_prefix); | 223 | BIO_printf(bio, "Content-Type: %smime;", mime_prefix); |
224 | if (msg_type) | ||
225 | BIO_printf(bio, " smime-type=%s;", msg_type); | ||
206 | BIO_printf(bio, " name=\"smime.p7m\"%s", mime_eol); | 226 | BIO_printf(bio, " name=\"smime.p7m\"%s", mime_eol); |
207 | BIO_printf(bio, "Content-Transfer-Encoding: base64%s%s", | 227 | BIO_printf(bio, "Content-Transfer-Encoding: base64%s%s", |
208 | mime_eol, mime_eol); | 228 | mime_eol, mime_eol); |