2 * Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 /* Simple S/MIME compress example */
11 #include <openssl/pem.h>
12 #include <openssl/cms.h>
13 #include <openssl/err.h>
15 int main(int argc, char **argv)
17 BIO *in = NULL, *out = NULL;
18 CMS_ContentInfo *cms = NULL;
22 * On OpenSSL 1.0.0+ only:
23 * for streaming set CMS_STREAM
25 int flags = CMS_STREAM;
27 OpenSSL_add_all_algorithms();
28 ERR_load_crypto_strings();
30 /* Open content being compressed */
32 in = BIO_new_file("comp.txt", "r");
37 /* compress content */
38 cms = CMS_compress(in, NID_zlib_compression, flags);
43 out = BIO_new_file("smcomp.txt", "w");
47 /* Write out S/MIME message */
48 if (!SMIME_write_CMS(out, cms, in, flags))
56 fprintf(stderr, "Error Compressing Data\n");
57 ERR_print_errors_fp(stderr);
60 CMS_ContentInfo_free(cms);