Debian Codegraph @

kernel-patches/4.15-rc3/kpp/v3-0002-icrypto-AF_ALG-add-DH-param-ECDH-curve-setsockopt.patch

raw
1 From 76e9ede9225dd75cc74b2e32306a17c4530cb200 Mon Sep 17 00:00:00 2001
2 From: Stephan Mueller <[email protected]>
3 Date: Sun, 7 Jan 2018 11:57:54 +0100
4 Subject: [PATCH v3 2/8] icrypto: AF_ALG -- add DH param / ECDH curve
5 setsockopt call
6
7 For supporting DH ciphers, user space must be able to set the
8 DH parameters. The patch adds a new setsockopt call for setting
9 these parameters.
10
11 Similarly, the ECDH curve information can be set by user space via the
12 newly added setsockopt call.
13
14 Signed-off-by: Stephan Mueller <[email protected]>
15 ---
16 crypto/af_alg.c | 12 ++++++++++++
17 include/crypto/if_alg.h | 2 ++
18 include/uapi/linux/if_alg.h | 2 ++
19 3 files changed, 16 insertions(+)
20
21 diff --git a/crypto/af_alg.c b/crypto/af_alg.c
22 index f2df3dc5210a..e3f7c5932f04 100644
23 --- a/crypto/af_alg.c
24 +++ b/crypto/af_alg.c
25 @@ -261,6 +261,18 @@ static int alg_setsockopt(struct socket *sock, int level, int optname,
26
27 err = alg_setkey(sk, optval, optlen, type->setpubkey);
28 break;
29 + case ALG_SET_DH_PARAMETERS:
30 + if (sock->state == SS_CONNECTED)
31 + goto unlock;
32 +
33 + err = alg_setkey(sk, optval, optlen, type->dhparams);
34 + break;
35 + case ALG_SET_ECDH_CURVE:
36 + if (sock->state == SS_CONNECTED)
37 + goto unlock;
38 +
39 + err = alg_setkey(sk, optval, optlen, type->ecdhcurve);
40 + break;
41 case ALG_SET_AEAD_AUTHSIZE:
42 if (sock->state == SS_CONNECTED)
43 goto unlock;
44 diff --git a/include/crypto/if_alg.h b/include/crypto/if_alg.h
45 index 79c5010a713b..641315e3051a 100644
46 --- a/include/crypto/if_alg.h
47 +++ b/include/crypto/if_alg.h
48 @@ -53,6 +53,8 @@ struct af_alg_type {
49 void (*release)(void *private);
50 int (*setkey)(void *private, const u8 *key, unsigned int keylen);
51 int (*setpubkey)(void *private, const u8 *key, unsigned int keylen);
52 + int (*dhparams)(void *private, const u8 *param, unsigned int paramlen);
53 + int (*ecdhcurve)(void *private, const u8 *param, unsigned int paramlen);
54 int (*accept)(void *private, struct sock *sk);
55 int (*accept_nokey)(void *private, struct sock *sk);
56 int (*setauthsize)(void *private, unsigned int authsize);
57 diff --git a/include/uapi/linux/if_alg.h b/include/uapi/linux/if_alg.h
58 index a53275c85612..e19a5addbb54 100644
59 --- a/include/uapi/linux/if_alg.h
60 +++ b/include/uapi/linux/if_alg.h
61 @@ -36,6 +36,8 @@ struct af_alg_iv {
62 #define ALG_SET_AEAD_ASSOCLEN 4
63 #define ALG_SET_AEAD_AUTHSIZE 5
64 #define ALG_SET_PUBKEY 6
65 +#define ALG_SET_DH_PARAMETERS 7
66 +#define ALG_SET_ECDH_CURVE 8
67
68 /* Operations */
69 #define ALG_OP_DECRYPT 0
70 --
71 2.14.3
72