Overview / Security & product

licensing

Ed25519 license kit that you embed in your product to license your own users. The product verifies with the public key only, and the issuer signs on the seller's server. It is separate from <code>bundle</code>, which licenses Ethereal itself.

Optional module: turn it on with -DETHEREAL_LICENSING=ONInclude #include <ethereal/cpp/licensing/activation.hpp>C layer

activation.hpp

#include <ethereal/cpp/licensing/activation.hpp>

Human facing activation keys: 'ETL-XXXXX-XXXXX-XXXXX-XXXXX'.

A key proves nothing by itself. It is an identifier that the issuer resolves. A client never grants rights from a well formed key, only the signed license does. What the key gives is a typo caught before any network call.

const

ACTIVATION_KEY_BUFFER

Ethereal::Licensing#
constexpr ETL_UINT32 ACTIVATION_KEY_BUFFER = 40u;

Size of a buffer that holds the formatted key with its terminator.

'PREFIX-XXXXX-XXXXX-XXXXX-XXXXX' with a prefix of up to 8 characters and the final zero.

function

FormatActivationKey

Ethereal::Licensing#
ELicenseStatus FormatActivationKey( ETL_UINT64 uValue, const ETL_CHAR * pPrefix, ETL_CHAR * pOut, ETL_UINT64 uCap ) noexcept;

Formats a 64 bit value as an activation key.

Crockford base32: no 'I', 'L', 'O' or 'U', so '0'/'O' and '1'/'I' are not confused. A check symbol at the end catches typos locally.

uValue
The identifier to encode.
pPrefix
The prefix ('ETL' by default). Configurable so the keys read as the customer's own.
pOut
Output buffer.
uCap
Size of the output buffer. See ACTIVATION_KEY_BUFFER.
eOk, eInvalidArgument or eBufferTooSmall.
function

ParseActivationKey

Ethereal::Licensing#
ELicenseStatus ParseActivationKey( const ETL_CHAR * pKey, ETL_UINT64 * pValueOut, const ETL_CHAR * pPrefix = nullptr ) noexcept;

Reads an activation key back into its value.

Case insensitive, hyphens optional. The key is normalized while read, and the check symbol is verified before returning: a typo stops here, without any network call.

Catches every single character error and every transposition of adjacent characters, which are the mistakes people make when copying a key.

pKey
The key, as the person typed it.
pValueOut
Receives the value.
pPrefix
The expected prefix, or null to accept any.
ELicenseStatus::eMalformed when the check symbol does not match.

clock_guard.hpp

#include <ethereal/cpp/licensing/clock_guard.hpp>

Guard against a clock set back.

A 30 day evaluation license that trusts the system clock lasts forever for whoever sets the clock back. The guard keeps the highest time ever seen (the high water mark) and:

  • Detects and reports. A time below the mark, beyond the tolerance, is a rollback (ELicenseStatus::eClockRollback, and 'bClockRollback' in the manager report).
  • Does not let the rollback count. The manager evaluates the validity with CClockGuard::EffectiveNow, the maximum of the clock and the mark. Setting the clock back extends nothing.

The mark also rises with signed times (the license issue time, the revocation list time, the lease server time), so a rollback is caught even on the first run.

Limit: the mark lives wherever the integrator stores it (the IClockMarkStore seam, with several slots such as a file, the registry or a data folder). Whoever erases every slot erases the guard memory. The checksum of each slot only catches corruption and copies from another product. It is not security, and a client running on the adversary's machine cannot have that. It is friction, like the rest of local licensing.

const

CLOCK_MARK_SIZE

Ethereal::Licensing#
constexpr ETL_UINT32 CLOCK_MARK_SIZE = 32u;

Size of a mark in one slot, in bytes.

struct

IClockMarkStore

Ethereal::Licensing#
C++
struct   IClockMarkStore
{
    /// @brief  Number of slots.
    ///
    virtual ETL_UINT32 SlotCount() ETL_NOEXCEPT = 0;


    ///
    /// Read
    ///
    /// @brief  Reads the @ref CLOCK_MARK_SIZE bytes of a slot.
    ///
    /// @param uSlot    The slot.
    /// @param pOut        Receives the bytes.
    ///
    /// @return  false when the slot is empty.
    ///
    virtual bool Read( ETL_UINT32 uSlot, ETL_UINT8 * pOut ) ETL_NOEXCEPT = 0;


    ///
    /// Write
    ///
    /// @brief  Writes the @ref CLOCK_MARK_SIZE bytes of a slot.
    ///
    /// @param uSlot    The slot.
    /// @param pData    The bytes.
    ///
    /// @return  false when the write failed.
    ///
    virtual bool Write( ETL_UINT32 uSlot, const ETL_UINT8 * pData ) ETL_NOEXCEPT = 0;


    /// @brief  Virtual destructor.
    ///
    virtual ~IClockMarkStore() = default;
};

Where the mark is stored. Several slots: the guard writes to all of them and reads the highest intact one.

struct

SClockGuardParams

Ethereal::Licensing#
C++
struct   SClockGuardParams   final
{
    /// @brief  Mark store. Required.
    IClockMarkStore *    pStore = nullptr;

    /// @brief  Goes into the checksum, so a mark from another product is not valid here.
    ETL_UINT64            uProductHash = 0u;

    /// @brief  How far the clock may go back without counting as a rollback (NTP
    ///             adjustments, a BIOS clock slightly behind). Two hours by default.
    ETL_INT64            iToleranceSeconds = 2 * 3600;

    /// @brief  Interval between writes when only the clock raises the mark (a signed
    ///             time writes at once). Avoids one write per query.
    ETL_INT64            iPersistEverySeconds = 60;
};

Clock guard parameters.

class

CClockGuard

Ethereal::Licensing#

The clock guard.

class CClockGuard final
function

Init

#
ELicenseStatus Init( const SClockGuardParams & Params ) noexcept;

Reads every slot and keeps the highest intact mark.

Params
Guard parameters.
eOk or eInvalidArgument.
function

Observe

#
ELicenseStatus Observe( ETL_INT64 iNowUnix ) noexcept;

Feeds one reading of the system clock.

iNowUnix
The clock reading.
ELicenseStatus::eClockRollback when iNowUnix is below the mark by more than the tolerance. ELicenseStatus::eOk otherwise (and the mark rises when the reading is higher).
function

ObserveTrusted

#
void ObserveTrusted( ETL_INT64 iSignedUnix ) noexcept;

Feeds a signed time (a license issue time, a server time). The mark rises to it and is written at once.

iSignedUnix
The signed time.
function

Flush

#
ELicenseStatus Flush() noexcept;

Writes the mark now, to every slot.

function

EffectiveNow

#
ETL_INT64 EffectiveNow( ETL_INT64 iNowUnix ) const noexcept;

The maximum of iNowUnix and the mark: the time used to evaluate validity.

function

RolledBack

#
bool RolledBack() const noexcept

Whether the last observation was a rollback.

function

RollbackSeconds

#
ETL_INT64 RollbackSeconds() const noexcept

Size of the rollback of the last observation, in seconds (zero without one).

function

HighWater

#
ETL_INT64 HighWater() const noexcept

The high water mark.

function

ValidSlots

#
ETL_UINT32 ValidSlots() const noexcept

Number of slots that held an intact mark in Init. Zero on a machine where the product already ran is a signal (someone erased them).

function

WriteFailures

#
ETL_UINT32 WriteFailures() const noexcept

Number of slot writes that failed since Init.

format.hpp

#include <ethereal/cpp/licensing/format.hpp>

