Using Trigger Codes for Telephone Activations

Trigger code validation is a means of achieving software activation through the manual exchange of numeric values (in other words, it is a challenge-response mechanism). Review the overview on trigger codes for additional, high-level details on how this works and how to generate activation codes.

Important

Keep in mind that any challenge-response mechanisms such as trigger code validation can be reverse engineered (similar to how "key generators" are available on the Internet for many popular software applications). Therefore, it is best to use Protection PLUS 5 SDK's standard online and manual activation features when possible, which offer much stronger security than trigger codes.

Adding Support for Trigger Codes to your Application

Before you can add support for any form of activation, your application must first initialize the context. Once activation has been implemented, the application will also need to include copy protection to ensure it only runs on devices in which it was activated.

To process trigger code activations, you will need to collect input from the user using a form/dialog or some other means. Most activation forms/dialogs are pretty similar, and can be designed similar to the illustration below.

As shown above, your application would need to show the User Code 1 and User Code 2 values to the user. The example code below outlines how you can add support for trigger code activations to your application.

C/C++
#define TRIGGER_CODE_SEED (400)
#define REGKEY2_SEED (123)

int userCode1 = 0;
int userCode2 = 0;
int activationCode1 = 0;
int activationCode2 = 0;
int triggerCodeNumber = 0;
int eventData = 0;
SK_ResultCode res = SK_ERROR_NONE;

res = SK_PLUS4_GenerateUserCode1Value(SK_FLAGS_NONE, &userCode1);
if (SK_ERROR_NONE != res)
{
//TODO: The User Code 1 value could not be generated. Add error handling here!
}
else
{
//Show the end-user the value generated and stored in userCode1.
//When adding support for delayed trigger codes, here is where you would store the userCode1 value for later use.
}

res = SK_PLUS4_GenerateUserCode2Value(context, SK_FLAGS_NONE, &userCode2);
if (SK_ERROR_NONE != res)
{
//TODO: The User Code 2 value could not be generated. Add error handling here!
}
else
{
//Show the end-user the value generated and stored in userCode2.
}

//Prompt the user to enter the activation codes here, and store these values in activationCode1 and activationCode2.

res = SK_PLUS4_ValidateTriggerCode(SK_FLAGS_NONE, activationCode1, activationCode2, userCode1, userCode2, TRIGGER_CODE_SEED, REGKEY2_SEED, &triggerCodeNumber, &eventData);
//When adding support for delayed trigger codes, here is where you would clear the stored the userCode1 value.
if (SK_ERROR_NONE != res)
{
//TODO: The activation codes failed validation. Add error handling here.
}
else
{
//The activation codes were validated successfully.
//TODO: Add your trigger code processing here! A rough example is outlined below.
switch (triggerCodeNumber)
{
case 1:
//As an example, code could be added here so that trigger code 1 activates your application as a full, non-expiring (or perpetual) license.
break;
case 10:
//As an example, code could be added here so that trigger code 10 activates your application as a time-limited (or lease/periodic) license.
//You could use the value in eventData to determine the number of days until the license expires by setting your license's EffectiveEndDate property using a value derived from SK_DateTimeGetCurrentString and SK_DateTimeAddDays.
break;
default:
//TODO: An unsupported trigger code number was specified. Add error handling here.
break;
}
}

Delayed Trigger Codes

A delayed trigger code is simply where you allow the user to process a trigger code activation after having closed and re-launched your application. The problem this solves primarily revolves around how the activation form/dialog initializes the User Code 1 value, as this value is randomized. Although this is not typically an issue with telephone activations, this can pose a challenge when the user might email, fax, or text the user code values, close the application, and re-launch the application to complete the activation later. If your application needs to support this kind of delay between when the user sends the user code values and when the user completes the activation, your application may need to implement this feature by storing the user code 1 value somewhere. This can be stored in a hidden file or registry key of your choosing, and it is strongly recommended that you consider encrypting the value as well.