dctx->generator = p1;
return 1;
+ case EVP_PKEY_CTRL_PEER_KEY:
+ /* Default behaviour is OK */
+ return 1;
+
default:
return -2;
}
}
+
static int pkey_dh_ctrl_str(EVP_PKEY_CTX *ctx,
const char *type, const char *value)
DH *dh = NULL;
if (ctx->pkey == NULL)
{
- DHerr(DH_F_PKEY_DH_KEYGEN, DSA_R_NO_PARAMETERS_SET);
+ DHerr(DH_F_PKEY_DH_KEYGEN, DH_R_NO_PARAMETERS_SET);
return 0;
}
dh = DH_new();
return DH_generate_key(pkey->pkey.dh);
}
+static int pkey_dh_derive(EVP_PKEY_CTX *ctx, unsigned char *key, int *keylen)
+ {
+ int ret;
+ if (!ctx->pkey || !ctx->peerkey)
+ {
+ DHerr(DH_F_PKEY_DH_DERIVE, DH_R_KEYS_NOT_SET);
+ return 0;
+ }
+ ret = DH_compute_key(key, ctx->peerkey->pkey.dh->pub_key,
+ ctx->pkey->pkey.dh);
+ if (ret < 0)
+ return ret;
+ *keylen = ret;
+ return 1;
+ }
+
const EVP_PKEY_METHOD dh_pkey_meth =
{
EVP_PKEY_DH,
- 0,
+ EVP_PKEY_FLAG_AUTOARGLEN,
pkey_dh_init,
pkey_dh_cleanup,
0,0,
+ 0,
+ pkey_dh_derive,
+
pkey_dh_ctrl,
pkey_dh_ctrl_str