1/* Simple S/MIME uncompression example */
2#include <openssl/pem.h>
3#include <openssl/cms.h>
4#include <openssl/err.h>
5
6int main(int argc, char **argv)
7{
8    BIO *in = NULL, *out = NULL;
9    CMS_ContentInfo *cms = NULL;
10    int ret = 1;
11
12    OpenSSL_add_all_algorithms();
13    ERR_load_crypto_strings();
14
15    /* Open compressed content */
16
17    in = BIO_new_file("smcomp.txt", "r");
18
19    if (!in)
20        goto err;
21
22    /* Sign content */
23    cms = SMIME_read_CMS(in, NULL);
24
25    if (!cms)
26        goto err;
27
28    out = BIO_new_file("smuncomp.txt", "w");
29    if (!out)
30        goto err;
31
32    /* Uncompress S/MIME message */
33    if (!CMS_uncompress(cms, out, NULL, 0))
34        goto err;
35
36    ret = 0;
37
38 err:
39
40    if (ret) {
41        fprintf(stderr, "Error Uncompressing Data\n");
42        ERR_print_errors_fp(stderr);
43    }
44
45    if (cms)
46        CMS_ContentInfo_free(cms);
47
48    if (in)
49        BIO_free(in);
50    if (out)
51        BIO_free(out);
52
53    return ret;
54
55}
56