UniKey RTC API Protection Solution

From SecuTech Wiki
Jump to: navigation, search


Introduction

UniKey Time provides a real-time clock (RTC) and this article will introduce how to integrate UniKey Time APIs with your own projects, and how to use the features UniKey Time provides. Each Unikey Time has an embedded battery, this provides the UniKey Time with a real-time clock. This means that clock inside of the UniKey is unique and independent from the computer’s system time. The protected software will expire on time, even if the user changes their system time. Each UniKey Time has 16 Time Modules, each UniKey Time Module can be used to set the duration of the protected software.

For example, I could set the start and end time for Time Module Number 0. Then bind my software with Time Module No.0, after this step, my software will have a limited start and end time. If the time inside of the dongle reaches the expired date, then the software will not run.

Setting Expiration Date for Software

Users can refer to the following steps on integrating UniKey Time APIs.

UniKey Time set start and end time or duration

Set Module Start Time and End Time

In order to set the start and end time, we need to use two UniKey APIs.

UniKey_Set_Time_Module_Start_Time(Handle, Module, Year, Month, Day, Hour);

UniKey_Set_Time_Module_End_Time(Handle, Module, Year, Month, Day, Hour);

After setting the start and end time for a specific UniKey Time Module (one of 16 Time Modules), our protected software has limited use within this time period.

Set Module Start Time and Duration Period

In order to set the start time and duration, we need to use two UniKey APIs.

UniKey_Set_Time_Module_Start_Time(Handle, Module, Year, Month, Day, Hour);

UniKey_Set_Time_Module_Duration(Handle, Module, Days, Hours);

This is another way to limit software run-time besides setting an end time directly.

Checking if Software has Expired

We need to use one UniKey Time API to check if software has expired.

UniKey_Check_Time_Module_Now(Handle, Module, RemainDays, RemainHours);

This API will use the current time inside of the UniKey Time dongle to compare with the expiry date stored within the specified Time Module and then return the remaining days and hours for us. Letting us know if our protected software has expired, or how many days and hours left.

Definition of UniKey Time APIs

  • UniKey_Set_Time(Handle, Year, Month, Day, Hour, Minute, Second); is used for setting a specific time for the UniKey Time dongle.
  • UniKey_Set_Time_Now(pHandle); is used to set the UniKey Time's real-time clock to the current system time.
  • UniKey_Get_Time(Handle, Year, Month, Day, Hour, Minute, Second); is used for getting the current date and time stored within UniKey Time dongle.
  • UniKey_Erase_Time_Module(Handle, Module); is used for erasing a UniKey Time Module; this can be used after configuring a UniKey Time Module.

UniKey_Set_Time_Module_Start_Time(Handle, Module, Year, Month, Day, Hour);

UniKey_Set_Time_Module_Start_Time_Now(Handle, Module);

UniKey_Set_Time_Module_Start_Time_Now_PC (Handle, Module);

  • UniKey_Set_Time_Module_Start_Time is used to set the start time for one UniKey Time Module; it has three formats, you can define the specific date by yourself, or use the current time stored within the UniKey Time dongle, or use the current computer’s system time.
  • UniKey_Set_Time_Module_End_Time(Handle, Module, Year, Month, Day, Hour); is used to set the end time for one UniKey Time Module.
  • UniKey_Set_Time_Module_Duration(Handle, Module, Days, Hours); is used to set the duration period for one UniKey Time Module.

UniKey_Check_Time_Module(Handle, Module, RemainDays, Year, Month, Day, Hour);

UniKey_Check_Time_Module_Now(Handle, Module, RemainDays, RemainHours);

UniKey_Check_Time_Module_Now_PC(Handle, Module, RemainDays, RemainHours);

  • UniKey_Check_Time_Module is used to check if the protected software has expired; it has three formats, you can define the specific date by yourself, or use the current time stored within the UniKey Time dongle, or use the current computer’s system time.