return 0;
}
-
static void dh_freectx(void *vpdhctx)
{
PROV_DH_CTX *pdhctx = (PROV_DH_CTX *)vpdhctx;
dstctx->kdf_ukm = NULL;
dstctx->kdf_cekalg = NULL;
- if (dstctx->dh != NULL && !DH_up_ref(srcctx->dh))
+ if (srcctx->dh != NULL && !DH_up_ref(srcctx->dh))
goto err;
else
dstctx->dh = srcctx->dh;
- if (dstctx->dhpeer != NULL && !DH_up_ref(srcctx->dhpeer))
+ if (srcctx->dhpeer != NULL && !DH_up_ref(srcctx->dhpeer))
goto err;
else
dstctx->dhpeer = srcctx->dhpeer;
static int pderive_test_run(EVP_TEST *t)
{
+ EVP_PKEY_CTX *dctx = NULL;
PKEY_DATA *expected = t->data;
unsigned char *got = NULL;
size_t got_len;
- if (EVP_PKEY_derive(expected->ctx, NULL, &got_len) <= 0) {
+ if (!TEST_ptr(dctx = EVP_PKEY_CTX_dup(expected->ctx))) {
+ t->err = "DERIVE_ERROR";
+ goto err;
+ }
+
+ if (EVP_PKEY_derive(dctx, NULL, &got_len) <= 0) {
t->err = "DERIVE_ERROR";
goto err;
}
t->err = "DERIVE_ERROR";
goto err;
}
- if (EVP_PKEY_derive(expected->ctx, got, &got_len) <= 0) {
+ if (EVP_PKEY_derive(dctx, got, &got_len) <= 0) {
t->err = "DERIVE_ERROR";
goto err;
}
t->err = NULL;
err:
OPENSSL_free(got);
+ EVP_PKEY_CTX_free(dctx);
return 1;
}