skillfed

PyKCS11

A Full PKCS#11 wrapper for Python

pykcs11 v1.5.18 330.4K downloads/30d#7,537 on PyPI118
Copyleft license GPL Active released

What it is and what it does

PyKCS11 is a Python binding to the PKCS#11 cryptographic standard, which defines how applications communicate with hardware security modules, smart cards, and other cryptographic tokens. It translates Python calls into the low-level C interface that these devices expose, allowing developers to perform cryptographic operations—signing, verification, key generation, encryption—without reimplementing the underlying protocols.

The package is primarily used in enterprise and security-sensitive environments where cryptographic keys must be stored on dedicated hardware rather than in software. It has no runtime dependencies beyond the PKCS#11 module itself (provided by the hardware vendor), making it lightweight once installed. The GPL license means it is best suited for open-source projects or internal tools; proprietary applications would need to either use a compatible license or seek an alternative.

Use it for:

  • Sign documents or certificates using keys stored on a hardware security module or smart card.
  • Verify digital signatures from tokens without exposing private keys to the application.
  • Integrate PKI workflows into Python applications that require compliance with key storage standards.
  • Access and manage cryptographic material on enterprise-grade HSMs from Python code.
  • Build authentication systems that rely on smart card or token-based credentials.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

PyKCS11 provides a Python wrapper around the PKCS#11 cryptographic interface standard, enabling Python applications to interact with hardware security modules, smart cards, and other cryptographic tokens.

Yes, if you need to work with PKCS#11 hardware tokens or smart cards in Python and can accept the GPL copyleft license. The package is stable, actively maintained, and widely used in security and PKI contexts. No, if your application is proprietary and cannot adopt GPL, or if you have no requirement to interact with hardware cryptographic devices.

Install

pykcs11 on PyPI

pip

pip install pykcs11

uv

uv add pykcs11

poetry

poetry add pykcs11

Installing PyKCS11

Before you install

Medium install friction: platform-specific wheels are provided for Windows and macOS, but the package requires compilation from source on other platforms. The project is actively maintained with recent commits and has been stable since its 2006 initial release.

License in practice

Licensed under GPL (copyleft), which means any code linking PyKCS11 must also be distributed under GPL or a compatible license. This is a significant constraint for proprietary or closed-source applications.

Quickstart

pip install pykcs11

import PyKCS11
lib = PyKCS11.PyKCS11Lib()
lib.load('path/to/pkcs11/module')
slots = lib.getSlotList()

Requires a PKCS#11 module (typically a .so, .dll, or .dylib file) provided by your hardware security module or smart card vendor to be installed and accessible on the system.

Verify before relying

  • Whether the package supports modern Python versions beyond 3.13 or has a documented minimum Python version requirement.
  • Whether pre-built wheels are available for Linux platforms or if compilation is always required on Linux systems.
  • Performance characteristics and throughput limits when working with high-volume cryptographic operations.

Package facts

License GPL (copyleft)
Python support not specified
Install friction medium — platform-specific wheel
Runtime dependencies none
Maintenance actively maintained — 376 days since the last release
Last repo commit
First released
Downloads 330,430/month — #7,537 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: PyKCS11-1.5.18-cp310-cp310-win32.whl; PyKCS11-1.5.18-cp310-cp310-win_amd64.whl; PyKCS11-1.5.18-cp311-cp311-win32.whl; PyKCS11-1.5.18-cp311-cp311-win_amd64.whl; pykcs11-1.5.18-cp312-cp312-win32.whl; pykcs11-1.5.18-cp312-cp312-win_amd64.whl; pykcs11-1.5.18-cp313-cp313-macosx_15_0_x86_64.whl; pykcs11-1.5.18-cp313-cp313-win32.whl; pykcs11-1.5.18-cp313-cp313-win_amd64.whl; PyKCS11-1.5.18-cp37-cp37m-win32.whl; PyKCS11-1.5.18-cp37-cp37m-win_amd64.whl; PyKCS11-1.5.18-cp38-cp38-win32.whl; PyKCS11-1.5.18-cp38-cp38-win_amd64.whl; PyKCS11-1.5.18-cp39-cp39-win32.whl; PyKCS11-1.5.18-cp39-cp39-win_amd64.whl

Keywords: crypto, pki, pkcs11, c++

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: GNU General Public License (GPL)Natural Language :: EnglishOperating System :: Microsoft :: WindowsOperating System :: OS IndependentOperating System :: UnixProgramming Language :: CProgramming Language :: C++Programming Language :: PythonTopic :: Security :: CryptographyTopic :: Software Development :: Libraries :: Python Modules

Tags

pkcs11 python wrapperhardware security module interfacesmart card cryptographypkcs11 bindingcryptographic token accesspki python libraryhsm integration python
hardware-securitypkicryptography

More Python Modules packages