UniKey API Reference for Delphi Language: Difference between revisions

From SecuTech Wiki
Jump to navigationJump to search
Bao (talk | contribs)
Bao (talk | contribs)
Added changes from C API reference, but replaced function prototypes. UniKey Drive headers may be incorrect? (function function_name instead of function_name: function)
Line 1: Line 1:
<!--
Check comments
-->
[[category:UniKey API]]
[[category:UniKey API]]


== UniKey API Reference ==
== UniKey API Reference ==


=== Find a UniKey dongle ===
=== Find a UniKey dongle ===


'''API Prototype'''
'''API Prototype'''


<code>function UniKey__Find(pHandle: pWord; pSetting1: pLongWord; pSetting2: pLongWord); DWORD; stdcall;</code>
<code>function UniKey__Find(pHandle: pWord; pSetting1: pLongWord; pSetting2: pLongWord): DWORD; stdcall;</code>


'''Description'''
'''Description'''
Line 72: Line 69:
=== Find the Next UniKey dongle ===
=== Find the Next UniKey dongle ===


'''API Prototype'''<br>
'''API Prototype'''
 
<code>function UniKey__Find_Next(pHandle: pWord; pSetting1: pLongWord; pSetting2: pLongWord): DWORD; stdcall;</code>
<code>function UniKey__Find_Next(pHandle: pWord; pSetting1: pLongWord; pSetting2: pLongWord): DWORD; stdcall;</code>


'''Description'''<br>
'''Description'''
Check if another UniKey is attached to the USB port.
 
Check if another UniKey is attached to the USB port.  
 
'''Parameters'''


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 89: Line 89:
</tr>
</tr>
<tr>
<tr>
<td>*pSetting1</td>
<td rowspan="2">*pSetting1</td>
<td>*[in] Working Mode (UniKey PRO only), useless for UniKey STD</td>
<td>[in] Working Mode (UniKey PRO only), useless for UniKey STD</td>
</tr>
</tr>
<tr>
<tr>
<td></td>
<td>[out] Hardware ID</td>
<td>[out] Hardware ID</td>
</tr>
</tr>
<tr>
<tr>
<td>*pSetting2</td>
<td rowspan="2">*pSetting2</td>
<td>*[in] Access Mode (UniKey PRO only), useless for UniKey STD(UniKeyPro only)</td>
<td>[in] Access Mode (UniKey PRO only), useless for UniKey STD</td>
</tr>
</tr>
<tr>
<tr>
<td></td>
<td>[out] Number of dongles attached , useless for UniKey STD</td>
<td>[out] Number of dongle attached , useless for UniKey STD</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 121: Line 120:
<td>ERROR_UNIKEY_NOMORE</td>
<td>ERROR_UNIKEY_NOMORE</td>
<td>214</td>
<td>214</td>
<td>No more dongle</td>
<td>No more dongles found</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_NEED_FIND</td>
<td>ERROR_UNIKEY_NEED_FIND</td>
<td>215</td>
<td>215</td>
<td>No Find before Find_Next</td>
<td>Find needs to be called before Find_Next</td>
</tr>
</tr>
</table>
</table>


<br>
<br>
=== Logon UniKey Dongle ===


'''API Prototype'''<br>
=== Log on to UniKey Dongle  ===
 
'''API Prototype'''
 
<code>function UniKey__User_Logon(pHandle: pWord; pPassword1: pWord; pPassword2: pWord): DWORD; stdcall;</code>
<code>function UniKey__User_Logon(pHandle: pWord; pPassword1: pWord; pPassword2: pWord): DWORD; stdcall;</code>


For UniKey Drive, the API Prototype is <code>UniKey_User_Logon(WORD* pHandle, DWORD* pPassword1, DWORD* pPassword2);</code>
For UniKey Drive, the API Prototype is


'''Description'''<br>
<code>function UniKey__User_Logon(pHandle: pWord; pPassword1: pWord; pPassword2: pWord): DWORD; stdcall;</code>
Logon a UniKey dongle with specified passwords. This API should be called in the released software in order to improve security.


'''Parameters'''<br>
'''Description'''
<table border="1">
 
Log in to a UniKey dongle with specified passwords. This API should be called in the commercial software in order to improve security.
 
'''Parameters'''
 
<table class="wikitable">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 150: Line 154:
<tr>
<tr>
<td>*pPassword1</td>
<td>*pPassword1</td>
<td>[in]Password  1</td>
<td>[in] Password  1</td>
</tr>
</tr>
<tr>
<tr>
<td>*pPassword2</td>
<td>*pPassword2</td>
<td>[in]Password  2</td>
<td>[in] Password  2</td>
</tr>
</tr>
<tr>
<tr>
Line 162: Line 166:
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 182: Line 187:
<td>ERROR_UNIKEY_INVALID_PASSWORD</td>
<td>ERROR_UNIKEY_INVALID_PASSWORD</td>
<td>201</td>
<td>201</td>
<td>UniKey dongle found, but Basic passwords are incorrect</td>
<td>Found UniKey dongle, but basic passwords (password 1 and 2) are incorrect</td>
</tr>
</tr>
<tr>
<tr>
Line 193: Line 198:
<br>
<br>


=== Logon UniKey Dongle in vendor mode ===
=== Log on to UniKey Dongle in vendor mode ===
 
'''API Prototype'''


'''API Prototype'''<br>
<code>function UniKey__Vender_Logon(pHandle: pWord; pPassword1: pWord; pPassword2: pWord; pPassword3: pWord; pPassword4: pWord): DWORD; stdcall;</code>
<code>function UniKey__Vender_Logon(pHandle: pWord; pPassword1: pWord; pPassword2: pWord; pPassword3: pWord; pPassword4: pWord): DWORD; stdcall;</code>


For UniKey Drive, the '''API Prototype'''<br>
For UniKey Drive, the API Prototype is
<code> is UniKey_Vender_Logon(WORD* pHandle, DWORD* pPassword1, DWORD* pPassword2, DWORD* pPassword3, DWORD* pPassword4);


<br>Description'''<br>
<code>function UniKey__Vender_Logon(pHandle: pWord; pPassword1: pWord; pPassword2: pWord; pPassword3: pWord; pPassword4: pWord): DWORD; stdcall;</code>
Logon a UniKey dongle in vendor mode with specified passwords. This API helps software vendors to logon the UniKey dongle in vendor mode, and get the full permission to UniKey dongle.
 
'''Description'''
 
Log in to a UniKey dongle in vendor mode with specified passwords. This API helps software vendors to log in to the UniKey dongle in vendor mode, and get full permissions to the UniKey dongle.
 
 
----
We do NOT advise you to enclose this API in the final released software. This API is only for software vendor’s usage.
We do NOT advise you to enclose this API in the final released software. This API is only for software vendor’s usage.
If password3 or password4 is wrong while password1 and password2 is correct, the dongle is also logged on in user mode automatically.
----


'''Parameters'''<br>
 
<table border="1">
----
<tr>
If password 3 or 4 is wrong, while password 1 and 2 is correct, the dongle is then logged on in user mode automatically.
<th>Parameter</th>
----
 
 
'''Parameters'''
 
<table class="wikitable">
<tr>
<th>Parameter</th>
<th>Description</th>
<th>Description</th>
</tr>
</tr>
<tr>
<tr>
<td>*pPassword1</td>
<td>*pPassword1</td>
<td>[in]Password 1</td>
<td>[in] Password 1</td>
</tr>
</tr>
<tr>
<tr>
<td>*pPassword2</td>
<td>*pPassword2</td>
<td>[in]Password 2</td>
<td>[in] Password 2</td>
</tr>
</tr>
<tr>
<tr>
<td>*pPassword3</td>
<td>*pPassword3</td>
<td>[in]Password 3</td>
<td>[in] Password 3</td>
</tr>
</tr>
<tr>
<tr>
<td>*pPassword4</td>
<td>*pPassword4</td>
<td>[in]Password 4</td>
<td>[in] Password 4</td>
</tr>
</tr>
<tr>
<tr>
Line 234: Line 252:
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 254: Line 273:
<td>ERROR_UNIKEY_INVALID_PASSWORD</td>
<td>ERROR_UNIKEY_INVALID_PASSWORD</td>
<td>201</td>
<td>201</td>
<td>Found UniKey dongle, but Basic passwords are incorrect</td>
<td>Found UniKey dongle, but basic passwords (password 1 and 2) are incorrect</td>
</tr>
</tr>
<tr>
<tr>
Line 265: Line 284:
<br>
<br>


=== Logoff the UniKey dongle ===
=== Log off the UniKey dongle ===
 
'''API Prototype'''


'''API Prototype'''<br>
<code>function UniKey__Logoff(pHandle: pWord): DWORD; stdcall;</code>
<code>function UniKey__Logoff(pHandle: pWord): DWORD; stdcall;</code>


'''Description'''<br>
'''Description'''
Logoff a UniKey dongle with a specific handle. This API should be called at the end of UniKey session.
 
Log off a UniKey dongle with a specific handle; this API should be called at the end of a UniKey session.  
 
'''Parameters'''


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 285: Line 307:
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 305: Line 328:
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>No logon dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
</table>
</table>
Line 311: Line 334:
<br>
<br>


<!--Missing "Get the UniKey dongle's Type"?-->
=== Get the UniKey Dongle's Type ===


=== Read UniKey dongle memory ===
'''API Prototype'''


'''API Prototype'''<br>
<code>function UniKey__Get_Type(pHandle: pWord; type: pLongWord): DWORD; stdcall;</code>
<code>function UniKey__Read_Memory(pHandle: pWord; pStartAddress: pWord; pBufferLength: pWord; pBuffer: pByteArray): DWORD; stdcall;</code>
 
'''Description'''


'''Description'''<br>
<code>UniKey__Get_Type</code> can help you get the type of the UniKey dongle.<br>
Read the contents of the Memory. This API needs to be called after logon of a UniKey dongle.
This functions return value will help to indicate the type of the UniKey dongle.


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Description</th>
<th>Code</th>
</tr>
</tr>
<tr>
<tr>
<td>*handle*pHandle</td>
<td>UNIKEY_TYPE_TIME</td>
<td>[in] Dongle handle</td>
<td>101</td>
</tr>
</tr>
<tr>
<tr>
<td>*pStartAddress</td>
<td>UNIKEY_TYPE_PRO</td>
<td>[in] Offset of Memory</td>
<td>102</td>
</tr>
</tr>
<tr>
<tr>
<td>*pBufferLenght</td>
<td>UNIKEY_TYPE_STD</td>
<td>[in] Number of bytes to read</td>
<td>103</td>
</tr>
<tr>
<td>pBbuffer</td>
<td>[out] Pointer to the buffer containing the data to be read</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Parameters'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Parameter</th>
<th>Value</th>
<th>Description</th>
<th>Description</th>
</tr>
</tr>
<tr>
<tr>
<td>SUCCESS</td>
<td>*pHandle</td>
<td>0</td>
<td>[in] Dongle handle</td>
<td>Success</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>*type</td>
<td>204</td>
<td>[out] The value indicating the type of your UniKey dongle</td>
<td>Read/Write address or length is wrong</td>
</tr>
</tr>
</table>
'''Return values'''
<table class="wikitable">
<tr>
<tr>
<td>ERROR_UNIKEY_READ_MEMORY</td>
<th>Result</th>
<td>207</td>
<th>Value</th>
<td>Read Error</td>
<th>Description</th>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>SUCCESS</td>
<td>212</td>
<td>0</td>
<td>No logon dongle before operating dongle</td>
<td>Success</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_GET_TYPE</td>
<td>215</td>
<td>256</td>
<td>No logon dongle before operating dongle</td>
<td>UniKey Get Type Error</td>
</tr>
</tr>
</table>
</table>


<br>
<br>
=== Write to UniKey dongle memory ===


'''API Prototype'''<br>
=== Read UniKey dongle memory  ===
<code>function UniKey__Write_Memory(pHandle: pWord; pStartAddress: pWord; pBufferLength: pWord; pBuffer: pByteArray): DWORD; stdcall;</code>


'''Description'''<br>
'''API Prototype'''
Write data into the memory. This API needs to be called after logging on to a UniKey dongle.


'''Parameters'''<br>
<code>function UniKey__Read_Memory(pHandle: pWord; pStartAddress: pWord; pBufferLength: pWord; pBuffer: pByteArray): DWORD; stdcall;</code>
<table border="1">
 
<tr>
'''Description'''
<th>Parameter</th>
 
<th>Description</th>
Read the contents of memory; this API needs to be called after logging in to a UniKey dongle.
 
'''Parameters'''
 
<table class="wikitable">
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</tr>
<tr>
<tr>
<td>*handle*pHandle</td>
<td>*pHandle</td>
<td>[in] Dongle handle</td>
<td>[in] Dongle handle</td>
</tr>
</tr>
<tr>
<tr>
<td>*pStartAddress</td>
<td>*pStartAddress</td>
<td>[in] Offset of the memory</td>
<td>[in] Offset of Memory</td>
</tr>
</tr>
<tr>
<tr>
<td>*pBufferLength</td>
<td>*pBufferLenght</td>
<td>[in] Number of bytes to write</td>
<td>[in] Number of bytes to read</td>
</tr>
</tr>
<tr>
<tr>
<td>pBbuffer</td>
<td>pBbuffer</td>
<td>[in] Pointer to the buffer containing the data to be written</td>
<td>[out] Pointer to the buffer containing the data to be read</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 428: Line 454:
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>204</td>
<td>204</td>
<td>Read/Write address or length is wrong</td>
<td>Read/Write address is incorrect or invalid length</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_WRITE_MEMORY</td>
<td>ERROR_UNIKEY_READ_MEMORY</td>
<td>207</td>
<td>207</td>
<td>Write Error</td>
<td>Read Error</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>No logon dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
<tr>
<td>ERROR_UNIKEY_VERIFY_ADV_PASSWORD</td>
<td>223</td>
<td>Advanced passwords (password3 and passowrd4) not verified</td>
</tr>
</tr>
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
<br>
To write the last 2k memory (for 2048 – 4096), you need to verify all the 4 passwords (vendor mode) to obtain full permission to the dongle.
<br>---------------------------------------------------------------------------------------------------<br>


<br>---------------------------------------------------------------------------------------------------<br>
=== Write to UniKey dongle memory  ===
UniKey_Read_Memory and UniKey_Write_Memory provide basic reading and writing functions to the dongle. You can store general information via such functions. And various levels of security can be applied too.
<br>---------------------------------------------------------------------------------------------------<br>


<br>
'''API Prototype'''
 
=== Generate a Random Number ===
<code>function UniKey__Write_Memory(pHandle: pWord; pStartAddress: pWord; pBufferLength: pWord; pBuffer: pByteArray): DWORD; stdcall;</code>
 
'''Description'''


'''API Prototype'''<br>
Write data into memory; this API needs to be called after logging on to a UniKey dongle.
<code>function UniKey__Random(pHandle: pWord; pReturn1: pWord; pReturn2: pWord; pReturn3: pWord; pReturn4: pWord): DWORD; stdcall;</code>


'''Description'''<br>
'''Parameters'''
Generate a random number from the dongle.


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 472: Line 488:
</tr>
</tr>
<tr>
<tr>
<td>*pHandle</td>
<td>*handle*pHandle</td>
<td>[in] Dongle handle</td>
<td>[in] Dongle handle</td>
</tr>
</tr>
<tr>
<tr>
<td>*pReturn1</td>
<td>*pStartAddress</td>
<td>[out] Random number</td>
<td>[in] Offset of the memory</td>
</tr>
</tr>
<tr>
<tr>
<td>*pReturn2</td>
<td>*pBufferLength</td>
<td>[out] Random number</td>
<td>[in] Number of bytes to write</td>
</tr>
</tr>
<tr>
<tr>
<td>*pReturn3</td>
<td>pBbuffer</td>
<td>[out] Random number</td>
<td>[in] Pointer to the buffer containing the data to be written</td>
</tr>
</tr>
<tr>
</table>
<td>*pReturn4</td>
 
<td>[out] Random number</td>
'''Return values'''
</tr>
</table>


'''Return values'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 504: Line 517:
<td>0</td>
<td>0</td>
<td>Success</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>204</td>
<td>Read/Write address is incorrect or invalid length</td>
</tr>
<tr>
<td>ERROR_UNIKEY_WRITE_MEMORY</td>
<td>207</td>
<td>Write Error</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>No logon dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_RANDOM</td>
<td>ERROR_UNIKEY_VERIFY_ADV_PASSWORD</td>
<td>209</td>
<td>223</td>
<td>Random number Error</td>
<td>Advanced passwords (password 3 and 4) not verified</td>
</tr>
</tr>
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
UNIKEY_RANDOM is to generate a random number inside the dongle. The UniKey dongle computing engine generates the number and the hardware of the dongle is the seed for the random number.
<br>---------------------------------------------------------------------------------------------------<br>


<br>
----
To write the last 2k memory (for 2048 – 4096), you need to verify all 4 passwords (vendor mode) to obtain the requisite permission.
=== Generate Seed Code Return Values ===
----
 
 
----
<code>UniKey__Read_Memory</code> and <code>UniKey__Write_Memory</code> provide basic reading and writing functions to the dongle. You can store general information via such functions. And various levels of security can be applied too.
----
 
<br>
 
=== Generate a Random Number ===
 
'''API Prototype'''


'''API Prototype'''<br>
<code>function UniKey__Random(pHandle: pWord; pReturn1: pWord; pReturn2: pWord; pReturn3: pWord; pReturn4: pWord): DWORD; stdcall;</code>
<code>function UniKey__Seed(pHandle: pWord; pSeed: pLongWord; pReturn1: pWord; pReturn2: pWord; pReturn3: pWord; pReturn4: pWord): DWORD; stdcall;</code>


'''Description'''<br>
'''Description'''
Get return codes from the input of a seed code. This API return for values which are related to pSeed and UniKey dongle’s password.


'''API Prototype'''<br>
Generates random numbers from the dongle.
<code>long UniKey_Seed(WORD* pHandle, DWORD* pSeed, WORD* pReturn1, WORD* pReturn2, WORD* pReturn3, WORD* pReturn4);</code>


'''Description'''<br>
'''Parameters'''
Get return codes from the input of a seed code. This API return for values which are related to pSeed and UniKey dongle’s password.


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 546: Line 572:
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in] Dongle handle</td>
<td>[in] Dongle handle</td>
</tr>
<tr>
<td>*pSeed</td>
<td>[in] Seed Code</td>
</tr>
</tr>
<tr>
<tr>
<td>*pReturn1</td>
<td>*pReturn1</td>
<td>[out] Return Code 1</td>
<td>[out] Random number</td>
</tr>
</tr>
<tr>
<tr>
<td>*pReturn2</td>
<td>*pReturn2</td>
<td>[out] Return Code 2</td>
<td>[out] Random number</td>
</tr>
</tr>
<tr>
<tr>
<td>*pReturn3</td>
<td>*pReturn3</td>
<td>[out] Return Code 3</td>
<td>[out] Random number</td>
</tr>
</tr>
<tr>
<tr>
<td>*pReturn4</td>
<td>*pReturn4</td>
<td>[out] Return Code 4</td>
<td>[out] Random number</td>
</tr>
</tr>
</table>  
</table>  


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 580: Line 603:
<td>0</td>
<td>0</td>
<td>Success</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_UNIKEY_RANDOM</td>
<td>209</td>
<td>Random number error</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>No logon dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
<tr>
<td>ERROR_UNIKEY_SEED</td>
<td>210</td>
<td>Seed code Error</td>
</tr>
</tr>
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
 
UniKey_Seed generate a set of seed codes. All of these seed codes are based on the password. It provides another method to verify the password and check the insertion of the dongle. Apart from this, the seed codes can be used to involve in other computation, for example, you use the seed returned as a 64-bit long encryption key.
----
<br>---------------------------------------------------------------------------------------------------<br>
<code>UNIKEY_RANDOM</code> is to generate a random number inside the dongle. The UniKey dongle computation engine generates the number and the hardware of the dongle is the seed for the random number.
----


<br>
<br>
=== Write the Soft ID ===


'''API Prototype'''<br>
=== Generate Seed Code Return Values ===
<code>function UniKey__Write_SoftID(pHandle: pWord; lp1: pLongWord): DWORD; stdcall;</code>


'''Description'''<br>
'''API Prototype'''
Write the vendor defined SoftID.
 
<code>function UniKey__Seed(pHandle: pWord; pSeed: pLongWord; pReturn1: pWord; pReturn2: pWord; pReturn3: pWord; pReturn4: pWord): DWORD; stdcall;</code>
 
'''Description'''
 
Get return codes from the input of a seed code; this API return for values which are related to pSeed and the UniKey dongle’s password.  


'''Parameters'''<br>
'''Parameters'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 618: Line 645:
</tr>
</tr>
<tr>
<tr>
<td>*pSoftID</td>
<td>*pSeed</td>
<td>[in] Soft ID</td>
<td>[in] Seed code</td>
</tr>
<tr>
<td>*pReturn1</td>
<td>[out] Return code 1</td>
</tr>
<tr>
<td>*pReturn2</td>
<td>[out] Return code 2</td>
</tr>
<tr>
<td>*pReturn3</td>
<td>[out] Return code 3</td>
</tr>
<tr>
<td>*pReturn4</td>
<td>[out] Return code 4</td>
</tr>
</tr>
</table>
</table>  
 
'''Return values'''


'''Return values'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 634: Line 678:
<td>0</td>
<td>0</td>
<td>Success</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_UNIKEY_SEED</td>
<td>210</td>
<td>Seed code error</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>No logon dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
<tr>
<td>ERROR_UNIKEY_SET_SOFTID</td>
<td>203</td>
<td>Set UniKey ID wrong</td>
</tr>
</tr>
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
 
You need to verify all 4 passwords (vendor mode) to write the SoftID.
----
<br>---------------------------------------------------------------------------------------------------<br>
<code>UniKey__Seed</code> generate a set of seed codes; all of these seed codes are based on the password. providing another method to verify passwords and check if a dongle has been inserted. Apart from this, the seed codes can be used in other computations, for example, you can use the seed returned as a 64-bit encryption key.
----


<br>
<br>
=== Read Soft ID ===


'''API Prototype'''<br>
=== Write Software ID ===
<code>function UniKey__Read_SoftID(pHandle: pWord; pSoftID: pLongWord): DWORD; stdcall;</code>
 
'''API Prototype'''
 
<code>function UniKey__Write_SoftID(pHandle: pWord; lp1: pLongWord): DWORD; stdcall;</code>
 
'''Description'''


'''Description'''<br>
Write the vendor-defined software ID.  
Read the user defined SoftID.


