Skip to content

Repository files navigation

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.

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

About

Dependency-free Python bindings for Linux kernel keyring.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages