]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
TEST: Fix CMP tests so they load keys in the current library context
authorRichard Levitte <levitte@openssl.org>
Sun, 23 Aug 2020 08:06:06 +0000 (10:06 +0200)
committerRichard Levitte <levitte@openssl.org>
Mon, 24 Aug 2020 16:20:29 +0000 (18:20 +0200)
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/12705)

test/cmp_client_test.c
test/cmp_msg_test.c
test/cmp_protect_test.c
test/cmp_testlib.c
test/cmp_testlib.h

index 9fb3050ac00f3c63ed63721d267a5ec85b669bfe..111a4c27f4a072860e8abfd5f57c5d608e650e3a 100644 (file)
@@ -372,9 +372,9 @@ int setup_tests(void)
     if (!test_get_libctx(&libctx, &default_null_provider, &provider, 5, USAGE))
         return 0;
 
-    if (!TEST_ptr(server_key = load_pem_key(server_key_f))
+    if (!TEST_ptr(server_key = load_pem_key(server_key_f, libctx))
             || !TEST_ptr(server_cert = load_pem_cert(server_cert_f, libctx))
-            || !TEST_ptr(client_key = load_pem_key(client_key_f))
+            || !TEST_ptr(client_key = load_pem_key(client_key_f, libctx))
             || !TEST_ptr(client_cert = load_pem_cert(client_cert_f, libctx))
             || !TEST_int_eq(1, RAND_bytes_ex(libctx, ref, sizeof(ref)))) {
         cleanup_tests();
index b9309a69836c274eb1958b202de9c2b181dde522..a56f04f1df74d8e4024203cb36d2cefe8af95cb1 100644 (file)
@@ -575,7 +575,7 @@ int setup_tests(void)
     if (!test_get_libctx(&libctx, &default_null_provider, &provider, 3, USAGE))
         return 0;
 
-    if (!TEST_ptr(newkey = load_pem_key(newkey_f))
+    if (!TEST_ptr(newkey = load_pem_key(newkey_f, libctx))
             || !TEST_ptr(cert = load_pem_cert(server_cert_f, libctx))
             || !TEST_int_eq(1, RAND_bytes_ex(libctx, ref, sizeof(ref)))) {
         cleanup_tests();
index 6413c20a23c9ab49aaad3f9737be390d94002cc0..66cc6af370d5fe4fc2d3864a3fa151e4ed29c39c 100644 (file)
@@ -521,11 +521,11 @@ int setup_tests(void)
     if (!test_get_libctx(&libctx, &default_null_provider, &provider, 10, USAGE))
         return 0;
 
-    if (!TEST_ptr(loadedkey = load_pem_key(server_key_f))
+    if (!TEST_ptr(loadedkey = load_pem_key(server_key_f, libctx))
             || !TEST_ptr(cert = load_pem_cert(server_cert_f, libctx)))
         return 0;
 
-    if (!TEST_ptr(loadedprivkey = load_pem_key(server_f)))
+    if (!TEST_ptr(loadedprivkey = load_pem_key(server_f, libctx)))
         return 0;
     if (TEST_true(EVP_PKEY_up_ref(loadedprivkey)))
         loadedpubkey = loadedprivkey;
index ffa43cd81cbb9682e8753a380b0877309a324067..754a6ba84509e5be2e61c00d197d97869f7c417d 100644 (file)
@@ -14,7 +14,7 @@
 
 DEFINE_STACK_OF(X509)
 
-EVP_PKEY *load_pem_key(const char *file)
+EVP_PKEY *load_pem_key(const char *file, OPENSSL_CTX *libctx)
 {
     EVP_PKEY *key = NULL;
     BIO *bio = NULL;
@@ -22,7 +22,8 @@ EVP_PKEY *load_pem_key(const char *file)
     if (!TEST_ptr(bio = BIO_new(BIO_s_file())))
         return NULL;
     if (TEST_int_gt(BIO_read_filename(bio, file), 0))
-        (void)TEST_ptr(key = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL));
+        (void)TEST_ptr(key = PEM_read_bio_PrivateKey_ex(bio, NULL, NULL, NULL,
+                                                        libctx, NULL));
 
     BIO_free(bio);
     return key;
index e24074cdd77270afb1eb59d4f18d5380ebc9fab6..e8ae7a18341e824ce4f5264859bc8f75386b5f66 100644 (file)
@@ -23,7 +23,7 @@
 
 # ifndef OPENSSL_NO_CMP
 #  define CMP_TEST_REFVALUE_LENGTH 15 /* arbitrary value */
-EVP_PKEY *load_pem_key(const char *file);
+EVP_PKEY *load_pem_key(const char *file, OPENSSL_CTX *libctx);
 X509 *load_pem_cert(const char *file, OPENSSL_CTX *libctx);
 X509_REQ *load_csr(const char *file);
 OSSL_CMP_MSG *load_pkimsg(const char *file);