KeyNub/ KeyNubLicDongle

Client for the KeyNub USB license dongle: genuineness check, license records, hardware counters, dongle-bound encryption

Contributed by: KeyNub

Wolfram Language client for the KeyNub USB license dongle: verify that a dongle is genuine, read and write the license records it stores, use its hardware counters, and encrypt data so that only a dongle can decrypt it. Pure Wolfram Language over the SDK's flat C API through ForeignFunctionLoad, for Mathematica, Wolfram Engine and wolframscript on Windows, Linux and macOS.

Installation Instructions

To install this paclet in your Wolfram Language environment, evaluate this code:
PacletInstall["KeyNub/KeyNubLicDongle"]


To load the code after installation, evaluate this code:
Needs["KeyNub`KeyNubLicDongle`"]

Details

Every function has a reference page in the paclet's documentation; the guide page KeyNub License Dongle lists them by group. Results are associations, byte data is ByteArray, and every failure is a Failure object carrying the library's status code, the operation and its diagnostic detail. The paclet exports 26 functions in the context KeyNubKeyNubLicDongle:
GroupFunctions
LibraryLicDongleLibraryPath, LicDongleLibraryVersion, LicDongleStatusText, LicDongleLastErrorDetail
DevicesLicDongleDevices, LicDongleOpen, LicDongleOpenPath, LicDongleClose, LicDongleSerial, LicDongleInfo
AuthenticityLicDongleVerifyGenuine, LicDongleGenuineQ, LicDongleSetTrustRoot
SessionLicDongleSessionOpen, LicDongleSessionClose, LicDongleAuthorizeWrite, LicDongleRotateWriteKey
RecordsLicDongleRecords, LicDongleReadRecord, LicDongleWriteRecord, LicDongleEraseRecord, LicDongleEraseAllRecords
CountersLicDongleReadCounter, LicDongleIncrementCounter
Application dataLicDongleAppEncrypt, LicDongleAppDecrypt

A dongle is an integer handle from LicDongleOpen; the library holds up to 32 open handles. LicDongleInfo gives an association with "ProtocolVersion", "FirmwareVersion", "SecureElementReady", "Provisioned", "Isolated", "WatchdogReboot", "WriteAuthRotated", "DataCapacity" and "DataFree". LicDongleVerifyGenuine gives "Genuine", "Serial" and "ProvisionedDate"; LicDongleGenuineQ is the non-failing form and gives False on every failure. Records, counters and application-data encryption need a session (LicDongleSessionOpen); writing, erasing, incrementing and key rotation need the session elevated with the dongle's write key (LicDongleAuthorizeWrite, a P-256 private key in PKCS#8 DER). Every function taking bytes accepts a ByteArray or a String (stored as UTF-8). Failures are Failure["LicDongleError", …] with "Status" (the C status code), "Operation" and "Detail". The native library keynub_licdongle_flat is part of the KeyNub SDK, not of the paclet. The paclet loads it from the path given to LicDongleLibraryPath, from the environment variable KEYNUB_LICDONGLE_FLAT_LIBRARY, from natives/ in a clone of the SDK repository (searched from the working directory upwards), or by its bare name through the operating system's library search. A kernel loads the library once; LicDongleLibraryPath[] tells which one.

Paclet Guide

Examples

Initialization for Examples

If the native library is not on the operating system's library path, name it first:

Basic Examples (6) 

List the attached dongles:

Open the first dongle and verify that it is genuine:

Gate on authenticity without handling a Failure; every failure gives False:

Read the device information:

Open a session and read the license record:

Close the session and release the dongle:

Scope (8) 

Open a dongle by serial or by device path:

Records take a ByteArray or a String; writing needs the write role:

Erase one record:

Read and increment a hardware counter; the increment gives the new value:

Encrypt data so that only a dongle can decrypt it. "Developer" lets any dongle issued to the same developer decrypt; "Device" binds the data to this dongle:

Replace the dongle's write key with your own; the shipped key is keys/keynub-shipping-writeauth.key.der in the SDK repository:

Failures carry the status code, the operation and the library's detail:

f["Status"];

Name the native library and report which one is loaded:

Publisher

KeyNub

Compatibility

Wolfram Language Version 13.1

Version History

  • 1.1.1 – 17 September 2026

License Information

Apache License 2.0

Paclet Source

Source Metadata