'''Parameters'''<br>
'''Parameters'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 673: Line 721:
<tr>
<tr>
<td>*pSoftID</td>
<td>*pSoftID</td>
<td>[out] Soft ID</td>
<td>[in] Software ID</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 688: Line 737:
<td>0</td>
<td>0</td>
<td>Success</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_UNIKEY_SET_SOFTID</td>
<td>203</td>
<td>Set software ID error</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>No logon dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
 
UniKey_Write_SoftID and UniKey_Read_SoftID provide a means to make a soft (write-able) ID for each software. You can write different software ID for each software and call UNIKEY_READ_SOFTID to check if the software ID is correct.
----
<br>---------------------------------------------------------------------------------------------------<br>
You need to verify all 4 passwords (vendor mode) to write the software ID to the dongle.
----


<br>
<br>
=== Set a UniKey License module ===


'''API Prototype'''<br>
=== Read Software ID ===
<code>function UniKey__Set_Module(pHandle: pWord; pModule: pWord; pValue: pWord; pDecrease: pWord): DWORD; stdcall;</code>
 
'''API Prototype'''
 
<code>function UniKey__Read_SoftID(pHandle: pWord; pSoftID: pLongWord): DWORD; stdcall;</code>
 
'''Description'''
 
Read the user-defined software ID.


'''Description'''<br>
'''Parameters'''
To write a value to a specific UniKey license module and set the Decrement attribute.


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 721: Line 779:
</tr>
</tr>
<tr>
<tr>
<td>*pModule</td>
<td>*pSoftID</td>
<td>[in] License module Number</td>
<td>[out] Software ID</td>
</tr>
</tr>
<tr>
</table>
<td>*pValue</td>
 
<td>[in] License module Unit Value</td>
'''Return values'''
</tr>
 
<tr>
<table class="wikitable">
<td>*pDecrease</td>
<td>[in] Decreasing attribute. If decreasing is allowed (1 = allowed, 0 = not allowed)</td>
</tr>
</table>
 
'''Return values'''<br>
<table border="1">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 745: Line 796:
<td>0</td>
<td>0</td>
<td>Success</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>202</td>
<td>Read/Write address or length is wrong</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>No logon dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
<tr>
<td>ERROR_UNIKEY_MODULE</td>
<td>216</td>
<td>License module error</td>
</tr>
</tr>
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
A successful operation will result in license module unit # "*pModule" storing value "*pValue" and the Decrement attribute set to "0" or "1".
<br>---------------------------------------------------------------------------------------------------<br>


<br>---------------------------------------------------------------------------------------------------<br>
----
You need verify 4 passwords (vendor mode) to set a module value successfully.
<code>UniKey__Write_SoftID</code> and <code>UniKey__Read_SoftID</code> provide a means to make a soft (write-able) ID for each software. You can write different software ID for each software and call <code>UNIKEY_READ_SOFTID</code> to check if the software ID is correct.
<br>---------------------------------------------------------------------------------------------------<br>
----


<br>
<br>
<!--"Get a UniKey License module"?-->
=== Check a UniKey License module ===


'''API Prototype'''<br>
=== Set a UniKey License module  ===
<code>function UniKey__Check_Module(pHandle: pWord; pModule: pWord; pValue: pWord; pDecrease: pWord): DWORD; stdcall;</code>
 
'''API Prototype'''
 
<code>function UniKey__Set_Module(pHandle: pWord; pModule: pWord; pValue: pWord; pDecrease: pWord): DWORD; stdcall;</code>
 
'''Description'''


'''Description'''<br>
To write a value to a specific UniKey license module and set the Decrement attribute.  
Read the attributes of a specific UniKey license module.


'''Parameters'''<br>
'''Parameters'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 793: Line 834:
<tr>
<tr>
<td>*pModule</td>
<td>*pModule</td>
<td>[in] License module Number</td>
<td>[in] License module number</td>
</tr>
</tr>
<tr>
<tr>
<td>*pValue</td>
<td>*pValue</td>
<td>[out] Validity (1 = license module value is not zero)</td>
<td>[in] License module unit value</td>
</tr>
</tr>
<tr>
<tr>
<td>*pDecrease</td>
<td>*pDecrease</td>
<td>[out] Decrement attribute (1 = license module can be decreased)</td>
<td>[in] Decrement attribute (1 = allowed, 0 = not allowed)</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 820: Line 862:
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>202</td>
<td>202</td>
<td>Read/Write address or length is wrong</td>
<td>Read/Write address is incorrect or invalid length</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>No logon dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
Line 834: Line 876:
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
A successful operation will result in "*pValue" with value from the Validity (1 = license module value is not zero), and "*pDecrease" with the value from the Decrement attribute (1 = license module can be decreased). The value of a license module cannot be read out directly and it is invisible to end users.
<br>---------------------------------------------------------------------------------------------------<br>


<br>---------------------------------------------------------------------------------------------------<br>
----
UniKey_Set_Module and UniKey_Check_Module provide an easy mean to implement software limitation. For example, if you want to set a software can be only executed 3 times, so you can call UNIKEY_SET_MODULE to set a license module (let us say license module 0) as 3. And when each execution, we decrease the license module, if the license module is invalid (zero), we stop the software. Apart from this, we can implement a module-selling model with help of license module functions. For example, the software has four function modules, A, B, C and D. And we can map the function modules to the license module in the UniKey dongle. Let us say the function module A is mapped to license module 0, B to 1, C to 2 and D to 3. If a customer only buys function A, B, you just need to enable the license module 0 and 1, and leave 2 and 3 as zero. So only function module A and B can be executed. If the customer buys more function, you can use UniKey remote update function to update the dongle remotely.
A successful operation will result in license module unit number *pModule storing value *pValue, and the Decrement attribute set to "0" or "1".
<br>---------------------------------------------------------------------------------------------------<br>
----
 
 
----
You need to verify all 4 passwords (vendor mode) to set a module value successfully.
----


<br>
<br>
=== Write Arithmetic ===


'''API Prototype'''<br>
=== Get a UniKey License module  ===
<code>function UniKey__Write_Arithmetic(pHandle: pWord; pStartAddress: pWord; pBuffer: pByteArray): DWORD; stdcall;</code>
 
'''API Prototype'''
 
<code>function UniKey__Check_Module(pHandle: pWord; pModule: pWord; pValue: pWord; pDecrease: pWord): DWORD; stdcall;</code>
 
'''Description'''
 
Get a value from a specific UniKey license module.


'''Description'''<br>
'''Parameters'''
Write user-defined mathematical algorithms. 


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 863: Line 910:
</tr>
</tr>
<tr>
<tr>
<td>*pStartAddress</td>
<td>*pModule</td>
<td>[in] Offset of first instruction </td>
<td>[in] Module Number</td>
</tr>
</tr>
<tr>
<tr>
<td>*pBuffer</td>
<td>*pValue</td>
<td>[in] Pointer to the algorithm command string</td>
<td>[out] Return the value in module</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br><table border="1">
'''Return values'''
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 885: Line 934:
<tr>
<tr>
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>204</td>
<td>202</td>
<td>Read/Write address or length is wrong</td>
<td>Read/Write address is incorrect or invalid length</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>No logon dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_AR_BAD_COMMAND</td>
<td>ERROR_UNIKEY_MODULE</td>
<td>217</td>
<td>216</td>
<td>Arithmetic instruction Error</td>
<td>License module error</td>
</tr>
</tr>
<tr>
</table>
<td>ERROR_UNIKEY_AR_UNKNOWN_OPCODE</td>
 
<td>218</td>
 
<td>Arithmetic operator Error</td>
----
</tr>
You need to verify 2 passwords (user mode) to get a module value successfully.
<tr>
----
<td>ERROR_UNIKEY_AR_WRON_GBEGIN</td>
 
<td>219</td>
<br>
<td>Const number can't use on first arithmetic instruction</td>
 
</tr>
=== Check a UniKey License module  ===
<tr>
<td>ERROR_UNIKEY_AR_WRONG_END</td>
<td>220</td>
<td>Const number can't use on last arithmetic instruction</td>
</tr>
<tr>
<td>ERROR_UNIKEY_AR_VALUE_OVERFLOW</td>
<td>221</td>
<td>Const number > 63</td>
</tr>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
'''API Prototype'''
A successful operation will result in the user-defined algorithm populated with the algorithm command string from the buffer.
<br>---------------------------------------------------------------------------------------------------<br>


<br>---------------------------------------------------------------------------------------------------<br>
<code>function UniKey__Check_Module(phandle: pWord; pModule: pWord; pValues: pWord; pDecrease: pWord): DWORD; stdcalll;</code>
UniKey_Write_Arithmetic is called when you write a series of algorithms into the dongle. This function is only called at software vendor side. For example, if you have a serial number generate algorithm, and you want to perform this algorithm inside the dongle, you need to call UniKey_Write_Arithmetic.
<br>---------------------------------------------------------------------------------------------------<br>


<br>
'''Description'''
=== User-defined Algorithm Calculate 1 ===


'''API Prototype'''<br>
Read the attributes of a specific UniKey license module.
<code>function UniKey__Calculate1(pHandle: pWord; pStartAddress: pLongWord; pModule: pLongWord; pRegisterA: pWord; pRegisterB: pWord; pRegisterC: pWord; pRegisterD: pWord): DWORD; stdcall;</code>


'''Description'''<br>
'''Parameters'''
Return the results of a calculation performed in UniKey, using input provided by the developer and the CALCULATE1 function.


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 947: Line 976:
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in] Dongle handle</td>
<td>[in] Dongle handle</td>
</tr>
<tr>
<td>*pStartAddress</td>
<td>[in] Start point of calculation</td>
</tr>
</tr>
<tr>
<tr>
Line 957: Line 982:
</tr>
</tr>
<tr>
<tr>
<td>*p1</td>
<td>*pValue</td>
<td>[in, out] Register A</td>
<td>[out] Validity (1 = license module value is not zero)</td>
</tr>
</tr>
<tr>
<tr>
<td>*p2</td>
<td>*pDecrease</td>
<td>[in, out] Register B</td>
<td>[out] Decrement attribute (1 = license module can be decreased)</td>
</tr>
<tr>
<td>*p3</td>
<td>[in, out] Register C</td>
</tr>
<tr>
<td>*p4</td>
<td>[in, out] Register D</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<tr>
<table class="wikitable">
<tr>
<th>Result</th>
<th>Result</th>
<th>Value</th>
<th>Value</th>
Line 988: Line 1,006:
<tr>
<tr>
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>204</td>
<td>202</td>
<td>Read/Write address or length is wrong</td>
<td>Read/Write address is incorrect or invalid length</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>No logon dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_AR_BAD_COMMAND</td>
<td>ERROR_UNIKEY_MODULE</td>
<td>217</td>
<td>216</td>
<td>Arithmetic instruction Error</td>
<td>License module error</td>
</tr>
<tr>
<td>ERROR_UNIKEY_AR_UNKNOWN_OPCODE</td>
<td>218</td>
<td>Arithmetic operator Error</td>
</tr>
<tr>
<td>ERROR_UNIKEY_AR_WRON_GBEGIN</td>
<td>219</td>
<td>Const number can't use on first arithmetic instruction</td>
</tr>
<tr>
<td>ERROR_UNIKEY_AR_WRONG_END</td>
<td>220</td>
<td>Const number can't use on last arithmetic instruction</td>
</tr>
<tr>
<td>ERROR_UNIKEY_AR_VALUE_OVERFLOW</td>
<td>221</td>
<td>Const number > 63</td>
</tr>
</tr>
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
When the calculation starts, the values of other internal registers are listed in the table below. <br>E and F are reversed hardware ID byte wisely. For example, if the hardware is 0x12345678 (in Hex), and E will be 0x7856, and F will be 0x3412.
<br>---------------------------------------------------------------------------------------------------<br>


<table border="1">
----
<tr>
A successful operation will result in *pValue having value from Validity (1 = license module value is not zero), and *pDecrease having value from the Decrement attribute (1 = license module can be decreased). The value of a license module cannot be read directly, and it is invisible to end users.
<th>Internal Register</th>
----
<th>Description</th>
 
</tr>
 
<tr>
----
<td>E</td>
<code>UniKey__Set_Module</code> and <code>UniKey__Check_Module</code> provide an easy way to implement software limitations. For example, if you want to set software to only be executed 3 times, you can call <code>UniKey__Set_Module</code> to set a license module (let us say license module 0) as 3. And, during each execution, we decrease the license module, if the license module is invalid (zero), we stop the software. Apart from this, we can implement a module-selling model with the help of license module functions. For example, the software has four function modules, A, B, C and D. And we can map the function modules to the license modules in the UniKey dongle. Let us say that function module A is mapped to license module 0, B to 1, C to 2 and D to 3. If a customer only buys function A and B, you only need to enable license module 0 and 1, and leave 2 and 3 as zero. So now only function module A and B can be executed. If the customer buys additional functions, you can use the UniKey Remote Updater tool to update the dongle as needed remotely.
<td>HiWord of reversed hardware ID </td>
----
</tr>
 
<tr>
<br>
<td>F</td>
 
<td>LoWord of reversed hardware ID </td>
=== Write Arithmetic  ===
</tr>
<tr>
<td>G</td>
<td>Value stored in license module *pModule</td>
</tr>
<tr>
<td>H</td>
<td>Random number </td>
</tr>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
'''API Prototype'''
Examples<br>If the internal algorithm is A = B + C, <br>Then the call result is *p1 = *p2 + *p3. <br>For example: The internal algorithm is A = A + G; If *p1 = 0, then when returning you may guess the content of license module *p1 = *pModule. Though you cannot read the content of modules directly, you may determine the content by algorithm. If possible, you had better check the content with an algorithm, not only comparing it in the program.
<br>---------------------------------------------------------------------------------------------------<br>


<br>
<code>function UniKey__Write_Arithmetic(pHandle: pWord; pStartAddress: pWord; pBuffer: pByteArray): DWORD; stdcall;</code>
=== User-defined Algorithm Calculate 2 ===


'''API Prototype'''<br>
'''Description'''
<code>function UniKey__Calculate2(pHandle: pWord; pStartAddress: pLongWord; pSeed: pLongWord; pRegisterA: pWord; pRegisterB: pWord; pRegisterC: pWord; pRegisterD: pWord): DWORD; stdcall;</code>


'''Description'''<br>
Write user-defined mathematical algorithms.  
Return the results of a calculation performed in UniKey, using input provided by the developer and the CALCULATE2 function.


'''Parameters'''<br>
'''Parameters'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 1,076: Line 1,056:
<tr>
<tr>
<td>*pStartAddress</td>
<td>*pStartAddress</td>
<td>[in] Start point of calculation</td>
<td>[in] Offset of first instruction</td>
</tr>
</tr>
<tr>
<tr>
<td>*pSeed</td>
<td>*pBuffer</td>
<td>[in] Seed Code (32-bit)</td>
<td>[in] Pointer to the algorithm command string</td>
</tr>
</tr>
</table>
'''Return values'''
<table class="wikitable">
<tr>
<tr>
<td>*p1</td>
<th>Result</th>
<td>[in, out] Register A</td>
<th>Value</th>
<th>Description</th>
</tr>
</tr>
<tr>
<tr>
<td>*p2</td>
<td>SUCCESS</td>
<td>[in, out] Register B</td>
<td>0</td>
<td>Success</td>
</tr>
</tr>
<tr>
<tr>
<td>*p3</td>
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>[in, out] Register C</td>
</tr>
<tr>
<td>*p4</td>
<td>[in, out] Register D</td>
</tr>
</table>
 
'''Return values'''<br>
<table border="1">
<tr>
<th>Result</th>
<th>Value</th>
<th>Description</th>
</tr>
<tr>
<td>SUCCESS</td>
<td>0</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>204</td>
<td>204</td>
<td>Read/Write address or length is wrong</td>
<td>Read/Write address is incorrect or invalid length</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>No logon dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_AR_BAD_COMMAND</td>
<td>ERROR_UNIKEY_AR_BAD_COMMAND</td>
<td>217</td>
<td>217</td>
<td>Arithmetic instruction Error</td>
<td>Arithmetic instruction error</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_AR_UNKNOWN_OPCODE</td>
<td>ERROR_UNIKEY_AR_UNKNOWN_OPCODE</td>
<td>218</td>
<td>218</td>
<td>Arithmetic operator Error</td>
<td>Arithmetic operator error</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_AR_WRON_GBEGIN</td>
<td>ERROR_UNIKEY_AR_WRONG_BEGIN</td>
<td>219</td>
<td>219</td>
<td>Const number can't use on first arithmetic instruction</td>
<td>Constant numbers can't be used on first arithmetic instruction</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_AR_WRONG_END</td>
<td>ERROR_UNIKEY_AR_WRONG_END</td>
<td>220</td>
<td>220</td>
<td>Const number can't use on last arithmetic instruction</td>
<td>Constant numbers can't be used on last arithmetic instruction</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_AR_VALUE_OVERFLOW</td>
<td>ERROR_UNIKEY_AR_VALUE_OVERFLOW</td>
<td>221</td>
<td>221</td>
<td>Const number > 63</td>
<td>Constant numbers > 63 will cause an overflow</td>
</tr>
</tr>
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
When performing calculation 2, the initial values of register E, F, G and H are the '''Return values''' of seed code *pSeed, to make it simple, UNIKEY calls function SEED with seed code *pSeed, and writes the '''Return values''' to register E, F, G and H for the next operation.
<br>---------------------------------------------------------------------------------------------------<br>


<table border="1">
----
<tr>
A successful operation will result in a user-defined algorithm containing the algorithm command string from the buffer.
<th>Internal Register</th>
----
<th>Description</th>
 
</tr>
 
<tr>
----
<td>E</td>
<code>UniKey__Write_Arithmetic</code> is called when you write a series of algorithms into the dongle. This function is only called on the software vendor side. For example, if you have a serial number generator algorithm, and you want to perform this algorithm inside the dongle, you need to call <code>UniKey__Write_Arithmetic</code>
<td>Seed Result 1</td>
----
</tr>
<tr>
<td>F</td>
<td>Seed Result 2</td>
</tr>
<tr>
<td>G</td>
<td>Seed Result 3</td>
</tr>
<tr>
<td>H</td>
<td>Seed Result 4</td>
</tr>
</table>


<br>
<br>
=== User-defined Algorithm Calculate 3 ===


'''API Prototype'''<br>
=== User-Defined Algorithm Calculate 1 ===
<code>function UniKey__Calculate3(pHandle: pWord; pStartAddress: pLongWord; pModule: pLongWord; pRegisterA: pWord; pRegisterB: pWord; pRegisterC: pWord; pRegisterD: pWord): DWORD; stdcall;</code>
 
'''API Prototype'''
 
<code>function UniKey__Calculate1(pHandle: pWord; pStartAddress: pLongWord; pModule: pLongWord; pRegisterA: pWord; pRegisterB: pWord; pRegisterC: pWord; pRegisterD: pWord): DWORD; stdcall;</code>
 
'''Description'''
 
Return the results of a calculation performed in the UniKey, using input provided by the developer and the CALCULATE1 function.


'''Description'''<br>
'''Parameters'''
Return results of a calculation performed in UniKey, using input provided by the developer and the CALCULATE3 function.


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 1,222: Line 1,172:
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 1,237: Line 1,188:
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>204</td>
<td>204</td>
<td>Read/Write address or length is wrong</td>
<td>Read/Write address is incorrect or invalid length</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>No logon dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_AR_BAD_COMMAND</td>
<td>ERROR_UNIKEY_AR_BAD_COMMAND</td>
<td>217</td>
<td>217</td>
<td>Arithmetic instruction Error</td>
<td>Arithmetic instruction error</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_AR_UNKNOWN_OPCODE</td>
<td>ERROR_UNIKEY_AR_UNKNOWN_OPCODE</td>
<td>218</td>
<td>218</td>
<td>Arithmetic operator Error</td>
<td>Arithmetic operator error</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_AR_WRON_GBEGIN</td>
<td>ERROR_UNIKEY_AR_WRONG_BEGIN</td>
<td>219</td>
<td>219</td>
<td>Const number can't use on first arithmetic instruction</td>
<td>Constant numbers can't be used on first arithmetic instruction</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_AR_WRONG_END</td>
<td>ERROR_UNIKEY_AR_WRONG_END</td>
<td>220</td>
<td>220</td>
<td>Const number can't use on last arithmetic instruction</td>
<td>Constant numbers can't be used on last arithmetic instruction</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_AR_VALUE_OVERFLOW</td>
<td>ERROR_UNIKEY_AR_VALUE_OVERFLOW</td>
<td>221</td>
<td>221</td>
<td>Const number > 63</td>
<td>Constant numbers > 63 will cause an overflow</td>
</tr>
</tr>
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
When performing calculation 3, the initial values of register E, F, G and H are the content of license module *lp2 and *lp2+1/2/3.
<br>---------------------------------------------------------------------------------------------------<br>


<table border="1">
----
When the calculation starts, the values of other internal registers are listed in the table below.<br>E and F is the bytewise reversed hardware ID. For example, if the hardware is 0x12345678 (in hex), then E will be 0x7856 and F will be 0x3412.
----
 
 
<table class="wikitable">
<tr>
<tr>
<th>Internal Register</th>
<th>Internal Register</th>
Line 1,282: Line 1,235:
<tr>
<tr>
<td>E</td>
<td>E</td>
<td>Value in license module *lp2</td>
<td>High-order byte of reversed hardware ID</td>
</tr>
</tr>
<tr>
<tr>
<td>F</td>
<td>F</td>
<td>Value in license module (*lp2 + 1)</td>
<td>Low-order byte of reversed hardware ID</td>
</tr>
</tr>
<tr>
<tr>
<td>G</td>
<td>G</td>
<td>Value in license module (*lp2 + 2)</td>
<td>Value stored in license module *pModule</td>
</tr>
</tr>
<tr>
<tr>
<td>H</td>
<td>H</td>
<td>Value in license module (*lp2 + 3)</td>
<td>Random number</td>
</tr>
</tr>
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
Examples<br>When calls calculation 3 with *pModule = 0, the initial values of register E, F, G and H are:<br>E = Value of license module 0<br>F = Value of license module 1<br>G = Value of license module 2<br>F = Value of license module 3<br>Note: The address will return to "0" when the license module address call exceeds 128. For example: Calculation 3 with *pModule = 126, the initial values of register E, F, G and H are:<br>E = Value of license module 126<br>F = Value of license module 127<br>G = Value of license module 0<br>H = Value of license module 1
<br>---------------------------------------------------------------------------------------------------<br>


<br>---------------------------------------------------------------------------------------------------<br>
----
UniKey_Calculate is called when you want to perform the algorithm you have written inside the UniKey dongle. For example, you have written a formula into the dongle, you can call UniKey_Calculate to perform the algorithms and get the return of the formula.
Examples:
<br>---------------------------------------------------------------------------------------------------<br>
<br>If the internal algorithm is A = B + C, then the call result is *pRegA = *pRegB + *pRegC
<br>The internal algorithm is A = A + G; if *pRegA = 0, then you may guess the result is the license module such that *pRegA = G = *pModule
<br>Though you cannot read the content of modules directly, you can determine the content by an algorithm. If possible, it would be best to also check this content with an algorithm, and not only compare it in the program.
----


<br>
<br>
=== Decrease a License Module ===


'''API Prototype'''<br>
=== User-Defined Algorithm Calculate 2  ===
<code>function UniKey__Module_Decrase(pHandle: pWord; pModule: pWord): DWORD; stdcall;</code>


'''Description'''<br>
'''API Prototype'''
Decrease the value in a specified UniKey license module by “1”.


'''Parameters'''<br>
<code>function UniKey__Calculate2(pHandle: pWord; pStartAddress: pLongWord; pSeed: pLongWord; pRegisterA: pWord; pRegisterB: pWord; pRegisterC: pWord; pRegisterD: pWord): DWORD; stdcall;</code>
<table border="1">
 
<tr>
'''Description'''
<th>Parameter</th>
 
<th>Description</th>
Return the results of a calculation performed in the UniKey, using input provided by the developer and the CALCULATE2 function.
 
'''Parameters'''
 
<table class="wikitable">
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</tr>
<tr>
<tr>
Line 1,327: Line 1,283:
</tr>
</tr>
<tr>
<tr>
<td>*pModule</td>
<td>*pStartAddress</td>
<td>[in] License module number</td>
<td>[in] Start point of calculation</td>
</tr>
<tr>
<td>*pSeed</td>
<td>[in] Seed code (32-bit)</td>
</tr>
<tr>
<td>*pRegA</td>
<td>[in, out] Register A</td>
</tr>
<tr>
<td>*pRegB</td>
<td>[in, out] Register B</td>
</tr>
<tr>
<td>*pRegC</td>
<td>[in, out] Register C</td>
</tr>
<tr>
<td>*pRegD</td>
<td>[in, out] Register D</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 1,347: Line 1,324:
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>204</td>
<td>204</td>
<td>Read/Write address or length is wrong</td>
<td>Read/Write address is incorrect or invalid length</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>No logon dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_MODULE</td>
<td>ERROR_UNIKEY_AR_BAD_COMMAND</td>
<td>216</td>
<td>217</td>
<td>License module error</td>
<td>Arithmetic instruction error</td>
</tr>
<tr>
<td>ERROR_UNIKEY_AR_UNKNOWN_OPCODE</td>
<td>218</td>
<td>Arithmetic operator error</td>
</tr>
<tr>
<td>ERROR_UNIKEY_AR_WRON_GBEGIN</td>
<td>219</td>
<td>Constant numbers can't be used on first arithmetic instruction</td>
</tr>
<tr>
<td>ERROR_UNIKEY_AR_WRONG_END</td>
<td>220</td>
<td>Constant numbers can't be used on last arithmetic instruction</td>
</tr>
<tr>
<td>ERROR_UNIKEY_AR_VALUE_OVERFLOW</td>
<td>221</td>
<td>Constant numbers > 63 will cause an overflow</td>
</tr>
</tr>
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
Please call UniKey_Check_Module to check if the license module is valid first.
<br>---------------------------------------------------------------------------------------------------<br>


<br>
----
When using calculate 2, the initial values of register E, F, G and H are the return values of seed code *pSeed, to make it simple, the UniKey calls function SEED with seed code *pSeed, and writes the return values to register E, F, G and H for the next operation.
=== Generate a New Password ===
----


'''API Prototype'''<br>
<code>function UniKey__Generate_New_Password(pHandle: pWord; pSeed: pLongWord; pPassword1: pWord; pPassword2: pWord; pPassword3: pWord; pPassword4: pWord): DWORD; stdcall;</code>


'''Description'''<br>
<table class="wikitable">
Generate a new password via a seed code; the mapping from the seed code to the password is only one way. Without the seed, you cannot generate the same password.
 
'''Parameters'''<br>
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Internal Register</th>
<th>Description</th>
<th>Description</th>
</tr>
</tr>
<tr>
<tr>
<td>*pHandle</td>
<td>E</td>
<td>[in] Dongle handle</td>
<td>Seed result 1</td>
</tr>
</tr>
<tr>
<tr>
<td>*pSeed</td>
<td>F</td>
<td>[in] Seed Code (32-bit)</td>
<td>Seed result 2</td>
</tr>
</tr>
<tr>
<tr>
<td>*pPassword1</td>
<td>G</td>
<td>[out] New password 1</td>
<td>Seed result 3</td>
</tr>
</tr>
<tr>
<tr>
<td>*pPassword2</td>
<td>H</td>
<td>[out] New password 2</td>
<td>Seed result 4</td>
</tr>
</tr>
<tr>
</table>
<td>*pPassword3</td>
 
<td>[out] New password 3</td>
<br>
</tr>
 
<tr>
=== User-Defined Algorithm Calculate 3 ===
<td>*pPassword4</td>
 
<td>[out] New password 4</td>
'''API Prototype'''
</tr>
 
</table>
<code>function UniKey__Calculate3(pHandle: pWord; pStartAddress: pLongWord; pModule: pLongWord; pRegisterA: pWord; pRegisterB: pWord; pRegisterC: pWord; pRegisterD: pWord): DWORD; stdcall;</code>
 
'''Description'''
 
Return results of a calculation performed in the UniKey, using input provided by the developer and the CALCULATE3 function.
 
'''Parameters'''


'''Return values'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Result</th>
<th>Parameter</th>
<th>Value</th>
<th>Description</th>
<th>Description</th>
</tr>
</tr>
<tr>
<tr>
<td>SUCCESS</td>
<td>*pHandle</td>
<td>0</td>
<td>[in] Dongle handle</td>
<td>Success</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>*pStartAddress</td>
<td>212</td>
<td>[in] Start point of calculation</td>
<td>No logon dongle before operating dongle</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_VERIFY_ADV_PASSWORD</td>
<td>*pModule</td>
<td>223</td>
<td>[in] License module number</td>
<td>Advanced passwords (password3 and passowrd4) not verified</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_GENERATE_NEW_PASSWORD</td>
<td>*pRegA</td>
<td>225</td>
<td>[in, out] Register A</td>
<td>Generate new password Error</td>
</tr>
</tr>
</table>
<br>---------------------------------------------------------------------------------------------------<br>
A file recording the new SEED and PASSWORDs will be created in the working path, and help the software vendor to recall everything. The passwords can be distributed to ordinary developers!
<br>---------------------------------------------------------------------------------------------------<br>
<br>---------------------------------------------------------------------------------------------------<br>
1. The dongle will be automatically logoff after a new set of passwords are generated. <br>2. The dongle will be fully formatted when a new password is generated.<br>3. A file including new password and seed will be created in the working directory.
<br>---------------------------------------------------------------------------------------------------<br>
<br>
=== Generate a New Encryption Key ===
'''API Prototype'''<br>
<code>function UniKey__Generate_Key(pHandle: pWord; lKeyNumber: pLongWord): DWORD; stdcall;</code>
'''Description'''<br>
Generate a new key in the specific key storage.
'''Parameters'''<br>
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<td>*pRegB</td>
<th>Description</th>
<td>[in, out] Register B</td>
</tr>
</tr>
<tr>
<tr>
<td>*pHandle</td>
<td>*pRegC</td>
<td>[in] Dongle handle</td>
<td>[in, out] Register C</td>
</tr>
</tr>
<tr>
<tr>
<td>*pKeyNumber</td>
<td>*pRegD</td>
<td>[in] Key Storage Number</td>
<td>[in, out] Register D</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 1,481: Line 1,448:
<td>0</td>
<td>0</td>
<td>Success</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>204</td>
<td>Read/Write address is incorrect or invalid length</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>No logon dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_INVALID_KEY_STORE</td>
<td>ERROR_UNIKEY_AR_BAD_COMMAND</td>
<td>224</td>
<td>217</td>
<td>Wrong key storage number</td>
<td>Arithmetic instruction error</td>
</tr>
</tr>
</table>
<tr>
 
