Sync usage with man page.
[netbsd-mini2440.git] / crypto / external / bsd / openssl / dist / demos / cms / cms_uncomp.c
blobf15ae2f1327432706b2d1fdea73ff0017d21be58
1 /* Simple S/MIME uncompression 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;
10 int ret = 1;
12 OpenSSL_add_all_algorithms();
13 ERR_load_crypto_strings();
15 /* Open compressed content */
17 in = BIO_new_file("smcomp.txt", "r");
19 if (!in)
20 goto err;
22 /* Sign content */
23 cms = SMIME_read_CMS(in, NULL);
25 if (!cms)
26 goto err;
28 out = BIO_new_file("smuncomp.txt", "w");
29 if (!out)
30 goto err;
32 /* Uncompress S/MIME message */
33 if (!CMS_uncompress(cms, out, NULL, 0))
34 goto err;
36 ret = 0;
38 err:
40 if (ret)
42 fprintf(stderr, "Error Uncompressing Data\n");
43 ERR_print_errors_fp(stderr);
46 if (cms)
47 CMS_ContentInfo_free(cms);
49 if (in)
50 BIO_free(in);
51 if (out)
52 BIO_free(out);
54 return ret;