diff options
author | Nicola Tuveri <nic.tuv@gmail.com> | 2020-10-21 01:38:44 +0300 |
---|---|---|
committer | Nicola Tuveri <nic.tuv@gmail.com> | 2020-10-23 17:54:40 +0300 |
commit | d1fb6b481b1d70932a1435f83eae10cc68edbe36 (patch) | |
tree | 1253a9c0cc7cccf93126fc518844e254b8cd8ed5 /crypto/dh/dh_key.c | |
parent | 85209c07459b1c6007e0fc550f40c05deec78531 (diff) |
Constify OSSL_FUNC_keymgmt_validate()
The keydata argument of OSSL_FUNC_keymgmt_validate() should be read-only.
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/13201)
Diffstat (limited to 'crypto/dh/dh_key.c')
-rw-r--r-- | crypto/dh/dh_key.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/crypto/dh/dh_key.c b/crypto/dh/dh_key.c index 8d9c72d65c..90802633a6 100644 --- a/crypto/dh/dh_key.c +++ b/crypto/dh/dh_key.c @@ -182,7 +182,7 @@ int DH_generate_key(DH *dh) #endif } -int dh_generate_public_key(BN_CTX *ctx, DH *dh, const BIGNUM *priv_key, +int dh_generate_public_key(BN_CTX *ctx, const DH *dh, const BIGNUM *priv_key, BIGNUM *pub_key) { int ret = 0; @@ -193,8 +193,16 @@ int dh_generate_public_key(BN_CTX *ctx, DH *dh, const BIGNUM *priv_key, return 0; if (dh->flags & DH_FLAG_CACHE_MONT_P) { - mont = BN_MONT_CTX_set_locked(&dh->method_mont_p, - dh->lock, dh->params.p, ctx); + /* + * We take the input DH as const, but we lie, because in some cases we + * want to get a hold of its Montgomery context. + * + * We cast to remove the const qualifier in this case, it should be + * fine... + */ + BN_MONT_CTX **pmont = (BN_MONT_CTX **)&dh->method_mont_p; + + mont = BN_MONT_CTX_set_locked(pmont, dh->lock, dh->params.p, ctx); if (mont == NULL) goto err; } |