Skip to main content

keyctl2

CI CodeQL OpenSSF Scorecard PyPI License: 0BSD

Dependency-free Python bindings for the Linux kernel keyring: add, search, read, describe, link and unlink keys in session and process keyrings, without shelling out to keyctl(1).

Requires Python 3.10+ and Linux. No runtime dependencies: the bindings call add_key(2), request_key(2) and keyctl(2) through ctypes.

Supported architectures: x86-64, i386, aarch64, riscv32/64, loongarch64, 32-bit ARM, powerpc, s390x and sparc. Other architectures raise UnsupportedError.

Install

pip install keyctl2

Example

import keyctl2

# Add a user key to the session keyring and read it back.
serial = keyctl2.add_key("user", "my-secret", b"hunter2")
key = keyctl2.Key(serial)
assert key.read() == b"hunter2"

# Search the session keyring for it later.
assert keyctl2.search("session", "user", "my-secret") == serial

# Inspect it and clean up.
print(key.describe())   # KeyDescription(type='user', ...)
key.unlink("session")

Development

uv sync --group dev
make check

License: 0BSD. Quad4 Software, https://quad4.io

Metadata

Release files for keyctl2 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for keyctl2 0.2.0
File Size Uploaded
keyctl2-0.2.0.tar.gz 73.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for keyctl2 0.2.0
File Interpreter ABI Platform
keyctl2-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 85.0 kB

Release files / keyctl2-0.2.0.tar.gz

Download URL keyctl2-0.2.0.tar.gz
Size 73.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ace21b1cdbb1d81a60c2bf10cbfa453cc481ff49ac5f41963d85f6dcce596a41
BLAKE2b-256 checksum
How to use checksums
9fd23abe31481f0decedfa676c20ad3b6bf8c8bfc300da3b4c02ae4978f51dea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / keyctl2-0.2.0-py3-none-any.whl

Download URL keyctl2-0.2.0-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a2439ea03fd42dc695f435f9cf1548cf2de0db1962e383f034b38bfbf4f6d28a
BLAKE2b-256 checksum
How to use checksums
55ed0b6cd966ef47605bcb576537fa0dab30470b092b8371d97fb8f7920494bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page