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 { 42 fprintf(stderr, "Error Uncompressing Data\n"); 43 ERR_print_errors_fp(stderr); 44 } 45 46 if (cms) 47 CMS_ContentInfo_free(cms); 48 49 if (in) 50 BIO_free(in); 51 if (out) 52 BIO_free(out); 53 54 return ret; 55 56 } 57