KEYCTL_PKEY_QUERY(3)
π keyctl_pkey_query β the vibe check for your public keys π
okay bestie, listen up, this is a Linux Key Management Calls moment, section 3 of the manual, and we're about to learn how to query public key parameters. No cap. π
β¨ NAME β¨
keyctl_pkey_query β ask a key "soβ¦ what can you even do, babes?" π
πΈ SYNOPSIS πΈ
#include <keyutils.h>
long keyctl_pkey_query(key_serial_t key, const char *info,
struct keyctl_pkey_query *result);
π¦ DESCRIPTION π¦
So keyctl_pkey_query() goes and asks a kernel key that supports these kinds of operations β typically an asymmetric-type key β all about its public key parameters. Iconic behaviour honestly. π«Ά
Heads up: the caller must have search permission on the target key to be able to query its parameters. No permission, no tea. β
When you invoke this function:
keyβ which key we're interrogating, bestie πinfoβ a pointer to a space- or tab-separated string of"key[=value]"parameters πresultβ a pointer to a buffer where the answer gets dropped off π
The parameters you can put in that info string? Depends entirely on the type of key. They can specify stuff like encoding types (for example enc=pkcs1) β go peek at asymmetric-key(7) for more on that. iykyk. π
If it works, the result lands in this struct, exactly like this:
struct keyctl_pkey_query {
unsigned int supported_ops;
unsigned int key_size;
unsigned short max_data_size;
unsigned short max_sig_size;
unsigned short max_enc_size;
unsigned short max_dec_size;
};
The supported_ops field is a bitmask of these constants, and they tell you what's supported β aka which of the other keyctl_pkey_*() operations you can actually use with this key: β
KEYCTL_SUPPORTS_ENCRYPTKEYCTL_SUPPORTS_DECRYPTKEYCTL_SUPPORTS_SIGNKEYCTL_SUPPORTS_VERIFY
And the rest of the squad:
key_sizeβ the number of bits in the key size π’max_data_sizeβ max size in bytes of a blob of data to be signedmax_sig_sizeβ max size in bytes of a signature blobmax_enc_sizeβ max size in bytes of a blob to be encryptedmax_dec_sizeβ max size in bytes of a blob to be decrypted
slay. that's the whole report card. π―
π RETURN VALUE π
- On success,
keyctl_pkey_query()returns0. π₯³ - On error, you get
-1back, anderrnowill have been set to an appropriate error. π
π ERRORS π
ENOKEYβ the key specified is invalid. not a real key, bestie, we can't work with that πEKEYEXPIREDβ the key specified has expired. it's giving ghosted. π»EKEYREVOKEDβ the key specified has been revoked. it's over, it's done πEACCESβ the key exists, but it's not searchable by the calling process. you can look but you cannot look, y'know? π«ENOPKGβ some facility needed to complete the requested operation is not available. this is most probably a requested or required digest or encryption algorithm. the algorithm ghosted us fr fr π€EFAULTβ bad address. π
π LINKING π
This is a library function, and it lives in libkeyutils. When you're linking, you need to pass -lkeyutils to the linker. Don't forget it, it's the whole vibe. π§
π SEE ALSO π
keyctl(1), add_key(2), keyctl(2), keyctl(3), keyctl_pkey_encrypt(3), keyctl_pkey_sign(3), asymmetric-key(7), keyrings(7), keyutils(7)
and that's the whole page, bestie!! πβ¨ this one's brought to you by the Linux girlies, dated 8 Nov 2018 β periodt. go query those keys, you absolute icon. ππ¦πΈ
π¦ where this page comes from
- alpine 3.22: keyutils-doc 1.6.3-r4 Β· GPL-2.0-or-later AND LGPL-2.0-or-later
- alpine 3.23: keyutils-doc 1.6.3-r4 Β· GPL-2.0-or-later AND LGPL-2.0-or-later
- alpine 3.24: keyutils-doc 1.6.3-r4 Β· GPL-2.0-or-later AND LGPL-2.0-or-later
- arch rolling: keyutils 1.6.3-4 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- centos-stream 10: keyutils-libs-devel 1.6.3-5.el10 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- centos-stream 9: keyutils-libs-devel 1.6.3-1.el9 Β· GPLv2+ and LGPLv2+
- centos-stream 9: keyutils-libs-devel 1.6.3-1.el9 Β· GPLv2+ and LGPLv2+
- debian bookworm: libkeyutils-dev 1.6.3-2 Β· GPL-2.0-or-later
- debian trixie: libkeyutils-dev 1.6.3-6 Β· GPL-2.0-or-later
- fedora 43: keyutils-libs-devel 1.6.3-6.fc43 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- fedora 43: keyutils-libs-devel 1.6.3-6.fc43 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- fedora 44: keyutils-libs-devel 1.6.3-7.fc44 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- fedora 44: keyutils-libs-devel 1.6.3-7.fc44 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- nixpkgs unstable: keyutils 1.6.3
- opensuse-leap 16.0: keyutils 1.6.3-160000.3.2 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- opensuse-leap 16.0: keyutils 1.6.3-160000.3.2 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- opensuse-leap 16.0: keyutils 1.6.3-160000.3.2 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- opensuse-leap 16.0: keyutils 1.6.3-160000.3.2 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- ubuntu noble: libkeyutils-dev 1.6.3-3build1 Β· GPL-2.0-or-later
- ubuntu questing: libkeyutils-dev 1.6.3-6ubuntu2
- ubuntu resolute: libkeyutils-dev 1.6.3-6ubuntu3 Β· GPL-2.0-or-later
- ubuntu stonking: libkeyutils-dev 1.6.3-6ubuntu3 Β· GPL-2.0-or-later
- Copyright (C) 2018 Red Hat, Inc. All Rights Reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms