Debian Codegraph @

kernel-patches/4.15-rc3/kpp/v3-0005-crypto-DH-allow-params-and-key-to-be-set-independ.patch

raw
1 From bf5d3b2785ce88cc607591eca1f9a07312f7a3ea Mon Sep 17 00:00:00 2001
2 From: Stephan Mueller <[email protected]>
3 Date: Sun, 7 Jan 2018 12:54:26 +0100
4 Subject: [PATCH v3 5/8] crypto: DH - allow params and key to be set
5 independently
6
7 Parameters are handled independently from the secret key. Therefore,
8 this patch allows setting of the parameter independently from the secret
9 key. Before invoking the actual crypto operation, the code must now
10 check that the secret key and the parameters are all present.
11
12 Signed-off-by: Stephan Mueller <[email protected]>
13 ---
14 crypto/dh.c | 6 +++++-
15 1 file changed, 5 insertions(+), 1 deletion(-)
16
17 diff --git a/crypto/dh.c b/crypto/dh.c
18 index 5659fe7f446d..7d3485682edc 100644
19 --- a/crypto/dh.c
20 +++ b/crypto/dh.c
21 @@ -53,6 +53,10 @@ static int dh_check_params_length(unsigned int p_len)
22
23 static int dh_set_params(struct dh_ctx *ctx, struct dh *params)
24 {
25 + /* If DH parameters are not given, do not check them. */
26 + if (!params->p_size && !params->g_size)
27 + return 0;
28 +
29 if (dh_check_params_length(params->p_size << 3))
30 return -EINVAL;
31
32 @@ -104,7 +108,7 @@ static int dh_compute_value(struct kpp_request *req)
33 if (!val)
34 return -ENOMEM;
35
36 - if (unlikely(!ctx->xa)) {
37 + if (unlikely(!ctx->xa || !ctx->p || !ctx->g)) {
38 ret = -EINVAL;
39 goto err_free_val;
40 }
41 --
42 2.14.3
43