licenz
Offline software license verification for Rust.
Cryptographically signed licenses that work without a server. Verify licenses offline, bind to hardware, detect tampering.
Security model, normative controls, and the online JWS contract are in SECURITY.md. Integrator-owned FMECA items (passphrases, pinning, TPM extensions) are in IMPLEMENTATION_FMECA.md.
Hardware: override default OS fingerprinting with HardwareEnvironment (see src/hardware.rs) on LicenseVerifier / CryptoVerifier / WitnessConfig.
Witness: set WitnessConfig::state_integrity_key when you enable check_clock or check_state_files (both default to off for simple examples).
use ;
const PUBLIC_KEY: &str = include_str!;
Features
- Offline Verification - No server required, works air-gapped
- RSA-SHA256 Signatures - Cryptographically signed, tamper-proof
- Hardware Binding - Tie licenses to MAC address, hostname, disk ID
- Expiration Management - Automatic expiration checking
- Anti-Tamper Detection - Clock manipulation, state file tampering
- Environment Detection - VM, container, cloud provider awareness
- Security Witness Pattern - Clean separation of attestation and enforcement
Installation
The GitHub repository is licenz. On crates.io the package is licenz-core (the shorter name licenz is taken by another crate). In Rust, import with use licenz_core::....
[]
= "0.2.0"
Architecture: Security Witness Pattern
This library follows the Security Witness Pattern, separating:
| Layer | Responsibility | This Crate |
|---|---|---|
| Attestation | Observe, measure, report facts | Yes |
| Enforcement | Decide, act on attestations | Your app / licenz-policy |
The library tells you what it observes. Your application decides what to do about it.
let attestation = witness.attest?;
// Attestation provides facts:
println!;
println!;
println!;
println!;
// Your app decides the response:
if !attestation.is_valid
Quick Start
Most users should use licenz-cli for key generation and license creation. The examples below show the Rust API for programmatic use cases (e.g. building your own license server).
Generate Keys (one-time setup)
use ;
let keypair = generate?;
keypair.save_to_files?;
Create a License (your license server)
use ;
let keypair = load_from_files?;
let generator = new;
let license = builder
.id
.serial
.customer_id
.product_id
.valid_days
.feature
.feature
.hardware_binding
.build?;
let signed = generator.generate?;
generator.save_binary?;
Verify a License (your application)
use ;
const PUBLIC_KEY: &str = include_str!;
Feature Flags
| Flag | Description | Default |
|---|---|---|
hardware-detect |
OS-visible hardware probes (MAC, disk IDs, hostname) | Yes |
online-check |
Online revocation checking and license sync (reqwest + JWS) | |
cloud-metadata |
Cloud container detection (AWS, GCP, Azure) | |
post-quantum |
Post-quantum cryptography (ML-DSA-65, ML-KEM-768) |
# Standard usage (includes hardware binding)
= "0.2.0"
# With online revocation checking
= { = "0.2.0", = ["online-check"] }
# With post-quantum cryptography
= { = "0.2.0", = ["post-quantum"] }
Security Model
What This Library Provides
- Cryptographic verification - RSA-2048/3072/4096 signatures
- Tamper detection - Clock manipulation, state file integrity
- Hardware fingerprinting - Multi-factor hardware binding
- Attestation - Detailed observations about license state
What This Library Does NOT Provide
- Obfuscation - Code is open source and auditable
- Anti-debugging - No runtime protection
- Enforcement - Library reports facts, doesn't make decisions
For enforcement (exit on failure, configurable thresholds, etc.), use the licenz-policy crate or implement your own policy layer.
Threat Model
This library is designed for honest customers in controlled environments, not adversarial reverse engineering. It prevents:
- Casual copying of license files
- Clock manipulation to extend expiration
- License sharing across machines (via hardware binding)
- Accidental use of expired licenses
It does NOT prevent:
- Determined attackers with debuggers
- Binary patching
- Memory manipulation
For high-security needs, combine with code signing, integrity checking, and server-side validation.
Used By
Use Cases
- Desktop Software - Applications that need to work offline
- On-Premise Deployments - Enterprise software behind firewalls
- Air-Gapped Environments - Defense, manufacturing, healthcare
- Embedded Systems - IoT devices without reliable connectivity
- Developer Tools - CLI tools, IDE plugins, build tools
License
MIT License - see LICENSE
Contributing
This crate is the open-source, auditable verification layer of the licenz.dev platform. It's published as source so customers and security teams can inspect the attestation logic. Bug fixes and improvements are welcome, but the scope is intentionally narrow — attestation only, no enforcement.
Related
- licenz-cli - CLI tool for key generation, license creation, and management (free, closed source)
- licenz.dev - Managed license management platform