keynub_licdongle 1.1.1 copy "keynub_licdongle: ^1.1.1" to clipboard
keynub_licdongle: ^1.1.1 copied to clipboard

Client for the KeyNub USB license dongle: verify that a dongle is genuine, read and write its license records, use its counters and encrypt data so that only a dongle can decrypt it. Pure Dart over th [...]

example/keynub_licdongle_example.dart

// The shape of a licence check: verify the dongle, then decrypt something the
// program needs. Run from a clone of the SDK repository it finds the native
// library on its own; elsewhere set KEYNUB_LICDONGLE_LIBRARY or
// LicDongleLibrary.path first. With no dongle attached it prints so and exits.
import 'dart:io';

import 'package:keynub_licdongle/keynub_licdongle.dart';

void main() {
  final ctx = Context();
  try {
    if (ctx.enumerate().isEmpty) {
      print('No dongle attached.');
      return;
    }
    final dongle = ctx.open(); // first dongle, or ctx.open(serial: '...')
    try {
      final result = dongle.verifyGenuine(); // throws unless genuine
      print('Dongle ${result.serial} is genuine.');

      // The sealed parameters would ship with the application; the program
      // holds no other copy, so removing the check removes the data.
      final sealed = dongle.withSession((s) => s.appEncrypt('the parameters', Scope.developer));
      final parameters = dongle.withSession((s) => s.appDecrypt(sealed));
      print('Recovered ${parameters.length} bytes through the dongle.');
    } finally {
      dongle.close();
    }
  } on LicenseDongleError catch (e) {
    stderr.writeln('KeyNub error: $e');
    exitCode = 1;
  } finally {
    ctx.close();
  }
}
0
likes
150
points
21
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Client for the KeyNub USB license dongle: verify that a dongle is genuine, read and write its license records, use its counters and encrypt data so that only a dongle can decrypt it. Pure Dart over the vendor's native library through dart:ffi; Windows, Linux and macOS.

Homepage
Repository (GitHub)
View/report issues

Topics

#licensing #copy-protection #usb #ffi #hardware

License

Apache-2.0 (license)

Dependencies

ffi

More

Packages that depend on keynub_licdongle