Rename OPENSSL_CTX prefix to OSSL_LIB_CTX
[openssl.git] / test / cmsapitest.c
index ad1cbd1c1475a40cc8b1a8690b0394d4854dd2ff..a69fcc949db05e7b04d0f893ffb55cf4c22f036e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
  *
- * Licensed under the OpenSSL license (the "License").  You may not use
+ * 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
@@ -19,7 +19,7 @@
 static X509 *cert = NULL;
 static EVP_PKEY *privkey = NULL;
 
-static int test_encrypt_decrypt(void)
+static int test_encrypt_decrypt(const EVP_CIPHER *cipher)
 {
     int testresult = 0;
     STACK_OF(X509) *certstack = sk_X509_new_null();
@@ -35,7 +35,7 @@ static int test_encrypt_decrypt(void)
     if (!TEST_int_gt(sk_X509_push(certstack, cert), 0))
         goto end;
 
-    content = CMS_encrypt(certstack, msgbio, EVP_aes_128_cbc(), CMS_TEXT);
+    content = CMS_encrypt(certstack, msgbio, cipher, CMS_TEXT);
     if (!TEST_ptr(content))
         goto end;
 
@@ -58,6 +58,26 @@ static int test_encrypt_decrypt(void)
     return testresult;
 }
 
+static int test_encrypt_decrypt_aes_cbc(void)
+{
+    return test_encrypt_decrypt(EVP_aes_128_cbc());
+}
+
+static int test_encrypt_decrypt_aes_128_gcm(void)
+{
+    return test_encrypt_decrypt(EVP_aes_128_gcm());
+}
+
+static int test_encrypt_decrypt_aes_192_gcm(void)
+{
+    return test_encrypt_decrypt(EVP_aes_192_gcm());
+}
+
+static int test_encrypt_decrypt_aes_256_gcm(void)
+{
+    return test_encrypt_decrypt(EVP_aes_256_gcm());
+}
+
 OPT_TEST_DECLARE_USAGE("certfile privkeyfile\n")
 
 int setup_tests(void)
@@ -97,7 +117,10 @@ int setup_tests(void)
     }
     BIO_free(privkeybio);
 
-    ADD_TEST(test_encrypt_decrypt);
+    ADD_TEST(test_encrypt_decrypt_aes_cbc);
+    ADD_TEST(test_encrypt_decrypt_aes_128_gcm);
+    ADD_TEST(test_encrypt_decrypt_aes_192_gcm);
+    ADD_TEST(test_encrypt_decrypt_aes_256_gcm);
 
     return 1;
 }