1 /* Simple S/MIME compress example */
2 #include <openssl/pem.h>
3 #include <openssl/cms.h>
4 #include <openssl/err.h>
6 int main(int argc, char **argv)
8 BIO *in = NULL, *out = NULL;
9 CMS_ContentInfo *cms = NULL;
13 * On OpenSSL 0.9.9 only:
14 * for streaming set CMS_STREAM
16 int flags = CMS_STREAM;
18 OpenSSL_add_all_algorithms();
19 ERR_load_crypto_strings();
21 /* Open content being compressed */
23 in = BIO_new_file("comp.txt", "r");
28 /* compress content */
29 cms = CMS_compress(in, NID_zlib_compression, flags);
34 out = BIO_new_file("smcomp.txt", "w");
38 /* Write out S/MIME message */
39 if (!SMIME_write_CMS(out, cms, in, flags))
48 fprintf(stderr, "Error Compressing Data\n");
49 ERR_print_errors_fp(stderr);
53 CMS_ContentInfo_free(cms);