summaryrefslogtreecommitdiff
path: root/crypto/dh.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/dh.c')
-rw-r--r--crypto/dh.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/crypto/dh.c b/crypto/dh.c
index 869a0476e5e2..d0d24f615b2d 100644
--- a/crypto/dh.c
+++ b/crypto/dh.c
@@ -444,17 +444,18 @@ static int dh_safe_prime_set_secret(struct crypto_kpp *tfm, const void *buffer,
struct dh_safe_prime_instance_ctx *inst_ctx =
dh_safe_prime_instance_ctx(tfm);
struct dh_safe_prime_tfm_ctx *tfm_ctx = kpp_tfm_ctx(tfm);
- struct dh params;
+ struct dh params = {};
void *buf = NULL, *key = NULL;
unsigned int buf_size;
int err;
- err = __crypto_dh_decode_key(buffer, len, &params);
- if (err)
- return err;
-
- if (params.p_size || params.g_size)
- return -EINVAL;
+ if (buffer) {
+ err = __crypto_dh_decode_key(buffer, len, &params);
+ if (err)
+ return err;
+ if (params.p_size || params.g_size)
+ return -EINVAL;
+ }
params.p = inst_ctx->safe_prime->p;
params.p_size = inst_ctx->safe_prime->p_size;