Path: blob/main/crypto/openssl/demos/cms/cms_uncomp.c
34879 views
/*1* Copyright 2008-2023 The OpenSSL Project Authors. All Rights Reserved.2*3* Licensed under the Apache License 2.0 (the "License"). You may not use4* this file except in compliance with the License. You can obtain a copy5* in the file LICENSE in the source distribution or at6* https://www.openssl.org/source/license.html7*/89/* Simple S/MIME uncompression example */10#include <openssl/pem.h>11#include <openssl/cms.h>12#include <openssl/err.h>1314int main(int argc, char **argv)15{16BIO *in = NULL, *out = NULL;17CMS_ContentInfo *cms = NULL;18int ret = EXIT_FAILURE;1920OpenSSL_add_all_algorithms();21ERR_load_crypto_strings();2223/* Open compressed content */2425in = BIO_new_file("smcomp.txt", "r");2627if (!in)28goto err;2930/* Sign content */31cms = SMIME_read_CMS(in, NULL);3233if (!cms)34goto err;3536out = BIO_new_file("smuncomp.txt", "w");37if (!out)38goto err;3940/* Uncompress S/MIME message */41if (!CMS_uncompress(cms, out, NULL, 0))42goto err;4344ret = EXIT_SUCCESS;45err:46if (ret != EXIT_SUCCESS) {47fprintf(stderr, "Error Uncompressing Data\n");48ERR_print_errors_fp(stderr);49}5051CMS_ContentInfo_free(cms);52BIO_free(in);53BIO_free(out);54return ret;55}565758