LIMAN SDK Documentation

Introduction

This section provides an overview of the LIMAN SDK, instructions for getting started, sample applications, and details concerning contact and support information. It introduces two utility applications that illustrate:

Directory Structure

After a successful setup, the following directories will be created within the root directory of LIMAN SDK. Assuming liman-x.y.z is the root directory:

You will need to repeat this setup process for each product you want to protect. The libliman.a library is specific to a certain product and should not be used for multiple products. In a hypothetical 3-product business, you will have:

directory structure
lib
   + linux64
        + FC16ADA16362
            + FC16ADA16362_private.key
            + FC16ADA16362_private_key.c
            + FC16ADA16362_public.key
            + FC16ADA16362_public_key.c
            + libliman.a
        + 2D548F7F540C
            + 2D548F7F540C_private.key
            + 2D548F7F540C_private_key.c
            + 2D548F7F540C_public.key
            + 2D548F7F540C_public_key.c
            + libliman.a
        + 52ADB5129389
            + 52ADB5129389_private.key
            + 52ADB5129389_private_key.c
            + 52ADB5129389_public.key
            + 52ADB5129389_public_key.c
            + libliman.a

Your products should be linked against the associated libliman.a and the license generator limgen should use the private key associated with that product.

License Generation

License generation involves creating an encrypted license key containing the following information:

Data Types

LIMAN SDK has two data types that must be initialized before any license operation:

License Creation Steps

  1. Create environment instance: lim_create_env()
  2. Read the private key: lim_read_private_key()
  3. Create empty license: lim_create_lic()
  4. Call lim_load_lic() with license parameters
  5. Export license: lim_write_lickey()
  6. Cleanup: lim_free_lic() and lim_free_env()
  7. Send the license key to your customer

limgen Command Line Tool

Build the license generator with make limgen. Available options:

bash
$ limgen --help

Liman Version: 1.2.9 (Linux64x86 Release Build)

Usage: limgen [options]

    -A, --platform=PLATFORM_ID  Platform identifier (0..255)
    -P, --product=PRODUCT_CODE  Product code (12 chars max)
    -M, --major=MAJOR           Major version (0..255)
    -J, --minor=MINOR           Minor version (0..255)
    -S, --size=SIZE_ID          License size identifier (0..255)
    -t, --type=TYPE_ID          License type identifier (0..255)
    -o, --seats=NSEATS          Number of seats/users allowed
    -e, --expiry=YYYYMMDD       Expiry date
    -r, --serial=SERIAL         Serial code (24 chars max)
    -H, --hostid=HOSTID         Target machine hostid
    -u, --userid=USERID         Customer userid
    -i, --uuid=UUID             Unique identifier (32 chars max)
    -f, --features=FEATURES     Feature bitmask (comma delimited)
    -I, --privkeyfile=PRIVKEYF  Private key file
    -U, --pubkeyfile=PUBKEYF    Public key file
    -k, --keysize=KEYSIZE       Key size in bits
    -Z, --hashsize=HASHSIZE     Hash size in bits
    -s, --seed=SEED             Random seed
    -m, --hostmask=HOSTMASK     Host identifier mask (1,2,4,8,16)
    -L, --licinfo               Display license information
    -g, --genkey                Generate keypair
    -D, --genuuid               Generate UUID
    -h, --help                  Show help

Examples

bash
# Generate license with features and expiry
$ limgen --product=PRODUCT1 --major=2 --minor=1 --serial=123456 \
         --expiry=20260401 --features=37,3,3,5

# Generate license with custom keypair
$ limgen --platform=8 --product=PRODUCT1 --major=2 --minor=1 \
         --serial=123456 \
         --privkeyfile=/path/to/priv/key \
         --pubkeyfile=/path/to/pub/key

Using Bitmasks for Optional Features

Your application may have different features that need to be licensed separately. LIMAN SDK allows up to 32 optional features using a 4-byte array. Each byte is an 8-bit bitmask (0-255).

Example: Sorting Algorithms

Suppose your application offers 8 sorting techniques:

text
    7       6       5       4       3       2       1       0
 _______ _______ _______ _______ _______ _______ _______ _______
|       |       |       |       |       |       |       |       |
|_______|_______|_______|_______|_______|_______|_______|_______|
    |       |       |       |       |       |       |       |
    |       |       |       |       |       |       |       +---> Quick Sort
    |       |       |       |       |       |       +-----------> Merge Sort
    |       |       |       |       |       +-------------------> Heap Sort
    |       |       |       |       +---------------------------> Insertion Sort
    |       |       |       +-----------------------------------> Intro Sort
    |       |       +-------------------------------------------> Block Sort
    |       +---------------------------------------------------> Shell Sort
    +-----------------------------------------------------------> Bubble Sort

For a license with Quick Sort, Heap Sort, and Block Sort enabled:

binary: 00100101 = 2^0 + 2^2 + 2^5 = 1 + 4 + 32 = 37

Feature Constants

c
#define LIMOPT_FEATURE_0      1    // 2^0, bit 0
#define LIMOPT_FEATURE_1      2    // 2^1, bit 1
#define LIMOPT_FEATURE_2      4    // 2^2, bit 2
#define LIMOPT_FEATURE_3      8    // 2^3, bit 3
#define LIMOPT_FEATURE_4     16    // 2^4, bit 4
#define LIMOPT_FEATURE_5     32    // 2^5, bit 5
#define LIMOPT_FEATURE_6     64    // 2^6, bit 6
#define LIMOPT_FEATURE_7    128    // 2^7, bit 7