The license format, defined and versioned.

The format is a product surface that will outlive several releases. Two rules hold:

1. Canonical encoding. Fixed field order, fixed width little-endian integers, length prefixed strings. Two encoders producing different bytes for the same license is a signature failure waiting to happen.

2. Verify the signature first, parse the payload after. Unauthenticated bytes are never parsed.

const

LICENSE_MAX_STR

Ethereal::Licensing#
constexpr ETL_UINT32 LICENSE_MAX_STR = 64u;

Size of the fixed strings (names, organization, e-mail).

const

LICENSE_MAX_FEATURES

Ethereal::Licensing#
constexpr ETL_UINT32 LICENSE_MAX_FEATURES = 16u;

Maximum number of named features.

const

LICENSE_MAX_LIMITS

Ethereal::Licensing#
constexpr ETL_UINT32 LICENSE_MAX_LIMITS = 16u;

Maximum number of named limits.

const

LICENSE_EXT_CRITICAL

Ethereal::Licensing#
constexpr ETL_UINT16 LICENSE_EXT_CRITICAL = 1u;

The critical extension bit.

const

LICENSE_MAX_EXTENSION_BYTES

Ethereal::Licensing#
constexpr ETL_UINT32 LICENSE_MAX_EXTENSION_BYTES = 4096u;

Maximum number of extension bytes (headers included) in a license.

const

LICENSE_FILE_MAX

Ethereal::Licensing#
constexpr ETL_UINT32 LICENSE_FILE_MAX = 8192u;

A buffer that holds any license file (with its extensions).

struct

SLicenseExtension

Ethereal::Licensing#
C++
struct   SLicenseExtension   final
{
    /// @brief  Extension tag.
    ETL_UINT16                        uTag = 0u;

    /// @brief  Flags. Only @ref LICENSE_EXT_CRITICAL is defined.
    ETL_UINT16                        uFlags = 0u;

    /// @brief  Extension bytes.
    std::span< const ETL_UINT8 >    Data;
};

One extension, to be written (issuer) or read (points into the license bytes).

function

NextLicenseExtension

Ethereal::Licensing#
bool NextLicenseExtension( std::span< const ETL_UINT8 > & Rest, SLicenseExtension * pOut ) noexcept;

Walks an extension area that was already verified (the one returned by 'DecodeAndVerify').

Takes the first extension of Rest into pOut and advances Rest.

Rest
The remaining extension area. Advanced past the extension.
pOut
Receives the extension.
false when the area is exhausted.
struct

SNamedLimit

Ethereal::Licensing#
C++
struct   SNamedLimit   final
{
    /// @brief  Hash of the limit name (see @ref HashName).
    ETL_UINT64    uNameHash = 0u;

    /// @brief  Value of the limit.
    ETL_INT64    iValue    = 0;
};

A name hash to value pair, for the named limits.

struct

SLicense

Ethereal::Licensing#
C++
struct   SLicense   final
{
    /// @brief  'sizeof( SLicense )'.
    ETL_UINT32        iStructSize = sizeof( SLicense );

    /// @brief  Schema version of the payload, distinct from the format version.
    ETL_UINT32        uSchemaVersion = 0u;

    /// @brief  Unique identifier. The handle for revocation and auditing.
    ETL_UINT64        uLicenseId = 0u;

    /// @brief  Hash of the product identifier.
    ETL_UINT64        uProductHash = 0u;

    /// @brief  Edition identifier.
    ETL_UINT32        uEditionId = 0u;

    /// @brief  License type.
    ELicenseType    eType = ELicenseType::ePerpetual;

    /// @brief  Seat model.
    ESeatModel        eSeat = ESeatModel::eNodeLocked;

    /// @brief  Padding, always zero.
    ETL_UINT8        uPadding = 0u;

    /// @brief  Number of seats.
    ETL_UINT32        uSeatCount = 0u;

    /// @brief  Unix times. Zero in @ref iExpiresAtUnix means perpetual.
    ETL_INT64        iIssuedAtUnix = 0;
    ETL_INT64        iExpiresAtUnix = 0;

    /// @brief  The field that matters for our model: up to which build date this
    ///             license covers updates. See @ref IsBuildCovered.
    ETL_INT64        iUpdateWindowEndUnix = 0;

    /// @brief  Grace period, in days.
    ETL_UINT32        uGracePeriodDays = 0u;

    /// @brief  Numeric features 0..63, one bit each.
    ETL_UINT64        uFeatureBits = 0u;

    /// @brief  Named features: the hashes of the names present.
    ETL_UINT32        uFeatureCount = 0u;
    ETL_UINT64        aFeatureHashes[ LICENSE_MAX_FEATURES ] = {};

    /// @brief  Named limits.
    ETL_UINT32        uLimitCount = 0u;
    SNamedLimit        aLimits[ LICENSE_MAX_LIMITS ] = {};

    /// @brief  Machine binding: the hashes and the M of N threshold.
    ETL_UINT32        uBindingCount = 0u;
    ETL_UINT32        uBindingThreshold = 0u;
    ETL_UINT64        aBindingHashes[ LICENSE_MAX_IDENTITY ] = {};

    /// @brief  The watermark: who the licensee is. Traceable and revocable.
    ETL_CHAR        aLicenseeName[ LICENSE_MAX_STR ] = {};
    ETL_CHAR        aLicenseeOrg[ LICENSE_MAX_STR ] = {};
    ETL_CHAR        aLicenseeEmail[ LICENSE_MAX_STR ] = {};
    ETL_UINT64        uCustomerId = 0u;

    /// @brief  Key that signed the license, for key rotation.
    ETL_UINT32        uKeyId = 0u;
};

A parsed license, as seen by the caller.

Fixed size, no heap. The client verification path does not allocate. Everything the license carries fits here.

function

CanonicalPayloadSize

Ethereal::Licensing#
ETL_UINT64 CanonicalPayloadSize() noexcept;

Size of the canonical payload encoding.

The size is fixed, but exposed through a function so callers do not hard code it.

function

EncodePayload

Ethereal::Licensing#
ELicenseStatus EncodePayload( const SLicense & Lic, ETL_UINT8 * pOut, ETL_UINT64 uCap, ETL_UINT64 * pWritten ) noexcept;

Writes the payload in canonical form. Writes neither header nor signature.

Deterministic: the same license gives the same bytes on any platform and compiler. That is what makes the signature verify on the other side.

Lic
The license.
pOut
Output buffer.
uCap
Size of the output buffer.
pWritten
Receives the number of bytes written.
eOk, eInvalidArgument or eBufferTooSmall.
function

DecodePayload

Ethereal::Licensing#
ELicenseStatus DecodePayload( std::span< const ETL_UINT8 > In, SLicense * pOut ) noexcept;

Reads a canonical payload back into a license. Does not verify a signature.

Call only after the signature verified. See DecodeAndVerify, which enforces the order.

In
The payload bytes.
pOut
Receives the license.
eOk, eInvalidArgument or eMalformed.
function

WriteLicenseFile

Ethereal::Licensing#
ELicenseStatus WriteLicenseFile( const SLicense & Lic, const ETL_UINT8 * pSignature, ETL_UINT8 * pOut, ETL_UINT64 uCap, ETL_UINT64 * pWritten ) noexcept;

Serializes header, payload and signature into a binary file.

Called by the issuer, after signing the canonical payload.

Lic
The license.
pSignature
The 64 bytes of the signature over the canonical payload.
pOut
Output buffer.
uCap
Size of the output buffer.
pWritten
Receives the number of bytes written.
eOk, eInvalidArgument or eBufferTooSmall.
function

