-/* Simple S/MIME signing example */
+/* Simple S/MIME decryption example */
#include <openssl/pem.h>
#include <openssl/cms.h>
#include <openssl/err.h>
if (!rcert || !rkey)
goto err;
- /* Open content being signed */
+ /* Open S/MIME message to decrypt */
in = BIO_new_file("smencr.txt", "r");
if (!in)
goto err;
- /* Sign content */
+ /* Parse message */
cms = SMIME_read_CMS(in, NULL);
if (!cms)
goto err;
- out = BIO_new_file("encrout.txt", "w");
+ out = BIO_new_file("decout.txt", "w");
if (!out)
goto err;
/* Decrypt S/MIME message */
- if (!CMS_decrypt(cms, rkey, rcert, out, NULL, 0))
+ if (!CMS_decrypt(cms, rkey, rcert, NULL, out, 0))
goto err;
ret = 0;
if (ret)
{
- fprintf(stderr, "Error Signing Data\n");
+ fprintf(stderr, "Error Decrypting Data\n");
ERR_print_errors_fp(stderr);
}
return ret;
}
-
-
-
-