<td>ERROR_UNIKEY_AR_UNKNOWN_OPCODE</td>
<br>---------------------------------------------------------------------------------------------------<br>
<td>218</td>
1. This function will delete the original key in the key storage, and generate a new key. <br>2. The data encrypted by the old key cannot be decrypted by the new key. <br>3. Each key is 128-bit long.
<td>Arithmetic operator error</td>
<br>---------------------------------------------------------------------------------------------------<br>
</tr>
<tr>
<td>ERROR_UNIKEY_AR_WRON_GBEGIN</td>
<td>219</td>
<td>Constant numbers can't be used on first arithmetic instruction</td>
</tr>
<tr>
<td>ERROR_UNIKEY_AR_WRONG_END</td>
<td>220</td>
<td>Constant numbers can't be used on last arithmetic instruction</td>
</tr>
<tr>
<td>ERROR_UNIKEY_AR_VALUE_OVERFLOW</td>
<td>221</td>
<td>Constant numbers > 63 will cause an overflow</td>
</tr>
</table>


<br>
=== Generate a New Encryption Key via Seed ===


'''API Prototype'''<br>
----
<code>function UniKey__Generate_Key_Via_Seed (pHandle: pWord; pKeyNumber: pLongWord; pSeed1: pWord; pSeed2: pWord; pSeed3: pWord; pSeed4: pWord): DWORD; stdcall;</code>
When using calculate 3, the initial values of register E, F, G and H are the content of license module *lp2 and *lp2 + 1/2/3.
----


'''Description'''<br>
Generate a new key in the specific key storage via seed.


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Internal Register</th>
<th>Description</th>
<th>Description</th>
</tr>
</tr>
<tr>
<tr>
<td>*pHandle</td>
<td>E</td>
<td>[in] Dongle handle</td>
<td>Value in license module *lp2</td>
</tr>
</tr>
<tr>
<tr>
<td>*pKeyNumber</td>
<td>F</td>
<td>[in] Key Storage Number</td>
<td>Value in license module (*lp2 + 1)</td>
</tr>
</tr>
<tr>
<tr>
<td>*pSeed1</td>
<td>G</td>
<td>[in] Seed1</td>
<td>Value in license module (*lp2 + 2)</td>
</tr>
</tr>
<tr>
<tr>
<td>*pSeed2</td>
<td>H</td>
<td>[in] Seed2</td>
<td>Value in license module (*lp2 + 3)</td>
</tr>
</tr>
<tr>
</table>
<td>*pSeed3</td>
 
<td>[in] Seed3</td>
 
----
Examples:
<br>When calling calculation 3 with *pModule = 0, the initial values of register E, F, G and H are:
<br>E = value of license module 0
<br>F = value of license module 1
<br>G = value of license module 2
<br>F = value of license module 3
<br>Note: The address will return to "0" when the license module address call exceeds 128. For example: Calculation 3 with *pModule = 126, the initial values of register E, F, G and H are:
<br>E = value of license module 126
<br>F = value of license module 127
<br>G = value of license module 0
<br>H = value of license module 1
----
 
 
----
<code>UniKey__Calculate</code> is called when you want to perform the algorithm you have written inside the UniKey dongle. For example, you have written a formula into the dongle, you can call <code>UniKey__Calculate</code> to perform the algorithm and get the return value of the formula.
----
 
<br>
 
=== Decrease a License Module ===
 
'''API Prototype'''
 
<code>function UniKey__Module_Decrease(pHandle: pWord; pModule: pWord): DWORD; stdcall;</code>
 
'''Description'''
 
Decrease the value in a specified UniKey license module by "1".
 
'''Parameters'''
 
<table class="wikitable">
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
<tr>
<td>*pHandle</td>
<td>[in] Dongle handle</td>
</tr>
</tr>
<tr>
<tr>
<td>*pSeed4</td>
<td>*pModule</td>
<td>[in] Seed4</td>
<td>[in] License module number</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 1,551: Line 1,576:
<td>0</td>
<td>0</td>
<td>Success</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>204</td>
<td>Read/Write address is incorrect or invalid length</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>No logon dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_INVALID_KEY_STORE</td>
<td>ERROR_UNIKEY_MODULE</td>
<td>224</td>
<td>216</td>
<td>Wrong key storage number</td>
<td>License module error</td>
</tr>
</tr>
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
 
1. This function will delete the original key in the key storage, and generate a new key via seed. <br>2. The data encrypted by the old key cannot be decrypted by the new key. <br>3. Each key is 128-bit long.
----
<br>---------------------------------------------------------------------------------------------------<br>
Please call <code>UniKey__Check_Module</code> to check if the license module is valid first.
----


<br>
<br>
=== Encrypt the Buffer with a Specific Encryption Key ===


'''API Prototype'''<br>
=== Generate a New Password ===
<code>function UniKey__Encrypt(pHandle: pWord; pBufferLength: pLongWord; pKeyNumber: pLongWord; pBuffer: pByteArray): DWORD; stdcall;</code>
 
'''API Prototype'''
 
<code>function UniKey__Generate_New_Password(pHandle: pWord; pSeed: pLongWord; pPassword1: pWord; pPassword2: pWord; pPassword3: pWord; pPassword4: pWord): DWORD; stdcall;</code>
 
'''Description'''
 
Generate a new password via a seed code; the mapping from the seed code to the password is a one-way function. Without the seed, you cannot generate the same password.


'''Description'''<br>
'''Parameters'''
Encrypt an amount of memory with a key. The length of data must be a multiple of 8.


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
<th>Meaning</th>
<th>Description</th>
</tr>
</tr>
<tr>
<tr>
Line 1,589: Line 1,623:
</tr>
</tr>
<tr>
<tr>
<td>*pBufferLength</td>
<td>*pSeed</td>
<td>[in] Number of bytes to encrypt</td>
<td>[in] Seed code (32-bit)</td>
</tr>
</tr>
<tr>
<tr>
<td>*pKeyNumber</td>
<td>*pPassword1</td>
<td>[in] Key Storage Number</td>
<td>[out] New password 1</td>
</tr>
</tr>
<tr>
<tr>
<td>*pBuffer</td>
<td>*pPassword2</td>
<td>[in] Pointer to the data to be encrypted</td>
<td>[out] New password 2</td>
</tr>
</tr>
<tr>
<tr>
<td></td>
<td>*pPassword3</td>
<td>[out] Pointer to the encrypted data</td>
<td>[out] New password 3</td>
</tr>
</tr>
</table>
<tr>
 
<td>*pPassword4</td>
'''Return values'''<br>
<td>[out] New password 4</td>
<table border="1">
</tr>
</table>
 
'''Return values'''
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 1,621: Line 1,660:
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>No logon dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_INVALID_KEY_STORE</td>
<td>ERROR_UNIKEY_VERIFY_ADV_PASSWORD</td>
<td>224</td>
<td>223</td>
<td>Wrong key storage number</td>
<td>Advanced passwords (passwords 3 and 4) not verified</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_ENCRYPT_FAILED</td>
<td>ERROR_UNIKEY_GENERATE_NEW_PASSWORD</td>
<td>228</td>
<td>225</td>
<td>Encrypt data error</td>
<td>Error generating new password</td>
</tr>
</tr>
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
 
This function only performs an encryption operation, no compression functions are involved.
----
<br>---------------------------------------------------------------------------------------------------<br>
A file recording the new seed and passwords will be created in the working path, helping the software vendor to record everything. The passwords can be distributed to ordinary developers!
----
 
 
----
# The dongle will automatically log off after a new set of passwords have been generated.
# The dongle will be fully formatted when a new password is generated.
# A file including the new passwords and seed will be created in the working directory.
----


<br>
<br>
=== Decrypt the Buffer with a Specific Encryption Key ===


'''API Prototype'''<br>
=== Generate a New Encryption Key ===
<code>function UniKey__Decrypt(pHandle: pWord; pBufferLength: pLongWord; pKeyNumber: pLongWord; pBuffer: pByteArray): DWORD; stdcall;</code>
 
'''API Prototype'''
 
<code>function UniKey__Generate_Key(pHandle: pWord; lKeyNumber: pLongWord): DWORD; stdcall;</code>
 
'''Description'''
 
Generate a new key in the specific key storage.


'''Description'''<br>
'''Parameters'''
Encrypt an amount of memory with a key. The length of data must be a multiple of 8.


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
<th>Meaning</th>
<th>Description</th>
</tr>
</tr>
<tr>
<tr>
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in] Dongle handle</td>
<td>[in] Dongle handle</td>
</tr>
<tr>
<td>*pBufferLength</td>
<td>[in] Number of bytes to encrypt</td>
</tr>
</tr>
<tr>
<tr>
<td>*pKeyNumber</td>
<td>*pKeyNumber</td>
<td>[in] Key Storage Number</td>
<td>[in] Key storage number</td>
</tr>
<tr>
<td>*pBuffer</td>
<td>[in] Pointer to the data to be decrypted</td>
</tr>
<tr>
<td></td>
<td>[out] Pointer to the decrypted data</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 1,692: Line 1,731:
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>Not logon dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
Line 1,698: Line 1,737:
<td>224</td>
<td>224</td>
<td>Wrong key storage number</td>
<td>Wrong key storage number</td>
</tr>
<tr>
<td>ERROR_UNIKEY_DECRYPT_FAILED</td>
<td>229</td>
<td>Decrypt data error</td>
</tr>
</tr>
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
Please use the key that encrypted data to decrypt the data; otherwise you cannot decrypt the data.
<br>---------------------------------------------------------------------------------------------------<br>


<br>---------------------------------------------------------------------------------------------------<br>
----
UniKey_Encrypt and UniKey_Decrypt offer a basic 128-bit encryption/decryption operation based on UniKey’s hardware. You can call these functions when an encryption or decryption operation is needed. For better security, you can encrypt the credential before saving it into the UniKey’s memory.
# This function will delete the original key in the key storage, and generate a new key.
<br>---------------------------------------------------------------------------------------------------<br>
# The data encrypted by the old key cannot be decrypted by the new key.
# Each key is 128-bits long.
----


<br>
<br>
=== Make an MD5 Digest for a Certain Content ===


'''API Prototype'''<br>
=== Generate a New Encryption Key via Seed ===
<code>function UniKey__MD5(pHandle: pWord; lp1: pLongWord; pBuffer: pByteArray): DWORD; stdcall;</code>
 
'''API Prototype'''
 
<code>function UniKey__Generate_Key_Via_Seed (pHandle: pWord; pKeyNumber: pLongWord; pSeed1: pWord; pSeed2: pWord; pSeed3: pWord; pSeed4: pWord): DWORD; stdcall;</code>
 
'''Description'''
 
Generate a new key in the specific key storage via a seed.


'''Description'''<br>
'''Parameters'''
Make an MD5 digest for a mount of content or data.


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
<th>Meaning</th>
<th>Description</th>
</tr>
</tr>
<tr>
<tr>
Line 1,735: Line 1,771:
</tr>
</tr>
<tr>
<tr>
<td>*pBufferLength</td>
<td>*pKeyNumber</td>
<td>[in] Number of bytes to MD5</td>
<td>[in] Key storage number</td>
</tr>
</tr>
<tr>
<tr>
<td>*pBuffer</td>
<td>*pSeed1</td>
<td>[in] Pointer to the data to be digested</td>
<td>[in] Seed 1</td>
</tr>
<tr>
<td>*pSeed2</td>
<td>[in] Seed 2</td>
</tr>
<tr>
<td>*pSeed3</td>
<td>[in] Seed 3</td>
</tr>
</tr>
<tr>
<tr>
<td></td>
<td>*pSeed4</td>
<td>[out] Pointer to the digested data</td>
<td>[in] Seed 4</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 1,763: Line 1,808:
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>No logon dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
<tr>
<td>ERROR_UNIKEY_INVALID_KEY_STORE</td>
<td>224</td>
<td>Wrong key storage number</td>
</tr>
</tr>
</table>
</table>
----
# This function will delete the original key in the key storage, and generate a new key via seed.
# The data encrypted by the old key cannot be decrypted by the new key.
# Each key is 128-bit long.
----


<br>
<br>
=== Read UpdateTag ===


'''API Prototype'''<br>
=== Encrypt the Buffer with a Specific Encryption Key ===
<code>function UniKey__Read_UpdateTag(pHandle: pWord; pUpdateTag: pLongWord): DWORD; stdcall;</code>
 
'''API Prototype'''
 
<code>function UniKey__Encrypt(pHandle: pWord; pBufferLength: pLongWord; pKeyNumber: pLongWord; pBuffer: pByteArray): DWORD; stdcall;</code>
 
'''Description'''
 
Encrypt an amount of memory with a key. The length of data must be a multiple of 8.


'''Description'''<br>
'''Parameters'''
Read UpdateTag from a specific dongle.


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
<th>Description</th>
<th>Meaning</th>
</tr>
</tr>
<tr>
<tr>
Line 1,788: Line 1,848:
</tr>
</tr>
<tr>
<tr>
<td>*pUpdateTag</td>
<td>*pBufferLength</td>
<td>[out] UpdateTag</td>
<td>[in] Number of bytes to encrypt</td>
</tr>
<tr>
<td>*pKeyNumber</td>
<td>[in] Key storage number</td>
</tr>
<tr>
<td rowspan="2">*pBuffer</td>
<td>[in] Pointer to the data to be encrypted</td>
</tr>
<tr>
<td>[out] Pointer to the encrypted data</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 1,808: Line 1,880:
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>No logon dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
<tr>
<td>ERROR_UNIKEY_INVALID_KEY_STORE</td>
<td>224</td>
<td>Wrong key storage number</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_READ_UPDATETAG</td>
<td>ERROR_UNIKEY_ENCRYPT_FAILED</td>
<td>226</td>
<td>228</td>
<td>Read UpdateTag error</td>
<td>Could not encrypt data</td>
</tr>
</tr>
</table>
</table>
----
This function only performs an encryption operation, no compression functions are involved.
----


<br>
<br>
=== Write UpdateTag ===


'''API Prototype'''<br>
=== Decrypt the Buffer with a Specific Encryption Key ===
<code>function UniKey__Write_UpdateTag(pHandle: pWord; pUpdateTag: pLongWord): DWORD; stdcall;</code>
 
'''API Prototype'''


'''Description'''<br>
<code>function UniKey__Decrypt(pHandle: pWord; pBufferLength: pLongWord; pKeyNumber: pLongWord; pBuffer: pByteArray): DWORD; stdcall;</code>
Write UpdateTag into a specific dongle.


'''Parameters'''<br>
'''Description'''
<table border="1">
 
<tr>
Encrypt an amount of memory with a key. The length of data must be a multiple of 8.
<th>Parameter</th>
 
<th>Description</th>
'''Parameters'''
 
<table class="wikitable">
<tr>
<th>Parameter</th>
<th>Meaning</th>
</tr>
</tr>
<tr>
<tr>
Line 1,838: Line 1,923:
</tr>
</tr>
<tr>
<tr>
<td>*pUpdateTag</td>
<td>*pBufferLength</td>
<td>[in] UpdateTag</td>
<td>[in] Number of bytes to encrypt</td>
</tr>
<tr>
<td>*pKeyNumber</td>
<td>[in] Key storage number</td>
</tr>
<tr>
<td rowspan="2">*pBuffer</td>
<td>[in] Pointer to the data to be decrypted</td>
</tr>
<tr>
<td>[out] Pointer to the decrypted data</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 1,858: Line 1,955:
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>No logon dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_WRITE_UPDATETAG</td>
<td>ERROR_UNIKEY_INVALID_KEY_STORE</td>
<td>227</td>
<td>224</td>
<td>Write UpdateTag error</td>
<td>Wrong key storage number</td>
</tr>
<tr>
<td>ERROR_UNIKEY_DECRYPT_FAILED</td>
<td>229</td>
<td>Could not decrypt data</td>
</tr>
</tr>
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
UniKey_Read_UpdateTag APIs give software vendors an easy method to identify if the UniKey dongle needs to be updated. When distributing the software, software vendors may use the UpdateTag as an ID which shows if the dongle needs to update or has been updated. You can also use this Tag as a tracking ID for each update. <br>---------------------------------------------------------------------------------------------------<br>


<br>
----
Please use the key that was used to encrypt the data to decrypt the data, otherwise you cannot properly decrypt the data.
=== Get UniKey Library Version ===
----


'''API Prototype'''<br>
<code>function UniKey__Get_Version(pHandle: pWord; pVersion: pLongWord): DWORD; stdcall;</code>


'''Description'''<br>
----
Get the current UniKey library version.
<code>UniKey__Encrypt</code> and <code>UniKey__Decrypt</code> offer a basic 128-bit encryption/decryption operation based on UniKey’s hardware. You can call these functions when an encryption or decryption operation is needed. For better security, you can encrypt a credential before saving it into the UniKey’s memory.
----
 
<br>


'''Parameters'''<br>
=== Make an MD5 Digest for Certain Content  ===
<table border="1">
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
<tr>
<td>*pHandle</td>
<td>[in] Dongle handle</td>
</tr>
<tr>
<td>*pVersion</td>
<td>[out] UniKey library version</td>
</tr>
</table>