DecodeAndVerify

Ethereal::Licensing#
ELicenseStatus DecodeAndVerify( std::span< const ETL_UINT8 > In, ISignatureVerifier * pVerifier, const ETL_UINT8 * pKeys, const ETL_UINT32 * pKeyIds, ETL_UINT32 uKeyCount, SLicense * pOut ) noexcept;

The right order in a single function: verify the signature, then parse.

Reads the header, picks the key by uKeyId, verifies the signature over the canonical payload, and only then parses the payload.

No payload byte is touched before the signature verifies. This is structural, not a convention: a caller cannot parse without verifying, because there is no other way in.

In
The whole file.
pVerifier
The signature seam.
pKeys
The customer public keys, in order.
pKeyIds
Their identifiers, in the same order.
uKeyCount
Number of keys.
pOut
Receives the parsed license, only on success.
eOk, or the reason for the rejection.
function

DecodeAndVerify

Ethereal::Licensing#
ELicenseStatus DecodeAndVerify( std::span< const ETL_UINT8 > In, ISignatureVerifier * pVerifier, const ETL_UINT8 * pKeys, const ETL_UINT32 * pKeyIds, ETL_UINT32 uKeyCount, SLicense * pOut, std::span< const ETL_UINT8 > * pExtensions ) noexcept;

Same as above, and also returns the extension area (verified, points into In, empty without extensions) in pExtensions.

function

WriteLicenseFileWithExtensions

Ethereal::Licensing#
ELicenseStatus WriteLicenseFileWithExtensions( const SLicense & Lic, std::span< const ETL_UINT8 > EncodedExtensions, const ETL_UINT8 * pSignature, ETL_UINT8 * pOut, ETL_UINT64 uCap, ETL_UINT64 * pWritten ) noexcept;

Serializes with extensions: header + signature + payload + extensions. The signature (pSignature) covers the payload and the extensions, in the form produced by EncodeExtensions.

function

EncodeExtensions

Ethereal::Licensing#
ELicenseStatus EncodeExtensions( std::span< const SLicenseExtension > Ext, ETL_UINT8 * pOut, ETL_UINT64 uCap, ETL_UINT64 * pWritten ) noexcept;

Encodes the extensions. The tags must be strictly increasing and the only allowed flag is LICENSE_EXT_CRITICAL. Empty for no extensions.

issuer.hpp

#include <ethereal/cpp/licensing/issuer.hpp>

The signing side of the Licensing module.

A library the customer links into their backend. It is never shipped to the end user.

The private key comes through an 'ISigner' seam, so an HSM or a KMS can be plugged in without the key passing through the process memory. A key file loaded in memory is the development path, not the production one.

struct

ISigner

Ethereal::Licensing#
C++
struct   ISigner
{
    ///
    /// Sign
    ///
    /// @brief  Signs @p Message, writing 64 bytes to @p pSignature.
    ///
    /// @param Message        The bytes to sign.
    /// @param pSignature    Receives the 64 byte signature.
    ///
    /// @return  false when the signing source refused. A signature is never made up:
    ///              failing here is better than issuing a license that does not verify.
    ///
    virtual bool Sign( std::span< const std::uint8_t > Message,
                       std::uint8_t * pSignature ) ETL_NOEXCEPT = 0;

    /// @brief  Virtual destructor.
    ///
    virtual ~ISigner() = default;
};

The signer. The private key lives on the other side of this seam.

class

CIssuer

Ethereal::Licensing#

The issuer. Produces signed licenses.

class CIssuer final
function

Init

#
ELicenseStatus Init( ISigner * pSigner, ETL_UINT32 uKeyId ) noexcept;

Sets the signer and the key identifier.

pSigner
The signing seam.
uKeyId
Identifier of the signing key.
eOk or eInvalidArgument. eNotLicensed when the library is not licensed.
function

IssueLicense

#
ELicenseStatus IssueLicense( const SLicense & Spec, ETL_UINT8 * pOut, ETL_UINT64 uCap, ETL_UINT64 * pWritten ) noexcept;

Issues a license from the specification.

Deterministic: the same specification with the same key gives identical bytes. That makes batch issuing testable and releases reproducible.

The uKeyId of the specification is ignored. The one given to Init is used.

Spec
The license to sign.
pOut
Output buffer for the binary file.
uCap
Size of the output buffer.
pWritten
Receives the number of bytes written.
eOk, or the reason for the failure.
function

IssueLicense

#
ELicenseStatus IssueLicense( const SLicense & Spec, std::span< const SLicenseExtension > Extensions, ETL_UINT8 * pOut, ETL_UINT64 uCap, ETL_UINT64 * pWritten ) noexcept;

Same as above, with extensions (see format.hpp): signed fields that an older client ignores, unless they are critical. In strictly increasing tag order.

function

IssueRevocationList

#
ELicenseStatus IssueRevocationList( std::span< ETL_UINT64 > Ids, ETL_UINT64 uProductHash, ETL_UINT64 uSequence, ETL_INT64 iIssuedAtUnix, ETL_UINT8 * pOut, ETL_UINT64 uCap, ETL_UINT64 * pWritten ) noexcept;

Issues a signed revocation list (revocation.hpp).

Ids is sorted and deduplicated in place (the caller provides the memory, nothing is allocated). uSequence must increase from list to list: the client rejects a list older than the last one it accepted.

Ids
The revoked license identifiers. Sorted in place.
uProductHash
Hash of the product identifier.
uSequence
Serial number of the list.
iIssuedAtUnix
Issue time.
pOut
Output buffer.
uCap
Size of the output buffer.
pWritten
Receives the size: 16 + 64 + 40 + 8 per identifier.
eOk, or the reason for the failure.
function

IssueActivationResponse

#
ELicenseStatus IssueActivationResponse( std::span< const ETL_UINT8 > Request, const SLicense & Spec, ETL_INT64 iNowUnix, ETL_UINT8 * pOut, ETL_UINT64 uCap, ETL_UINT64 * pWritten, std::span< const SLicenseExtension > Extensions = {} ) noexcept;

Answers an offline activation request (offline_activation.hpp).

The activation key is checked before, in the vendor database. This function does not know which keys exist or how many times they were activated. Spec is the license of that key. Its binding is replaced by the identity of the request, with the threshold of Spec when it fits (1..N) and the majority otherwise.

Request
The encoded activation request.
Spec
The license of the activation key.
iNowUnix
Issuer time. Used as the license issue time when Spec has none.
pOut
Output buffer.
uCap
Size of the output buffer.
pWritten
Receives the number of bytes written.
Extensions
Extensions of the license.
eOk, or the reason for the failure.

lease.hpp

#include <ethereal/cpp/licensing/lease.hpp>

Floating license, client side.

N seats shared by whoever asks for them. The reference server is 'CLeaseServer' (lease_server.hpp), in the vendor backend or in the network of the buying organization.

A seat is a loan with a deadline. The server grants a lease that expires, and the client renews it halfway through. A client that dies (crash, closed laptop, network cut) does not give the seat back, and does not need to: the lease expires and the server reclaims it. This prevents seats stuck forever, the number one support request of floating licenses.

Without network, the seat is valid until the end of the lease, and no longer. The client measures the deadline with its own clock, from what the server said was left (not from the server time), so the two clocks do not need to agree.

The server response is signed and echoes the request nonce: a recorded grant cannot be replayed to keep a seat, and a fake server grants nothing.

