+/*
+ * Copyright 2008-2016 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
+ */
+
/*
* S/MIME detached data encrypt example: rarely done but should the need
* arise this is an example....
X509 *rcert = NULL;
STACK_OF(X509) *recips = NULL;
CMS_ContentInfo *cms = NULL;
- int ret = 1;
+ int ret = EXIT_FAILURE;
int flags = CMS_STREAM | CMS_DETACHED;
goto err;
/*
- * sk_X509_pop_free will free up recipient STACK and its contents so set
- * rcert to NULL so it isn't freed up twice.
+ * OSSL_STACK_OF_X509_free() free up recipient STACK and its contents
+ * so set rcert to NULL so it isn't freed up twice.
*/
rcert = NULL;
if (!PEM_write_bio_CMS(out, cms))
goto err;
- ret = 0;
-
+ ret = EXIT_SUCCESS;
err:
-
- if (ret) {
+ if (ret != EXIT_SUCCESS) {
fprintf(stderr, "Error Encrypting Data\n");
ERR_print_errors_fp(stderr);
}
- if (cms)
- CMS_ContentInfo_free(cms);
- if (rcert)
- X509_free(rcert);
- if (recips)
- sk_X509_pop_free(recips, X509_free);
-
+ CMS_ContentInfo_free(cms);
+ X509_free(rcert);
+ OSSL_STACK_OF_X509_free(recips);
BIO_free(in);
BIO_free(out);
BIO_free(dout);
BIO_free(tbio);
-
return ret;
-
}