KeyNub License Dongle — Python binding
keynub-licdongle is a thin ctypes
wrapper over the native keynub_licdongle core — no protocol or crypto logic in
Python. Pure Python (no compiler needed at install); the native library is bundled
per platform. Works on Windows, Linux, and macOS with no drivers.
Install
pip install keynub-licdongle
Use
import keynub_licdongle as kn
with kn.LicenseDongleContext() as ctx:
for d in ctx.enumerate():
print(d.serial, d.path)
dongle = ctx.open() # first attached dongle (or open(serial=...))
print(dongle.get_serial())
result = dongle.verify_genuine() # cert chain + live challenge-response
print("genuine:", result.is_genuine)
with dongle.open_session() as session: # ECDH -> HKDF -> AES-256-GCM
license = session.read_record("license") # read role
# Developer/provisioning tools elevate to the write role:
session.authorize_write(master_key_der)
session.write_record("license", new_bytes)
# App-data envelope encryption — unusable without a genuine dongle:
blob = session.app_encrypt(kn.Scope.DEVICE, plaintext)
assert session.app_decrypt(blob) == plaintext
LicenseDongleContext— enumerate / open / logging (a context manager).Dongle—get_info,get_serial,verify_genuine,open_session.Session— records, counters, app-crypto,authorize_write.- Failures raise
LicenseDongleError(with a.status); common cases have subclasses (NotGenuineError,WriteAuthorizationRequiredError,RecordNotFoundError, …). read_record/write_recordaccept aprogresscallback(TransferProgress) -> bool; returnFalseto cancel (raisesOperationCancelledError).
Native library resolution
The binding loads, in order: $KEYNUB_LICDONGLE_LIBRARY (explicit path), the
bundled keynub_licdongle/_libs/<lib>, a copy next to the package, then the
system search path. Linux additionally needs the shipped udev rule (a permission
rule, not a driver).
licd-tool — the command line
Installing the wheel also installs licd-tool, which drives the same
production core an application would. Useful for licence issuance, for support
("what is this dongle and is it genuine?"), and for reproducing what an
application sees without the application.
licd-tool list # attached dongles
licd-tool info # firmware, storage, provisioning state
licd-tool --trust-root ca.der verify # prove it is genuine
# Anything inside a session needs --trust-root; anything that writes needs the
# developer master key.
licd-tool --trust-root ca.der records list
licd-tool --trust-root ca.der --master-key mk.der records write license lic.bin
licd-tool --trust-root ca.der records read license -o lic.bin
licd-tool --trust-root ca.der counter read
# Envelope-encrypt data so it only decrypts with a dongle attached.
licd-tool --trust-root ca.der appcrypto encrypt assets.bin -o assets.enc --scope developer
licd-tool --trust-root ca.der appcrypto decrypt assets.enc -o assets.bin
--json makes every command emit machine-readable output on stdout, so it drops
into a licence-issuing script. Irreversible operations refuse to run without
--yes: incrementing a monotonic counter cannot be undone, and records erase --all wipes the dongle. Record writes are read back and compared before the tool
reports success, because a silent truncation would otherwise surface at the
customer.
Factory provisioning is deliberately not in this tool — it lives with the CA
in the firmware repo's tools/provision, is vendor-internal, and has irreversible
steps.
Security
Read docs/integration-security.md before
writing your licensing check. verify_genuine() proves a genuine dongle is attached;
it cannot stop an attacker from patching your application or pointing
KEYNUB_LICDONGLE_LIBRARY at a fake library. Branch on a boolean and you will be
bypassed — put dongle-derived data (app_encrypt/app_decrypt) on the path your
application actually needs.
License
Apache-2.0 — see LICENSE, NOTICE, and
THIRD-PARTY-NOTICES.txt (all three ship inside the
wheel, under .dist-info/licenses/). The bundled native statically links Mbed TLS
(Apache-2.0 elected) and hidapi (BSD-style elected); no GPL terms apply.
Links
- KeyNub License Dongle for Python: the product, and how to order one
- Source, samples and issue tracker on GitHub
- Native library for your platform
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file keynub_licdongle-1.1.1.tar.gz.
File metadata
- Download URL: keynub_licdongle-1.1.1.tar.gz
- Upload date:
- Size: 31.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
686d5b1cb589c82057064cbdfafd9d2ab030c2c753bd97a189ce0e8c6a9c2b86
|
|
| MD5 |
bf78bc549be0cf65fe84d7ee57448fb9
|
|
| BLAKE2b-256 |
0d90f8c78c7da5ba1c47a46b1fbe81816e5e2ec600cb6d57deb3654b51137720
|
File details
Details for the file keynub_licdongle-1.1.1-py3-none-win_arm64.whl.
File metadata
- Download URL: keynub_licdongle-1.1.1-py3-none-win_arm64.whl
- Upload date:
- Size: 103.1 kB
- Tags: Python 3, Windows ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3862b5e62736855dd0a3022cebf8f080cac58fc5ab7a281330cdca91075772b9
|
|
| MD5 |
69263b781abd793bdd1a2769fe4eb781
|
|
| BLAKE2b-256 |
2192390f7b49ce895a2c051c05759efd6f2068bdcf56c81f63325c6d377faa3a
|
File details
Details for the file keynub_licdongle-1.1.1-py3-none-win_amd64.whl.
File metadata
- Download URL: keynub_licdongle-1.1.1-py3-none-win_amd64.whl
- Upload date:
- Size: 109.5 kB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0d68863d5d3471f205ca16d03da6470c747006e0222c0cd74346e98173eb661
|
|
| MD5 |
d547ad71845f04ab96d3e1b02610e9dd
|
|
| BLAKE2b-256 |
870efee83839a0aee1c334236e86224b2321a52062c76e625e1c8469d78a50fb
|
File details
Details for the file keynub_licdongle-1.1.1-py3-none-win32.whl.
File metadata
- Download URL: keynub_licdongle-1.1.1-py3-none-win32.whl
- Upload date:
- Size: 90.0 kB
- Tags: Python 3, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aea33ea3b1c6dd356a8484d94191bce06cf0f7f62e161350ea2b2e638b8beb65
|
|
| MD5 |
1ecf95a9f631ad562a05af4cd6a17f77
|
|
| BLAKE2b-256 |
8be273720bd103bd6e21677ced0ad06c55f7188c1f7d24075160472097ac94a5
|
File details
Details for the file keynub_licdongle-1.1.1-py3-none-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: keynub_licdongle-1.1.1-py3-none-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 140.9 kB
- Tags: Python 3, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c469836ad6a30f8e2fffa234c1b6d96a9b0b33ee415c1a107dc571908ad86d5
|
|
| MD5 |
a34d71cac061f2ff059f458e426c7cc0
|
|
| BLAKE2b-256 |
688a7e4465ba369cb508c89abe9b760acc42b60b972736d105054d9e9fd07c9d
|
File details
Details for the file keynub_licdongle-1.1.1-py3-none-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: keynub_licdongle-1.1.1-py3-none-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 139.8 kB
- Tags: Python 3, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df9a9bf26cb4fdf7a74a849b69448c82ebfe83907e211ac33f1005dcbb36190a
|
|
| MD5 |
b8e6c471910df427fd47e600165b836c
|
|
| BLAKE2b-256 |
592def123b4239fa54c7d08a8ac2de563a5130cc543727ada0f96dbc5c37a4fd
|
File details
Details for the file keynub_licdongle-1.1.1-py3-none-macosx_11_0_universal2.whl.
File metadata
- Download URL: keynub_licdongle-1.1.1-py3-none-macosx_11_0_universal2.whl
- Upload date:
- Size: 219.4 kB
- Tags: Python 3, macOS 11.0+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
287b233d809ced916b33724e131cac7cfa0eb8c4b4ece928b348a37ffd710a47
|
|
| MD5 |
014427519f5f9a9556059966859b1a86
|
|
| BLAKE2b-256 |
39ba24e0d8b4ad658a238b5b9bde7ca75f5aca8b213939adb58b3c8072697e2e
|