Ada reaches the dongle through the SDK’s C ABI with Convention => C records, so the compiler lays them out as C does, and loads the native library at run time — the crate links nothing and needs no library path at build time. For a licensing component that is the right shape: nothing sits in the path of the check that a customer could substitute for something more agreeable. GNAT and gprbuild, through Alire.
alr with keynub_licdongleCode language: Ada (ada)
Reading a license
with KeyNub_LicDongle; use KeyNub_LicDongle;
Ctx : aliased Context;
D : Dongle;
...
Create (Ctx);
Open (Ctx, D); -- first dongle, or Open (Ctx, D, Serial)
declare
R : constant Genuine_Result := Verify_Genuine (D); -- raises unless genuine
begin
Session_Open (D);
declare
License : constant Bytes := Read_Record (D, "license");
begin
...
end;
Session_Close (D);
end;Code language: Ada (ada)
What you are actually protecting
Ada is where avionics, rail and defence tooling is written, and that software ships to a small number of well-funded customers — the profile that makes a hardware dongle worth its price. It also ships as a native binary, and if not Is_Genuine (D) then raise ... compiles to one conditional branch, which a release build can lose to one patch.
What cannot be patched away is data the program needs and only the dongle can decrypt. Seal it once with a developer dongle, ship only the sealed form, and the program has no copy to fall back on:
-- Weak -- one patched branch.
if not Is_Genuine (D) then raise Unlicensed; end if;
-- Strong -- the parameters only exist with the dongle present.
Parameters := Decode (App_Decrypt (D, Sealed_Blob_Shipped_With_The_Program));Code language: Ada (ada)
Context and Dongle are controlled types that close themselves when they go out of scope, so there is no cleanup path to forget. Every failure is an exception of its own (No_Device_Error, Not_Genuine_Error, Auth_Required_Error, …) with the SDK’s text and detail in the message.
Shipping the native library with an Ada application
The keynub_licdongle Alire crate is a static library project for GNAT that loads the core library at run time (a POSIX loader body on Linux and macOS, a LoadLibrary body on Windows, chosen by Alire’s configuration). alr with keynub_licdongle is the whole installation; the crate does not carry the native library.
A shipped program takes keynub_licdongle for its platform from the SDK’s natives/ folder, next to the executable or on the search path, or names it with Set_Library_Path or KEYNUB_LICDONGLE_LIBRARY. On Linux, install the udev rule from NATIVES.md once, so that ordinary users may open the device.
Questions Ada developers ask
Which Ada compilers does the binding support?
GNAT, through Alire, on Windows, Linux and macOS. The crate is Ada 2012 and uses the standard Interfaces.C facilities.
Can safety-related or certified software use a hardware dongle for licensing?
The check is ordinary application code over a documented C API, and the loader body is a few dozen lines that can be reviewed; how a licence check fits your assurance process is a question for that process, and the SDK does not stand in its way.
Does a Ada 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 Ada 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.
Can a license written from Ada 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: ada/src/verify_and_read.adb. Binding source: bindings/ada. 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