Authenticated request (protocol 2). With a secret per installation (32 bytes, given by the vendor to each client, at activation for example) and an 'IMac', the request carries a sequence number and an HMAC-SHA-256. A server that knows the secrets rejects a request without the right HMAC (a client posing as another, or making up identities to take every seat) and a request with an old sequence (the replay of a recorded request, which would keep or release someone else's seat). Without secrets, protocol 1: the server counts seats for honest clients and does not defend against impersonation.

const

LEASE_REQUEST_SIZE

Ethereal::Licensing#
constexpr ETL_UINT32 LEASE_REQUEST_SIZE = 56u;

Size of a lease request (protocol 1, not authenticated).

const

LEASE_REQUEST_AUTH_SIZE

Ethereal::Licensing#
constexpr ETL_UINT32 LEASE_REQUEST_AUTH_SIZE = 88u;

Size of an authenticated request (protocol 2: sequence and HMAC).

const

LEASE_CLIENT_SECRET_SIZE

Ethereal::Licensing#
constexpr ETL_UINT32 LEASE_CLIENT_SECRET_SIZE = 32u;

Size of a client secret.

const

LEASE_RESPONSE_SIZE

Ethereal::Licensing#
constexpr ETL_UINT32 LEASE_RESPONSE_SIZE = 16u + 64u + 64u;

Size of a lease response (envelope, signature and payload).

enum

ELeaseOp

Ethereal::Licensing#
C++
enum class   ELeaseOp : ETL_UINT8
{
    /// @brief  Acquire a seat, renew the lease, release the seat.
    eAcquire = 1, eRenew, eRelease
};

Lease operation.

enum

ELeaseResult

Ethereal::Licensing#
C++
enum class   ELeaseResult : ETL_UINT8
{
    /// @brief  The lease is this one, until this deadline.
    eGranted = 0,

    /// @brief  Every seat is taken.
    eNoSeat,

    /// @brief  The renewal came late (the lease expired) or the lease does not exist.
    eUnknownLease,

    /// @brief  Released.
    eReleased,

    /// @brief  The server does not serve this license or this product.
    eWrongLicense,

    /// @brief  The server requires authentication, and the HMAC does not verify (or is missing).
    eUnauthenticated,

    /// @brief  The sequence is not newer than the last accepted one (a replay).
    eStaleSequence
};

What the server answered.

struct

ILeaseTransport

Ethereal::Licensing#
C++
struct   ILeaseTransport
{
    ///
    /// Exchange
    ///
    /// @brief  Sends @p Request and receives the response in @p pResponse.
    ///
    /// @param Request        The request bytes.
    /// @param pResponse    Receives the response.
    /// @param uCap            Size of @p pResponse.
    /// @param pWritten        Receives the response size.
    ///
    /// @return  false when there was no response (network, server down).
    ///
    virtual bool Exchange( std::span< const ETL_UINT8 > Request,
                           ETL_UINT8 * pResponse, ETL_UINT64 uCap,
                           ETL_UINT64 * pWritten ) ETL_NOEXCEPT = 0;

    /// @brief  Virtual destructor.
    ///
    virtual ~ILeaseTransport() = default;
};

Exchanges a request for a response. Synchronous: the integrator picks the thread (the client 'Tick' calls it at most once).

struct

SLeaseClientParams

Ethereal::Licensing#
C++
struct   SLeaseClientParams   final
{
    /// @brief  'sizeof( SLeaseClientParams )'.
    ETL_UINT32                iStructSize = sizeof( SLeaseClientParams );

    /// @brief  Number of public keys.
    ETL_UINT32                uKeyCount = 0u;

    /// @brief  The transport seam. Required.
    ILeaseTransport *        pTransport = nullptr;

    /// @brief  The signature seam. Required.
    ISignatureVerifier *    pVerifier = nullptr;

    /// @brief  The public keys, in order: @c uKeyCount * 32 bytes.
    const ETL_UINT8 *        pPublicKeys = nullptr;

    /// @brief  The key identifiers, in the same order.
    const ETL_UINT32 *        pKeyIds = nullptr;

    /// @brief  Hash of the product identifier.
    ETL_UINT64                uProductHash = 0u;

    /// @brief  The floating license (its 'uLicenseId').
    ETL_UINT64                uLicenseId = 0u;

    /// @brief  Who this client is to the server (stable per installation, for example
    ///             a hash of the machine identity). Never zero.
    ETL_UINT64                uClientId = 0u;

    /// @brief  Different on every start (from the system random generator). The
    ///             nonces come from it, and a repeated nonce would allow replaying a grant
    ///             recorded in an earlier run.
    ETL_UINT64                uNonceSeed = 0u;

    /// @brief  How long to wait after a failure (network, no seat) before trying again.
    ETL_INT64                iRetrySeconds = 30;

    /// @brief  (optional) The secret of this installation, @ref LEASE_CLIENT_SECRET_SIZE
    ///             bytes, and the authenticator. With both, requests are authenticated
    ///             (protocol 2).
    const ETL_UINT8 *        pClientSecret = nullptr;
    IMac *                    pMac = nullptr;
};

Lease client parameters.

enum

ELeaseState

Ethereal::Licensing#
C++
enum class   ELeaseState : ETL_UINT8
{
    /// @brief  No seat (yet, or the server refused).
    eNoLease = 0,

    /// @brief  Holding a seat, within the deadline.
    eHeld,

    /// @brief  Held one and lost it (the lease expired without renewal, or the server forgot it).
    eLost
};

State of the lease client.

class

CLeaseClient

Ethereal::Licensing#

The lease client. No thread: the integrator calls Tick.

class CLeaseClient final
function

Init

#
ELicenseStatus Init( const SLeaseClientParams & Params ) noexcept;

Validates the parameters and resets the client.

Params
Client parameters.
eOk or eInvalidArgument. eNotLicensed when the library is not licensed.
function

Tick

#
ELicenseStatus Tick( ETL_INT64 iNowUnix ) noexcept;

Acquires, renews or waits, depending on the deadline. At most one exchange per call (two when a late renewal turns into a new request).

iNowUnix
Current time on this client clock.
What happened in this call: ELicenseStatus::eOk (with a seat, or nothing to do), ELicenseStatus::eNoSeat, ELicenseStatus::eTransportError (the seat, if any, lasts until the deadline), ELicenseStatus::eReplay (a response that does not belong to this request, or the server found the sequence old), ELicenseStatus::eBadSignature (the response is not from the server, or the server did not accept this client HMAC). Whether a seat is held is told by HasSeat.
function

Release

#
ELicenseStatus Release( ETL_INT64 iNowUnix ) noexcept;

Gives the seat back (on shutdown). Without network, the deadline gives it back by itself.

iNowUnix
Current time on this client clock.
The result of the exchange, or eOk when no seat was held.
function

HasSeat

#
bool HasSeat( ETL_INT64 iNowUnix ) const noexcept;

Whether a seat is held, within the deadline.

function

State

#
ELeaseState State() const noexcept

Current state.

function

ExpiresAtLocal

#
ETL_INT64 ExpiresAtLocal() const noexcept

When the seat expires, on this client clock.

function

LastServerTime

#
ETL_INT64 LastServerTime() const noexcept

Server time in the last signed response (for the CClockGuard).

function

SeatsInUse

#
ETL_UINT32 SeatsInUse() const noexcept

Seats in use and total seats, in the last response.

function

SeatCount

#
ETL_UINT32 SeatCount() const noexcept

lease_server.hpp

#include <ethereal/cpp/licensing/lease_server.hpp>

Reference lease server.

Signing side: it is never shipped to the end user. One floating license per instance. The seats live in a table the integrator provides (no heap).

It is a reference, not a service: it has no networking (the integrator connects 'Handle' to a socket, to HTTP, to whatever it has). What it guarantees: never more seats than the license allows, reclaiming expired leases, and a repeated request that does not take two seats. With secrets ('ILeaseSecrets') it only accepts authenticated requests with a new sequence (see lease.hpp). The table can be exported and imported ('ExportState' / 'ImportState'): the integrator stores it, and a server that restarts keeps the leases instead of forgetting them.

struct

SLeaseSeat

Ethereal::Licensing#
C++
struct   SLeaseSeat   final
{
    /// @brief  Lease identifier. Zero when the seat is free.
    ETL_UINT64    uLeaseId = 0u;

    /// @brief  Client holding the seat.
    ETL_UINT64    uClientId = 0u;

    /// @brief  Lease end, in server time.
    ETL_INT64    iExpiresAtUnix = 0;

    /// @brief  Sequence of the last accepted request (protocol 2).
    ETL_UINT64    uLastSequence = 0u;
};

A seat in the server table. Free when 'uLeaseId' is zero or the lease expired.

struct

ILeaseSecrets

Ethereal::Licensing#
C++
struct   ILeaseSecrets
{
    ///
    /// SecretFor
    ///
    /// @brief  Writes the secret of @p uClientId to @p pOut32.
    ///
    /// @param uClientId    The client.
    /// @param pOut32        Receives the 32 byte secret.
    ///
    /// @return  false when the client is unknown.
    ///
    virtual bool SecretFor( ETL_UINT64 uClientId, ETL_UINT8 * pOut32 ) ETL_NOEXCEPT = 0;

    /// @brief  Virtual destructor.
    ///
    virtual ~ILeaseSecrets() = default;
};

The client secrets, on the server side.

function

LeaseServerStateSize

Ethereal::Licensing#
constexpr ETL_UINT64 LeaseServerStateSize( const ETL_UINT32 uSeats ) noexcept

Size in bytes of the exported state of a server with uSeats seats.

struct

SLeaseServerParams

Ethereal::Licensing#
C++
struct   SLeaseServerParams   final
{
    /// @brief  The signing seam. Required.
    ISigner *                pSigner = nullptr;

    /// @brief  Identifier of the signing key.
    ETL_UINT32                uKeyId = 0u;

    /// @brief  Number of seats of the license ('SLicense::uSeatCount').
    ETL_UINT32                uSeatCount = 0u;

    /// @brief  Hash of the product identifier.
    ETL_UINT64                uProductHash = 0u;

    /// @brief  Identifier of the floating license.
    ETL_UINT64                uLicenseId = 0u;

    /// @brief  The table, with at least @ref uSeatCount slots. Lives as long as the server.
    std::span< SLeaseSeat >    Seats;

    /// @brief  Lease length. Five minutes by default: a client that dies holds the seat
    ///             at most this long.
    ETL_INT64                iLeaseSeconds = 300;

    /// @brief  Mixed into the lease identifiers (different on every start).
    ETL_UINT64                uLeaseIdSeed = 0u;

    /// @brief  (optional) The client secrets and the authenticator. With both, only
    ///             authenticated requests (protocol 2) with a new sequence are accepted.
    ILeaseSecrets *            pSecrets = nullptr;
    IMac *                    pMac = nullptr;
};

Lease server parameters.

class

CLeaseServer

Ethereal::Licensing#

The reference lease server.

class CLeaseServer final
function

Init

#
ELicenseStatus Init( const SLeaseServerParams & Params ) noexcept;

Validates the parameters and clears the seat table.

Params
Server parameters.
eOk or eInvalidArgument. eNotLicensed when the library is not licensed.
function

Handle

#
ELicenseStatus Handle( std::span< const ETL_UINT8 > Request, ETL_INT64 iNowUnix, ETL_UINT8 * pOut, ETL_UINT64 uCap, ETL_UINT64 * pWritten ) noexcept;

Answers a request with a signed response of LEASE_RESPONSE_SIZE bytes.

Request
The request bytes.
iNowUnix
The server time.
pOut
Output buffer.
uCap
Size of the output buffer.
pWritten
Receives the response size.
ELicenseStatus::eOk when a response was written (even "no seat"). ELicenseStatus::eMalformed when the request cannot be read (and nothing is answered).
function

ExportState

#
ELicenseStatus ExportState( ETL_UINT8 * pOut, ETL_UINT64 uCap, ETL_UINT64 * pWritten ) const noexcept;

Writes the state (the leases and the counter), LeaseServerStateSize bytes, for the integrator to store after each 'Handle' (or from time to time: losing the state only makes the clients ask again).

pOut
Output buffer.
uCap
Size of the output buffer.
pWritten
Receives the state size.
eOk, eInvalidArgument or eBufferTooSmall.
function

ImportState

#
ELicenseStatus ImportState( std::span< const ETL_UINT8 > In ) noexcept;

Restores an exported state (after 'Init').

It must be from the same license and with the same number of seats. A damaged state is rejected and nothing changes.

In
The exported state.
eOk, eInvalidArgument, eMalformed or eWrongProduct.
function

SeatsInUse

#
ETL_UINT32 SeatsInUse( ETL_INT64 iNowUnix ) const noexcept;

Number of seats in use at time iNowUnix.

licensing_common.hpp

#include <ethereal/cpp/licensing/licensing_common.hpp>

Shared types of the Licensing module.

This does not license Ethereal. It is a kit we sell, which the customer embeds in their product to license their own users. The customer is the authority, not us. The module has no endpoint and never phones home. A build without 'ETL_LICENSING' contains none of this.

Asymmetric only, Ed25519. A symmetric key can be forged as soon as someone dumps the binary, because the key that verifies is the key that signs. The customer embeds the public key and verifies. The private key never leaves the customer's infrastructure.

struct

ISignatureVerifier

Ethereal::Licensing#
C++
struct   ISignatureVerifier
{
    ///
    /// Verify
    ///
    /// @brief  Verifies @p Signature over @p Message with @p PublicKey.
    ///
    /// @param Message        The signed bytes.
    /// @param Signature    The signature.
    /// @param PublicKey    The public key.
    ///
    /// @return  true only when the signature is from that key over that message.
    ///              It does not say why it failed: the difference would only help a forger.
    ///
    virtual bool Verify( std::span< const std::uint8_t > Message,
                         std::span< const std::uint8_t > Signature,
                         std::span< const std::uint8_t > PublicKey ) ETL_NOEXCEPT = 0;

    /// @brief  Virtual destructor.
    ///
    virtual ~ISignatureVerifier() = default;
};

Verifies a signature. The module does not link the Crypto module.

The customer product only verifies. It checks with the embedded public key, and that is the only cryptographic material it carries.

Crypto provides an Ed25519 implementation through 'ethereal-licensing-crypto-glue'. The integrator may supply its own.

struct

IMac

Ethereal::Licensing#
C++
struct   IMac
{
    ///
    /// Compute
    ///
    /// @brief  Writes the 32 byte authenticator of @p Message with @p Key to @p pOut32.
    ///
    /// @param Key            The secret key.
    /// @param Message        The bytes to authenticate.
    /// @param pOut32        Receives the 32 bytes.
    ///
    /// @return  false when the authenticator could not be computed.
    ///
    virtual bool Compute( std::span< const std::uint8_t > Key,
                          std::span< const std::uint8_t > Message,
                          std::uint8_t * pOut32 ) ETL_NOEXCEPT = 0;

    /// @brief  Virtual destructor.
    ///
    virtual ~IMac() = default;
};

Keyed message authenticator (HMAC-SHA-256). The module does not link the Crypto module. The glue provides one ('Glue::CHmacSha256').

Used by the lease client to prove its identity to the server (see lease.hpp).

enum

EIdentityComponent

Ethereal::Licensing#
C++
enum class   EIdentityComponent : ETL_UINT8
{
    /// @brief  CPU signature.
    eCpuSignature = 0,

    /// @brief  Machine GUID of the operating system.
    eMachineGuid,

    /// @brief  Serial of the primary disk.
    ePrimaryDiskSerial,

    /// @brief  Serial of the baseboard.
    eBaseboardSerial,

    /// @brief  MAC address of the primary network interface.
    ePrimaryMacAddress,

    /// @brief  Host name.
    eHostname,

    /// @brief  Identifier of the operating system installation.
    eOsInstallId,

    /// @brief  Defined by the integrator.
    eCustomerDefined
};

Source of a machine identity component, for the machine binding.

struct

SIdentityComponent

Ethereal::Licensing#
C++
struct   SIdentityComponent   final
{
    /// @brief  Source of the component.
    EIdentityComponent    eKind = EIdentityComponent::eCustomerDefined;

    /// @brief  Padding, always zero.
    ETL_UINT8            uPadding[ 7 ] = {};

    /// @brief  Hash of the value. Zero when the component does not exist on this machine.
    ETL_UINT64            uHash = 0u;
};

One identity component, already hashed.

The raw serial never leaves the machine and never goes into the license. Only the hash does. This matters for GDPR and LGPD, and customers will be asked about it.

struct

IMachineIdentity

Ethereal::Licensing#
C++
struct   IMachineIdentity
{
    ///
    /// Collect
    ///
    /// @brief  Fills @p Out with the components this machine has.
    ///
    /// @param Out        Receives the components.
    ///
    /// @return  Number of components written.
    ///
    virtual std::size_t Collect( std::span< SIdentityComponent > Out ) ETL_NOEXCEPT = 0;

    /// @brief  Virtual destructor.
    ///
    virtual ~IMachineIdentity() = default;
};

Source of the machine identity. The Platform module provides one through glue.

enum

ELicenseStatus

Ethereal::Licensing#
C++
enum class   ELicenseStatus : ETL_UINT32
{
    /// @brief  Success.
    eOk = 0,

    /// @brief  An argument is null or out of range.
    eInvalidArgument,

    /// @brief  The buffer is too small. Two pass protocol.
    eBufferTooSmall,

    /// @brief  The signature does not verify. Nothing more is said.
    eBadSignature,

    /// @brief  The signing key is not among the keys the customer has.
    eUnknownKeyId,

    /// @brief  The bytes are not a license of this format.
    eMalformed,

    /// @brief  The license uses a format version this client cannot read.
    eSchemaTooNew,

    /// @brief  Past the expiry date.
    eExpired,

    /// @brief  Not valid yet (the clock is before the start).
    eNotYetValid,

    /// @brief  This build is later than the paid update window.
    eBuildNotCovered,

    /// @brief  The machine does not match the binding (below the M of N threshold).
    eMachineMismatch,

    /// @brief  Listed in the revocation list.
    eRevoked,

    /// @brief  The license belongs to another product.
    eWrongProduct,

    /// @brief  No license is loaded.
    eNoLicense,

    /// Added on 2026-09-28 (the online layers). At the end, so the values above
    /// do not change.

    /// @brief  A revocation list older than the last accepted one (anti-rollback).
    eStale,

    /// @brief  A signed response that does not belong to this request (another nonce,
    ///             another machine, another key): a replay.
    eReplay,

    /// @brief  The lease server has no free seat.
    eNoSeat,

    /// @brief  The transport seam failed.
    eTransportError,

    /// @brief  The clock went back beyond the tolerance (see @ref CClockGuard).
    eClockRollback,

    /// @brief  The operation does not fit the current state.
    eWrongState,

    /// @brief  Refused: no license was accepted and the evaluation of this machine has
    ///             ended, or the license passed was refused (see Bundle::UnlockBundle). This
    ///             is the Ethereal license itself, not the customer's (see @ref eNoLicense).
    eNotLicensed
};

Result of a licensing operation.

enum

ELicenseType

Ethereal::Licensing#
C++
enum class   ELicenseType : ETL_UINT8
{
    /// @brief  Perpetual, subscription, trial, evaluation, site and OEM.
    ePerpetual = 0, eSubscription, eTrial, eEvaluation, eSite, eOem
};

License types.

enum

ESeatModel

Ethereal::Licensing#
C++
enum class   ESeatModel : ETL_UINT8
{
    /// @brief  Locked to a node, locked to a user, floating, unrestricted.
    eNodeLocked = 0, eUserLocked, eFloating, eUnrestricted
};

Seat models.

function

LicenseStatusName

Ethereal::Licensing#
const ETL_CHAR * LicenseStatusName( ELicenseStatus eStatus ) noexcept;

Name of a status, for messages.

eStatus
The status.
The name. Never null.
const

LICENSE_MAGIC

Ethereal::Licensing#
constexpr ETL_UINT32 LICENSE_MAGIC = 0x4C4C5445u;

The 'ETLL' of the header.

const

LICENSE_FORMAT_VERSION

Ethereal::Licensing#
constexpr ETL_UINT16 LICENSE_FORMAT_VERSION = 1u;
const

LICENSE_SIGNATURE_SIZE

Ethereal::Licensing#
constexpr ETL_UINT32 LICENSE_SIGNATURE_SIZE = 64u;

Size of an Ed25519 signature.

const

LICENSE_PUBLIC_KEY_SIZE

Ethereal::Licensing#
constexpr ETL_UINT32 LICENSE_PUBLIC_KEY_SIZE = 32u;

Size of an Ed25519 public key.

const

LICENSE_MAX_KEYS

Ethereal::Licensing#
constexpr ETL_UINT32 LICENSE_MAX_KEYS = 4u;

Maximum number of public keys the customer may hold, for key rotation.

const

LICENSE_MAX_IDENTITY

Ethereal::Licensing#
constexpr ETL_UINT32 LICENSE_MAX_IDENTITY = 8u;

Maximum number of identity components in a machine binding.

manager.hpp

#include <ethereal/cpp/licensing/manager.hpp>

Client side license verifier.

It only verifies: it loads a signed license, validates it, and answers queries for features and limits.

There is no 'bool IsLicensed()' that a 'nop' can patch. This is the most important rule of the module: validation returns every problem, each with its own status, and the consequence happens elsewhere, later. The product degrades, it does not crash. A license system that actually stops a paying customer because of a network failure costs more than piracy.

function

HashName

Ethereal::Licensing#
ETL_UINT64 HashName( const ETL_CHAR * pName ) noexcept;

Hash of a feature or limit name.

Both sides must use the same one. The issuer hashes the name when writing, and the client hashes the query when reading. It is a 64 bit FNV-1a.

pName
The name.
The hash.
struct

SValidationReport

Ethereal::Licensing#
C++
struct   SValidationReport   final
{
    /// @brief  'sizeof( SValidationReport )'.
    ETL_UINT32        iStructSize = sizeof( SValidationReport );

    /// @brief  No problem at all. This is the closest thing to a "yes", and on purpose
    ///             it is not a lone bool that can be patched.
    ETL_UINT8        bAllClear = 0u;

    /// @brief  Past the expiry date.
    ETL_UINT8        bExpired = 0u;

    /// @brief  Not valid yet.
    ETL_UINT8        bNotYetValid = 0u;

    /// @brief  This build is later than the update window.
    ETL_UINT8        bBuildNotCovered = 0u;

    /// @brief  The machine does not match the binding.
    ETL_UINT8        bMachineMismatch = 0u;

    /// @brief  The license belongs to another product.
    ETL_UINT8        bWrongProduct = 0u;

    /// @brief  The license is in the revocation list.
    ETL_UINT8        bRevoked = 0u;

    /// @brief  The clock went back beyond the tolerance (only with a @ref CClockGuard
    ///             attached). It was the padding byte: the size did not change.
    ETL_UINT8        bClockRollback = 0u;

    /// @brief  Number of machine components that matched, and the threshold, for the message.
    ETL_UINT32        uMachineMatched = 0u;
    ETL_UINT32        uMachineThreshold = 0u;
};

Where the problems of a license are. All of them, not just the first.

Returning the first problem would hide the others. A license may be expired and belong to another product and not match the machine. The integrator wants the full list to give a useful message, not to hunt them one at a time.

struct

SLicensingParams

Ethereal::Licensing#
C++
struct   SLicensingParams   final
{
    /// @brief  'sizeof( SLicensingParams )'.
    ETL_UINT32        iStructSize = sizeof( SLicensingParams );

    /// @brief  Which product this client is. The hash of the identifier.
    ETL_UINT64        uProductHash = 0u;

    /// @brief  The build timestamp of this binary, not the system clock.
    ///
    /// @details  See @ref IsBuildCovered: this is what keeps the "perpetual with an
    ///            update window" model independent of the clock.
    ETL_INT64        iBuildEpochUnix = 0;

    /// @brief  The signature seam. Required.
    ISignatureVerifier *    pVerifier = nullptr;

    /// @brief  The machine identity seam. Null disables the binding.
    IMachineIdentity *        pMachine = nullptr;

    /// @brief  The public keys, in order: @c uKeyCount * 32 bytes.
    const ETL_UINT8 *    pPublicKeys = nullptr;

    /// @brief  The key identifiers, in the same order.
    const ETL_UINT32 *    pKeyIds = nullptr;

    /// @brief  Number of keys.
    ETL_UINT32            uKeyCount = 0u;

    /// @brief  (optional) The critical extension tags this client understands. A license
    ///             with a critical extension outside this list gives
    ///             @ref ELicenseStatus::eSchemaTooNew ("needs a newer client").
    const ETL_UINT16 *    pUnderstoodCriticalTags = nullptr;
    ETL_UINT32            uUnderstoodCriticalCount = 0u;
};

Verifier parameters.

function

IsBuildCovered

Ethereal::Licensing#
bool IsBuildCovered( const SLicense & Lic, ETL_INT64 iBuildEpochUnix ) noexcept;

Compares the update window of Lic with the build timestamp.

A binary built before the end of the window runs forever, on any machine, at any system date. One built after it is refused, and the reason is reported exactly.

There is no dependency on the clock, and nothing to gain by changing the date. That is the meaning of a perpetual license with a paid window.

Lic
The license.
iBuildEpochUnix
The build timestamp.
true when the build is covered.
class

CLicenseManager

Ethereal::Licensing#

The license verifier. Loads, validates, answers.

class CLicenseManager final
constructor

CLicenseManager

#
CLicenseManager() noexcept;

Default constructor. Call Init before use.

function

Init

#
ELicenseStatus Init( const SLicensingParams & Params ) noexcept;

Validates and stores the parameters.

Params
Verifier parameters.
eOk or eInvalidArgument. eNotLicensed when the library is not licensed.
function

LoadFromMemory

#
ELicenseStatus LoadFromMemory( std::span< const ETL_UINT8 > In ) noexcept;

Loads a license from bytes in memory. Verifies the signature right away.

The signature is verified here, once. The feature queries after it do not pay for it.

In
The license file.
eOk, or the reason for the rejection. eNotLicensed when the library is not licensed.
function

LoadRevocationList

#
ELicenseStatus LoadRevocationList( std::span< const ETL_UINT8 > In, ETL_UINT64 uMinSequence ) noexcept;

Verifies a revocation list and keeps the verdict for the loaded license ('bRevoked' in Validate).

Load the license first. The list is not kept (only the verdict and the serial number). Loading another license forgets the verdict, and the list must be loaded again.

In
The signed list.
uMinSequence
Serial number of the last accepted list (persisted by the integrator). A list below it gives ELicenseStatus::eStale, and nothing changes.
ELicenseStatus::eWrongProduct for a list of another product. ELicenseStatus::eNoLicense without a loaded license. ELicenseStatus::eNotLicensed when the library is not licensed.
function

AcceptedRevocationSequence

#
ETL_UINT64 AcceptedRevocationSequence() const noexcept

Serial number of the accepted list, for the integrator to persist.

function

AttachClockGuard

#
void AttachClockGuard( CClockGuard * pGuard ) noexcept

Attaches a clock guard (null detaches). Validate then evaluates the validity with CClockGuard::EffectiveNow, feeds it the license issue time as a signed time, and reports the rollback.

function

Validate

#
ELicenseStatus Validate( ETL_INT64 iNowUnix, SValidationReport * pOut ) noexcept;

Validates everything and returns every problem. Cost: moderate.

iNowUnix
Current time. Comes from outside so the bench can control it, and because the clock belongs to the integrator.
pOut
Receives the report.
eOk (the problems are in the report), eInvalidArgument or eNoLicense.
function

HasFeature

#
bool HasFeature( ETL_UINT32 uId ) const noexcept;

Whether the numeric feature uId (0..63) is enabled.

Cost: cheap, one bit test. A product that queries this in a render loop cannot pay 50 us per call.

function

HasFeatureNamed

#
bool HasFeatureNamed( const ETL_CHAR * pName ) const noexcept;

Whether the named feature pName is present.

function

GetLimit

#
ETL_INT64 GetLimit( const ETL_CHAR * pName, ETL_INT64 iDefault ) const noexcept;

The named limit pName.

pName
The limit name.
iDefault
Returned when the limit is not in the license.
The limit value, or iDefault.
function

License

#
const SLicense & License() const noexcept

The loaded license, for whoever wants the raw fields.

function

GetExtension

#
bool GetExtension( ETL_UINT16 uTag, std::span< const ETL_UINT8 > * pOut ) const noexcept;

The bytes of extension uTag of the loaded license (signed with it).

uTag
The extension tag.
pOut
Receives the bytes. The span lives until the next 'LoadFromMemory'.
false when the extension is not present.
function

HasLicense

#
bool HasLicense() const noexcept

Whether a license is loaded.

function

RemainingSeconds

#
ETL_INT64 RemainingSeconds( ETL_INT64 iNowUnix ) const noexcept;

Seconds left until expiry. Negative when already past, the maximum when perpetual.

offline_activation.hpp

#include <ethereal/cpp/licensing/offline_activation.hpp>

Offline activation, client side: the request and the acceptance of the response.

The response comes from 'CIssuer::IssueActivationResponse' (issuer.hpp), in the vendor backend.

The round trip: 1. The offline machine makes a request (CreateActivationRequest): the activation key, the product, the machine identity hashes and a nonce. The integrator stores it (the "pending request") and carries the bytes to a machine with network (file, QR code, e-mail). 2. The backend checks the key in its database and issues a signed response: a license bound to the identity of the request, plus the echo of the nonce and of the key. 3. The machine accepts the response (AcceptActivationResponse) against the pending request, and the integrator deletes the pending request.

What the response cannot do: work on another machine (the nonce belongs to another request, and the license is bound to another identity), work twice (the pending request is deleted on acceptance, and an old response carries the nonce of a request that no longer exists), or be forged (it is signed, and so is the license inside it).

The request is not signed (the client has no private key, by design). It carries a checksum that catches a byte changed in transit.

const

ACTIVATION_REQUEST_SIZE

Ethereal::Licensing#
constexpr ETL_UINT32 ACTIVATION_REQUEST_SIZE = 120u;

Size of the encoded request.

const

ACTIVATION_RESPONSE_MAX

Ethereal::Licensing#
constexpr ETL_UINT32 ACTIVATION_RESPONSE_MAX = LICENSE_FILE_MAX + 256u;

A buffer that holds any activation response (the license, with its extensions, and the echo).

struct

SActivationRequest

Ethereal::Licensing#
C++
struct   SActivationRequest   final
{
    /// @brief  'sizeof( SActivationRequest )'.
    ETL_UINT32        iStructSize = sizeof( SActivationRequest );

    /// @brief  Number of identity hashes (the non zero ones, in collection order).
    ETL_UINT32        uIdentityCount = 0u;

    /// @brief  Hash of the product identifier.
    ETL_UINT64        uProductHash = 0u;

    /// @brief  Value of the activation key (already checked by the check symbol).
    ETL_UINT64        uActivationKey = 0u;

    /// @brief  Must be unpredictable and new in every request (from the system random
    ///             generator). Never zero.
    ETL_UINT64        uNonce = 0u;

    /// @brief  Creation time.
    ETL_INT64        iCreatedAtUnix = 0;

    /// @brief  Identity hashes of the machine.
    ETL_UINT64        aIdentityHashes[ LICENSE_MAX_IDENTITY ] = {};
};

The activation request. Also the "pending request" the integrator stores.

function

CreateActivationRequest

Ethereal::Licensing#
ELicenseStatus CreateActivationRequest( ETL_UINT64 uProductHash, const ETL_CHAR * pActivationKey, ETL_UINT64 uNonce, ETL_INT64 iNowUnix, IMachineIdentity * pMachine, SActivationRequest * pOut ) noexcept;

Makes the request: reads and checks the key, and collects the machine identity.

uProductHash
Hash of the product identifier.
pActivationKey
The key as the person typed it ('ETL-XXXXX-...').
uNonce
Unpredictable and new. Zero is rejected.
iNowUnix
Current time.
pMachine
Identity of this machine. Required: an activation without a binding would be a license that works on any machine.
pOut
Receives the request.
eOk, or the reason for the failure. eNotLicensed when the library is not licensed.
function

EncodeActivationRequest

Ethereal::Licensing#
ELicenseStatus EncodeActivationRequest( const SActivationRequest & Request, ETL_UINT8 * pOut, ETL_UINT64 uCap, ETL_UINT64 * pWritten ) noexcept;

Writes the ACTIVATION_REQUEST_SIZE bytes of the request, to carry and to store.

Request
The request.
pOut
Output buffer.
uCap
Size of the output buffer.
pWritten
Receives the number of bytes written.
eOk, eInvalidArgument or eBufferTooSmall.
function

DecodeActivationRequest

Ethereal::Licensing#
ELicenseStatus DecodeActivationRequest( std::span< const ETL_UINT8 > In, SActivationRequest * pOut ) noexcept;

Reads a request (the issuer, or the client reading back the pending one). Checks the checksum.

In
The encoded request.
pOut
Receives the request.
eOk, eInvalidArgument, eMalformed or eSchemaTooNew.
function

AcceptActivationResponse

Ethereal::Licensing#
ELicenseStatus AcceptActivationResponse( std::span< const ETL_UINT8 > In, const SActivationRequest & Pending, ISignatureVerifier * pVerifier, const ETL_UINT8 * pKeys, const ETL_UINT32 * pKeyIds, ETL_UINT32 uKeyCount, ETL_UINT8 * pLicenseOut, ETL_UINT64 uCap, ETL_UINT64 * pLicenseSize, SLicense * pLicense = nullptr ) noexcept;

Accepts the response against the pending request.

Checks the response signature, the echo (product, key and nonce: another one gives ELicenseStatus::eReplay), the license inside it (with its own signature), and that its binding is the identity of the request (another one gives ELicenseStatus::eMachineMismatch). Only with everything right it copies the license file to pLicenseOut. The integrator stores it, loads it in the manager, and deletes the pending request.

In
The response.
Pending
The pending request.
pVerifier
The signature seam.
pKeys
The public keys, in order.
pKeyIds
Their identifiers, in the same order.
uKeyCount
Number of keys.
pLicenseOut
Receives the license file.
uCap
Size of pLicenseOut.
pLicenseSize
Receives the size of the license file.
pLicense
Optional: receives the parsed license.
eOk, or the reason for the rejection.

revocation.hpp

#include <ethereal/cpp/licensing/revocation.hpp>

Revocation list, client side: verify and read.

The list is issued by 'CIssuer::IssueRevocationList' (issuer.hpp).

Signed and numbered. The list comes through the same channel as the rest (a file, an HTTP request made by the integrator), and what makes it trustworthy is the signature. The serial number ('uSequence') only goes up: the integrator stores the last accepted one and rejects an older list (ELicenseStatus::eStale). Otherwise restoring a list from before the revocation would be enough.

The list is not copied. SRevocationList points into the caller bytes, which must live while the list is queried. The manager (manager.hpp) queries it once on load and keeps only the verdict.

const

REVOCATION_MAX_IDS

Ethereal::Licensing#
constexpr ETL_UINT32 REVOCATION_MAX_IDS = 1u << 20;

Maximum number of identifiers in a list (8 MiB of identifiers).

struct

SRevocationList

Ethereal::Licensing#
C++
struct   SRevocationList   final
{
    /// @brief  Hash of the product identifier.
    ETL_UINT64            uProductHash = 0u;

    /// @brief  Serial number. It only goes up. Store the last accepted one.
    ETL_UINT64            uSequence = 0u;

    /// @brief  Issue time.
    ETL_INT64            iIssuedAtUnix = 0;

    /// @brief  Number of identifiers, strictly increasing.
    ETL_UINT32            uCount = 0u;

    /// @brief  Key that signed the list.
    ETL_UINT32            uKeyId = 0u;

    /// @brief  The identifiers, 8 bytes each, little-endian (inside the caller buffer).
    const ETL_UINT8 *    pIds = nullptr;
};

A verified list. Points into the caller bytes.

function

DecodeAndVerifyRevocationList

Ethereal::Licensing#
ELicenseStatus DecodeAndVerifyRevocationList( std::span< const ETL_UINT8 > In, ISignatureVerifier * pVerifier, const ETL_UINT8 * pKeys, const ETL_UINT32 * pKeyIds, ETL_UINT32 uKeyCount, SRevocationList * pOut ) noexcept;

Verifies the signature, and only then reads the list.

Rejects (ELicenseStatus::eMalformed) a list whose identifiers are not strictly increasing: the search is binary, and an unordered list would hide an identifier.

In
The signed list.
pVerifier
The signature seam.
pKeys
The public keys, in order.
pKeyIds
Their identifiers, in the same order.
uKeyCount
Number of keys.
pOut
Receives the list.
eOk, or the reason for the rejection.
function

IsRevoked

Ethereal::Licensing#
bool IsRevoked( const SRevocationList & List, ETL_UINT64 uLicenseId ) noexcept;

Whether uLicenseId is in the list. Binary search, no allocation.

List
The verified list.
uLicenseId
The license identifier.
true when the license is revoked.