Setting Features

c
void set_features(char feature[4]) {
    feature[0] = 0;
    feature[0] |= LIMOPT_FEATURE_0;  // Quick Sort
    feature[0] |= LIMOPT_FEATURE_2;  // Heap Sort
    feature[0] |= LIMOPT_FEATURE_5;  // Block Sort

    feature[1] = 0;
    feature[2] = 0;
    feature[3] = 0;
}

Checking Features

c
if (lim_has_feature(pLic, 0, LIMOPT_FEATURE_0)) {
    printf("Quick Sort is available\n");
}
if (lim_has_feature(pLic, 0, LIMOPT_FEATURE_2)) {
    printf("Heap Sort is available\n");
}
if (lim_has_feature(pLic, 0, LIMOPT_FEATURE_5)) {
    printf("Block Sort is available\n");
}

License Key Format

License keys are encrypted strings containing all license properties. Creation requires your private key (keep secret); validation uses the public key embedded in libliman.a.

text
#----- BEGIN LICENSE KEY (Id:0F1BBCE44015) -----
UjP8kPXFXl82y97eTAgCbOMLTyDOK9o8p9USut/zkanO+Mhs10E3dMT5ceqpDefr
I5NDb/1bGkaTI/Nue6u6LGZ4azJEOcjT1b1tqVSAU60vgSeyUTEJUj2ujDjxofGl
2ybdpdbkdUsyb6jEFpn2t+zEOwNolmeEXnq1yZHkTW+ta8hymvnv31B3z21rmuu5
QQKAhGkTTdEpXga0bMYR55oNmTwx83KufRHFGbSLd+kSBAiqIuiTpzcQe0fT+2wM
5C20vpWyKeW0k9wknY+r1fw7lD/oQCB7Rv9g+DHYqKmT+1e4GpGxuRMgJf125gCc
kfZ0rja6blhocnM+3GYrzg==
#----- END LICENSE KEY -----

Contact and Support

For sales inquiries and licensing: info@baroks.com

For technical support: info@baroks.com

Error Codes

The following error codes are defined in include/liman.h:

Constant Description
LIM_OKNo error, operation successful
LIMERR_MEMORYError in allocating memory
LIMERR_FILE_NOT_FOUNDSpecified file was not found
LIMERR_INVALID_NULLSpecified reference is invalid or null
LIMERR_INVALID_LICENSESpecified license is invalid
LIMERR_ENVAR_NOT_FOUNDEnvironment variable not found
LIMERR_LICENSE_EXPIREDLicense has expired
LIMERR_LICENSE_NOT_LOADEDLicense is not loaded
LIMERR_INVALID_DOMAINDomain parameters are invalid
LIMERR_INVALID_PRODUCT_CODEProduct code invalid for license
LIMERR_INVALID_USERCurrent user invalid for license
LIMERR_INVALID_PRODUCT_VERSIONProduct version invalid for license
LIMERR_INVALID_PLATFORMPlatform code invalid for license
LIMERR_INVALID_ENVAREnvironment variable is invalid
LIMERR_INVALID_ENVEnvironment is invalid
LIMERR_INVALID_INPUTInput is invalid
LIMERR_UNABLE_TO_OPEN_FILEFailed to open file
LIMERR_INVALID_LICENSE_FILE_NAMELicense filename is invalid
LIMERR_OPERATION_FAILEDInternal operation failed
LIMERR_PRIVKEY_FILE_NOT_FOUNDPrivate key not found
LIMERR_PUBKEY_FILE_NOT_FOUNDPublic key not found
LIMERR_NOT_SUPPORTEDFeature not supported
LIMERR_INVALID_KEYLENKey length is invalid
LIMERR_NOT_AVAILABLEInformation not available
LIMERR_INVALID_KEYKey is invalid
LIMERR_SHORT_KEYKey is too short
LIMERR_BAD_ERRORCODEError code is invalid
LIMERR_INTERNALInternal error - contact vendor
LIMERR_ENV_NOT_READYEnvironment not ready
LIMERR_ALREADY_LOADEDObject already loaded
LIMERR_SYSTEMPlatform-specific system error
LIMERR_CLOCK_SETBACKClock setback detected
LIMERR_INVALID_HOSTHost invalid or hardware changed
LIMERR_KEYS_NOT_LOADEDKeys not loaded
LIMERR_PRIVKEY_FILE_EXISTSPrivate key file already exists
LIMERR_PUBKEY_FILE_EXISTSPublic key file already exists
LIMERR_KEYSIZE_MISMATCH_ENVKey size doesn't match environment
LIMERR_RANGE_TYPE_CODEType code out of range
LIMERR_RANGE_PRODUCT_CODEProduct code out of range
LIMERR_RANGE_MAJOR_VERSIONMajor version out of range
LIMERR_RANGE_MINOR_VERSIONMinor version out of range
LIMERR_RANGE_SIZE_CODESize code out of range
LIMERR_RANGE_PLATFORM_CODEPlatform code out of range