keynub-licdongle: Client for the KeyNub USB license dongle

[ apache, hardware, library ] [ Propose Tags ] [ Report a vulnerability ]

Verify that a KeyNub USB license 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 Haskell over the SDK's flat C API: the native library is loaded at run time, nothing is linked.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 1.1.1
Change log CHANGELOG.md
Dependencies base (>=4.14 && <5), bytestring (>=0.10 && <0.13), directory (>=1.3 && <1.4), filepath (>=1.4 && <1.6), unix (>=2.7 && <2.9), Win32 (>=2.6 && <2.15) [details]
Tested with ghc ==9.12.4
License Apache-2.0
Copyright 2026 KeyNub
Author KeyNub
Maintainer info@keynub.com
Uploaded by abtools at 2026-09-22T14:04:16Z
Category Hardware
Home page https://www.keynub.com/developers/haskell/
Bug tracker https://github.com/AB-KeyNub/KeyNub-SDK/issues
Source repo head: git clone https://github.com/AB-KeyNub/KeyNub-SDK.git(bindings/haskell)
Distributions Stackage:1.1.1
Downloads 4 total (4 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
All reported builds failed as of 2026-09-22 [all 1 reports]

Readme for keynub-licdongle-1.1.1

[back to package description]

KeyNub License Dongle — Haskell package

import KeyNub.LicDongle

main :: IO ()
main = withDongle open $ \d -> do            -- first dongle, or openSerial "..."
  _ <- verifyGenuine d                        -- throws unless genuine
  secret <- withSession d $                   -- closed on every exit path
    appDecrypt d sealed                       -- <- build the licence check on this
  ...

Pure Haskell. The package calls the SDK's flat companion API through function pointers resolved at run time, so nothing is linked at build time, there is no C to compile and nothing sits in the path of the check that a customer could substitute. base, bytestring, directory, filepath and the platform's loader package (unix, or Win32 on Windows) are the dependencies. GHC 9.4 or later, on Windows, Linux and macOS.

Setup

cabal install keynub-licdongle

or keynub-licdongle in build-depends. The package does not carry the native library. Take keynub_licdongle_flat for your platform from the SDK's natives folder and either put it where the operating system finds libraries (next to the executable, or on PATH, LD_LIBRARY_PATH, DYLD_LIBRARY_PATH), or name it before the first call:

setLibraryPath "/opt/keynub/libkeynub_licdongle_flat.so"

KEYNUB_LICDONGLE_FLAT_LIBRARY in the environment does the same. In a clone of the SDK repository the package finds natives/<platform>/ on its own, from the working directory upwards, so the samples run with nothing set. A process loads the library once; loadedLibraryPath tells which. On Linux, install the udev rule described in NATIVES.md so the dongle is accessible without root.

Notes

  • Results are records (Info, GenuineResult, Device, RecordInfo); byte data is ByteString. The package calls the SDK's flat API: integer handles and caller-provided buffers, no C structures and no hand-written layouts.
  • Failures throw LicDongleError with errorStatus (NoDevice, NotGenuine, AuthRequired, ...), errorCode, errorOperation and errorDetail; loading problems throw LibraryError.
  • isGenuine is the non-throwing form for a gate and fails closed: every failure gives False.
  • withDongle and withSession are brackets: the dongle and the session are closed on every exit path, exceptions included.
  • eraseAllRecords is deliberately separate from eraseRecord: an accidentally empty name must not wipe the dongle.
  • Records are transferred in one call; the flat API has no progress reporting.

Read docs/integration-security.md before writing the check. ok <- isGenuine d; unless ok exitFailure is one conditional branch, and patching one of those in a release binary is a beginner exercise. Route something the program needs through appEncrypt and appDecrypt, so removing the check removes the data.

Tests

cabal test runs without a dongle: it compiles a stand-in for the flat C API (bindings/flat/licd_flat.c over bindings/julia/test/stub/licd_stub.c) with the C compiler on the path and exercises every call against it. In a package taken from Hackage the SDK sources are not present; point KEYNUB_SDK_ROOT at a clone, or KEYNUB_LICDONGLE_FLAT_LIBRARY at a compiled stand-in.