summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2021-03-02 15:52:00 +0000
committerMatt Caswell <matt@openssl.org>2021-03-08 15:13:09 +0000
commit7bc0fdd3fd4535e06c35b92d71afab9a6de94cc5 (patch)
tree2e57cd75e2b81a4ae2bc8d375096e094f8b5b0e5 /test
parentcc57dc962516410f6269023c8a93913617414b5e (diff)
Make the EVP_PKEY_get0* functions have a const return type
OTC have decided that the EVP_PKEY_get0* functions should have a const return type. This is a breaking change to emphasise that these values should be considered as immutable. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14319)
Diffstat (limited to 'test')
-rw-r--r--test/endecoder_legacy_test.c12
-rw-r--r--test/sslapitest.c14
2 files changed, 18 insertions, 8 deletions
diff --git a/test/endecoder_legacy_test.c b/test/endecoder_legacy_test.c
index cdf86530ce..c72d15bdaa 100644
--- a/test/endecoder_legacy_test.c
+++ b/test/endecoder_legacy_test.c
@@ -58,11 +58,11 @@
#include "testutil.h"
-typedef int PEM_write_bio_of_void_protected(BIO *out, void *obj,
+typedef int PEM_write_bio_of_void_protected(BIO *out, const void *obj,
const EVP_CIPHER *enc,
unsigned char *kstr, int klen,
pem_password_cb *cb, void *u);
-typedef int PEM_write_bio_of_void_unprotected(BIO *out, void *obj);
+typedef int PEM_write_bio_of_void_unprotected(BIO *out, const void *obj);
typedef void *PEM_read_bio_of_void(BIO *out, void **obj,
pem_password_cb *cb, void *u);
typedef int EVP_PKEY_print_fn(BIO *out, const EVP_PKEY *pkey,
@@ -294,7 +294,7 @@ static int test_membio_str_eq(BIO *bio_provided, BIO *bio_legacy)
}
static int test_protected_PEM(const char *keytype, int evp_type,
- void *legacy_key,
+ const void *legacy_key,
PEM_write_bio_of_void_protected *pem_write_bio,
PEM_read_bio_of_void *pem_read_bio,
EVP_PKEY_eq_fn *evp_pkey_eq,
@@ -362,7 +362,7 @@ static int test_protected_PEM(const char *keytype, int evp_type,
}
static int test_unprotected_PEM(const char *keytype, int evp_type,
- void *legacy_key,
+ const void *legacy_key,
PEM_write_bio_of_void_unprotected *pem_write_bio,
PEM_read_bio_of_void *pem_read_bio,
EVP_PKEY_eq_fn *evp_pkey_eq,
@@ -429,7 +429,7 @@ static int test_unprotected_PEM(const char *keytype, int evp_type,
}
static int test_DER(const char *keytype, int evp_type,
- void *legacy_key, i2d_of_void *i2d, d2i_of_void *d2i,
+ const void *legacy_key, i2d_of_void *i2d, d2i_of_void *d2i,
EVP_PKEY_eq_fn *evp_pkey_eq,
EVP_PKEY_print_fn *evp_pkey_print,
EVP_PKEY *provided_pkey, int selection,
@@ -506,7 +506,7 @@ static int test_key(int idx)
int ok = 0;
size_t i;
EVP_PKEY *pkey = NULL, *downgraded_pkey = NULL;
- void *legacy_obj = NULL;
+ const void *legacy_obj = NULL;
/* Get the test data */
if (!TEST_ptr(test_stanza = &test_stanzas[idx])
diff --git a/test/sslapitest.c b/test/sslapitest.c
index 06d8e80200..b469d80a17 100644
--- a/test/sslapitest.c
+++ b/test/sslapitest.c
@@ -8313,7 +8313,14 @@ static DH *tmp_dh_callback(SSL *s, int is_export, int keylen)
if (!TEST_ptr(dhpkey))
return NULL;
- ret = EVP_PKEY_get0_DH(dhpkey);
+ /*
+ * libssl does not free the returned DH, so we free it now knowing that even
+ * after we free dhpkey, there will still be a reference to the owning
+ * EVP_PKEY in tmp_dh_params, and so the DH object will live for the length
+ * of time we need it for.
+ */
+ ret = EVP_PKEY_get1_DH(dhpkey);
+ DH_free(ret);
EVP_PKEY_free(dhpkey);
@@ -8361,7 +8368,7 @@ static int test_set_tmp_dh(int idx)
}
# ifndef OPENSSL_NO_DEPRECATED_3_0
if (idx == 7 || idx == 8) {
- dh = EVP_PKEY_get0_DH(dhpkey);
+ dh = EVP_PKEY_get1_DH(dhpkey);
if (!TEST_ptr(dh))
goto end;
}
@@ -8431,6 +8438,9 @@ static int test_set_tmp_dh(int idx)
testresult = 1;
end:
+# ifndef OPENSSL_NO_DEPRECATED_3_0
+ DH_free(dh);
+# endif
SSL_free(serverssl);
SSL_free(clientssl);
SSL_CTX_free(sctx);