{
DH_PKEY_CTX *dctx;
- if ((dctx = OPENSSL_zalloc(sizeof(*dctx))) == NULL) {
- ERR_raise(ERR_LIB_DH, ERR_R_MALLOC_FAILURE);
+ if ((dctx = OPENSSL_zalloc(sizeof(*dctx))) == NULL)
return 0;
- }
dctx->prime_len = 2048;
dctx->subprime_len = -1;
dctx->generator = 2;
/* Note: if error return, pkey is freed by parent routine */
if (ctx->pkey != NULL && !EVP_PKEY_copy_parameters(pkey, ctx->pkey))
return 0;
- return DH_generate_key(pkey->pkey.dh);
+ return DH_generate_key((DH *)EVP_PKEY_get0_DH(pkey));
}
static int pkey_dh_derive(EVP_PKEY_CTX *ctx, unsigned char *key,
ERR_raise(ERR_LIB_DH, DH_R_KEYS_NOT_SET);
return 0;
}
- dh = ctx->pkey->pkey.dh;
+ dh = (DH *)EVP_PKEY_get0_DH(ctx->pkey);
dhpub = EVP_PKEY_get0_DH(ctx->peerkey);
if (dhpub == NULL) {
ERR_raise(ERR_LIB_DH, DH_R_KEYS_NOT_SET);
else if (dctx->kdf_type == EVP_PKEY_DH_KDF_X9_42) {
unsigned char *Z = NULL;
- size_t Zlen = 0;
+ int Zlen = 0;
+
if (!dctx->kdf_outlen || !dctx->kdf_oid)
return 0;
if (key == NULL) {
ret = 0;
if ((Zlen = DH_size(dh)) <= 0)
return 0;
- if ((Z = OPENSSL_malloc(Zlen)) == NULL) {
- ERR_raise(ERR_LIB_DH, ERR_R_MALLOC_FAILURE);
+ if ((Z = OPENSSL_malloc(Zlen)) == NULL)
return 0;
- }
if (DH_compute_key_padded(Z, dhpubbn, dh) <= 0)
goto err;
if (!DH_KDF_X9_42(key, *keylen, Z, Zlen, dctx->kdf_oid,