[LTP] [PATCH 21/33] lapi/keyctl.h: Add fallback definitions for public key ops
Andrea Cervesato
andrea.cervesato@suse.de
Wed Sep 2 13:04:36 CEST 2026
From: Andrea Cervesato <andrea.cervesato@suse.com>
Add fallback definitions for KEYCTL_PKEY_QUERY, KEYCTL_PKEY_ENCRYPT,
KEYCTL_PKEY_DECRYPT, KEYCTL_PKEY_SIGN, KEYCTL_PKEY_VERIFY, and
KEYCTL_SUPPORTS_*, as well as fallback structs keyctl_pkey_query
and keyctl_pkey_params when built without keyutils.h or linux/keyctl.h.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
include/lapi/keyctl.h | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/include/lapi/keyctl.h b/include/lapi/keyctl.h
index a056ddaad..8820c3ddb 100644
--- a/include/lapi/keyctl.h
+++ b/include/lapi/keyctl.h
@@ -33,6 +33,26 @@ struct keyctl_kdf_params {
uint32_t otherinfolen;
uint32_t __spare[8];
};
+
+struct keyctl_pkey_query {
+ uint32_t supported_ops;
+ uint32_t key_size;
+ uint16_t max_data_size;
+ uint16_t max_sig_size;
+ uint16_t max_enc_size;
+ uint16_t max_dec_size;
+ uint32_t __spare[10];
+};
+
+struct keyctl_pkey_params {
+ int32_t key_id;
+ uint32_t in_len;
+ union {
+ uint32_t out_len;
+ uint32_t in2_len;
+ };
+ uint32_t __spare[7];
+};
#endif
static inline key_serial_t add_key(const char *type,
@@ -199,6 +219,33 @@ static inline key_serial_t keyctl_join_session_keyring(const char *name) {
# define KEYCTL_MOVE_EXCL 0x00000001 /* do not displace from the to-keyring */
#endif
+#ifndef KEYCTL_PKEY_QUERY
+# define KEYCTL_PKEY_QUERY 24
+#endif
+
+#ifndef KEYCTL_PKEY_ENCRYPT
+# define KEYCTL_PKEY_ENCRYPT 25
+#endif
+
+#ifndef KEYCTL_PKEY_DECRYPT
+# define KEYCTL_PKEY_DECRYPT 26
+#endif
+
+#ifndef KEYCTL_PKEY_SIGN
+# define KEYCTL_PKEY_SIGN 27
+#endif
+
+#ifndef KEYCTL_PKEY_VERIFY
+# define KEYCTL_PKEY_VERIFY 28
+#endif
+
+#ifndef KEYCTL_SUPPORTS_ENCRYPT
+# define KEYCTL_SUPPORTS_ENCRYPT 0x01
+# define KEYCTL_SUPPORTS_DECRYPT 0x02
+# define KEYCTL_SUPPORTS_SIGN 0x04
+# define KEYCTL_SUPPORTS_VERIFY 0x08
+#endif
+
/* key permissions */
#ifndef KEY_POS_VIEW
# define KEY_POS_VIEW 0x01000000
@@ -259,6 +306,11 @@ static inline long safe_keyctl(const char *file, const int lineno,
case KEYCTL_GET_SECURITY:
case KEYCTL_GET_PERSISTENT:
case KEYCTL_DH_COMPUTE:
+ case KEYCTL_PKEY_QUERY:
+ case KEYCTL_PKEY_ENCRYPT:
+ case KEYCTL_PKEY_DECRYPT:
+ case KEYCTL_PKEY_SIGN:
+ case KEYCTL_PKEY_VERIFY:
if (rval < 0)
failure = 1;
break;
--
2.51.0
More information about the ltp
mailing list