<br>
'''API Prototype'''


== UniKey Time API Reference ==
<code>function UniKey__MD5(pHandle: pWord; lp1: pLongWord; pBuffer: pByteArray): DWORD; stdcall;</code>


=== Get UniKey Time  ===
'''Description'''


'''API Prototype'''<br>
Make an MD5 digest of content or data.
<code>function UniKey__Get_Time(pHandle: pWord; pYear: pLongWord; pMonth: pLongWord; pDay: pWord; pHour: pWord; pMinute: pWord; pSecond: pWord: DWORD; stdcall;
</code>


'''Description'''<br>
'''Parameters'''
Get UniKey Time’s real time clock’s time.


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
<th>Description</th>
<th>Meaning</th>
</tr>
</tr>
<tr>
<tr>
Line 1,920: Line 2,003:
</tr>
</tr>
<tr>
<tr>
<td>*pYear</td>
<td>*pBufferLength</td>
<td>[out] Year (input or output is 10, which refers to 2010)</td>
<td>[in] Number of bytes to MD5</td>
</tr>
</tr>
<tr>
<tr>
<td>*pMonth</td>
<td rowspan="2">*pBuffer</td>
<td>[out] Month</td>
<td>[in] Pointer to the data to be digested</td>
</tr>
</tr>
<tr>
<tr>
<td>*pDay</td>
<td>[out] Pointer to the digested data</td>
<td>[out] Day</td>
</tr>
<tr>
<td>*pHour</td>
<td>[out] Hour</td>
</tr>
<tr>
<td>*pMinute</td>
<td>[out] Minute</td>
</tr>
<tr>
<td>*pSecond</td>
<td>[out] Second</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 1,960: Line 2,031:
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>Need open dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
<tr>
<td>ERROR_UNIKEY_READ_TIME</td>
<td>230</td>
<td>Get UniKey time error</td>
</tr>
</tr>
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
<br>
Calling UniKey_Check_Time can check if the UniKey dongle is a real time dongle. If ERROR_UNIKEY_READ_TIME is returned, then the dongle is not a real time dongle.
<br>---------------------------------------------------------------------------------------------------<br>


<br>
=== Read UpdateTag  ===
 
'''API Prototype'''


=== Set UniKey Time  ===
<code>function UniKey__Read_UpdateTag(pHandle: pWord; pUpdateTag: pLongWord): DWORD; stdcall;</code>


'''API Prototype'''<br>
'''Description'''
<code>function UniKey__Set_Time(pHandle: pWord; pYear: pLongWord; pMonth: pLongWord; pDay: pWord; pHour: pWord; pMinute: pWord; pSecond: pWord): DWORD; stdcall;</code>


'''Description'''<br>
Read UpdateTag from a specific dongle
Set UniKey Time’s real time clock’s time.


'''Parameters'''<br>
'''Parameters'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 1,994: Line 2,059:
</tr>
</tr>
<tr>
<tr>
<td>*pYear</td>
<td>*pUpdateTag</td>
<td>[in] Year (input or output is 10, which refers to 2010)</td>
<td>[out] UpdateTag</td>
</tr>
</tr>
<tr>
</table>
<td>*pMonth</td>
 
<td>[in] Month</td>
'''Return values'''
</tr>
<tr>
<td>*pDay</td>
<td>[in] Day</td>
</tr>
<tr>
<td>*pHour</td>
<td>[in] Hour</td>
</tr>
<tr>
<td>*pMinute</td>
<td>[in] Minute</td>
</tr>
<tr>
<td>*pSecond</td>
<td>[in] Second</td>
</tr>
</table>


'''Return values'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 2,034: Line 2,080:
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>Need open dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_READ_TIME</td>
<td>ERROR_UNIKEY_READ_UPDATETAG</td>
<td>230</td>
<td>226</td>
<td>Get UniKey time error</td>
<td>Read UpdateTag error</td>
</tr>
</tr>
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
<br>
You need verify all the 4 passwords (vendor mode) to set the time for UniKey internal clock.
<br>---------------------------------------------------------------------------------------------------<br>


<br>
=== Write UpdateTag ===


=== Set UniKey Time by Host’s Clock  ===
'''API Prototype'''


'''API Prototype'''<br>
<code>function UniKey__Write_UpdateTag(pHandle: pWord; pUpdateTag: pLongWord): DWORD; stdcall;</code>
<code>function UniKey__Set_Time(pHandle: pWord; pYear: pLongWord; pMonth: pLongWord; pDay: pWord; pHour: pWord; pMinute: pWord; pSecond: pWord): DWORD; stdcall;</code>


'''Description'''<br>
'''Description'''
Set UniKey Time’s real time clock’s time by the host computer’s clock.


'''Parameters'''<br>
Write UpdateTag into a specific dongle.
<table border="1">
 
<tr>
'''Parameters'''
<th>Parameter</th>
 
<table class="wikitable">
<tr>
<th>Parameter</th>
<th>Description</th>
<th>Description</th>
</tr>
</tr>
Line 2,066: Line 2,111:
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in] Dongle handle</td>
<td>[in] Dongle handle</td>
</tr>
<tr>
<td>*pUpdateTag</td>
<td>[in] UpdateTag</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 2,084: Line 2,134:
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>Need open dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_WRITE_TIME</td>
<td>ERROR_UNIKEY_WRITE_UPDATETAG</td>
<td>231</td>
<td>227</td>
<td>Write UniKey time error</td>
<td>Write UpdateTag error</td>
</tr>
</tr>
</table>
</table>
----
<code>UniKey__Read_UpdateTag</code> APIs give software vendors an easy method to identify if the UniKey dongle needs to be updated. When distributing software, software vendors may use the UpdateTag as an ID which shows if the dongle needs to be updated or has been updated. You can also use this tag as a tracking ID for each update.
----


<br>
<br>


=== Erase Real Time Module  ===
=== Get UniKey Library Version ===
 
'''API Prototype'''
 
<code>function UniKey__Get_Version(pHandle: pWord; pVersion: pLongWord): DWORD; stdcall;</code>
 
'''Description'''


'''API Prototype'''<br>
Get the current UniKey library version.
<code>function UniKey__Erase_Time_Module(pHandle: pWord; pModule: pLongWord): DWORD; stdcall;</code>


'''Description'''<br>
'''Parameters'''
Erase/Reset a real time module, and all the info in the module will be erased including start, end or duration.


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 2,114: Line 2,172:
</tr>
</tr>
<tr>
<tr>
<td>*pModule</td>
<td>*pVersion</td>
<td>[in] Real time module number (0-15)</td>
<td>[out] UniKey library version</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
<br>
<table border="1">
 
<tr>
== UniKey Time API Reference ==
<th>Result</th>
 
<th>Value</th>
=== Get UniKey Time  ===
<th>Description</th>
</tr>
<tr>
<td>SUCCESS</td>
<td>0</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>Need open dongle before operating dongle</td>
</tr>
<tr>
<td>ERROR_UNIKEY_WRITE_TIME</td>
<td>231</td>
<td>Write UniKey time error</td>
</tr>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
'''API Prototype'''
You need verify all the 4 passwords (vendor mode) to reset a module. If a real time module’s write once flag is enabled, only the first START_TIME call works. Later START_TIME call will return an error until this module is reset.
<br>---------------------------------------------------------------------------------------------------<br>


<br>
<code>function UniKey__Get_Time(pHandle: pWord; pYear: pLongWord; pMonth: pLongWord; pDay: pWord; pHour: pWord; pMinute: pWord; pSecond: pWord): DWORD; stdcall;</code>


=== Set a Real Time Module’s Start Time ===
'''Description'''


'''API Prototype'''<br>
Get the time from the UniKey Time’s real-time clock.
<code>function UniKey__Set_Time_Module_Start_Time(pHandle: pWord; pModule: pLongWord; pYear: pWord; pMonth: pWord; pDay: pWord; pHour: pWord): DWORD; stdcall;</code>


'''Description'''<br>
'''Parameters'''
Set a real time module’s start time.


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 2,166: Line 2,201:
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in] Dongle handle</td>
<td>[in] Dongle handle</td>
</tr>
<tr>
<td>*pModule</td>
<td>[in] Real time module number (0-15)</td>
</tr>
</tr>
<tr>
<tr>
<td>*pYear</td>
<td>*pYear</td>
<td>[in] Year (input or output is 10, which refers to 2010)</td>
<td>[out] Year (input or output is 10, which refers to 2010)</td>
</tr>
</tr>
<tr>
<tr>
<td>*pMonth</td>
<td>*pMonth</td>
<td>[in] Month</td>
<td>[out] Month</td>
</tr>
</tr>
<tr>
<tr>
<td>*pDay</td>
<td>*pDay</td>
<td>[in] Day</td>
<td>[out] Day</td>
</tr>
</tr>
<tr>
<tr>
<td>*pHour</td>
<td>*pHour</td>
<td>[in] Hour</td>
<td>[out] Hour</td>
</tr>
<tr>
<td>*pMinute</td>
<td>[out] Minute</td>
</tr>
<tr>
<td>*pSecond</td>
<td>[out] Second</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 2,204: Line 2,244:
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>Need open dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_WRITE_TIME_MODULE</td>
<td>ERROR_UNIKEY_READ_TIME</td>
<td>231</td>
<td>230</td>
<td>Write time module error</td>
<td>Get UniKey time error</td>
</tr>
<tr>
<td>ERROR_UNIKEY_TIME_MODULE_NOT_NULL</td>
<td>234</td>
<td>The real time module is not null, this error is returned when write once flag is set</td>
</tr>
</tr>
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
 
Write Once flag is very useful for setting the Start for a real time module. If write once flag is set, only the first START_TIME call can set the start time for a module. All the later START_TIME will not work and return an ERROR_UNIKEY_TIME_MODULE_NOT_NULL. Software vendors may use this flag when the start for a module is not clear.
----
<br>---------------------------------------------------------------------------------------------------<br>
Calling <code>UniKey__Check_Time</code> can check if the dongle is a UniKey Time model. If ERROR_UNIKEY_READ_TIME is returned, then the dongle is not a UniKey Time.
----


<br>
<br>


=== Set a Real Time Module’s Start Time by UniKey Dongle’s Clock ===
=== Set UniKey Time  ===
 
'''API Prototype'''


'''API Prototype'''<br>
<code>function UniKey__Set_Time(pHandle: pWord; pYear: pLongWord; pMonth: pLongWord; pDay: pWord; pHour: pWord; pMinute: pWord; pSecond: pWord): DWORD; stdcall;</code>
<code>function UniKey__Set_Time_Module_Start_Time_Now(pHandle: pWord; pModule: pLongWord): DWORD; stdcall;</code>
 
'''Description'''


'''Description'''<br>
Set the time on the UniKey Time’s clock.  
Set a real time module’s start time as the now time in UniKey dongle’s clock.


'''Parameters'''<br>
'''Parameters'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 2,243: Line 2,282:
</tr>
</tr>
<tr>
<tr>
<td>*pModule</td>
<td>*pYear</td>
<td>[in] Real time module number (0-15)</td>
<td>[in] Year (input or output is 10, which refers to 2010)</td>
</tr>
</tr>
</table>
<tr>
 
<td>*pMonth</td>
'''Return values'''<br>
<td>[in] Month</td>
<table border="1">
</tr>
<tr>
<td>*pDay</td>
<td>[in] Day</td>
</tr>
<tr>
<td>*pHour</td>
<td>[in] Hour</td>
</tr>
<tr>
<td>*pMinute</td>
<td>[in] Minute</td>
</tr>
<tr>
<td>*pSecond</td>
<td>[in] Second</td>
</tr>
</table>
 
'''Return values'''
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 2,263: Line 2,323:
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>Need open dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_WRITE_TIME_MODULE</td>
<td>ERROR_UNIKEY_READ_TIME</td>
<td>231</td>
<td>230</td>
<td>Write time module error</td>
<td>Get UniKey time error</td>
</tr>
<tr>
<td>ERROR_UNIKEY_TIME_MODULE_NOT_NULL</td>
<td>234</td>
<td>The real time module is not null, this error is returned when write once flag is set</td>
</tr>
</tr>
</table>
</table>


<br>


=== Set a Real Time Module’s Start Time by Host’s Clock ===
----
You need to verify all 4 passwords (vendor mode) to set the time of the UniKey Time's internal clock.
----


'''API Prototype'''<br>
<code>function UniKey__Set_Time_Module_Start_Time_Now_PC(pHandle: pWord; pModule: pLongWord): DWORD; stdcall;</code>


'''Description'''<br>
<br>
Set a real time module’s start time as the now time in host computer.
 
=== Set UniKey Time by Host’s Clock  ===
 
'''API Prototype'''
 
<code>function UniKey__Set_Time_Now(pHandle: pWord): DWORD; stdcall;</code>
 
'''Description'''
 
Set the time of the UniKey Time’s real-time clock to the host computer’s clock.
 
'''Parameters'''


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 2,296: Line 2,360:
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in] Dongle handle</td>
<td>[in] Dongle handle</td>
</tr>
<tr>
<td>*pHandle</td>
<td>[in] Real time module number (0-15)</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 2,318: Line 2,379:
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>Need open dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_WRITE_TIME_MODULE</td>
<td>ERROR_UNIKEY_WRITE_TIME</td>
<td>231</td>
<td>231</td>
<td>Write time module error</td>
<td>Set UniKey time error</td>
</tr>
<tr>
<td>ERROR_UNIKEY_TIME_MODULE_NOT_NULL</td>
<td>234</td>
<td>The real time module is not null, this error is returned when write once flag is set</td>
</tr>
</tr>
</table>
</table>
Line 2,334: Line 2,390:
<br>
<br>


=== Set a Real Time Module’s End Time ===
=== Erase Real Time Module  ===
 
'''API Prototype'''
 
<code>function UniKey__Erase_Time_Module(pHandle: pWord; pModule: pLongWord): DWORD; stdcall;</code>
 
'''Description'''


'''API Prototype'''<br>
Erase/Reset a real-time module, and all the information in the module will be erased including start, and end or duration.
<code>function UniKey__Set_Time_Module_End_Time(pHandle: pWord; pModule: pLongWord; pYear: pWord; pMonth: pWord; pDay: pWord; pHour: pWord): DWORD; stdcall;</code>


'''Description'''<br>
'''Parameters'''
Set a real time module’s end time.


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 2,353: Line 2,412:
</tr>
</tr>
<tr>
<tr>
<td>*pHandle </td>
<td>*pModule</td>
<td>[in] Real time module number (0-15)</td>
<td>[in] Real-time module number (0-15)</td>
</tr>
</tr>
<tr>
</table>
<td>*pYear</td>
 
<td>[in] Year (input or output is 10, which refers to 2010)</td>
'''Return values'''
</tr>
<tr>
<td>*pMonth</td>
<td>[in] Month</td>
</tr>
<tr>
<td>*pDay</td>
<td>[in] Day</td>
</tr>
<tr>
<td>*pHour</td>
<td>[in] Hour</td>
</tr>
</table>


'''Return values'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 2,389: Line 2,433:
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>Need open dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_WRITE_TIME_MODULE</td>
<td>ERROR_UNIKEY_WRITE_TIME</td>
<td>231</td>
<td>231</td>
<td>Write time module error</td>
<td>Set UniKey time error</td>
</tr>
</tr>
</table>
</table>
----
You need to verify all 4 passwords (vendor mode) to reset a module. If a real-time module’s write-once flag is enabled, only the first START_TIME call works. Successive START_TIME calls will return an error until this module is reset.
----


<br>
<br>


=== Set a Real Time Module’s Duration ===
=== Set a Real Time Module’s Start Time ===
 
'''API Prototype'''
 
<code>function UniKey__Set_Time_Module_Start_Time(pHandle: pWord; pModule: pLongWord; pYear: pWord; pMonth: pWord; pDay: pWord; pHour: pWord): DWORD; stdcall;</code>
 
'''Description'''


'''API Prototype'''<br>
Set a real-time module’s start time.
<code>function UniKey__Set_Time_Module_Duration(pHandle: pWord; pModule: pLongWord; pDay: pLongWord; pHour: pWord): DWORD; stdcall;</code>


'''Description'''<br>
'''Parameters'''
Set the duration time for a specific real time module. The total duration is (*pDay)*24 + (*pHour) in hours.


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 2,420: Line 2,472:
<tr>
<tr>
<td>*pModule</td>
<td>*pModule</td>
<td>[in] Real time module number (0-15)</td>
<td>[in] Real-time module number (0-15)</td>
</tr>
</tr>
<tr>
<tr>
<td>*pDay</td>
<td>*pYear</td>
<td>[in] Number of days</td>
<td>[in] Year (input or output is 10, which refers to 2010)</td>
</tr>
<tr>
<td>*pMonth</td>
<td>[in] Month</td>
</tr>
<tr>
<td>*pDay</td>
<td>[in] Day</td>
</tr>
</tr>
<tr>
<tr>
<td>*pHour</td>
<td>*pHour</td>
<td>[in] Number of hours</td>
<td>[in] Hour</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 2,447: Line 2,508:
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>Need open dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_WRITE_TIME_MODULE</td>
<td>ERROR_UNIKEY_WRITE_TIME_MODULE</td>
<td>231</td>
<td>231</td>
<td>Write time module error</td>
<td>Set UniKey time error</td>
</tr>
<tr>
<td>ERROR_UNIKEY_TIME_MODULE_NOT_NULL</td>
<td>234</td>
<td>The real-time module is not null, this error is returned when the 'write once' flag is set</td>
</tr>
</tr>
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
 
You need verify all the 4 passwords (vendor mode) to set the duration for a real time module.
----
<br>---------------------------------------------------------------------------------------------------<br>
The write-once flag is very useful for setting the start for a real-time module. If the write-once flag is set, only the first START_TIME call can set the start time for a module; all successive START_TIME calls will not work and return an ERROR_UNIKEY_TIME_MODULE_NOT_NULL. Software vendors may use this flag when the start for a module is not clear.
----


<br>
<br>


=== Check a UniKey Time License module ===
=== Set a Real Time Module’s Start Time by the UniKey's Internal Clock  ===
 
'''API Prototype'''
 
<code>function UniKey__Set_Time_Module_Start_Time_Now(pHandle: pWord; pModule: pLongWord): DWORD; stdcall;</code>
 
'''Description'''


'''API Prototype'''<br>
Set a real-time module’s start time as the current time in the UniKey's internal clock.
<code>function UniKey__Check_Time_Module(pHandle: pWord; pModule: pLongWord; pRemainDay: pLongWord; pYear: pWord; pMonth: pWord; pDay: pWord; pHour: pWord): DWORD; stdcall;</code>


'''Description'''<br>
'''Parameters'''
Read the attributes of a specific UniKey Time license module.


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 2,482: Line 2,552:
<tr>
<tr>
<td>*pModule</td>
<td>*pModule</td>
<td>[in] License module Number</td>
<td>[in] Real-time module number (0-15)</td>
</tr>
</tr>
</table>
'''Return values'''
<table class="wikitable">
<tr>
<tr>
<td>*pRemainDays</td>
<th>Result</th>
<td>[out] Remain days</td>
</tr>
<tr>
<td>*pYear</td>
<td>[in] Year (input or output is 10 ,which refers to 2010)</td>
</tr>
<tr>
<td>*pMonth</td>
<td>[in] Month</td>
</tr>
<tr>
<td>*pDay</td>
<td>[in] Day</td>
</tr>
<tr>
<td>*pHour</td>
<td>[in] Hour</td>
</tr>
</table>
 
'''Return values'''<br>
<table border="1">
<tr>
<th>Result</th>
<th>Value</th>
<th>Value</th>
<th>Description</th>
<th>Description</th>
Line 2,519: Line 2,570:
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>202</td>
<td>212</td>
<td>Read/Write address or length is wrong</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_WRITE_TIME_MODULE</td>
<td>212</td>
<td>231</td>
<td>No logon dongle before operating dongle</td>
<td>Set UniKey time error</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_MODULE</td>
<td>ERROR_UNIKEY_TIME_MODULE_NOT_NULL</td>
<td>216</td>
<td>234</td>
<td>License module error</td>
<td>The real-time module is not null, this error is returned when the 'write once' flag is set</td>
</tr>
</tr>
</table>
</table>
<br>---------------------------------------------------------------------------------------------------<br>
A successful operation will result in "*pValue" with value from the Validity (1 = license module value is not zero). <br>The value of a license module cannot be read out directly and it is invisible to end users.
<br>---------------------------------------------------------------------------------------------------<br>


<br>
<br>


=== Check a UniKey Time License Module Now ===
=== Set a Real Time Module’s Start Time by Host’s Clock ===


'''API Prototype'''<br>
'''API Prototype'''
<code>function UniKey__Check_Time_Module_Now(pHandle: pWord; pModule: pLongWord; pRemainDay: pLongWord; pRemainHour: pWord): DWORD; stdcall;</code>
 
<code>function UniKey__Set_Time_Module_Start_Time_Now_PC(pHandle: pWord; pModule: pLongWord): DWORD; stdcall;</code>


'''Description'''
'''Description'''
<br>Read the attributes of a specific UniKey Time license module now.


'''Parameters'''<br>
Set a real time module’s start time as the current time of the host computer.
<table border="1">
 
'''Parameters'''
 
<table class="wikitable">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 2,560: Line 2,610:
</tr>
</tr>
<tr>
<tr>
<td>*pModule</td>
<td>*pHandle</td>
<td>[in] License module Number</td>
<td>[in] Real-time module number (0-15)</td>
</tr>
<tr>
<td>*pRemainDays</td>
<td>[out] Remain days</td>
</tr>
<tr>
<td>*pRemainHours</td>
<td>[out] Remain hours</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 2,586: Line 2,629:
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>202</td>
<td>212</td>
<td>Read/Write address or length is wrong</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_WRITE_TIME_MODULE</td>
<td>212</td>
<td>231</td>
<td>No logon dongle before operating dongle</td>
<td>Set UniKey time error</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_MODULE</td>
<td>ERROR_UNIKEY_TIME_MODULE_NOT_NULL</td>
<td>216</td>
<td>234</td>
<td>License module error</td>
<td>The real-time module is not null, this error is returned when the 'write once' flag is set</td>
</tr>
</tr>
</table>
</table>
<br>---------------------------------------------------------------------------------------------------<br>
A successful operation will result in "*pValue" with value from the Validity (1 = license module value is not zero). The value of a license module cannot be read out directly and it is invisible to end users.
<br>---------------------------------------------------------------------------------------------------<br>


<br>
<br>


=== Check a UniKey Time License Module Now PC ===
=== Set a Real Time Module’s End Time ===


'''API Prototype'''<br>
'''API Prototype'''
<code>function UniKey__Check_Time_Module_Now_PC(pHandle: pWord; pModule: pLongWord; pRemainDay: pLongWord; pRemainHour: pWord): DWORD; stdcall;</code>


'''Description'''<br>
<code>function UniKey__Set_Time_Module_End_Time(pHandle: pWord; pModule: pLongWord; pYear: pWord; pMonth: pWord; pDay: pWord; pHour: pWord): DWORD; stdcall;</code>
Read the attributes of a specific UniKey Time license module Now PC.


'''Parameters'''<br>
'''Description'''
<table border="1">
 
Set a real-time module’s end time.
 
'''Parameters'''
 
