Factor out CONFIG_KEYCTL_PKEY from CONFIG_ASYMMETRIC_KEY_TYPE so key
types other than asymmetric can select keyctl public-key operations
without pulling in crypto/asymmetric_keys/.

Signed-off-by: Jarkko Sakkinen <[email protected]>
---
 crypto/asymmetric_keys/Kconfig | 1 +
 security/keys/Kconfig          | 3 +++
 security/keys/Makefile         | 2 +-
 security/keys/internal.h       | 2 +-
 security/keys/keyctl.c         | 2 +-
 5 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/crypto/asymmetric_keys/Kconfig b/crypto/asymmetric_keys/Kconfig
index c73979b2e98e..1c78a9a663c5 100644
--- a/crypto/asymmetric_keys/Kconfig
+++ b/crypto/asymmetric_keys/Kconfig
@@ -2,6 +2,7 @@
 menuconfig ASYMMETRIC_KEY_TYPE
        bool "Asymmetric (public-key cryptographic) key type"
        depends on KEYS
+       select KEYCTL_PKEY
        help
          This option provides support for a key type that holds the data for
          the asymmetric keys used for public key cryptographic operations such
diff --git a/security/keys/Kconfig b/security/keys/Kconfig
index 3f64d60d0f8a..c0cd894d306c 100644
--- a/security/keys/Kconfig
+++ b/security/keys/Kconfig
@@ -22,6 +22,9 @@ menuconfig KEYS
 
 if KEYS
 
+config KEYCTL_PKEY
+       bool
+
 config KEYS_REQUEST_CACHE
        bool "Enable temporary caching of the last request_key() result"
        help
diff --git a/security/keys/Makefile b/security/keys/Makefile
index 5f40807f05b3..aafd28f7ee2f 100644
--- a/security/keys/Makefile
+++ b/security/keys/Makefile
@@ -22,7 +22,7 @@ obj-$(CONFIG_PROC_FS) += proc.o
 obj-$(CONFIG_SYSCTL) += sysctl.o
 obj-$(CONFIG_PERSISTENT_KEYRINGS) += persistent.o
 obj-$(CONFIG_KEY_DH_OPERATIONS) += dh.o
-obj-$(CONFIG_ASYMMETRIC_KEY_TYPE) += keyctl_pkey.o
+obj-$(CONFIG_KEYCTL_PKEY) += keyctl_pkey.o
 
 #
 # Key types
diff --git a/security/keys/internal.h b/security/keys/internal.h
index c452d71cce03..28c6cd942c59 100644
--- a/security/keys/internal.h
+++ b/security/keys/internal.h
@@ -314,7 +314,7 @@ static inline long compat_keyctl_dh_compute(
 #endif
 #endif
 
-#ifdef CONFIG_ASYMMETRIC_KEY_TYPE
+#ifdef CONFIG_KEYCTL_PKEY
 extern long keyctl_pkey_query(key_serial_t,
                              const char __user *,
                              struct keyctl_pkey_query __user *);
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index d6b10fd67627..417bba539bb1 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -28,7 +28,7 @@ static const unsigned char keyrings_capabilities[2] = {
        [0] = (KEYCTL_CAPS0_CAPABILITIES |
               (IS_ENABLED(CONFIG_PERSISTENT_KEYRINGS)  ? 
KEYCTL_CAPS0_PERSISTENT_KEYRINGS : 0) |
               (IS_ENABLED(CONFIG_KEY_DH_OPERATIONS)    ? 
KEYCTL_CAPS0_DIFFIE_HELLMAN : 0) |
-              (IS_ENABLED(CONFIG_ASYMMETRIC_KEY_TYPE)  ? 
KEYCTL_CAPS0_PUBLIC_KEY : 0) |
+              (IS_ENABLED(CONFIG_KEYCTL_PKEY)          ? 
KEYCTL_CAPS0_PUBLIC_KEY : 0) |
               (IS_ENABLED(CONFIG_BIG_KEYS)             ? KEYCTL_CAPS0_BIG_KEY 
: 0) |
               KEYCTL_CAPS0_INVALIDATE |
               KEYCTL_CAPS0_RESTRICT_KEYRING |
-- 
2.47.3


Reply via email to