Skip to content

Software License Dongle for Racket

Racket reaches the dongle through the SDK’s flat C API with ffi/unsafe, loading the native library at run time on the first call, so nothing is linked and nothing sits in the path of the check that a customer could substitute for something more agreeable. Every provided function has a contract. The keynub-licdongle package, Racket 8.0 or later, on Windows, Linux and macOS.

Racket packages version badge

raco pkg install keynub-licdongle

Reading a License

(require keynub/licdongle)

(define license
  (with-dongle (d)                    ; first dongle, or (d #:serial "...")
    (dongle-verify-genuine d)         ; raises unless genuine
    (with-session d                   ; closed on every exit path
      (read-record d "license"))))Code language: PHP (php)

What You Are Protecting

Racket software that is sold ships as an executable from raco exe or as compiled bytecode: a desktop tool, a teaching application, a domain-specific language. A check that returns #t or #f is one conditional in that program, and patching one of those is a beginner exercise.

So the strong pattern is the one to reach for: the data the program needs only exists when the dongle is present.

; Weak: one patched branch.
(unless (dongle-genuine? d) (exit 1))

; Strong: the parameters only exist with the dongle present.
(define parameters
  (with-session d
    (decode-parameters (app-decrypt d sealed-blob-shipped-with-your-program))))Code language: JavaScript (javascript)

Every failed call raises exn:fail:keynub with the status ('no-device, 'not-genuine, 'auth-required, …), the operation and the library’s detail; dongle-genuine? fails closed. with-dongle and with-session release the dongle and the session on every exit path. The package calls the SDK’s flat companion API, the one designed for foreign function interfaces: integer handles and buffers, no hand-written structure layouts.

Shipping the Native Library with a Racket Application

The keynub-licdongle package loads the SDK’s flat API through ffi/unsafe on the first call, so requiring the module and building its documentation need no library, and nothing is linked. An executable from raco exe or a distribution from raco distribute takes keynub_licdongle_flat for its platform in natives/<platform>/ beside it, or names it with set-library-path! or KEYNUB_LICDONGLE_FLAT_LIBRARY.

The prebuilt libraries for every platform are in the SDK repository’s natives/<platform>/ folder, with a SHA-256 manifest: Windows x64, x86 and ARM64, Linux x86_64 and aarch64, and universal macOS binaries for Intel and Apple silicon. On Linux, install the udev rule from NATIVES.md once, so that ordinary users may open the device.

Questions Racket Developers Ask

Which Racket Versions Does the Package Support?

Racket 8.0 and later on Racket CS, on Windows, Linux and macOS. The package depends only on base.

Does the Racket Package Need a C Compiler?

No. It is Racket over ffi/unsafe, and the native library ships prebuilt for every platform.

Does a Racket Application Need Administrator Rights to Talk to the Dongle?

No, and no driver either: the dongle is a USB HID device that the operating systems handle with their built-in class drivers. On Linux, install the shipped udev rule once so that ordinary users may open it; without the rule the SDK reports access denied and names the cause in its error detail.

Does a Racket License Check Need an Internet Connection?

No. Verification is a local exchange between your program and the dongle over USB: the SDK checks the dongle’s certificate chain to KeyNub’s root and runs a live challenge-response. There is no activation server and no account, so the check works on air-gapped machines.

Who Can Read the License Records on a Dongle?

Anyone holding the dongle: a program opens a session and reads records, and can decrypt data sealed for that dongle. Writing records, erasing them and incrementing counters need your write key. What the dongle guarantees is that none of it is available without the dongle present.

Does It Run on ARM: Windows on ARM, Apple Silicon, aarch64 Linux?

Yes. The SDK ships native libraries for Windows x64, x86 and ARM64, Linux x86_64 and aarch64, and universal macOS binaries for Intel and Apple silicon.

Can a License Written from Racket Be Read by a Program in Another Language?

Yes. Every binding drives the same core library and the same dongle, and records and sealed data are language-neutral bytes. Your issuing tool can be written in one language and your product in another.

Code

Runnable sample: racket/verify-and-read.rkt. Binding source: bindings/racket. Both are Apache-2.0, in the public SDK repository; the prebuilt native libraries are in the repository’s natives/ folder, one per platform.

All supported languages · All industries · Buy a KeyNub · Ask us something