cms demos: print signingTime attributes
[openssl.git] / demos / cms / cms_dec.c
index 832b54d43cf2cfabd607d1894e0aa47fb3046616..f64a68ab42bc8100a1ef3ef9bdf1165dc7f19ba6 100644 (file)
@@ -1,3 +1,12 @@
+/*
+ * Copyright 2008-2023 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License").  You may not use
+ * this file except in compliance with the License.  You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
 /* Simple S/MIME decryption example */
 #include <openssl/pem.h>
 #include <openssl/cms.h>
@@ -9,7 +18,7 @@ int main(int argc, char **argv)
     X509 *rcert = NULL;
     EVP_PKEY *rkey = NULL;
     CMS_ContentInfo *cms = NULL;
-    int ret = 1;
+    int ret = EXIT_FAILURE;
 
     OpenSSL_add_all_algorithms();
     ERR_load_crypto_strings();
@@ -50,24 +59,21 @@ int main(int argc, char **argv)
     if (!CMS_decrypt(cms, rkey, rcert, NULL, out, 0))
         goto err;
 
-    ret = 0;
+    printf("Decryption Successful\n");
 
- err:
+    ret = EXIT_SUCCESS;
 
-    if (ret) {
+ err:
+    if (ret != EXIT_SUCCESS) {
         fprintf(stderr, "Error Decrypting Data\n");
         ERR_print_errors_fp(stderr);
     }
 
-    if (cms)
-        CMS_ContentInfo_free(cms);
+    CMS_ContentInfo_free(cms);
     X509_free(rcert);
     EVP_PKEY_free(rkey);
-
     BIO_free(in);
     BIO_free(out);
     BIO_free(tbio);
-
     return ret;
-
 }