diff options
author | Stephan Mueller <smueller@chronox.de> | 2016-05-26 17:38:12 -0400 |
---|---|---|
committer | James Morris <james.l.morris@oracle.com> | 2016-06-03 02:14:34 -0400 |
commit | 4693fc734d675c5518ea9bd4c9623db45bc37402 (patch) | |
tree | 54dcf2388f5868c5d5a8ab4faf3b64a8e2fa4f79 /security | |
parent | 4340fa55298d17049e71c7a34e04647379c269f3 (diff) |
KEYS: Add placeholder for KDF usage with DH
The values computed during Diffie-Hellman key exchange are often used
in combination with key derivation functions to create cryptographic
keys. Add a placeholder for a later implementation to configure a
key derivation function that will transform the Diffie-Hellman
result returned by the KEYCTL_DH_COMPUTE command.
[This patch was stripped down from a patch produced by Mat Martineau that
had a bug in the compat code - so for the moment Stephan's patch simply
requires that the placeholder argument must be NULL]
Original-signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Stephan Mueller <smueller@chronox.de>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
Diffstat (limited to 'security')
-rw-r--r-- | security/keys/compat.c | 2 | ||||
-rw-r--r-- | security/keys/dh.c | 8 | ||||
-rw-r--r-- | security/keys/internal.h | 5 | ||||
-rw-r--r-- | security/keys/keyctl.c | 4 |
4 files changed, 13 insertions, 6 deletions
diff --git a/security/keys/compat.c b/security/keys/compat.c index c8783b3b628c..36c80bf5b89c 100644 --- a/security/keys/compat.c +++ b/security/keys/compat.c | |||
@@ -134,7 +134,7 @@ COMPAT_SYSCALL_DEFINE5(keyctl, u32, option, | |||
134 | 134 | ||
135 | case KEYCTL_DH_COMPUTE: | 135 | case KEYCTL_DH_COMPUTE: |
136 | return keyctl_dh_compute(compat_ptr(arg2), compat_ptr(arg3), | 136 | return keyctl_dh_compute(compat_ptr(arg2), compat_ptr(arg3), |
137 | arg4); | 137 | arg4, compat_ptr(arg5)); |
138 | 138 | ||
139 | default: | 139 | default: |
140 | return -EOPNOTSUPP; | 140 | return -EOPNOTSUPP; |
diff --git a/security/keys/dh.c b/security/keys/dh.c index 880505a4b9f1..531ed2ec132f 100644 --- a/security/keys/dh.c +++ b/security/keys/dh.c | |||
@@ -78,7 +78,8 @@ error: | |||
78 | } | 78 | } |
79 | 79 | ||
80 | long keyctl_dh_compute(struct keyctl_dh_params __user *params, | 80 | long keyctl_dh_compute(struct keyctl_dh_params __user *params, |
81 | char __user *buffer, size_t buflen) | 81 | char __user *buffer, size_t buflen, |
82 | void __user *reserved) | ||
82 | { | 83 | { |
83 | long ret; | 84 | long ret; |
84 | MPI base, private, prime, result; | 85 | MPI base, private, prime, result; |
@@ -97,6 +98,11 @@ long keyctl_dh_compute(struct keyctl_dh_params __user *params, | |||
97 | goto out; | 98 | goto out; |
98 | } | 99 | } |
99 | 100 | ||
101 | if (reserved) { | ||
102 | ret = -EINVAL; | ||
103 | goto out; | ||
104 | } | ||
105 | |||
100 | keylen = mpi_from_key(pcopy.prime, buflen, &prime); | 106 | keylen = mpi_from_key(pcopy.prime, buflen, &prime); |
101 | if (keylen < 0 || !prime) { | 107 | if (keylen < 0 || !prime) { |
102 | /* buflen == 0 may be used to query the required buffer size, | 108 | /* buflen == 0 may be used to query the required buffer size, |
diff --git a/security/keys/internal.h b/security/keys/internal.h index 8ec7a528365d..a705a7d92ad7 100644 --- a/security/keys/internal.h +++ b/security/keys/internal.h | |||
@@ -260,10 +260,11 @@ static inline long keyctl_get_persistent(uid_t uid, key_serial_t destring) | |||
260 | 260 | ||
261 | #ifdef CONFIG_KEY_DH_OPERATIONS | 261 | #ifdef CONFIG_KEY_DH_OPERATIONS |
262 | extern long keyctl_dh_compute(struct keyctl_dh_params __user *, char __user *, | 262 | extern long keyctl_dh_compute(struct keyctl_dh_params __user *, char __user *, |
263 | size_t); | 263 | size_t, void __user *); |
264 | #else | 264 | #else |
265 | static inline long keyctl_dh_compute(struct keyctl_dh_params __user *params, | 265 | static inline long keyctl_dh_compute(struct keyctl_dh_params __user *params, |
266 | char __user *buffer, size_t buflen) | 266 | char __user *buffer, size_t buflen, |
267 | void __user *reserved) | ||
267 | { | 268 | { |
268 | return -EOPNOTSUPP; | 269 | return -EOPNOTSUPP; |
269 | } | 270 | } |
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c index 3b135a0af344..d580ad06b792 100644 --- a/security/keys/keyctl.c +++ b/security/keys/keyctl.c | |||
@@ -1688,8 +1688,8 @@ SYSCALL_DEFINE5(keyctl, int, option, unsigned long, arg2, unsigned long, arg3, | |||
1688 | 1688 | ||
1689 | case KEYCTL_DH_COMPUTE: | 1689 | case KEYCTL_DH_COMPUTE: |
1690 | return keyctl_dh_compute((struct keyctl_dh_params __user *) arg2, | 1690 | return keyctl_dh_compute((struct keyctl_dh_params __user *) arg2, |
1691 | (char __user *) arg3, | 1691 | (char __user *) arg3, (size_t) arg4, |
1692 | (size_t) arg4); | 1692 | (void __user *) arg5); |
1693 | 1693 | ||
1694 | default: | 1694 | default: |
1695 | return -EOPNOTSUPP; | 1695 | return -EOPNOTSUPP; |