<table class="wikitable">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 2,627: Line 2,669:
</tr>
</tr>
<tr>
<tr>
<td>*pModule</td>
<td>*pHandle </td>
<td>[in] License module Number</td>
<td>[in] Real-time module number (0-15)</td>
</tr>
<tr>
<td>*pYear</td>
<td>[in] Year (input or output is 10, which refers to 2010)</td>
</tr>
<tr>
<td>*pMonth</td>
<td>[in] Month</td>
</tr>
</tr>
<tr>
<tr>
<td>*pRemainDays</td>
<td>*pDay</td>
<td>[out] Remain days</td>
<td>[in] Day</td>
</tr>
</tr>
<tr>
<tr>
<td>*pRemainHours</td>
<td>*pHour</td>
<td>[out] Remain hours</td>
<td>[in] Hour</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 2,651: Line 2,702:
<td>0</td>
<td>0</td>
<td>Success</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>202</td>
<td>Read/Write address or length is wrong</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>212</td>
<td>No logon dongle before operating dongle</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_MODULE</td>
<td>ERROR_UNIKEY_WRITE_TIME_MODULE</td>
<td>216</td>
<td>231</td>
<td>License module error</td>
<td>Set UniKey time error</td>
</tr>
</tr>
</table>
</table>
<br>---------------------------------------------------------------------------------------------------<br>
A successful operation will result in "*pValue" with value from the Validity (1 = license module value is not zero). The value of a license module cannot be read out directly and it is invisible to end users.
<br>---------------------------------------------------------------------------------------------------<br>


<br>
<br>


== UniKey Drive API Reference ==
=== Set a Real Time Module’s Duration ===


=== Initialize File System ===
'''API Prototype'''


'''API Prototype'''<br>
<code>function UniKey__Set_Time_Module_Duration(pHandle: pWord; pModule: pLongWord; pDay: pLongWord; pHour: pWord): DWORD; stdcall;</code>
<code>UniKey_FS_Init:function(handle: pWord; PW1: pLongWord; PW2: pLongWord; PW3: pLongWord; PW4: pLongWord): DWORD; stdcall;</code>


'''Description'''<br>
'''Description'''
The user needs to call this function to initialize the file system before calling other file system related functions. The default password of the file system is 12345678.
 
Set the duration for a specific real-time module. The total duration is (*pDay) * 24 + (*pHour) in hours.
 
'''Parameters'''


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 2,693: Line 2,736:
<tr>
<tr>
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Dongle handle</td>
</tr>
</tr>
<tr>
<tr>
<td>* pPassword1</td>
<td>*pModule</td>
<td>[in]Password1</td>
<td>[in] Real-time module number (0-15)</td>
</tr>
</tr>
<tr>
<tr>
<td>* pPassword2</td>
<td>*pDay</td>
<td>[in]Password2</td>
<td>[in] Number of days</td>
</tr>
</tr>
<tr>
<tr>
<td>* pPassword3</td>
<td>*pHour</td>
<td>[in]Password3</td>
<td>[in] Number of hours</td>
</tr>
<tr>
<td>* pPassword4</td>
<td>[in]Password4</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 2,726: Line 2,766:
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_INVALID_PASSWORD_OR_ID</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>202</td>
<td>212</td>
<td>Invalid password or ID results in an error.</td>
<td>Need to log on to a dongle before running</td>
</tr>
<tr>
<td>ERROR_UNIKEY_WRITE_TIME_MODULE</td>
<td>231</td>
<td>Set UniKey time error</td>
</tr>
</tr>
</table>
</table>
----
You need to verify all 4 passwords (vendor mode) to set the duration for a real-time module.
----


<br>
<br>


=== Format the file system ===
=== Check a UniKey Time License module ===


'''API Prototype'''<br>
'''API Prototype'''
<code>UniKey_FS_Format:function(handle: pWord): DWORD; stdcall;</code>


'''Description'''<br>
<code>function UniKey__Check_Time_Module(pHandle: pWord; pModule: pLongWord; pRemainDay: pLongWord; pYear: pWord; pMonth: pWord; pDay: pWord; pHour: pWord): DWORD; stdcall;</code>
Format the file system.
 
'''Description'''


'''Parameters'''<br>
Read the attributes of a specific UniKey Time license module.
<table border="1">
 
<tr>
'''Parameters'''
<th>Parameter</th>
 
<table class="wikitable">
<tr>
<th>Parameter</th>
<th>Description</th>
<th>Description</th>
</tr>
</tr>
<tr>
<tr>
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Dongle handle</td>
</tr>
<tr>
<td>*pModule</td>
<td>[in] License module Number</td>
</tr>
<tr>
<td>*pRemainDays</td>
<td>[out] Days remaining</td>
</tr>
<tr>
<td>*pYear</td>
<td>[in] Year (input or output is 10, which refers to 2010)</td>
</tr>
<tr>
<td>*pMonth</td>
<td>[in] Month</td>
</tr>
<tr>
<td>*pDay</td>
<td>[in] Day</td>
</tr>
<tr>
<td>*pHour</td>
<td>[in] Hour</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 2,767: Line 2,845:
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_FS_FILE_EXIST</td>
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>245</td>
<td>204</td>
<td>File already existed.</td>
<td>Read/Write address is incorrect or invalid length</td>
</tr>
<tr>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>Need to log on to a dongle before running</td>
</tr>
<tr>
<td>ERROR_UNIKEY_MODULE</td>
<td>216</td>
<td>License module error</td>
</tr>
</tr>
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
 
Note: The user needs to initialize the file system successfully before calling other file system related functions.
----
<br>---------------------------------------------------------------------------------------------------<br>
A successful operation will result in *pValue having value from the validity of a license module (1 = license module value is not zero).
 
The value of a license module cannot be read out directly and it is invisible to end users.
----


<br>
<br>


=== Create files ===
=== Check a UniKey Time License Module Now ===
 
'''API Prototype'''


'''API Prototype'''<br>
<code>function UniKey__Check_Time_Module_Now(pHandle: pWord; pModule: pLongWord; pRemainDay: pLongWord; pRemainHour: pWord): DWORD; stdcall;</code>
<code>UniKey_FS_CreateFile:function(handle: pWord; filename: pByteArray): DWORD; stdcall;</code>


'''Description'''<br>
'''Description'''
Create files.  
 
Read the attributes of a specific UniKey Time license module Now.
 
