summaryrefslogtreecommitdiffstats
path: root/test/cmsapitest.c
diff options
context:
space:
mode:
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>2022-07-14 17:11:22 +0200
committerDr. David von Oheimb <dev@ddvo.net>2022-07-16 08:15:49 +0200
commit98b183d3c65e56b0f21f4e77b2cd3d2aa62374f2 (patch)
treece9b1a079135dddc5e9d64f0ab6ecf080bc43ff9 /test/cmsapitest.c
parentd7d3dae694fa4611c1cd953dccf81b3d2b4121c6 (diff)
cmsapitest.c: add test case for CMS_EnvelopedData_decrypt()
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com> (Merged from https://github.com/openssl/openssl/pull/18667)
Diffstat (limited to 'test/cmsapitest.c')
-rw-r--r--test/cmsapitest.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/test/cmsapitest.c b/test/cmsapitest.c
index 460e4693c2..df54edb43d 100644
--- a/test/cmsapitest.c
+++ b/test/cmsapitest.c
@@ -13,7 +13,7 @@
#include <openssl/bio.h>
#include <openssl/x509.h>
#include <openssl/pem.h>
-#include "../crypto/cms/cms_local.h" /* for access to cms->d.signedData */
+#include "../crypto/cms/cms_local.h" /* for d.signedData and d.envelopedData */
#include "testutil.h"
@@ -29,6 +29,7 @@ static int test_encrypt_decrypt(const EVP_CIPHER *cipher)
BIO *msgbio = BIO_new_mem_buf(msg, strlen(msg));
BIO *outmsgbio = BIO_new(BIO_s_mem());
CMS_ContentInfo* content = NULL;
+ BIO *contentbio = NULL;
char buf[80];
if (!TEST_ptr(certstack) || !TEST_ptr(msgbio) || !TEST_ptr(outmsgbio))
@@ -45,6 +46,12 @@ static int test_encrypt_decrypt(const EVP_CIPHER *cipher)
CMS_TEXT)))
goto end;
+ if (!TEST_ptr(contentbio =
+ CMS_EnvelopedData_decrypt(content->d.envelopedData,
+ NULL, privkey, cert, NULL,
+ CMS_TEXT, NULL, NULL)))
+ goto end;
+
/* Check we got the message we first started with */
if (!TEST_int_eq(BIO_gets(outmsgbio, buf, sizeof(buf)), strlen(msg))
|| !TEST_int_eq(strcmp(buf, msg), 0))
@@ -52,6 +59,7 @@ static int test_encrypt_decrypt(const EVP_CIPHER *cipher)
testresult = 1;
end:
+ BIO_free(contentbio);
sk_X509_free(certstack);
BIO_free(msgbio);
BIO_free(outmsgbio);