'''Parameters'''


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 2,795: Line 2,889:
<tr>
<tr>
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Dongle handle</td>
</tr>
<tr>
<td>*pModule</td>
<td>[in] License module number</td>
</tr>
<tr>
<td>*pRemainDays</td>
<td>[out] Days remaining</td>
</tr>
</tr>
<tr>
<tr>
<td>*filename</td>
<td>*pRemainHours</td>
<td>[in/out]Input/Output file name</td>
<td>[out] Hours remaining</td>
</tr>
</tr>
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
'''Return values'''
Note: single slash ( "\") should be added before the name of the file.
<br>---------------------------------------------------------------------------------------------------<br>


'''Return values'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 2,820: Line 2,919:
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_FS_ERR_SYS_UNINIT</td>
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>246</td>
<td>204</td>
<td>The file system is not initialized.</td>
<td>Read/Write address is incorrect or invalid length</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_FS_FILE_NAME</td>
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>240</td>
<td>212</td>
<td>Wrong or invalid file name</td>
<td>Need to log on to a dongle before running</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_FS_FILE_EXIST</td>
<td>ERROR_UNIKEY_MODULE</td>
<td>245</td>
<td>216</td>
<td>The file already existed.</td>
<td>License module error</td>
</tr>
</tr>
</table>
</table>
----
A successful operation will result in *pValue having value from the validity (1 = license module value is not zero).
The value of a license module cannot be read out directly and it is invisible to end users.
----


<br>
<br>


=== Delete files ===
=== Check a UniKey Time License Module Now PC ===


'''API Prototype'''<br>
'''API Prototype'''
<code>UniKey_FS_DeleteFile:function(handle: pWord; filename: pByteArray): DWORD; stdcall;</code>


'''Description'''<br>
<code>function UniKey__Check_Time_Module_Now_PC(pHandle: pWord; pModule: pLongWord; pRemainDay: pLongWord; pRemainHour: pWord): DWORD; stdcall;</code>
Delete files.  
 
'''Description'''
 
Read the attributes of a specific UniKey Time license module Now PC.  
 
'''Parameters'''


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 2,854: Line 2,963:
<tr>
<tr>
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Dongle handle</td>
</tr>
</tr>
<tr>
<tr>
<td>*filename</td>
<td>*pModule</td>
<td>[in/out]Input/Output file name</td>
<td>[in] License module number</td>
</tr>
</tr>
</table>
'''Return values'''<br>
<table border="1">
<tr>
<tr>
<th>Result</th>
<td>*pRemainDays</td>
<th>Value</th>
<td>[out] Days remaining</td>
<th>Description</th>
</tr>
</tr>
<tr>
<tr>
<td>SUCCESS</td>
<td>*pRemainHours</td>
<td>0</td>
<td>[out] Hours remaining</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_UNIKEY_FS_ERR_SYS_UNINIT</td>
<td>246</td>
<td>The file is not yet initialized.</td>
</tr>
<tr>
<td>ERROR_UNIKEY_FS_NO_FILE</td>
<td>241</td>
<td>No such file name.</td>
</tr>
</tr>
</table>
</table>


<br>
'''Return values'''


=== Open files ===
<table class="wikitable">
 
'''API Prototype'''<br>
<code>UniKey_FS_File_Open:function(handle: pWord; filename: pChar): DWORD; stdcall;</code>
 
'''Description'''<br>
Open files.
 
'''Parameters'''<br>
<table border="1">
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
<tr>
<td>*pHandle</td>
<td>[in]Device handle</td>
</tr>
<tr>
<td>*filename</td>
<td>[in]Input/Output file name</td>
</tr>
</table>
 
'''Return values'''<br>
<table border="1">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 2,925: Line 2,993:
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_FS_NO_FILE</td>
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td>
<td>241</td>
<td>204</td>
<td>No such file name</td>
<td>Read/Write address is incorrect or invalid length</td>
</tr>
</tr>
</table>
<tr>
 
<td>ERROR_UNIKEY_NEED_OPEN</td>
<td>212</td>
<td>Need to log on to a dongle before running</td>
</tr>
<tr>
<td>ERROR_UNIKEY_MODULE</td>
<td>216</td>
<td>License module error</td>
</tr>
</table>
 
 
----
A successful operation will result in *pValue having value from the validity (1 = license module value is not zero).
 
The value of a license module cannot be read out directly and it is invisible to end users.
----
 
<br>
<br>


=== Get system space ===
== UniKey Drive API Reference ==
 
=== Initialize File System ===


'''API Prototype'''<br>
'''API Prototype'''
<code>UniKey_FS_Get_Free_Size:function(handle: pWord; usedsize: pLongWord; freesize: pLongWord): DWORD; stdcall;</code>


'''Description'''<br>
<code>UniKey_FS_Init:function(pHandle: pWord; PW1: pLongWord; PW2: pLongWord; PW3: pLongWord; PW4: pLongWord): DWORD; stdcall;</code>
Get system space.


'''Parameters'''<br>
'''Description'''
<table border="1">
 
The user needs to call this function to initialize the file system before calling other file system related functions. The default password of the file system is "12345678", without quotations.
 
'''Parameters'''
 
<table class="wikitable">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 2,949: Line 3,039:
<tr>
<tr>
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Device handle</td>
</tr>
<tr>
<td>*PW1</td>
<td>[in] Password 1</td>
</tr>
<tr>
<td>*PW2</td>
<td>[in] Password 2</td>
</tr>
</tr>
<tr>
<tr>
<td>*usedsize</td>
<td>*PW3</td>
<td>[out]System space size which has already been used</td>
<td>[in] Password 3</td>
</tr>
</tr>
<tr>
<tr>
<td>*freesize</td>
<td>*PW4</td>
<td>[out]System space size that hasn’t been used</td>
<td>[in] Password 4</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 2,972: Line 3,071:
<td>0</td>
<td>0</td>
<td>Success</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_UNIKEY_INVALID_PASSWORD_OR_ID</td>
<td>202</td>
<td>Wrong password or UniKey HID</td>
</tr>
</tr>
</table>
</table>
Line 2,977: Line 3,081:
<br>
<br>


=== Modify file data ===
=== Format the File System ===


'''API Prototype'''<br>
'''API Prototype'''
<code>UniKey_FS_File_Modify_Data:function(handle: pWord; offset: pLongWord; len: pLongWord; buffer: pByteArray): DWORD; stdcall;</code>


'''Description'''<br>
<code>UniKey_FS_Format:function(pHandle: pWord): DWORD; stdcall;</code>
Modify file data.
 
'''Description'''
 
Format the file system.
 
'''Parameters'''


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 2,993: Line 3,100:
<tr>
<tr>
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Device handle</td>
</tr>
<tr>
<td>*offset</td>
<td>[in]Address to be modified</td>
</tr>
<tr>
<td>*len</td>
<td>[in]Modify the data length</td>
</tr>
<tr>
<td>*buffer</td>
<td>[in]Modify the data</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 3,022: Line 3,118:
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_FS_ERR_OPEN_FILE</td>
<td>ERROR_UNIKEY_FS_FILE_EXIST</td>
<td>247</td>
<td>245</td>
<td>The file to be modified hasn’t been opened yet.</td>
<td>File already exists</td>
</tr>
<tr>
<td>ERROR_UNIKEY_FS_FILE_OFFSET</td>
<td>242</td>
<td>Offset of file error</td>
</tr>
</tr>
</table>
</table>
----
Note: The user needs to initialize the file system successfully before calling other file system related functions.
----


<br>
<br>


=== Append data to the end-of-file ===
=== Create Files ===


'''API Prototype'''<br>
'''API Prototype'''
<code>UniKey_FS_File_Append_Data:function(handle: pWord; len: pLongWord; buffer: pByteArray): DWORD; stdcall;</code>


'''Description'''<br>
<code>UniKey_FS_CreateFile:function(pHandle: pWord; filename: pByteArray): DWORD; stdcall;</code>
Append data to the end-of-file.
 
'''Description'''


'''Parameters'''<br>
Create files.
<table border="1">
 
<tr>
'''Parameters'''
 
<table class="wikitable">
<tr>
<th>Parameter</th>
<th>Parameter</th>
<th>Meaning</th>
<th>Description</th>
</tr>
</tr>
<tr>
<tr>
<td>*len</td>
<td>*pHandle</td>
<td>[in]The length of the append data</td>
<td>[in] Device handle</td>
</tr>
</tr>
<tr>
<tr>
<td>*buffer</td>
<td>*filename</td>
<td>[in]Append data</td>
<td>[in/out] Input/Output file name</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
 
<table border="1">
----
Note: a single backslash ("\") should be added before the name of the file.
----
 
 
'''Return values'''
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
<th>Value</th>
<th>Value</th>
<th>Meaning</th>
<th>Description</th>
</tr>
</tr>
<tr>
<tr>
Line 3,072: Line 3,178:
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_FS_NO_MEMORY</td>
<td>ERROR_UNIKEY_FS_FILE_NAME</td>
<td>244</td>
<td>240</td>
<td>Not enough free memory</td>
<td>Wrong or invalid filename</td>
</tr>
<tr>
<td>ERROR_UNIKEY_FS_FILE_EXIST</td>
<td>245</td>
<td>File already exists</td>
</tr>
<tr>
<td>ERROR_UNIKEY_FS_ERR_SYS_UNINIT</td>
<td>246</td>
<td>The file system is not initialized</td>
</tr>
</tr>
</table>
</table>
Line 3,080: Line 3,196:
<br>
<br>


=== Read file data ===
=== Delete Files ===


'''API Prototype'''<br>
'''API Prototype'''
<code>UniKey_FS_File_Read_Data:function(handle: pWord; offset: pLongWord; len: pLongWord; buffer: pByteArray): DWORD; stdcall;</code>
 
<code>UniKey_FS_DeleteFile:function(pHandle: pWord; filename: pByteArray): DWORD; stdcall;</code>


'''Description'''<br>
'''Description'''
Read data file.


'''Parameters'''<br>
Delete files.
<table border="1">
 
<tr>
'''Parameters'''
 
<table class="wikitable">
<tr>
<th>Parameter</th>
<th>Parameter</th>
<th>Description</th>
<th>Description</th>
Line 3,096: Line 3,215:
<tr>
<tr>
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Device handle</td>
</tr>
</tr>
<tr>
<tr>
<td>*offset</td>
<td>*filename</td>
<td>[in]Read address</td>
<td>[in/out] Input/Output file name</td>
</tr>
<tr>
<td>*len</td>
<td>[in]Read the data length</td>
</tr>
<tr>
<td>*buffer</td>
<td>[out]Read data</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 3,125: Line 3,237:
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_FS_ERR_OPEN_FILE</td>
<td>ERROR_UNIKEY_FS_NO_FILE</td>
<td>247</td>
<td>241</td>
<td>The file to be modified is not opened yet.</td>
<td>No such filename</td>
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_FS_FILE_OFFSET</td>
<td>ERROR_UNIKEY_FS_ERR_SYS_UNINIT</td>
<td>242</td>
<td>246</td>
<td>Offset of file error.</td>
<td>The file system is not initialized</td>
</tr>
</tr>
</table>
</table>
Line 3,138: Line 3,250:
<br>
<br>


=== Close files ===
=== Open Files ===


'''API Prototype'''<br>
'''API Prototype'''
<code>UniKey_FS_File_Close:function(handle: pWord; filename: pByteArray): DWORD; stdcall;</code>


'''Description'''<br>
<code>UniKey_FS_File_Open:function(pHandle: pWord; filename: pChar): DWORD; stdcall;</code>
Close files.
 
'''Description'''
 
Open files.  
 
'''Parameters'''


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 3,154: Line 3,269:
<tr>
<tr>
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Device handle</td>
</tr>
</tr>
<tr>
<tr>
<td>*filename</td>
<td>*filename</td>
<td>[in]file name</td>
<td>[in] Input/Output file name</td>
</tr>
</tr>
<tr>
</table>
<td>*len</td>
 
<td>[in]Read the data length</td>
'''Return values'''
</tr>
<tr>
<td>*buffer</td>
<td>[in]Read data</td>
</tr>
</table>


'''Return values'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 3,181: Line 3,289:
<td>0</td>
<td>0</td>
<td>Success</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_UNIKEY_FS_NO_FILE</td>
<td>241</td>
<td>No such filename</td>
</tr>
</tr>
</table>
</table>
Line 3,186: Line 3,299:
<br>
<br>


=== Get file list ===
=== Get System Space ===
 
'''API Prototype'''
 
<code>UniKey_FS_Get_Free_Size:function(pHandle: pWord; usedsize: pLongWord; freesize: pLongWord): DWORD; stdcall;</code>


'''API Prototype'''<br>
'''Description'''
<code>UniKey_FS_File_Get_List:function(handle: pWord; filecount: pLongWord; filelist: pByteArray): DWORD; stdcall;</code>


'''Description'''<br>
Get occupied and free system space.  
Get file list.


'''Parameters'''<br>
'''Parameters'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 3,202: Line 3,318:
<tr>
<tr>
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Device handle</td>
</tr>
</tr>
<tr>
<tr>
<td>*filecount</td>
<td>*usedsize</td>
<td>[out]The number of files</td>
<td>[out] System memory that is in use</td>
</tr>
</tr>
<tr>
<tr>
<td>*filelist</td>
<td>*freesize</td>
<td>[out]</td>
<td>[out] Free system memory</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 3,230: Line 3,347:
<br>
<br>


=== Get the file size ===
=== Modify File Data ===


'''API Prototype'''<br>
'''API Prototype'''
<code>UniKey_FS_File_Get_Size:function(handle: pWord; filesize: pLongWord): DWORD; stdcall;</code>


'''Description'''<br>
<code>UniKey_FS_File_Modify_Data:function(pHandle: pWord; offset: pLongWord; len: pLongWord; buffer: pByteArray): DWORD; stdcall;</code>
Get the file size.
 
'''Description'''
 
Modify file data.
 
'''Parameters'''


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 3,246: Line 3,366:
<tr>
<tr>
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Device handle</td>
</tr>
</tr>
<tr>
<tr>
<td>*filesize</td>
<td>*offset</td>
<td>[out]The size of the file</td>
<td>[in] Address to be modified</td>
</tr>
<tr>
<td>*len</td>
<td>[in] Length of data to be modified</td>
</tr>
<tr>
<td>*buffer</td>
<td>[in] Modified data</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 3,265: Line 3,394:
<td>0</td>
<td>0</td>
<td>Success</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_UNIKEY_FS_FILE_OFFSET</td>
<td>242</td>
<td>File offset error</td>
</tr>
<tr>
<td>ERROR_UNIKEY_FS_ERR_OPEN_FILE</td>
<td>247</td>
<td>Failed to open file</td>
</tr>
</tr>
</table>
</table>
Line 3,270: Line 3,409:
<br>
<br>


=== Users reset file system password ===
=== Append Data to the End-Of-File ===


'''API Prototype'''<br>
'''API Prototype'''
<code>UniKey_FS_Set_Password:function(handle: pWord; PW1: pLongWord; PW2: pLongWord; PW3: pLongWord; PW4: pLongWord): DWORD; stdcall;</code>


'''Description'''<br>
<code>UniKey_FS_File_Append_Data:function(pHandle: pWord; len: pLongWord; buffer: pByteArray): DWORD; stdcall;</code>
Users reset the password to the file system.


'''Parameters'''<br>
'''Description'''
<table border="1">
 
Append data to the end-of-file.
 
'''Parameters'''
 
<table class="wikitable">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
<th>Description</th>
<th>Meaning</th>
</tr>
</tr>
<tr>
<tr>
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Device handle</td>
</tr>
</tr>
<tr>
<td>*pPassword1</td>
<td>[in]Password 1</td>
</tr>
</tr>
<tr>
<tr>
<td>*pPassword2</td>
<td>*len</td>
<td>[in]Password 2</td>
<td>[in] The length of the data to be appended</td>
</tr>
</tr>
<tr>
<tr>
<td>*pPassword3</td>
<td>*buffer</td>
<td>[in]Password 3</td>
<td>[in] Data to append</td>
</tr>
<tr>
<td>*pPassword4</td>
<td>[in]Password 4</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<tr>
<table class="wikitable">
<tr>
<th>Result</th>
<th>Result</th>
<th>Value</th>
<th>Value</th>
<th>Description</th>
<th>Meaning</th>
</tr>
</tr>
<tr>
<tr>
Line 3,319: Line 3,455:
</tr>
</tr>
<tr>
<tr>
<td>ERROR_GENERATE_NEW_PASSWORD</td>
<td>ERROR_UNIKEY_FS_NO_MEMORY</td>
<td>225 </td>
<td>244</td>
<td>Fail to generate new password.</td>
<td>Not enough free memory</td>
</tr>
</tr>
</table>
</table>


<br>---------------------------------------------------------------------------------------------------<br>
<br>
The reset of the password can only be successfully done after initializing the file system successfully.
 
<br>---------------------------------------------------------------------------------------------------<br>
=== Read File Data ===


<br>
'''API Prototype'''


=== Generate a RSA Key ===
<code>UniKey_FS_File_Read_Data:function(pHandle: pWord; offset: pLongWord; len: pLongWord; buffer: pByteArray): DWORD; stdcall;</code>


'''API Prototype'''<br>
'''Description'''
<code>UniKey_RSA_Generate_Key:function(handle: pWord; KeyIndex: pWord): DWORD; stdcall;</code>


'''Description'''<br>
Read file data.
UniKey Drive has encryption &amp; decryption modules with 1024-bit RSA keys. <br>Calling this function can generate a 1024-bit RSA key.
 
'''Parameters'''


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 3,347: Line 3,482:
<tr>
<tr>
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Device handle</td>
</tr>
<tr>
<td>*offset</td>
<td>[in] Read address</td>
</tr>
<tr>
<td>*len</td>
<td>[in] Length of data to be read</td>
</tr>
</tr>
<tr>
<tr>
<td>*KeyIndex</td>
<td>*buffer</td>
<td>[in]Return the handle generated Key</td>
<td>[out] Read data</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 3,368: Line 3,512:
</tr>
</tr>
<tr>
<tr>
<td>ERROR_KEY_INDEX</td>
<td>ERROR_UNIKEY_FS_FILE_OFFSET</td>
<td>239</td>
<td>242</td>
<td>The handle of the key is invalid.</td>
<td>File offset error</td>
</tr>
<tr>
<td>ERROR_UNIKEY_FS_ERR_OPEN_FILE</td>
<td>247</td>
<td>Failed to open file</td>
</tr>
</tr>
</table>
</table>
Line 3,376: Line 3,525:
<br>
<br>


=== Generate a DES Key ===
=== Close Files ===


'''API Prototype'''<br>
'''API Prototype'''
<code>UniKey_DES_Generate_Key:function(handle: pWord; KeyIndex: pWord): DWORD; stdcall;</code>


'''Description'''<br>
<code>UniKey_FS_File_Close:function(pHandle: pWord; filename: pByteArray): DWORD; stdcall;</code>
Calling this function can generate a DES key.


'''Parameters'''<br>
'''Description'''
<table border="1">
 
Close files.
 
'''Parameters'''
 
<table class="wikitable">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 3,392: Line 3,544:
<tr>
<tr>
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Device handle</td>
</tr>
</tr>
<tr>
<tr>
<td>*KeyIndex</td>
<td>*filename</td>
<td>[in]Return the handle generated Key</td>
<td>[in] Filename</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 3,411: Line 3,564:
<td>0</td>
<td>0</td>
<td>Success</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_KEY_INDEX</td>
<td>239</td>
<td>The handle of the key is invalid.</td>
</tr>
</tr>
</table>
</table>
Line 3,421: Line 3,569:
<br>
<br>


=== RSA Get key counts generated  ===
=== Get File List ===


'''API Prototype'''<br>
'''API Prototype'''
<code>UniKey_RSA_Get_Key_Counts:function(handle: pWord; KeyIndex: pLongWord): DWORD; stdcall;</code>


'''Description'''<br>
<code>UniKey_FS_File_Get_List:function(pHandle: pWord; filecount: pLongWord; filelist: pByteArray): DWORD; stdcall;</code>
Get the number of keys that are generated.


'''Parameters'''<br>
'''Description'''
<table border="1">
 
Get list of files on the UniKey Drive.
 
'''Parameters'''
 
<table class="wikitable">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 3,436: Line 3,587:
</tr>
</tr>
<tr>
<tr>
<td>*Phandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Device handle</td>
</tr>
<tr>
<td>*filecount</td>
<td>[out] The number of files</td>
</tr>
</tr>
<tr>
<tr>
<td>*KeyIndex</td>
<td>*filelist</td>
<td>[out]The key counts returned</td>
<td>[out] File list</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 3,456: Line 3,612:
<td>0</td>
<td>0</td>
<td>Success</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_KEY_INDEX</td>
<td>239</td>
<td>The handle of the key is invalid.</td>
</tr>
</tr>
</table>
</table>
Line 3,466: Line 3,617:
<br>
<br>


=== DES Get key counts generated ===  
=== Get File Size ===


'''API Prototype'''<br>
'''API Prototype'''
<code>UniKey_DES_Get_Key_Counts:function(handle: pWord; KeyIndex: pLongWord): DWORD; stdcall;</code>
 
<code>UniKey_FS_File_Get_Size:function(pHandle: pWord; filesize: pLongWord): DWORD; stdcall;</code>


'''Description'''<br>
'''Description'''
Get the number of keys that are generated.


'''Parameters'''<br>
Get the file size.
<table border="1">
 
<tr>
'''Parameters'''
 
<table class="wikitable">
<tr>
<th>Parameter</th>
<th>Parameter</th>
<th>Description</th>
<th>Description</th>
</tr>
</tr>
<tr>
<tr>
<td>*Phandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Device handle</td>
</tr>
</tr>
<tr>
<tr>
<td>*KeyIndex</td>
<td>*filesize</td>
<td>[out]The key counts returned</td>
<td>[out] The size of the file</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 3,501: Line 3,656:
<td>0</td>
<td>0</td>
<td>Success</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_KEY_INDEX</td>
<td>239</td>
<td>The handle of the key is invalid.</td>
</tr>
</tr>
</table>
</table>
Line 3,511: Line 3,661:
<br>
<br>


=== RSA encryption  ===
=== User Reset File System Password ===


'''API Prototype'''<br>
'''API Prototype'''
<code>UniKey_RSA_Encrypt:function(handle: pWord; KeyIndex: pWord; Encrypt_Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;</code>


'''Description'''<br>
<code>UniKey_FS_Set_Password:function(pHandle: pWord; PW1: pLongWord; PW2: pLongWord; PW3: pLongWord; PW4: pLongWord): DWORD; stdcall;</code>
Encrypt data using RSA.
 
'''Description'''
 
Allows a user to reset the file system password.
 
'''Parameters'''


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 3,526: Line 3,679:
</tr>
</tr>
<tr>
<tr>
<td>*Phandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Device handle</td>
</tr>
<tr>
<td>*PW1</td>
<td>[in] Password 1</td>
</tr>
</tr>
<tr>
<tr>
<td>*KeyIndex</td>
<td>*PW2</td>
<td>[in]Encrypt & decrypt using the key handle</td>
<td>[in] Password 2</td>
</tr>
</tr>
<tr>
<tr>
<td>*Len</td>
<td>*PW3</td>
<td>[in]The length of encryption & decryption data</td>
<td>[in] Password 3</td>
</tr>
</tr>
<tr>
<tr>
<td>*Buffer</td>
<td>*PW4</td>
<td>[in/out]Input encrypted text and output plain text.</td>
<td>[in] Password 4</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 3,556: Line 3,714:
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_ENCRYPT_FAILED</td>
<td>ERROR_UNIKEY_GENERATE_NEW_PASSWORD</td>
<td>228</td>
<td>225</td>
<td>Encryption failed.</td>
<td>Error generating new password</td>
</tr>
</tr>
</table>
</table>


<br>


=== RSA decryption  ===
----
A password reset can only be successfully done after initializing the file system.
----
 
<br>
 
=== Generate RSA Key ===
 
'''API Prototype'''
 
<code>UniKey_RSA_Generate_Key:function(pHandle: pWord; KeyIndex: pWord): DWORD; stdcall;</code>
 
'''Description'''


'''API Prototype'''<br>
UniKey Drive has encryption and decryption modules with 1024-bit RSA keys. Calling this function can generate a 1024-bit RSA key.
<code>UniKey_RSA_Decrypt:function(handle: pWord; KeyIndex: pWord; Encrypt_Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;</code>


'''Description'''<br>
'''Parameters'''
Decrypt data using RSA.


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 3,579: Line 3,745:
</tr>
</tr>
<tr>
<tr>
<td>*Phandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Device handle</td>
</tr>
</tr>
<tr>
<tr>
<td>*KeyIndex</td>
<td>*KeyIndex</td>
<td>[in]Encrypt & decrypt using the key handle</td>
<td>[out] Return the handle generated key</td>
</tr>
<tr>
<td>*Len</td>
<td>[in]The length of encryption & decryption data</td>
</tr>
<tr>
<td>*Buffer</td>
<td>[in/out]Input encrypted text and output plain text.</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 3,609: Line 3,768:
</tr>
</tr>
<tr>
<tr>
<td>ERROR_KEY_INDEX</td>
<td>ERROR_UNIKEY_KEY_INDEX</td>
<td>239</td>
<td>239</td>
<td>The key handle is invalid. </td>
<td>The handle of the key is invalid</td>
</tr>
<tr>
<td>ERROR_UNIKEY_DECRYPT_FAILED</td>
<td>229</td>
<td>Decryption failed.</td>
</tr>
</tr>
</table>
</table>
Line 3,622: Line 3,776:
<br>
<br>


=== DES encryption  ===
=== Generate a DES Key ===


'''API Prototype'''<br>
'''API Prototype'''
<code>UniKey_DES1_Encrypt:function(handle: pWord; EncryptMode: pWord; KeyIndex: pWord; Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;</code>


<code>UniKey_DES2_Encrypt:function(handle: pWord; EncryptMode: pWord; KeyIndex: pWord; Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;</code>
<code>UniKey_DES_Generate_Key:function(pHandle: pWord; KeyIndex: pWord): DWORD; stdcall;</code>


<code>UniKey_DES3_Encrypt:function(handle: pWord; EncryptMode: pWord; KeyIndex: pWord; Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;</code>
'''Description'''


'''Description'''<br>
Calling this function can generate a DES key.
Encrypt data using DES.
 
'''Parameters'''


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 3,641: Line 3,794:
</tr>
</tr>
<tr>
<tr>
<td>*Phandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Device handle</td>
</tr>
</tr>
<tr>
<tr>
<td>*KeyIndex</td>
<td>*KeyIndex</td>
<td>[in]Encrypt & decrypt using the key handle</td>
<td>[out] Return the handle generated key</td>
</tr>
</tr>
<tr>
</table>
<td>*Len</td>
 
<td>[in]The length of encryption & decryption data</td>
'''Return values'''
</tr>
<tr>
<td>*Buffer</td>
<td>[in/out]Input encrypted text and output plain text.</td>
</tr>
</table>


'''Return values'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 3,671: Line 3,817:
</tr>
</tr>
<tr>
<tr>
<td>ERROR_KEY_INDEX</td>
<td>ERROR_UNIKEY_KEY_INDEX</td>
<td>239</td>
<td>239</td>
<td>The key handle is invalid. </td>
<td>The handle of the key is invalid</td>
</tr>
<tr>
<td>ERROR_UNIKEY_ENCRYPT_FAILED</td>
<td>228</td>
<td>Encryption failed.</td>
</tr>
</tr>
</table>
</table>
Line 3,684: Line 3,825:
<br>
<br>


=== DES decryption ===
=== RSA Get Number of Generated Keys ===
 
'''API Prototype'''


'''API Prototype'''<br>
<code>UniKey_RSA_Get_Key_Counts:function(pHandle: pWord; KeyIndex: pLongWord): DWORD; stdcall;</code>
<code>UniKey_DES1_Decrypt:function(handle: pWord; EncryptMode: pWord; KeyIndex: pWord; Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;</code>


<code>UniKey_DES2_Decrypt:function(handle: pWord; EncryptMode: pWord; KeyIndex: pWord; Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;</code>
'''Description'''


<code>UniKey_DES3_Decrypt:function(handle: pWord; EncryptMode: pWord; KeyIndex: pWord; Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;</code>
Get the number of RSA keys that are generated.


'''Description'''<br>
'''Parameters'''
Encrypt data using DES.


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 3,703: Line 3,843:
</tr>
</tr>
<tr>
<tr>
<td>*Phandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Device handle</td>
</tr>
</tr>
<tr>
<tr>
<td>*KeyIndex</td>
<td>*KeyIndex</td>
<td>[in]Encrypt & decrypt using the key handle</td>
<td>[out] Key count</td>
</tr>
<tr>
<td>*Len</td>
<td>[in]The length of encryption & decryption data</td>
</tr>
<tr>
<td>*Buffer</td>
<td>[in/out]Input encrypted text and output plain text.</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 3,733: Line 3,866:
</tr>
</tr>
<tr>
<tr>
<td>ERROR_KEY_INDEX</td>
<td>ERROR_UNIKEY_KEY_INDEX</td>
<td>239</td>
<td>239</td>
<td>The key handle is invalid. </td>
<td>The handle of the key is invalid</td>
</tr>
<tr>
<td>ERROR_UNIKEY_DECRYPT_FAILED</td>
<td>229</td>
<td>Decryption failed.</td>
</tr>
</tr>
</table>
</table>
Line 3,746: Line 3,874:
<br>
<br>


=== RSA Delete Key  ===
=== DES Get Number of Generated Keys ===  


'''API Prototype'''<br>
'''API Prototype'''
<code>UniKey_RSA_Del_Key:function(handle: pWord; KeyIndex: pWord): DWORD; stdcall;</code>
 
<code>UniKey_DES_Get_Key_Counts:function(pHandle: pWord; KeyIndex: pLongWord): DWORD; stdcall;</code>


'''Description'''<br>
'''Description'''
Delete a key.


'''Parameters'''<br>
Get the number of DES keys that are generated.
<table border="1">
 
<tr>
'''Parameters'''
 
<table class="wikitable">
<tr>
<th>Parameter</th>
<th>Parameter</th>
<th>Description</th>
<th>Description</th>
Line 3,762: Line 3,893:
<tr>
<tr>
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Device handle</td>
</tr>
</tr>
<tr>
<tr>
<td>*KeyIndex</td>
<td>*KeyIndex</td>
<td>[in]The handle to be deleted</td>
<td>[out] Key count</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
<th>Value</th>
<th>Value</th>
<th>Meaning</th>
<th>Description</th>
</tr>
</tr>
<tr>
<tr>
Line 3,783: Line 3,915:
</tr>
</tr>
<tr>
<tr>
<td>ERROR_KEY_INDEX</td>
<td>ERROR_UNIKEY_KEY_INDEX</td>
<td>239</td>
<td>239</td>
<td>The key handle is invalid.<br>KeyIndex <0 or KeyIndex > 3.</td>
<td>The handle of the key is invalid</td>
</tr>
</tr>
</table>
</table>
Line 3,791: Line 3,923:
<br>
<br>


=== DES Delete key ===
=== RSA Encryption ===
 
'''API Prototype'''
 
<code>UniKey_RSA_Encrypt:function(pHandle: pWord; KeyIndex: pWord; Encrypt_Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;</code>
 
'''Description'''


'''API Prototype'''<br>
Encrypt data using RSA.
<code>UniKey_DES_Del_Key:function(handle: pWord; KeyIndex: pWord): DWORD; stdcall;</code>


'''Description'''<br>
'''Parameters'''
Delete a key.


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 3,807: Line 3,942:
<tr>
<tr>
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Device handle</td>
</tr>
</tr>
<tr>
<tr>
<td>*KeyIndex</td>
<td>*KeyIndex</td>
<td>[in]The handle to be deleted</td>
<td>[in] Encrypt and decrypt using the key handle</td>
</tr>
<tr>
<td>*Encrypt_Len</td>
<td>[in] Data length to be encrypted</td>
</tr>
<tr>
<td>*Buffer</td>
<td>[in/out] Input plain text and output encrypted text</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 3,828: Line 3,972:
</tr>
</tr>
<tr>
<tr>
<td>ERROR_KEY_INDEX</td>
<td>ERROR_UNIKEY_ENCRYPT_FAILED</td>
<td>239</td>
<td>228</td>
<td>The key handle is invalid.</td>
<td>Could not encrypt data</td>
</tr>
<tr>
<td></td>
<td></td>
<td>KeyIndex <0 or KeyIndex > 14.</td>
</tr>
</tr>
</table>
</table>
Line 3,841: Line 3,980:
<br>
<br>


=== Get user counts ===
=== RSA Decryption  ===


'''API Prototype'''<br>
'''API Prototype'''
<code>UniKey_Get_UserCount:function(handle: pWord; Count: pWord): DWORD; stdcall;</code>


'''Description'''<br>
<code>UniKey_RSA_Decrypt:function(pHandle: pWord; KeyIndex: pWord; Encrypt_Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;</code>
UniKey Drive can enable 32 concurrent users to logon. This function can be called to get the number of logon users.


'''Parameters'''<br>
'''Description'''
<table border="1">
 
<tr>
Decrypt data using RSA.
<th>Parameter</th>
 
'''Parameters'''
 
<table class="wikitable">
<tr>
<th>Parameter</th>
<th>Description</th>
<th>Description</th>
</tr>
</tr>
Line 3,860: Line 4,002:
</tr>
</tr>
<tr>
<tr>
<td>*Count </td>
<td>*KeyIndex</td>
<td>[in]Number of logon users returned</td>
<td>[in] Encrypt and decrypt using the key handle</td>
</tr>
<tr>
<td>*Decrypt_Len</td>
<td>[in] Length of data to be decrypted</td>
</tr>
<tr>
<td>*Buffer</td>
<td>[in/out] Input encrypted text and output plain text.</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 3,878: Line 4,029:
</tr>
</tr>
<tr>
<tr>
<td>ERROR_KEY_INDEX</td>
<td>ERROR_UNIKEY_DECRYPT_FAILED</td>
<td>229</td>
<td>Could not decrypt data</td>
</tr>
<tr>
<td>ERROR_UNIKEY_KEY_INDEX</td>
<td>239</td>
<td>239</td>
<td>The key handle is invalid.<br>KeyIndex <0 or KeyIndex > 14.</td>
<td>The key handle is invalid</td>
</tr>
</tr>
</table>
</table>
Line 3,886: Line 4,042:
<br>
<br>


=== Only allow one user to logon ===
=== DES Encryption  ===


'''API Prototype'''<br>
'''API Prototype'''
<code>Unikey_Logon_Single:function(handle: pWord; pPassword1: pLongWord; pPassword2: pLongWord; pPassword3: pLongWord; pPassword4: pLongWord): DWORD; stdcall;</code>
 
<code>
UniKey_DES1_Encrypt:function(pHandle: pWord; EncryptMode: pWord; KeyIndex: pWord; Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;
 
UniKey_DES2_Encrypt:function(pHandle: pWord; EncryptMode: pWord; KeyIndex: pWord; Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;
 
UniKey_DES3_Encrypt:function(pHandle: pWord; EncryptMode: pWord; KeyIndex: pWord; Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;
</code>


'''Description'''<br>
'''Description'''
After calling this function, UniKey Drive only allows the active user to logon and other users will not be allowed to logon.


'''Parameters'''<br>
Encrypt data using DES.
<table border="1">
 
'''Parameters'''
 
<table class="wikitable">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 3,902: Line 4,067:
<tr>
<tr>
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Device handle</td>
</tr>
</tr>
<tr>
<tr>
<td>*pPassword1</td>
<tr>
<td>[in]Password 1</td>
<td>*EncryptMode</td>
<td>[in] Block cipher mode of operation</td>
</tr>
</tr>
<tr>
<tr>
<td>*pPassword2</td>
<td>*KeyIndex</td>
<td>[in]Password 2</td>
<td>[in] Encrypt and decrypt using the key handle</td>
</tr>
</tr>
<tr>
<tr>
<td>*pPassword3</td>
<td>*Len</td>
<td>[in]Password 3</td>
<td>[in] Length of data to be encrypted</td>
</tr>
</tr>
<tr>
<tr>
<td>*pPassword4</td>
<td>*Buffer</td>
<td>[in]Password 4</td>
<td>[in/out] Input plain text and output encrypted text.</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 3,935: Line 4,102:
</tr>
</tr>
<tr>
<tr>
<td>ERROR_UNIKEY_INVALID_PASSWORD_OR_ID</td>
<td>ERROR_UNIKEY_ENCRYPT_FAILED</td>
<td>202</td>
<td>228</td>
<td>The password or ID is invalid.</td>
<td>Could not encrypt data</td>
</tr>
<tr>
<td>ERROR_UNIKEY_KEY_INDEX</td>
<td>239</td>
<td>The key handle is invalid</td>
</tr>
</tr>
</table>
</table>
Line 3,943: Line 4,115:
<br>
<br>


=== Logoff the active user ===
=== DES Decryption  ===
 
'''API Prototype'''
 
<code>
UniKey_DES1_Decrypt:function(pHandle: pWord; EncryptMode: pWord; KeyIndex: pWord; Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;
 
UniKey_DES2_Decrypt:function(pHandle: pWord; EncryptMode: pWord; KeyIndex: pWord; Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;


'''API Prototype'''<br>
UniKey_DES3_Decrypt:function(pHandle: pWord; EncryptMode: pWord; KeyIndex: pWord; Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;
<code>UniKey_Logoff:function(handle: pWord):DWORD; stdcall;</code>
</code>


'''Description'''<br>
'''Description'''
After calling this function, the active user will be logoff, without affecting other users’ logon status.


'''Parameters'''<br>
Encrypt data using DES.
<table border="1">
 
'''Parameters'''
 
<table class="wikitable">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 3,959: Line 4,140:
<tr>
<tr>
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Device handle</td>
</tr>
<tr>
<tr>
<td>*DecryptMode</td>
<td>[in] Block cipher mode of operation</td>
</tr>
<tr>
<td>*KeyIndex</td>
<td>[in] Encrypt and decrypt using the key handle</td>
</tr>
<tr>
<td>*Len</td>
<td>[in] Length of data to be decrypted</td>
</tr>
<tr>
<td>*Buffer</td>
<td>[in/out] Input encrypted text and output plain text.</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
'''Return values'''
<table border="1">
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>
Line 3,974: Line 4,173:
<td>0</td>
<td>0</td>
<td>Success</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_UNIKEY_DECRYPT_FAILED</td>
<td>229</td>
<td>Could not decrypt data</td>
</tr>
<tr>
<td>ERROR_UNIKEY_KEY_INDEX</td>
<td>239</td>
<td>The key handle is invalid</td>
</tr>
</tr>
</table>
</table>
Line 3,979: Line 4,188:
<br>
<br>


=== Logoff all users ===
=== Delete RSA Key  ===
 
'''API Prototype'''
 
<code>UniKey_RSA_Del_Key:function(pHandle: pWord; KeyIndex: pWord): DWORD; stdcall;</code>
 
'''Description'''


'''API Prototype'''<br>
Delete a RSA key.
<code>UniKey_Logoff_All:function(handle: pWord): DWORD; stdcall;</code>


'''Description'''<br>
'''Parameters'''
After calling this function, all users will be logged off.


'''Parameters'''<br>
<table class="wikitable">
<table border="1">
<tr>
<tr>
<th>Parameter</th>
<th>Parameter</th>
Line 3,995: Line 4,207:
<tr>
<tr>
<td>*pHandle</td>
<td>*pHandle</td>
<td>[in]Device handle</td>
<td>[in] Device handle</td>
</tr>
<tr>
<td>*KeyIndex</td>
<td>[in] The handle to be deleted</td>
</tr>
</table>
 
'''Return values'''
 
<table class="wikitable">
<tr>
<th>Result</th>
<th>Value</th>
<th>Meaning</th>
</tr>
<tr>
<td>SUCCESS</td>
<td>0</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_UNIKEY_KEY_INDEX</td>
<td>239</td>
<td>The handle of the key is invalid<br>0 > KeyIndex > 3</td>
</tr>
</tr>
</table>
</table>


'''Return values'''<br>
<br>
<table border="1">
 
=== Delete DES Key ===
 
'''API Prototype'''
 
<code>UniKey_DES_Del_Key:function(pHandle: pWord; KeyIndex: pWord): DWORD; stdcall;</code>
 
'''Description'''
 
Delete a DES key.
 
'''Parameters'''
 
<table class="wikitable">
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
<tr>
<td>*pHandle</td>
<td>[in] Device handle</td>
</tr>
<tr>
<td>*KeyIndex</td>
<td>[in] Key handle to be deleted</td>
</tr>
</table>
 
'''Return values'''
 
<table class="wikitable">
<tr>
<th>Result</th>
<th>Value</th>
<th>Description</th>
</tr>
<tr>
<td>SUCCESS</td>
<td>0</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_UNIKEY_KEY_INDEX</td>
<td>239</td>
<td>The handle of the key is invalid<br>0 > KeyIndex > 14</td>
</tr>
</table>
 
<br>
 
=== Get User Counts ===
 
'''API Prototype'''
 
<code>UniKey_Get_UserCount:function(pHandle: pWord; Count: pWord): DWORD; stdcall;</code>
 
'''Description'''
 
UniKey Drive can enable 32 concurrent users to log in. This function can be called to get the number of users logged in.
 
'''Parameters'''
 
<table class="wikitable">
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
<tr>
<td>*pHandle</td>
<td>[in] Device handle</td>
</tr>
<tr>
<td>*Count </td>
<td>[out] Number of users logged in</td>
</tr>
</table>
 
'''Return values'''
 
<table class="wikitable">
<tr>
<th>Result</th>
<th>Value</th>
<th>Description</th>
</tr>
<tr>
<td>SUCCESS</td>
<td>0</td>
<td>Success</td>
</tr>
</table>
 
<br>
 
=== Only Allow One User to Log in ===
 
'''API Prototype'''
 
<code>Unikey_Logon_Single:function(pHandle: pWord; pPassword1: pLongWord; pPassword2: pLongWord; pPassword3: pLongWord; pPassword4: pLongWord): DWORD; stdcall;</code>
 
'''Description'''
 
After calling this function, the UniKey Drive will only allow the active user to log in, other users will not be allowed to log in.
 
'''Parameters'''
 
<table class="wikitable">
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
<tr>
<td>*pHandle</td>
<td>[in] Device handle</td>
</tr>
<tr>
<td>*pPassword1</td>
<td>[in] Password 1</td>
</tr>
<tr>
<td>*pPassword2</td>
<td>[in] Password 2</td>
</tr>
<tr>
<td>*pPassword3</td>
<td>[in] Password 3</td>
</tr>
<tr>
<td>*pPassword4</td>
<td>[in] Password 4</td>
</tr>
</table>
 
'''Return values'''
 
<table class="wikitable">
<tr>
<th>Result</th>
<th>Value</th>
<th>Description</th>
</tr>
<tr>
<td>SUCCESS</td>
<td>0</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_UNIKEY_INVALID_PASSWORD_OR_ID</td>
<td>202</td>
<td>Wrong password or UniKey HID</td>
</tr>
</table>
 
<br>
 
=== Log off the Active User ===
 
'''API Prototype'''
 
<code>UniKey_Logoff:function(pHandle: pWord):DWORD; stdcall;</code>
 
'''Description'''
 
After calling this function, the active user will be logged out, does not affect other users’ login status.
 
'''Parameters'''
 
<table class="wikitable">
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
<tr>
<td>*pHandle</td>
<td>[in] Device handle</td>
</tr>
</table>
 
'''Return values'''
 
<table class="wikitable">
<tr>
<th>Result</th>
<th>Value</th>
<th>Description</th>
</tr>
<tr>
<td>SUCCESS</td>
<td>0</td>
<td>Success</td>
</tr>
</table>
 
<br>
 
=== Log off all Users ===
 
'''API Prototype'''
 
<code>UniKey_Logoff_All:function(pHandle: pWord): DWORD; stdcall;</code>
 
'''Description'''
 
After calling this function, all users will be logged off.
 
'''Parameters'''
 
<table class="wikitable">
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
<tr>
<td>*pHandle</td>
<td>[in] Device handle</td>
</tr>
</table>
 
'''Return values'''
 
<table class="wikitable">
<tr>
<tr>
<th>Result</th>
<th>Result</th>

Revision as of 11:44, 13 July 2016


UniKey API Reference

Find a UniKey dongle

API Prototype

function UniKey__Find(pHandle: pWord; pSetting1: pLongWord; pSetting2: pLongWord): DWORD; stdcall;

Description

Check if a specific UniKey is attached to the USB port. This is the first API used to start a UniKey session.

Parameters

Parameter Description
*pHandle [out] Dongle handle
*pSetting1 [in] Working mode (UniKey PRO only), useless for UniKey STD
[out] Hardware ID
*pSetting2 [in] Access mode (UniKey PRO only), useless for UniKey STD
[out] Number of dongles attached, useless for UniKey STD

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_NOT_FOUND 200 No UniKey dongle



For UniKey PRO (Network UniKey), *pSetting specifies the working mode. If you do not specify the value in *lp1, the working mode will be read from the NetUniKey.ini.



Find the Next UniKey dongle

API Prototype

function UniKey__Find_Next(pHandle: pWord; pSetting1: pLongWord; pSetting2: pLongWord): DWORD; stdcall;

Description

Check if another UniKey is attached to the USB port.

Parameters

Parameter Description
*pHandle [out] Dongle handle
*pSetting1 [in] Working Mode (UniKey PRO only), useless for UniKey STD
[out] Hardware ID
*pSetting2 [in] Access Mode (UniKey PRO only), useless for UniKey STD
[out] Number of dongles attached , useless for UniKey STD

Return values

Result Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NOMORE 214 No more dongles found
ERROR_UNIKEY_NEED_FIND 215 Find needs to be called before Find_Next


Log on to UniKey Dongle

API Prototype

function UniKey__User_Logon(pHandle: pWord; pPassword1: pWord; pPassword2: pWord): DWORD; stdcall;

For UniKey Drive, the API Prototype is

function UniKey__User_Logon(pHandle: pWord; pPassword1: pWord; pPassword2: pWord): DWORD; stdcall;

Description

Log in to a UniKey dongle with specified passwords. This API should be called in the commercial software in order to improve security.

Parameters

Parameter Description
*pPassword1 [in] Password 1
*pPassword2 [in] Password 2
*pHandle [out] Dongle handle

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_NOT_FOUND 200 No UniKey dongle
ERROR_UNIKEY_INVALID_PASSWORD 201 Found UniKey dongle, but basic passwords (password 1 and 2) are incorrect
ERROR_UNIKEY_INVALID_PASSWORD_OR_ID 202 Wrong password or UniKey HID


Log on to UniKey Dongle in vendor mode

API Prototype

function UniKey__Vender_Logon(pHandle: pWord; pPassword1: pWord; pPassword2: pWord; pPassword3: pWord; pPassword4: pWord): DWORD; stdcall;

For UniKey Drive, the API Prototype is

function UniKey__Vender_Logon(pHandle: pWord; pPassword1: pWord; pPassword2: pWord; pPassword3: pWord; pPassword4: pWord): DWORD; stdcall;

Description

Log in to a UniKey dongle in vendor mode with specified passwords. This API helps software vendors to log in to the UniKey dongle in vendor mode, and get full permissions to the UniKey dongle.



We do NOT advise you to enclose this API in the final released software. This API is only for software vendor’s usage.




If password 3 or 4 is wrong, while password 1 and 2 is correct, the dongle is then logged on in user mode automatically.



Parameters

Parameter Description
*pPassword1 [in] Password 1
*pPassword2 [in] Password 2
*pPassword3 [in] Password 3
*pPassword4 [in] Password 4
*pHandle [out] Dongle handle

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_NOT_FOUND 200 No UniKey dongle
ERROR_UNIKEY_INVALID_PASSWORD 201 Found UniKey dongle, but basic passwords (password 1 and 2) are incorrect
ERROR_UNIKEY_INVALID_PASSWORD_OR_ID 202 Wrong password or UniKey HID


Log off the UniKey dongle

API Prototype

function UniKey__Logoff(pHandle: pWord): DWORD; stdcall;

Description

Log off a UniKey dongle with a specific handle; this API should be called at the end of a UniKey session.

Parameters

Parameter Description
*pHandle [in] Dongle handle

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_NOT_FOUND 200 No UniKey dongle
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running


Get the UniKey Dongle's Type

API Prototype

function UniKey__Get_Type(pHandle: pWord; type: pLongWord): DWORD; stdcall;

Description

UniKey__Get_Type can help you get the type of the UniKey dongle.
This functions return value will help to indicate the type of the UniKey dongle.

Type Code
UNIKEY_TYPE_TIME 101
UNIKEY_TYPE_PRO 102
UNIKEY_TYPE_STD 103

Parameters

Parameter Description
*pHandle [in] Dongle handle
*type [out] The value indicating the type of your UniKey dongle

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_GET_TYPE 256 UniKey Get Type Error


Read UniKey dongle memory

API Prototype

function UniKey__Read_Memory(pHandle: pWord; pStartAddress: pWord; pBufferLength: pWord; pBuffer: pByteArray): DWORD; stdcall;

Description

Read the contents of memory; this API needs to be called after logging in to a UniKey dongle.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pStartAddress [in] Offset of Memory
*pBufferLenght [in] Number of bytes to read
pBbuffer [out] Pointer to the buffer containing the data to be read

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address is incorrect or invalid length
ERROR_UNIKEY_READ_MEMORY 207 Read Error
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running


Write to UniKey dongle memory

API Prototype

function UniKey__Write_Memory(pHandle: pWord; pStartAddress: pWord; pBufferLength: pWord; pBuffer: pByteArray): DWORD; stdcall;

Description

Write data into memory; this API needs to be called after logging on to a UniKey dongle.

Parameters

Parameter Description
*handle*pHandle [in] Dongle handle
*pStartAddress [in] Offset of the memory
*pBufferLength [in] Number of bytes to write
pBbuffer [in] Pointer to the buffer containing the data to be written

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address is incorrect or invalid length
ERROR_UNIKEY_WRITE_MEMORY 207 Write Error
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_VERIFY_ADV_PASSWORD 223 Advanced passwords (password 3 and 4) not verified



To write the last 2k memory (for 2048 – 4096), you need to verify all 4 passwords (vendor mode) to obtain the requisite permission.




UniKey__Read_Memory and UniKey__Write_Memory provide basic reading and writing functions to the dongle. You can store general information via such functions. And various levels of security can be applied too.



Generate a Random Number

API Prototype

function UniKey__Random(pHandle: pWord; pReturn1: pWord; pReturn2: pWord; pReturn3: pWord; pReturn4: pWord): DWORD; stdcall;

Description

Generates random numbers from the dongle.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pReturn1 [out] Random number
*pReturn2 [out] Random number
*pReturn3 [out] Random number
*pReturn4 [out] Random number

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_RANDOM 209 Random number error
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running



UNIKEY_RANDOM is to generate a random number inside the dongle. The UniKey dongle computation engine generates the number and the hardware of the dongle is the seed for the random number.



Generate Seed Code Return Values

API Prototype

function UniKey__Seed(pHandle: pWord; pSeed: pLongWord; pReturn1: pWord; pReturn2: pWord; pReturn3: pWord; pReturn4: pWord): DWORD; stdcall;

Description

Get return codes from the input of a seed code; this API return for values which are related to pSeed and the UniKey dongle’s password.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pSeed [in] Seed code
*pReturn1 [out] Return code 1
*pReturn2 [out] Return code 2
*pReturn3 [out] Return code 3
*pReturn4 [out] Return code 4

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_SEED 210 Seed code error
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running



UniKey__Seed generate a set of seed codes; all of these seed codes are based on the password. providing another method to verify passwords and check if a dongle has been inserted. Apart from this, the seed codes can be used in other computations, for example, you can use the seed returned as a 64-bit encryption key.



Write Software ID

API Prototype

function UniKey__Write_SoftID(pHandle: pWord; lp1: pLongWord): DWORD; stdcall;

Description

Write the vendor-defined software ID.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pSoftID [in] Software ID

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_SET_SOFTID 203 Set software ID error
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running



You need to verify all 4 passwords (vendor mode) to write the software ID to the dongle.



Read Software ID

API Prototype

function UniKey__Read_SoftID(pHandle: pWord; pSoftID: pLongWord): DWORD; stdcall;

Description

Read the user-defined software ID.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pSoftID [out] Software ID

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running



UniKey__Write_SoftID and UniKey__Read_SoftID provide a means to make a soft (write-able) ID for each software. You can write different software ID for each software and call UNIKEY_READ_SOFTID to check if the software ID is correct.



Set a UniKey License module

API Prototype

function UniKey__Set_Module(pHandle: pWord; pModule: pWord; pValue: pWord; pDecrease: pWord): DWORD; stdcall;

Description

To write a value to a specific UniKey license module and set the Decrement attribute.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pModule [in] License module number
*pValue [in] License module unit value
*pDecrease [in] Decrement attribute (1 = allowed, 0 = not allowed)

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 202 Read/Write address is incorrect or invalid length
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_MODULE 216 License module error



A successful operation will result in license module unit number *pModule storing value *pValue, and the Decrement attribute set to "0" or "1".




You need to verify all 4 passwords (vendor mode) to set a module value successfully.



Get a UniKey License module

API Prototype

function UniKey__Check_Module(pHandle: pWord; pModule: pWord; pValue: pWord; pDecrease: pWord): DWORD; stdcall;

Description

Get a value from a specific UniKey license module.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pModule [in] Module Number
*pValue [out] Return the value in module

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 202 Read/Write address is incorrect or invalid length
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_MODULE 216 License module error



You need to verify 2 passwords (user mode) to get a module value successfully.



Check a UniKey License module

API Prototype

function UniKey__Check_Module(phandle: pWord; pModule: pWord; pValues: pWord; pDecrease: pWord): DWORD; stdcalll;

Description

Read the attributes of a specific UniKey license module.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pModule [in] License module number
*pValue [out] Validity (1 = license module value is not zero)
*pDecrease [out] Decrement attribute (1 = license module can be decreased)

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 202 Read/Write address is incorrect or invalid length
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_MODULE 216 License module error



A successful operation will result in *pValue having value from Validity (1 = license module value is not zero), and *pDecrease having value from the Decrement attribute (1 = license module can be decreased). The value of a license module cannot be read directly, and it is invisible to end users.




UniKey__Set_Module and UniKey__Check_Module provide an easy way to implement software limitations. For example, if you want to set software to only be executed 3 times, you can call UniKey__Set_Module to set a license module (let us say license module 0) as 3. And, during each execution, we decrease the license module, if the license module is invalid (zero), we stop the software. Apart from this, we can implement a module-selling model with the help of license module functions. For example, the software has four function modules, A, B, C and D. And we can map the function modules to the license modules in the UniKey dongle. Let us say that function module A is mapped to license module 0, B to 1, C to 2 and D to 3. If a customer only buys function A and B, you only need to enable license module 0 and 1, and leave 2 and 3 as zero. So now only function module A and B can be executed. If the customer buys additional functions, you can use the UniKey Remote Updater tool to update the dongle as needed remotely.



Write Arithmetic

API Prototype

function UniKey__Write_Arithmetic(pHandle: pWord; pStartAddress: pWord; pBuffer: pByteArray): DWORD; stdcall;

Description

Write user-defined mathematical algorithms.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pStartAddress [in] Offset of first instruction
*pBuffer [in] Pointer to the algorithm command string

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address is incorrect or invalid length
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_AR_BAD_COMMAND 217 Arithmetic instruction error
ERROR_UNIKEY_AR_UNKNOWN_OPCODE 218 Arithmetic operator error
ERROR_UNIKEY_AR_WRONG_BEGIN 219 Constant numbers can't be used on first arithmetic instruction
ERROR_UNIKEY_AR_WRONG_END 220 Constant numbers can't be used on last arithmetic instruction
ERROR_UNIKEY_AR_VALUE_OVERFLOW 221 Constant numbers > 63 will cause an overflow



A successful operation will result in a user-defined algorithm containing the algorithm command string from the buffer.




UniKey__Write_Arithmetic is called when you write a series of algorithms into the dongle. This function is only called on the software vendor side. For example, if you have a serial number generator algorithm, and you want to perform this algorithm inside the dongle, you need to call UniKey__Write_Arithmetic



User-Defined Algorithm Calculate 1

API Prototype

function UniKey__Calculate1(pHandle: pWord; pStartAddress: pLongWord; pModule: pLongWord; pRegisterA: pWord; pRegisterB: pWord; pRegisterC: pWord; pRegisterD: pWord): DWORD; stdcall;

Description

Return the results of a calculation performed in the UniKey, using input provided by the developer and the CALCULATE1 function.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pStartAddress [in] Start point of calculation
*pModule [in] License module number
*pRegA [in, out] Register A
*pRegB [in, out] Register B
*pRegC [in, out] Register C
*pRegD [in, out] Register D

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address is incorrect or invalid length
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_AR_BAD_COMMAND 217 Arithmetic instruction error
ERROR_UNIKEY_AR_UNKNOWN_OPCODE 218 Arithmetic operator error
ERROR_UNIKEY_AR_WRONG_BEGIN 219 Constant numbers can't be used on first arithmetic instruction
ERROR_UNIKEY_AR_WRONG_END 220 Constant numbers can't be used on last arithmetic instruction
ERROR_UNIKEY_AR_VALUE_OVERFLOW 221 Constant numbers > 63 will cause an overflow



When the calculation starts, the values of other internal registers are listed in the table below.
E and F is the bytewise reversed hardware ID. For example, if the hardware is 0x12345678 (in hex), then E will be 0x7856 and F will be 0x3412.



Internal Register Description
E High-order byte of reversed hardware ID
F Low-order byte of reversed hardware ID
G Value stored in license module *pModule
H Random number



Examples:
If the internal algorithm is A = B + C, then the call result is *pRegA = *pRegB + *pRegC
The internal algorithm is A = A + G; if *pRegA = 0, then you may guess the result is the license module such that *pRegA = G = *pModule
Though you cannot read the content of modules directly, you can determine the content by an algorithm. If possible, it would be best to also check this content with an algorithm, and not only compare it in the program.



User-Defined Algorithm Calculate 2

API Prototype

function UniKey__Calculate2(pHandle: pWord; pStartAddress: pLongWord; pSeed: pLongWord; pRegisterA: pWord; pRegisterB: pWord; pRegisterC: pWord; pRegisterD: pWord): DWORD; stdcall;

Description

Return the results of a calculation performed in the UniKey, using input provided by the developer and the CALCULATE2 function.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pStartAddress [in] Start point of calculation
*pSeed [in] Seed code (32-bit)
*pRegA [in, out] Register A
*pRegB [in, out] Register B
*pRegC [in, out] Register C
*pRegD [in, out] Register D

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address is incorrect or invalid length
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_AR_BAD_COMMAND 217 Arithmetic instruction error
ERROR_UNIKEY_AR_UNKNOWN_OPCODE 218 Arithmetic operator error
ERROR_UNIKEY_AR_WRON_GBEGIN 219 Constant numbers can't be used on first arithmetic instruction
ERROR_UNIKEY_AR_WRONG_END 220 Constant numbers can't be used on last arithmetic instruction
ERROR_UNIKEY_AR_VALUE_OVERFLOW 221 Constant numbers > 63 will cause an overflow



When using calculate 2, the initial values of register E, F, G and H are the return values of seed code *pSeed, to make it simple, the UniKey calls function SEED with seed code *pSeed, and writes the return values to register E, F, G and H for the next operation.



Internal Register Description
E Seed result 1
F Seed result 2
G Seed result 3
H Seed result 4


User-Defined Algorithm Calculate 3

API Prototype

function UniKey__Calculate3(pHandle: pWord; pStartAddress: pLongWord; pModule: pLongWord; pRegisterA: pWord; pRegisterB: pWord; pRegisterC: pWord; pRegisterD: pWord): DWORD; stdcall;

Description

Return results of a calculation performed in the UniKey, using input provided by the developer and the CALCULATE3 function.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pStartAddress [in] Start point of calculation
*pModule [in] License module number
*pRegA [in, out] Register A
*pRegB [in, out] Register B
*pRegC [in, out] Register C
*pRegD [in, out] Register D

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address is incorrect or invalid length
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_AR_BAD_COMMAND 217 Arithmetic instruction error
ERROR_UNIKEY_AR_UNKNOWN_OPCODE 218 Arithmetic operator error
ERROR_UNIKEY_AR_WRON_GBEGIN 219 Constant numbers can't be used on first arithmetic instruction
ERROR_UNIKEY_AR_WRONG_END 220 Constant numbers can't be used on last arithmetic instruction
ERROR_UNIKEY_AR_VALUE_OVERFLOW 221 Constant numbers > 63 will cause an overflow



When using calculate 3, the initial values of register E, F, G and H are the content of license module *lp2 and *lp2 + 1/2/3.



Internal Register Description
E Value in license module *lp2
F Value in license module (*lp2 + 1)
G Value in license module (*lp2 + 2)
H Value in license module (*lp2 + 3)



Examples:
When calling calculation 3 with *pModule = 0, the initial values of register E, F, G and H are:
E = value of license module 0
F = value of license module 1
G = value of license module 2
F = value of license module 3
Note: The address will return to "0" when the license module address call exceeds 128. For example: Calculation 3 with *pModule = 126, the initial values of register E, F, G and H are:
E = value of license module 126
F = value of license module 127
G = value of license module 0
H = value of license module 1




UniKey__Calculate is called when you want to perform the algorithm you have written inside the UniKey dongle. For example, you have written a formula into the dongle, you can call UniKey__Calculate to perform the algorithm and get the return value of the formula.



Decrease a License Module

API Prototype

function UniKey__Module_Decrease(pHandle: pWord; pModule: pWord): DWORD; stdcall;

Description

Decrease the value in a specified UniKey license module by "1".

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pModule [in] License module number

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address is incorrect or invalid length
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_MODULE 216 License module error



Please call UniKey__Check_Module to check if the license module is valid first.



Generate a New Password

API Prototype

function UniKey__Generate_New_Password(pHandle: pWord; pSeed: pLongWord; pPassword1: pWord; pPassword2: pWord; pPassword3: pWord; pPassword4: pWord): DWORD; stdcall;

Description

Generate a new password via a seed code; the mapping from the seed code to the password is a one-way function. Without the seed, you cannot generate the same password.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pSeed [in] Seed code (32-bit)
*pPassword1 [out] New password 1
*pPassword2 [out] New password 2
*pPassword3 [out] New password 3
*pPassword4 [out] New password 4

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_VERIFY_ADV_PASSWORD 223 Advanced passwords (passwords 3 and 4) not verified
ERROR_UNIKEY_GENERATE_NEW_PASSWORD 225 Error generating new password



A file recording the new seed and passwords will be created in the working path, helping the software vendor to record everything. The passwords can be distributed to ordinary developers!




  1. The dongle will automatically log off after a new set of passwords have been generated.
  2. The dongle will be fully formatted when a new password is generated.
  3. A file including the new passwords and seed will be created in the working directory.


Generate a New Encryption Key

API Prototype

function UniKey__Generate_Key(pHandle: pWord; lKeyNumber: pLongWord): DWORD; stdcall;

Description

Generate a new key in the specific key storage.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pKeyNumber [in] Key storage number

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_INVALID_KEY_STORE 224 Wrong key storage number



  1. This function will delete the original key in the key storage, and generate a new key.
  2. The data encrypted by the old key cannot be decrypted by the new key.
  3. Each key is 128-bits long.


Generate a New Encryption Key via Seed

API Prototype

function UniKey__Generate_Key_Via_Seed (pHandle: pWord; pKeyNumber: pLongWord; pSeed1: pWord; pSeed2: pWord; pSeed3: pWord; pSeed4: pWord): DWORD; stdcall;

Description

Generate a new key in the specific key storage via a seed.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pKeyNumber [in] Key storage number
*pSeed1 [in] Seed 1
*pSeed2 [in] Seed 2
*pSeed3 [in] Seed 3
*pSeed4 [in] Seed 4

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_INVALID_KEY_STORE 224 Wrong key storage number



  1. This function will delete the original key in the key storage, and generate a new key via seed.
  2. The data encrypted by the old key cannot be decrypted by the new key.
  3. Each key is 128-bit long.


Encrypt the Buffer with a Specific Encryption Key

API Prototype

function UniKey__Encrypt(pHandle: pWord; pBufferLength: pLongWord; pKeyNumber: pLongWord; pBuffer: pByteArray): DWORD; stdcall;

Description

Encrypt an amount of memory with a key. The length of data must be a multiple of 8.

Parameters

Parameter Meaning
*pHandle [in] Dongle handle
*pBufferLength [in] Number of bytes to encrypt
*pKeyNumber [in] Key storage number
*pBuffer [in] Pointer to the data to be encrypted
[out] Pointer to the encrypted data

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_INVALID_KEY_STORE 224 Wrong key storage number
ERROR_UNIKEY_ENCRYPT_FAILED 228 Could not encrypt data



This function only performs an encryption operation, no compression functions are involved.



Decrypt the Buffer with a Specific Encryption Key

API Prototype

function UniKey__Decrypt(pHandle: pWord; pBufferLength: pLongWord; pKeyNumber: pLongWord; pBuffer: pByteArray): DWORD; stdcall;

Description

Encrypt an amount of memory with a key. The length of data must be a multiple of 8.

Parameters

Parameter Meaning
*pHandle [in] Dongle handle
*pBufferLength [in] Number of bytes to encrypt
*pKeyNumber [in] Key storage number
*pBuffer [in] Pointer to the data to be decrypted
[out] Pointer to the decrypted data

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_INVALID_KEY_STORE 224 Wrong key storage number
ERROR_UNIKEY_DECRYPT_FAILED 229 Could not decrypt data



Please use the key that was used to encrypt the data to decrypt the data, otherwise you cannot properly decrypt the data.




UniKey__Encrypt and UniKey__Decrypt offer a basic 128-bit encryption/decryption operation based on UniKey’s hardware. You can call these functions when an encryption or decryption operation is needed. For better security, you can encrypt a credential before saving it into the UniKey’s memory.



Make an MD5 Digest for Certain Content

API Prototype

function UniKey__MD5(pHandle: pWord; lp1: pLongWord; pBuffer: pByteArray): DWORD; stdcall;

Description

Make an MD5 digest of content or data.

Parameters

Parameter Meaning
*pHandle [in] Dongle handle
*pBufferLength [in] Number of bytes to MD5
*pBuffer [in] Pointer to the data to be digested
[out] Pointer to the digested data

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running


Read UpdateTag

API Prototype

function UniKey__Read_UpdateTag(pHandle: pWord; pUpdateTag: pLongWord): DWORD; stdcall;

Description

Read UpdateTag from a specific dongle

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pUpdateTag [out] UpdateTag

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_READ_UPDATETAG 226 Read UpdateTag error


Write UpdateTag

API Prototype

function UniKey__Write_UpdateTag(pHandle: pWord; pUpdateTag: pLongWord): DWORD; stdcall;

Description

Write UpdateTag into a specific dongle.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pUpdateTag [in] UpdateTag

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_WRITE_UPDATETAG 227 Write UpdateTag error



UniKey__Read_UpdateTag APIs give software vendors an easy method to identify if the UniKey dongle needs to be updated. When distributing software, software vendors may use the UpdateTag as an ID which shows if the dongle needs to be updated or has been updated. You can also use this tag as a tracking ID for each update.



Get UniKey Library Version

API Prototype

function UniKey__Get_Version(pHandle: pWord; pVersion: pLongWord): DWORD; stdcall;

Description

Get the current UniKey library version.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pVersion [out] UniKey library version


UniKey Time API Reference

Get UniKey Time

API Prototype

function UniKey__Get_Time(pHandle: pWord; pYear: pLongWord; pMonth: pLongWord; pDay: pWord; pHour: pWord; pMinute: pWord; pSecond: pWord): DWORD; stdcall;

Description

Get the time from the UniKey Time’s real-time clock.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pYear [out] Year (input or output is 10, which refers to 2010)
*pMonth [out] Month
*pDay [out] Day
*pHour [out] Hour
*pMinute [out] Minute
*pSecond [out] Second

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_READ_TIME 230 Get UniKey time error



Calling UniKey__Check_Time can check if the dongle is a UniKey Time model. If ERROR_UNIKEY_READ_TIME is returned, then the dongle is not a UniKey Time.



Set UniKey Time

API Prototype

function UniKey__Set_Time(pHandle: pWord; pYear: pLongWord; pMonth: pLongWord; pDay: pWord; pHour: pWord; pMinute: pWord; pSecond: pWord): DWORD; stdcall;

Description

Set the time on the UniKey Time’s clock.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pYear [in] Year (input or output is 10, which refers to 2010)
*pMonth [in] Month
*pDay [in] Day
*pHour [in] Hour
*pMinute [in] Minute
*pSecond [in] Second

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_READ_TIME 230 Get UniKey time error



You need to verify all 4 passwords (vendor mode) to set the time of the UniKey Time's internal clock.




Set UniKey Time by Host’s Clock

API Prototype

function UniKey__Set_Time_Now(pHandle: pWord): DWORD; stdcall;

Description

Set the time of the UniKey Time’s real-time clock to the host computer’s clock.

Parameters

Parameter Description
*pHandle [in] Dongle handle

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_WRITE_TIME 231 Set UniKey time error


Erase Real Time Module

API Prototype

function UniKey__Erase_Time_Module(pHandle: pWord; pModule: pLongWord): DWORD; stdcall;

Description

Erase/Reset a real-time module, and all the information in the module will be erased including start, and end or duration.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pModule [in] Real-time module number (0-15)

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_WRITE_TIME 231 Set UniKey time error



You need to verify all 4 passwords (vendor mode) to reset a module. If a real-time module’s write-once flag is enabled, only the first START_TIME call works. Successive START_TIME calls will return an error until this module is reset.



Set a Real Time Module’s Start Time

API Prototype

function UniKey__Set_Time_Module_Start_Time(pHandle: pWord; pModule: pLongWord; pYear: pWord; pMonth: pWord; pDay: pWord; pHour: pWord): DWORD; stdcall;

Description

Set a real-time module’s start time.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pModule [in] Real-time module number (0-15)
*pYear [in] Year (input or output is 10, which refers to 2010)
*pMonth [in] Month
*pDay [in] Day
*pHour [in] Hour

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_WRITE_TIME_MODULE 231 Set UniKey time error
ERROR_UNIKEY_TIME_MODULE_NOT_NULL 234 The real-time module is not null, this error is returned when the 'write once' flag is set



The write-once flag is very useful for setting the start for a real-time module. If the write-once flag is set, only the first START_TIME call can set the start time for a module; all successive START_TIME calls will not work and return an ERROR_UNIKEY_TIME_MODULE_NOT_NULL. Software vendors may use this flag when the start for a module is not clear.



Set a Real Time Module’s Start Time by the UniKey's Internal Clock

API Prototype

function UniKey__Set_Time_Module_Start_Time_Now(pHandle: pWord; pModule: pLongWord): DWORD; stdcall;

Description

Set a real-time module’s start time as the current time in the UniKey's internal clock.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pModule [in] Real-time module number (0-15)

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_WRITE_TIME_MODULE 231 Set UniKey time error
ERROR_UNIKEY_TIME_MODULE_NOT_NULL 234 The real-time module is not null, this error is returned when the 'write once' flag is set


Set a Real Time Module’s Start Time by Host’s Clock

API Prototype

function UniKey__Set_Time_Module_Start_Time_Now_PC(pHandle: pWord; pModule: pLongWord): DWORD; stdcall;

Description

Set a real time module’s start time as the current time of the host computer.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pHandle [in] Real-time module number (0-15)

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_WRITE_TIME_MODULE 231 Set UniKey time error
ERROR_UNIKEY_TIME_MODULE_NOT_NULL 234 The real-time module is not null, this error is returned when the 'write once' flag is set


Set a Real Time Module’s End Time

API Prototype

function UniKey__Set_Time_Module_End_Time(pHandle: pWord; pModule: pLongWord; pYear: pWord; pMonth: pWord; pDay: pWord; pHour: pWord): DWORD; stdcall;

Description

Set a real-time module’s end time.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pHandle [in] Real-time module number (0-15)
*pYear [in] Year (input or output is 10, which refers to 2010)
*pMonth [in] Month
*pDay [in] Day
*pHour [in] Hour

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_WRITE_TIME_MODULE 231 Set UniKey time error


Set a Real Time Module’s Duration

API Prototype

function UniKey__Set_Time_Module_Duration(pHandle: pWord; pModule: pLongWord; pDay: pLongWord; pHour: pWord): DWORD; stdcall;

Description

Set the duration for a specific real-time module. The total duration is (*pDay) * 24 + (*pHour) in hours.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pModule [in] Real-time module number (0-15)
*pDay [in] Number of days
*pHour [in] Number of hours

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_WRITE_TIME_MODULE 231 Set UniKey time error



You need to verify all 4 passwords (vendor mode) to set the duration for a real-time module.



Check a UniKey Time License module

API Prototype

function UniKey__Check_Time_Module(pHandle: pWord; pModule: pLongWord; pRemainDay: pLongWord; pYear: pWord; pMonth: pWord; pDay: pWord; pHour: pWord): DWORD; stdcall;

Description

Read the attributes of a specific UniKey Time license module.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pModule [in] License module Number
*pRemainDays [out] Days remaining
*pYear [in] Year (input or output is 10, which refers to 2010)
*pMonth [in] Month
*pDay [in] Day
*pHour [in] Hour

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address is incorrect or invalid length
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_MODULE 216 License module error



A successful operation will result in *pValue having value from the validity of a license module (1 = license module value is not zero).

The value of a license module cannot be read out directly and it is invisible to end users.



Check a UniKey Time License Module Now

API Prototype

function UniKey__Check_Time_Module_Now(pHandle: pWord; pModule: pLongWord; pRemainDay: pLongWord; pRemainHour: pWord): DWORD; stdcall;

Description

Read the attributes of a specific UniKey Time license module Now.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pModule [in] License module number
*pRemainDays [out] Days remaining
*pRemainHours [out] Hours remaining

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address is incorrect or invalid length
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_MODULE 216 License module error



A successful operation will result in *pValue having value from the validity (1 = license module value is not zero).

The value of a license module cannot be read out directly and it is invisible to end users.



Check a UniKey Time License Module Now PC

API Prototype

function UniKey__Check_Time_Module_Now_PC(pHandle: pWord; pModule: pLongWord; pRemainDay: pLongWord; pRemainHour: pWord): DWORD; stdcall;

Description

Read the attributes of a specific UniKey Time license module Now PC.

Parameters

Parameter Description
*pHandle [in] Dongle handle
*pModule [in] License module number
*pRemainDays [out] Days remaining
*pRemainHours [out] Hours remaining

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address is incorrect or invalid length
ERROR_UNIKEY_NEED_OPEN 212 Need to log on to a dongle before running
ERROR_UNIKEY_MODULE 216 License module error



A successful operation will result in *pValue having value from the validity (1 = license module value is not zero).

The value of a license module cannot be read out directly and it is invisible to end users.



UniKey Drive API Reference

Initialize File System

API Prototype

UniKey_FS_Init:function(pHandle: pWord; PW1: pLongWord; PW2: pLongWord; PW3: pLongWord; PW4: pLongWord): DWORD; stdcall;

Description

The user needs to call this function to initialize the file system before calling other file system related functions. The default password of the file system is "12345678", without quotations.

Parameters

Parameter Description
*pHandle [in] Device handle
*PW1 [in] Password 1
*PW2 [in] Password 2
*PW3 [in] Password 3
*PW4 [in] Password 4

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_PASSWORD_OR_ID 202 Wrong password or UniKey HID


Format the File System

API Prototype

UniKey_FS_Format:function(pHandle: pWord): DWORD; stdcall;

Description

Format the file system.

Parameters

Parameter Description
*pHandle [in] Device handle

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_FS_FILE_EXIST 245 File already exists



Note: The user needs to initialize the file system successfully before calling other file system related functions.



Create Files

API Prototype

UniKey_FS_CreateFile:function(pHandle: pWord; filename: pByteArray): DWORD; stdcall;

Description

Create files.

Parameters

Parameter Description
*pHandle [in] Device handle
*filename [in/out] Input/Output file name



Note: a single backslash ("\") should be added before the name of the file.



Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_FS_FILE_NAME 240 Wrong or invalid filename
ERROR_UNIKEY_FS_FILE_EXIST 245 File already exists
ERROR_UNIKEY_FS_ERR_SYS_UNINIT 246 The file system is not initialized


Delete Files

API Prototype

UniKey_FS_DeleteFile:function(pHandle: pWord; filename: pByteArray): DWORD; stdcall;

Description

Delete files.

Parameters

Parameter Description
*pHandle [in] Device handle
*filename [in/out] Input/Output file name

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_FS_NO_FILE 241 No such filename
ERROR_UNIKEY_FS_ERR_SYS_UNINIT 246 The file system is not initialized


Open Files

API Prototype

UniKey_FS_File_Open:function(pHandle: pWord; filename: pChar): DWORD; stdcall;

Description

Open files.

Parameters

Parameter Description
*pHandle [in] Device handle
*filename [in] Input/Output file name

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_FS_NO_FILE 241 No such filename


Get System Space

API Prototype

UniKey_FS_Get_Free_Size:function(pHandle: pWord; usedsize: pLongWord; freesize: pLongWord): DWORD; stdcall;

Description

Get occupied and free system space.

Parameters

Parameter Description
*pHandle [in] Device handle
*usedsize [out] System memory that is in use
*freesize [out] Free system memory

Return values

Result Value Description
SUCCESS 0 Success


Modify File Data

API Prototype

UniKey_FS_File_Modify_Data:function(pHandle: pWord; offset: pLongWord; len: pLongWord; buffer: pByteArray): DWORD; stdcall;

Description

Modify file data.

Parameters

Parameter Description
*pHandle [in] Device handle
*offset [in] Address to be modified
*len [in] Length of data to be modified
*buffer [in] Modified data

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_FS_FILE_OFFSET 242 File offset error
ERROR_UNIKEY_FS_ERR_OPEN_FILE 247 Failed to open file


Append Data to the End-Of-File

API Prototype

UniKey_FS_File_Append_Data:function(pHandle: pWord; len: pLongWord; buffer: pByteArray): DWORD; stdcall;

Description

Append data to the end-of-file.

Parameters

Parameter Meaning
*pHandle [in] Device handle
*len [in] The length of the data to be appended
*buffer [in] Data to append

Return values

Result Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_FS_NO_MEMORY 244 Not enough free memory


Read File Data

API Prototype

UniKey_FS_File_Read_Data:function(pHandle: pWord; offset: pLongWord; len: pLongWord; buffer: pByteArray): DWORD; stdcall;

Description

Read file data.

Parameters

Parameter Description
*pHandle [in] Device handle
*offset [in] Read address
*len [in] Length of data to be read
*buffer [out] Read data

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_FS_FILE_OFFSET 242 File offset error
ERROR_UNIKEY_FS_ERR_OPEN_FILE 247 Failed to open file


Close Files

API Prototype

UniKey_FS_File_Close:function(pHandle: pWord; filename: pByteArray): DWORD; stdcall;

Description

Close files.

Parameters

Parameter Description
*pHandle [in] Device handle
*filename [in] Filename

Return values

Result Value Description
SUCCESS 0 Success


Get File List

API Prototype

UniKey_FS_File_Get_List:function(pHandle: pWord; filecount: pLongWord; filelist: pByteArray): DWORD; stdcall;

Description

Get list of files on the UniKey Drive.

Parameters

Parameter Description
*pHandle [in] Device handle
*filecount [out] The number of files
*filelist [out] File list

Return values

Result Value Description
SUCCESS 0 Success


Get File Size

API Prototype

UniKey_FS_File_Get_Size:function(pHandle: pWord; filesize: pLongWord): DWORD; stdcall;

Description

Get the file size.

Parameters

Parameter Description
*pHandle [in] Device handle
*filesize [out] The size of the file

Return values

Result Value Description
SUCCESS 0 Success


User Reset File System Password

API Prototype

UniKey_FS_Set_Password:function(pHandle: pWord; PW1: pLongWord; PW2: pLongWord; PW3: pLongWord; PW4: pLongWord): DWORD; stdcall;

Description

Allows a user to reset the file system password.

Parameters

Parameter Description
*pHandle [in] Device handle
*PW1 [in] Password 1
*PW2 [in] Password 2
*PW3 [in] Password 3
*PW4 [in] Password 4

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_GENERATE_NEW_PASSWORD 225 Error generating new password



A password reset can only be successfully done after initializing the file system.



Generate RSA Key

API Prototype

UniKey_RSA_Generate_Key:function(pHandle: pWord; KeyIndex: pWord): DWORD; stdcall;

Description

UniKey Drive has encryption and decryption modules with 1024-bit RSA keys. Calling this function can generate a 1024-bit RSA key.

Parameters

Parameter Description
*pHandle [in] Device handle
*KeyIndex [out] Return the handle generated key

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_KEY_INDEX 239 The handle of the key is invalid


Generate a DES Key

API Prototype

UniKey_DES_Generate_Key:function(pHandle: pWord; KeyIndex: pWord): DWORD; stdcall;

Description

Calling this function can generate a DES key.

Parameters

Parameter Description
*pHandle [in] Device handle
*KeyIndex [out] Return the handle generated key

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_KEY_INDEX 239 The handle of the key is invalid


RSA Get Number of Generated Keys

API Prototype

UniKey_RSA_Get_Key_Counts:function(pHandle: pWord; KeyIndex: pLongWord): DWORD; stdcall;

Description

Get the number of RSA keys that are generated.

Parameters

Parameter Description
*pHandle [in] Device handle
*KeyIndex [out] Key count

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_KEY_INDEX 239 The handle of the key is invalid


DES Get Number of Generated Keys

API Prototype

UniKey_DES_Get_Key_Counts:function(pHandle: pWord; KeyIndex: pLongWord): DWORD; stdcall;

Description

Get the number of DES keys that are generated.

Parameters

Parameter Description
*pHandle [in] Device handle
*KeyIndex [out] Key count

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_KEY_INDEX 239 The handle of the key is invalid


RSA Encryption

API Prototype

UniKey_RSA_Encrypt:function(pHandle: pWord; KeyIndex: pWord; Encrypt_Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;

Description

Encrypt data using RSA.

Parameters

Parameter Description
*pHandle [in] Device handle
*KeyIndex [in] Encrypt and decrypt using the key handle
*Encrypt_Len [in] Data length to be encrypted
*Buffer [in/out] Input plain text and output encrypted text

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_ENCRYPT_FAILED 228 Could not encrypt data


RSA Decryption

API Prototype

UniKey_RSA_Decrypt:function(pHandle: pWord; KeyIndex: pWord; Encrypt_Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;

Description

Decrypt data using RSA.

Parameters

Parameter Description
*pHandle [in]Device handle
*KeyIndex [in] Encrypt and decrypt using the key handle
*Decrypt_Len [in] Length of data to be decrypted
*Buffer [in/out] Input encrypted text and output plain text.

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_DECRYPT_FAILED 229 Could not decrypt data
ERROR_UNIKEY_KEY_INDEX 239 The key handle is invalid


DES Encryption

API Prototype

UniKey_DES1_Encrypt:function(pHandle: pWord; EncryptMode: pWord; KeyIndex: pWord; Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;

UniKey_DES2_Encrypt:function(pHandle: pWord; EncryptMode: pWord; KeyIndex: pWord; Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;

UniKey_DES3_Encrypt:function(pHandle: pWord; EncryptMode: pWord; KeyIndex: pWord; Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;

Description

Encrypt data using DES.

Parameters

Parameter Description
*pHandle [in] Device handle
*EncryptMode [in] Block cipher mode of operation
*KeyIndex [in] Encrypt and decrypt using the key handle
*Len [in] Length of data to be encrypted
*Buffer [in/out] Input plain text and output encrypted text.

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_ENCRYPT_FAILED 228 Could not encrypt data
ERROR_UNIKEY_KEY_INDEX 239 The key handle is invalid


DES Decryption

API Prototype

UniKey_DES1_Decrypt:function(pHandle: pWord; EncryptMode: pWord; KeyIndex: pWord; Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;

UniKey_DES2_Decrypt:function(pHandle: pWord; EncryptMode: pWord; KeyIndex: pWord; Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;

UniKey_DES3_Decrypt:function(pHandle: pWord; EncryptMode: pWord; KeyIndex: pWord; Len: pLongWord; Buffer: pByteArray): DWORD; stdcall;

Description

Encrypt data using DES.

Parameters

Parameter Description
*pHandle [in] Device handle
*DecryptMode [in] Block cipher mode of operation
*KeyIndex [in] Encrypt and decrypt using the key handle
*Len [in] Length of data to be decrypted
*Buffer [in/out] Input encrypted text and output plain text.

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_DECRYPT_FAILED 229 Could not decrypt data
ERROR_UNIKEY_KEY_INDEX 239 The key handle is invalid


Delete RSA Key

API Prototype

UniKey_RSA_Del_Key:function(pHandle: pWord; KeyIndex: pWord): DWORD; stdcall;

Description

Delete a RSA key.

Parameters

Parameter Description
*pHandle [in] Device handle
*KeyIndex [in] The handle to be deleted

Return values

Result Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_KEY_INDEX 239 The handle of the key is invalid
0 > KeyIndex > 3


Delete DES Key

API Prototype

UniKey_DES_Del_Key:function(pHandle: pWord; KeyIndex: pWord): DWORD; stdcall;

Description

Delete a DES key.

Parameters

Parameter Description
*pHandle [in] Device handle
*KeyIndex [in] Key handle to be deleted

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_KEY_INDEX 239 The handle of the key is invalid
0 > KeyIndex > 14


Get User Counts

API Prototype

UniKey_Get_UserCount:function(pHandle: pWord; Count: pWord): DWORD; stdcall;

Description

UniKey Drive can enable 32 concurrent users to log in. This function can be called to get the number of users logged in.

Parameters

Parameter Description
*pHandle [in] Device handle
*Count [out] Number of users logged in

Return values

Result Value Description
SUCCESS 0 Success


Only Allow One User to Log in

API Prototype

Unikey_Logon_Single:function(pHandle: pWord; pPassword1: pLongWord; pPassword2: pLongWord; pPassword3: pLongWord; pPassword4: pLongWord): DWORD; stdcall;

Description

After calling this function, the UniKey Drive will only allow the active user to log in, other users will not be allowed to log in.

Parameters

Parameter Description
*pHandle [in] Device handle
*pPassword1 [in] Password 1
*pPassword2 [in] Password 2
*pPassword3 [in] Password 3
*pPassword4 [in] Password 4

Return values

Result Value Description
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_PASSWORD_OR_ID 202 Wrong password or UniKey HID


Log off the Active User

API Prototype

UniKey_Logoff:function(pHandle: pWord):DWORD; stdcall;

Description

After calling this function, the active user will be logged out, does not affect other users’ login status.

Parameters

Parameter Description
*pHandle [in] Device handle

Return values

Result Value Description
SUCCESS 0 Success


Log off all Users

API Prototype

UniKey_Logoff_All:function(pHandle: pWord): DWORD; stdcall;

Description

After calling this function, all users will be logged off.

Parameters

Parameter Description
*pHandle [in] Device handle

Return values

Result Value Description
SUCCESS 0 Success