UniKey API Reference for Java Language: Difference between revisions
mNo edit summary |
|||
| (15 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
[[category:UniKey API]] | [[category:UniKey API]] | ||
| Line 7: | Line 5: | ||
=== Find a UniKey dongle === | === Find a UniKey dongle === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Find(short[] pHandle, int[] pSetting1, int[] pSetting2);</code> | <code>public int UniKey_Find(short[] pHandle, int[] pSetting1, int[] pSetting2);</code> | ||
'''Description''' | '''Description''' | ||
'''Parameters''' | Check if a specific UniKey is attached to the USB port. This is the first API used to start a UniKey session. | ||
<table | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 20: | Line 21: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[out] Dongle handle </td> | <td>[out] Dongle handle </td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td rowspan="2">pSetting1</td> | ||
<td> | <td>[in] Working mode (UniKey PRO only), useless for UniKey STD</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>[out] Hardware ID</td> | <td>[out] Hardware ID</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td rowspan="2">pSetting2</td> | ||
<td> | <td>[in] Access mode (UniKey PRO only), useless for UniKey STD</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>[out] Number of dongles attached, useless for UniKey STD</td> | |||
<td>[out] Number of | |||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 54: | Line 54: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>ERROR_UNIKEY_NOT_FOUND</td> | ||
<td>200</td> | <td>200</td> | ||
<td>No UniKey dongle</td> | <td>No UniKey dongle</td> | ||
| Line 60: | Line 60: | ||
</table> | </table> | ||
---- | |||
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. | |||
---- | |||
<br> | <br> | ||
| Line 66: | Line 69: | ||
=== Find the Next UniKey dongle === | === Find the Next UniKey dongle === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Find_Next(short[] pHandle, int[] pSetting1, int[] pSetting2);</code> | <code>public int UniKey_Find_Next(short[] pHandle, int[] pSetting1, int[] pSetting2);</code> | ||
'''Description''' | '''Description''' | ||
Check if another UniKey is attached to the USB port. | Check if another UniKey is attached to the USB port. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 79: | Line 85: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[out] Dongle handle </td> | <td>[out] Dongle handle </td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td rowspan="2">pSetting1</td> | ||
<td> | <td>[in] Working Mode (UniKey PRO only), useless for UniKey STD</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>[out] Hardware ID</td> | <td>[out] Hardware ID</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td rowspan="2">pSetting2</td> | ||
<td> | <td>[in] Access Mode (UniKey PRO only), useless for UniKey STD</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>[out] Number of dongles attached , useless for UniKey STD</td> | |||
<td>[out] Number of | |||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 115: | Line 120: | ||
<td>ERROR_UNIKEY_NOMORE</td> | <td>ERROR_UNIKEY_NOMORE</td> | ||
<td>214</td> | <td>214</td> | ||
<td>No more | <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> | <td>Find needs to be called before Find_Next</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 126: | Line 131: | ||
<br> | <br> | ||
=== | === Log on to UniKey Dongle === | ||
'''API Prototype''' | |||
<code>public int UniKey_User_Logon(short[] pHandle, short[] pPassword1, short[] pPassword2);</code> | <code>public int UniKey_User_Logon(short[] pHandle, short[] pPassword1, short[] pPassword2);</code> | ||
For UniKey Drive, the API Prototype is | For UniKey Drive, the API Prototype is | ||
<code>public native int UniKeyUserLogon(short[] pHandle, int[] pPassword1, int[] pPassword2);</code> | |||
'''Parameters''' | '''Description''' | ||
<table | |||
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 144: | Line 153: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[ | <td>[out] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pPassword1</td> | ||
<td>[in]Password | <td>[in] Password 1</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pPassword2</td> | ||
<td>[ | <td>[in] Password 2</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 177: | Line 187: | ||
<td>ERROR_UNIKEY_INVALID_PASSWORD</td> | <td>ERROR_UNIKEY_INVALID_PASSWORD</td> | ||
<td>201</td> | <td>201</td> | ||
<td>UniKey dongle | <td>Found UniKey dongle, but basic passwords (password 1 and 2) are incorrect</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
| Line 188: | Line 198: | ||
<br> | <br> | ||
=== | === Log on to UniKey Dongle in vendor mode === | ||
'''API Prototype''' | |||
<code>public int UniKey_Vender_Logon(short[] pHandle, short[] pPassword1, short[] pPassword2, short[] pPassword3, short[] pPassword4);</code> | <code>public int UniKey_Vender_Logon(short[] pHandle, short[] pPassword1, short[] pPassword2, short[] pPassword3, short[] pPassword4);</code> | ||
For UniKey Drive, the API Prototype is | |||
For UniKey Drive, the API Prototype is | |||
<code>public native int UniKeyVenderLogon(short[] pHandle, int[] pPassword1, int[] pPassword2, int[] pPassword3, int[] pPassword4);</code> | |||
'''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 password 3 or 4 is wrong, while password 1 and 2 is correct, the dongle is then logged on in user mode automatically. | |||
---- | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<table | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 216: | Line 231: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[ | <td>[out] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pPassword1</td> | ||
<td>[in]Password | <td>[in] Password 1</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pPassword2</td> | ||
<td>[in]Password | <td>[in] Password 2</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pPassword3</td> | ||
<td>[in]Password | <td>[in] Password 3</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pPassword4</td> | ||
<td>[ | <td>[in] Password 4</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 257: | 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 | <td>Found UniKey dongle, but basic passwords (password 1 and 2) are incorrect</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
| Line 268: | Line 284: | ||
<br> | <br> | ||
=== | === Log off the UniKey dongle === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Logoff(short[] pHandle);</code> | |||
'''Parameters''' | '''Description''' | ||
<table | |||
Log off a UniKey dongle with a specific handle; this API should be called at the end of a UniKey session. | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 283: | Line 302: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 308: | Line 328: | ||
<td>ERROR_UNIKEY_NEED_OPEN</td> | <td>ERROR_UNIKEY_NEED_OPEN</td> | ||
<td>212</td> | <td>212</td> | ||
<td> | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 314: | Line 334: | ||
<br> | <br> | ||
=== Get the UniKey Dongle's Type === | |||
=== Get the UniKey | |||
'''API Prototype''' | '''API Prototype''' | ||
<code> | |||
<code>public int UniKey_Get_Type(short[] pHandle, int[] type);</code> | |||
'''Description''' | |||
<code>UniKey_Get_Type</code> can help you get the type of the UniKey dongle.<br> | <code>UniKey_Get_Type</code> can help you get the type of the UniKey dongle.<br> | ||
This functions return value will help to indicate the type of the UniKey dongle. | |||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Type</th> | <th>Type</th> | ||
| Line 342: | Line 364: | ||
</table> | </table> | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 349: | Line 372: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>type</td> | ||
<td>[out] The value indicating the type of your UniKey dongle</td> | <td>[out] The value indicating the type of your UniKey dongle</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 371: | Line 395: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>ERROR_UNIKEY_GET_TYPE</td> | ||
<td> | <td>256</td> | ||
<td>UniKey Get Type Error</td> | <td>UniKey Get Type Error</td> | ||
</tr> | </tr> | ||
| Line 378: | Line 402: | ||
<br> | <br> | ||
=== Read UniKey dongle memory === | === Read UniKey dongle memory === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Read_Memory(short[] pHandle, short[] pStartAddress, short[] pBufferLength, byte[] pBuffer);</code> | <code>public int UniKey_Read_Memory(short[] pHandle, short[] pStartAddress, short[] pBufferLength, byte[] pBuffer);</code> | ||
'''Description''' | '''Description''' | ||
'''Parameters''' | Read the contents of memory; this API needs to be called after logging in to a UniKey dongle. | ||
<table | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 394: | Line 421: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pStartAddress</td> | ||
<td>[in] Offset of Memory</td> | <td>[in] Offset of Memory</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pBufferLength</td> | ||
<td>[in] Number of bytes to read</td> | <td>[in] Number of bytes to read</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pBuffer</td> | ||
<td>[out] Pointer to the buffer containing the data to be read</td> | <td>[out] Pointer to the buffer containing the data to be read</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 426: | 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 | <td>Read/Write address is incorrect or invalid length</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
| Line 436: | Line 464: | ||
<td>ERROR_UNIKEY_NEED_OPEN</td> | <td>ERROR_UNIKEY_NEED_OPEN</td> | ||
<td>212</td> | <td>212</td> | ||
<td> | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 449: | Line 472: | ||
=== Write to UniKey dongle memory === | === Write to UniKey dongle memory === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Write_Memory(short[] pHandle, short[] pStartAddress, short[] pBufferLength, byte[] pBuffer);</code> | <code>public int UniKey_Write_Memory(short[] pHandle, short[] pStartAddress, short[] pBufferLength, byte[] pBuffer);</code> | ||
'''Description''' | '''Description''' | ||
Write data into | |||
Write data into memory; this API needs to be called after logging on to a UniKey dongle. | |||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 462: | Line 488: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pStartAddress</td> | ||
<td>[in] Offset of the memory</td> | <td>[in] Offset of the memory</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pBufferLength</td> | ||
<td>[in] Number of bytes to write</td> | <td>[in] Number of bytes to write</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pBuffer</td> | ||
<td>[in] Pointer to the buffer containing the data to be written</td> | <td>[in] Pointer to the buffer containing the data to be written</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 494: | Line 521: | ||
<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 | <td>Read/Write address is incorrect or invalid length</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
| Line 504: | Line 531: | ||
<td>ERROR_UNIKEY_NEED_OPEN</td> | <td>ERROR_UNIKEY_NEED_OPEN</td> | ||
<td>212</td> | <td>212</td> | ||
<td> | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>ERROR_UNIKEY_VERIFY_ADV_PASSWORD</td> | <td>ERROR_UNIKEY_VERIFY_ADV_PASSWORD</td> | ||
<td>223</td> | <td>223</td> | ||
<td>Advanced passwords ( | <td>Advanced passwords (password 3 and 4) not verified</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
---- | |||
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. | To write the last 2k memory (for 2048 – 4096), you need to verify all 4 passwords (vendor mode) to obtain the requisite permission. | ||
---- | |||
---- | |||
<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> | <br> | ||
| Line 525: | Line 554: | ||
=== Generate a Random Number === | === Generate a Random Number === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Random(short[] pHandle , short[] pReturn1, short[] pReturn2, short[] pReturn3, short[] pReturn4);</code> | <code>public int UniKey_Random(short[] pHandle , short[] pReturn1, short[] pReturn2, short[] pReturn3, short[] pReturn4);</code> | ||
'''Description''' | '''Description''' | ||
'''Parameters''' | Generates random numbers from the dongle. | ||
<table | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 538: | Line 570: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pReturn1</td> | ||
<td>[out] Random number</td> | <td>[out] Random number</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pReturn2</td> | ||
<td>[out] Random number</td> | <td>[out] Random number</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pReturn3</td> | ||
<td>[out] Random number</td> | <td>[out] Random number</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pReturn4</td> | ||
<td>[out] Random number</td> | <td>[out] Random number</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 570: | 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> | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
---- | |||
<code>UniKey_Random</code> is used 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> | ||
| Line 591: | Line 625: | ||
=== Generate Seed Code Return Values === | === Generate Seed Code Return Values === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Seed(short[] pHandle, int[] pSeed, short[] pReturn1, short[] pReturn2, short[] pReturn3, short[] pReturn4);</code> | <code>public int UniKey_Seed(short[] pHandle, int[] pSeed, short[] pReturn1, short[] pReturn2, short[] pReturn3, short[] pReturn4);</code> | ||
'''Description''' | '''Description''' | ||
'''Parameters''' | 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. | ||
<table | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 604: | Line 641: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pSeed</td> | ||
<td>[in] Seed | <td>[in] Seed code</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pReturn1</td> | ||
<td>[out] Return | <td>[out] Return code 1</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pReturn2</td> | ||
<td>[out] Return | <td>[out] Return code 2</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pReturn3</td> | ||
<td>[out] Return | <td>[out] Return code 3</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pReturn4</td> | ||
<td>[out] Return | <td>[out] Return code 4</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 640: | 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> | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
UniKey_Seed generate a set of seed codes | ---- | ||
<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> | ||
=== Write | === Write Software ID === | ||
'''API Prototype''' | |||
<code>public int UniKey_Write_SoftID(short[] pHandle, int[] pSoftID);</code> | <code>public int UniKey_Write_SoftID(short[] pHandle, int[] pSoftID);</code> | ||
'''Description''' | '''Description''' | ||
'''Parameters''' | Write the vendor-defined software ID. | ||
<table | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 674: | Line 716: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pSoftID</td> | ||
<td>[in] | <td>[in] Software ID</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 694: | 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> | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
You need to verify all 4 passwords (vendor mode) to write the | ---- | ||
You need to verify all 4 passwords (vendor mode) to write the software ID to the dongle. | |||
---- | |||
<br> | <br> | ||
=== Read | === Read Software ID === | ||
'''API Prototype''' | |||
<code>public int UniKey_Read_SoftID(short[] pHandle, int[] pSoftID);</code> | <code>public int UniKey_Read_SoftID(short[] pHandle, int[] pSoftID);</code> | ||
'''Description''' | '''Description''' | ||
Read the user defined | |||
Read the user-defined software ID. | |||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 728: | Line 775: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pSoftID</td> | ||
<td>[out] | <td>[out] Software ID</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 752: | Line 800: | ||
<td>ERROR_UNIKEY_NEED_OPEN</td> | <td>ERROR_UNIKEY_NEED_OPEN</td> | ||
<td>212</td> | <td>212</td> | ||
<td> | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
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. | ---- | ||
<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> | ||
| Line 764: | Line 813: | ||
=== Set a UniKey License module === | === Set a UniKey License module === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Set_Module(short[] pHandle, short[] pModule, short[] pValue, short[] pDecrease);</code> | <code>public int UniKey_Set_Module(short[] pHandle, short[] pModule, short[] pValue, short[] pDecrease);</code> | ||
'''Description''' | '''Description''' | ||
To write a value to a specific UniKey license module and set the Decrement attribute. | To write a value to a specific UniKey license module and set the Decrement attribute. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 777: | Line 829: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pModule</td> | ||
<td>[in] License module | <td>[in] License module number</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pValue</td> | ||
<td>[in] License module | <td>[in] License module unit value</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pDecrease</td> | ||
<td>[in] | <td>[in] Decrement attribute (1 = allowed, 0 = not allowed)</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 809: | 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 | <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> | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
| Line 823: | Line 876: | ||
</table> | </table> | ||
---- | |||
You need verify 4 passwords (vendor mode) to set a module value successfully. | 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. | |||
---- | |||
<br> | <br> | ||
=== Get a UniKey License module === | |||
'''API Prototype''' | |||
<code>long UniKey_Get_Module(WORD* pHandle, WORD* pModule, WORD* pValue);</code> | <code>long UniKey_Get_Module(WORD* pHandle, WORD* pModule, WORD* pValue);</code> | ||
'''Description''' | '''Description''' | ||
Get a value from a specific UniKey license module. | Get a value from a specific UniKey license module. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 850: | Line 906: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pModule</td> | ||
<td>[in] Module Number</td> | <td>[in] Module Number</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pValue</td> | ||
<td>[out] Return the value in module</td> | <td>[out] Return the value in module</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 878: | Line 935: | ||
<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 | <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> | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
| Line 892: | Line 949: | ||
</table> | </table> | ||
<br | ---- | ||
You need to verify 2 passwords (user mode) to get a module value successfully. | |||
---- | |||
<br> | |||
=== Check a UniKey License module === | === Check a UniKey License module === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Check_Module(short[] pHandle, short[] pModule, short[] pValue, short[] pDecrease);</code> | <code>public int UniKey_Check_Module(short[] pHandle, short[] pModule, short[] pValue, short[] pDecrease);</code> | ||
'''Description''' | '''Description''' | ||
Read the attributes of a specific UniKey license module. | Read the attributes of a specific UniKey license module. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 913: | Line 974: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pModule</td> | ||
<td>[in] License module | <td>[in] License module number</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pValue</td> | ||
<td>[out] Validity (1 = license module value is not zero)</td> | <td>[out] Validity (1 = license module value is not zero)</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pDecrease</td> | ||
<td>[out] Decrement attribute (1 = license module can be decreased)</td> | <td>[out] Decrement attribute (1 = license module can be decreased)</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 945: | Line 1,007: | ||
<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 | <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> | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
| Line 959: | Line 1,021: | ||
</table> | </table> | ||
---- | |||
UniKey_Set_Module and UniKey_Check_Module provide an easy | 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. | ||
---- | |||
---- | |||
<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. | |||
---- | |||
<br> | <br> | ||
=== Write Arithmetic === | === Write Arithmetic === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code> | |||
<code>public int UniKey_Write_Arithmetic(short[] pHandle, short[] pStartAddress, byte[] pBuffer);</code> | |||
'''Description''' | |||
Write user-defined mathematical algorithms. | Write user-defined mathematical algorithms. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 985: | Line 1,051: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pStartAddress</td> | ||
<td>[in] Offset of first instruction </td> | <td>[in] Offset of first instruction</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pBuffer</td> | ||
<td>[in] Pointer to the algorithm command string</td> | <td>[in] Pointer to the algorithm command string</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 1,012: | Line 1,079: | ||
<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 | <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> | <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 | <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 | <td>Arithmetic operator error</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>ERROR_UNIKEY_AR_WRONG_BEGIN</td> | ||
<td>219</td> | <td>219</td> | ||
<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> | <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> | <td>Constant numbers > 63 will cause an overflow</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
---- | |||
UniKey_Write_Arithmetic is called when you write a series of algorithms into the dongle. This function is only called | A successful operation will result in a user-defined algorithm containing the algorithm command string from the buffer. | ||
< | ---- | ||
---- | |||
<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> | |||
---- | |||
<br> | <br> | ||
=== User- | === User-Defined Algorithm Calculate 1 === | ||
'''API Prototype''' | |||
<code>public int UniKey_Calculate1(short[] pHandle, int[] pStartAddress, int[] pModule, short[] pRegA, short[] pRegB, short[] pRegC, short[] pRegD);</code> | |||
<code> | |||
'''Description''' | '''Description''' | ||
'''Parameters''' | Return the results of a calculation performed in the UniKey, using input provided by the developer and the CALCULATE1 function. | ||
<table | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 1,071: | Line 1,143: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pStartAddress</td> | ||
<td>[in] Start point of calculation</td> | <td>[in] Start point of calculation</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pModule</td> | ||
<td>[in] License module number</td> | <td>[in] License module number</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pRegA</td> | ||
<td>[in, out] Register A</td> | <td>[in, out] Register A</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pRegB</td> | ||
<td>[in, out] Register B</td> | <td>[in, out] Register B</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pRegC</td> | ||
<td>[in, out] Register C</td> | <td>[in, out] Register C</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pRegD</td> | ||
<td>[in, out] Register D</td> | <td>[in, out] Register D</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 1,115: | 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 | <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> | <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 | <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 | <td>Arithmetic operator error</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>ERROR_UNIKEY_AR_WRONG_BEGIN</td> | ||
<td>219</td> | <td>219</td> | ||
<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> | <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> | <td>Constant numbers > 63 will cause an overflow</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
<table | ---- | ||
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,160: | Line 1,235: | ||
<tr> | <tr> | ||
<td>E</td> | <td>E</td> | ||
<td> | <td>High-order byte of reversed hardware ID</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>F</td> | <td>F</td> | ||
<td> | <td>Low-order byte of reversed hardware ID</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
| Line 1,172: | Line 1,247: | ||
<tr> | <tr> | ||
<td>H</td> | <td>H</td> | ||
<td>Random number </td> | <td>Random number</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
Examples<br>If the internal algorithm is A = B + C, | ---- | ||
Examples: | |||
<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> | ||
=== User- | === User-Defined Algorithm Calculate 2 === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Calculate2(short[] pHandle, int[] pStartAddress, int[] pSeed, short[] pRegA, short[] pRegB, short[] pRegC, short[] pRegD);</code> | |||
'''Parameters''' | '''Description''' | ||
<table | |||
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> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 1,197: | Line 1,279: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pStartAddress</td> | ||
<td>[in] Start point of calculation</td> | <td>[in] Start point of calculation</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pSeed</td> | ||
<td>[in] Seed | <td>[in] Seed code (32-bit)</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pRegA</td> | ||
<td>[in, out] Register A</td> | <td>[in, out] Register A</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pRegB</td> | ||
<td>[in, out] Register B</td> | <td>[in, out] Register B</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pRegC</td> | ||
<td>[in, out] Register C</td> | <td>[in, out] Register C</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pRegD</td> | ||
<td>[in, out] Register D</td> | <td>[in, out] Register D</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 1,241: | 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 | <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> | <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 | <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 | <td>Arithmetic operator error</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>ERROR_UNIKEY_AR_WRON_GBEGIN</td> | <td>ERROR_UNIKEY_AR_WRON_GBEGIN</td> | ||
<td>219</td> | <td>219</td> | ||
<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> | <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> | <td>Constant numbers > 63 will cause an overflow</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
<table | ---- | ||
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. | |||
---- | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Internal Register</th> | <th>Internal Register</th> | ||
| Line 1,286: | Line 1,371: | ||
<tr> | <tr> | ||
<td>E</td> | <td>E</td> | ||
<td>Seed | <td>Seed result 1</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>F</td> | <td>F</td> | ||
<td>Seed | <td>Seed result 2</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>G</td> | <td>G</td> | ||
<td>Seed | <td>Seed result 3</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>H</td> | <td>H</td> | ||
<td>Seed | <td>Seed result 4</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 1,304: | Line 1,389: | ||
<br> | <br> | ||
=== User- | === User-Defined Algorithm Calculate 3 === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Calculate3(short[] pHandle, int[] pStartAddress, int[] pModule, short[] pRegA, short[] pRegB, short[] pRegC, short[] pRegD);</code> | |||
'''Parameters''' | '''Description''' | ||
<table | |||
Return results of a calculation performed in the UniKey, using input provided by the developer and the CALCULATE3 function. | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 1,319: | Line 1,407: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pStartAddress</td> | ||
<td>[in] Start point of calculation</td> | <td>[in] Start point of calculation</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pModule</td> | ||
<td>[in] License module number</td> | <td>[in] License module number</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pRegA</td> | ||
<td>[in, out] Register A</td> | <td>[in, out] Register A</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pRegB</td> | ||
<td>[in, out] Register B</td> | <td>[in, out] Register B</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pRegC</td> | ||
<td>[in, out] Register C</td> | <td>[in, out] Register C</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pRegD</td> | ||
<td>[in, out] Register D</td> | <td>[in, out] Register D</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 1,363: | Line 1,452: | ||
<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 | <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> | <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 | <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 | <td>Arithmetic operator error</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>ERROR_UNIKEY_AR_WRON_GBEGIN</td> | <td>ERROR_UNIKEY_AR_WRON_GBEGIN</td> | ||
<td>219</td> | <td>219</td> | ||
<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> | <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> | <td>Constant numbers > 63 will cause an overflow</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
<table | ---- | ||
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. | |||
---- | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Internal Register</th> | <th>Internal Register</th> | ||
| Line 1,424: | Line 1,515: | ||
</table> | </table> | ||
---- | |||
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 | 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> | <br> | ||
=== Decrease a License Module === | === Decrease a License Module === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int | |||
<code>public int UniKey_Module_Decrease(short[] pHandle, short[] pModule);</code> | |||
'''Description''' | |||
Decrease the value in a specified UniKey license module by "1". | Decrease the value in a specified UniKey license module by "1". | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 1,449: | Line 1,555: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pModule</td> | ||
<td>[in] License module number</td> | <td>[in] License module number</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 1,473: | Line 1,580: | ||
<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 | <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> | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
| Line 1,487: | Line 1,594: | ||
</table> | </table> | ||
Please call UniKey_Check_Module to check if the license module is valid first. | ---- | ||
Please call <code>UniKey_Check_Module</code> to check if the license module is valid first. | |||
---- | |||
<br> | <br> | ||
| Line 1,495: | Line 1,603: | ||
=== Generate a New Password === | === Generate a New Password === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Generate_New_Password(short[] pHandle, int[] pSeed, short[] pPassword1, short[] pPassword2, short[] pPassword3, short[] pPassword4);</code> | <code>public int UniKey_Generate_New_Password(short[] pHandle, int[] pSeed, short[] pPassword1, short[] pPassword2, short[] pPassword3, short[] pPassword4);</code> | ||
'''Description''' | '''Description''' | ||
Generate a new password via a seed code; the mapping from the seed code to the password is | |||
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''' | |||
<table class="wikitable"> | |||
<table | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 1,508: | Line 1,619: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pSeed</td> | ||
<td>[in] Seed | <td>[in] Seed code (32-bit)</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pPassword1</td> | ||
<td>[out] New password 1</td> | <td>[out] New password 1</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pPassword2</td> | ||
<td>[out] New password 2</td> | <td>[out] New password 2</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pPassword3</td> | ||
<td>[out] New password 3</td> | <td>[out] New password 3</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pPassword4</td> | ||
<td>[out] New password 4</td> | <td>[out] New password 4</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 1,548: | Line 1,660: | ||
<td>ERROR_UNIKEY_NEED_OPEN</td> | <td>ERROR_UNIKEY_NEED_OPEN</td> | ||
<td>212</td> | <td>212</td> | ||
<td> | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>ERROR_UNIKEY_VERIFY_ADV_PASSWORD</td> | <td>ERROR_UNIKEY_VERIFY_ADV_PASSWORD</td> | ||
<td>223</td> | <td>223</td> | ||
<td>Advanced passwords ( | <td>Advanced passwords (passwords 3 and 4) not verified</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>ERROR_UNIKEY_GENERATE_NEW_PASSWORD</td> | <td>ERROR_UNIKEY_GENERATE_NEW_PASSWORD</td> | ||
<td>225</td> | <td>225</td> | ||
<td> | <td>Error generating new password</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
---- | |||
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> | ||
| Line 1,574: | Line 1,690: | ||
=== Generate a New Encryption Key === | === Generate a New Encryption Key === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Generate_Key(short[] pHandle, short[] pKeyNumber);</code> | <code>public int UniKey_Generate_Key(short[] pHandle, short[] pKeyNumber);</code> | ||
'''Description''' | '''Description''' | ||
Generate a new key in the specific key storage. | Generate a new key in the specific key storage. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 1,587: | Line 1,706: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pKeyNumber</td> | ||
<td>[in] Key | <td>[in] Key storage number</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 1,611: | Line 1,731: | ||
<td>ERROR_UNIKEY_NEED_OPEN</td> | <td>ERROR_UNIKEY_NEED_OPEN</td> | ||
<td>212</td> | <td>212</td> | ||
<td> | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
| Line 1,620: | Line 1,740: | ||
</table> | </table> | ||
---- | |||
# This function will delete the original key in the key storage, and generate a new key. | |||
# The data encrypted by the old key cannot be decrypted by the new key. | |||
# Each key is 128-bits long. | |||
---- | |||
<br> | <br> | ||
=== Generate a New Encryption Key via Seed === | |||
'''API Prototype''' | |||
<code>long UniKey_Generate_Key_Via_Seed(WORD* pHandle, DWORD* pKeyNumber, WORD pSeed1, WORD pSeed2, WORD pSeed3, WORD pSeed4);</code> | <code>long UniKey_Generate_Key_Via_Seed(WORD* pHandle, DWORD* pKeyNumber, WORD pSeed1, WORD pSeed2, WORD pSeed3, WORD pSeed4);</code> | ||
'''Description''' | '''Description''' | ||
'''Parameters''' | Generate a new key in the specific key storage via a seed. | ||
<table | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 1,641: | Line 1,767: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pKeyNumber</td> | ||
<td>[in] Key | <td>[in] Key storage number</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pSeed1</td> | ||
<td>[in] | <td>[in] Seed 1</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pSeed2</td> | ||
<td>[in] | <td>[in] Seed 2</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pSeed3</td> | ||
<td>[in] | <td>[in] Seed 3</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pSeed4</td> | ||
<td>[in] | <td>[in] Seed 4</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 1,681: | Line 1,808: | ||
<td>ERROR_UNIKEY_NEED_OPEN</td> | <td>ERROR_UNIKEY_NEED_OPEN</td> | ||
<td>212</td> | <td>212</td> | ||
<td> | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
| Line 1,690: | Line 1,817: | ||
</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> | ||
| Line 1,698: | Line 1,828: | ||
=== Encrypt the Buffer with a Specific Encryption Key === | === Encrypt the Buffer with a Specific Encryption Key === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Encrypt(short[] pHandle, int[] pBufferLength, int[] pKeyNumber, byte[] pBuffer);</code> | <code>public int UniKey_Encrypt(short[] pHandle, int[] pBufferLength, int[] pKeyNumber, byte[] pBuffer);</code> | ||
'''Description''' | '''Description''' | ||
Encrypt an amount of memory with a key. The length of data must be a multiple of 8. | Encrypt an amount of memory with a key. The length of data must be a multiple of 8. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 1,711: | Line 1,844: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pBufferLength</td> | ||
<td>[in] Number of bytes to encrypt</td> | <td>[in] Number of bytes to encrypt</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pKeyNumber</td> | ||
<td>[in] Key | <td>[in] Key storage number</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td rowspan="2">pBuffer</td> | ||
<td>[in] Pointer to the data to be encrypted</td> | <td>[in] Pointer to the data to be encrypted</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>[out] Pointer to the encrypted data</td> | <td>[out] Pointer to the encrypted data</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 1,747: | Line 1,880: | ||
<td>ERROR_UNIKEY_NEED_OPEN</td> | <td>ERROR_UNIKEY_NEED_OPEN</td> | ||
<td>212</td> | <td>212</td> | ||
<td> | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
| Line 1,757: | Line 1,890: | ||
<td>ERROR_UNIKEY_ENCRYPT_FAILED</td> | <td>ERROR_UNIKEY_ENCRYPT_FAILED</td> | ||
<td>228</td> | <td>228</td> | ||
<td> | <td>Could not encrypt data</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
---- | |||
This function only performs an encryption operation, no compression functions are involved. | This function only performs an encryption operation, no compression functions are involved. | ||
---- | |||
<br> | <br> | ||
| Line 1,769: | Line 1,903: | ||
=== Decrypt the Buffer with a Specific Encryption Key === | === Decrypt the Buffer with a Specific Encryption Key === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Decrypt(short[] pHandle, int[] | |||
<code>public int UniKey_Decrypt(short[] pHandle, int[] pBufferLength, int[] pKeyNumber, byte[] buffer);</code> | |||
'''Description''' | |||
Encrypt an amount of memory with a key. The length of data must be a multiple of 8. | Encrypt an amount of memory with a key. The length of data must be a multiple of 8. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 1,782: | Line 1,919: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pBufferLength</td> | ||
<td>[in] Number of bytes to encrypt</td> | <td>[in] Number of bytes to encrypt</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pKeyNumber</td> | ||
<td>[in] Key | <td>[in] Key storage number</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td rowspan="2">pBuffer</td> | ||
<td>[in] Pointer to the data to be decrypted</td> | <td>[in] Pointer to the data to be decrypted</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>[out] Pointer to the decrypted data</td> | <td>[out] Pointer to the decrypted data</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 1,818: | Line 1,955: | ||
<td>ERROR_UNIKEY_NEED_OPEN</td> | <td>ERROR_UNIKEY_NEED_OPEN</td> | ||
<td>212</td> | <td>212</td> | ||
<td> | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
| Line 1,828: | Line 1,965: | ||
<td>ERROR_UNIKEY_DECRYPT_FAILED</td> | <td>ERROR_UNIKEY_DECRYPT_FAILED</td> | ||
<td>229</td> | <td>229</td> | ||
<td> | <td>Could not decrypt data</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
---- | |||
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 | Please use the key that was used to encrypt the data to decrypt the data, otherwise you cannot properly decrypt the data. | ||
---- | |||
---- | |||
<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> | <br> | ||
=== Make an MD5 Digest for | === Make an MD5 Digest for Certain Content === | ||
'''API Prototype''' | |||
<code>public int UniKey_MD5(short[] pHandle, int[] pBufferLength, byte[] pBuffer);</code> | <code>public int UniKey_MD5(short[] pHandle, int[] pBufferLength, byte[] pBuffer);</code> | ||
'''Description''' | '''Description''' | ||
'''Parameters''' | Make an MD5 digest of content or data. | ||
<table | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 1,857: | Line 1,999: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pBufferLength</td> | ||
<td>[in] Number of bytes to MD5</td> | <td>[in] Number of bytes to MD5</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td rowspan="2">pBuffer</td> | ||
<td>[in] Pointer to the data to be digested</td> | <td>[in] Pointer to the data to be digested</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>[out] Pointer to the digested data</td> | <td>[out] Pointer to the digested data</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 1,889: | Line 2,031: | ||
<td>ERROR_UNIKEY_NEED_OPEN</td> | <td>ERROR_UNIKEY_NEED_OPEN</td> | ||
<td>212</td> | <td>212</td> | ||
<td> | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 1,897: | Line 2,039: | ||
=== Read UpdateTag === | === Read UpdateTag === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int | |||
<code>public int UniKey_Read_UpdateTag(short[] pHandle, int[] pUpdateTag);</code> | |||
'''Description''' | |||
Read UpdateTag from a specific dongle | Read UpdateTag from a specific dongle | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 1,910: | Line 2,055: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pUpdateTag</td> | ||
<td>[out] UpdateTag</td> | <td>[out] UpdateTag</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 1,934: | Line 2,080: | ||
<td>ERROR_UNIKEY_NEED_OPEN</td> | <td>ERROR_UNIKEY_NEED_OPEN</td> | ||
<td>212</td> | <td>212</td> | ||
<td> | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
| Line 1,947: | Line 2,093: | ||
=== Write UpdateTag === | === Write UpdateTag === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int | |||
<code>public int UniKey_Write_UpdateTag(short[] pHandle, int[] pUpdateTag);</code> | |||
'''Description''' | |||
Write UpdateTag into a specific dongle. | Write UpdateTag into a specific dongle. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 1,960: | Line 2,109: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pUpdateTag</td> | ||
<td>[in] UpdateTag</td> | <td>[in] UpdateTag</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 1,984: | Line 2,134: | ||
<td>ERROR_UNIKEY_NEED_OPEN</td> | <td>ERROR_UNIKEY_NEED_OPEN</td> | ||
<td>212</td> | <td>212</td> | ||
<td> | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
| Line 1,993: | Line 2,143: | ||
</table> | </table> | ||
UniKey_Read_UpdateTag APIs give software vendors an easy method to identify if the UniKey dongle needs to be updated. When distributing | ---- | ||
<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> | ||
| Line 2,000: | Line 2,152: | ||
=== Get UniKey Library Version === | === Get UniKey Library Version === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Get_Version(short[] pHandle, int[] pVersion);</code> | <code>public int UniKey_Get_Version(short[] pHandle, int[] pVersion);</code> | ||
'''Description''' | '''Description''' | ||
Get the current UniKey library version. | Get the current UniKey library version. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 2,013: | Line 2,168: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pVersion</td> | ||
<td>[out] UniKey library version</td> | <td>[out] UniKey library version</td> | ||
</tr> | </tr> | ||
| Line 2,028: | Line 2,183: | ||
=== Get UniKey Time === | === Get UniKey Time === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Get_Time(short[] pHandle, int[] pYear, int[] pMonth, short[] pDay, short[] pHour, short[] pMinute, short[] pSecond);</code> | <code>public int UniKey_Get_Time(short[] pHandle, int[] pYear, int[] pMonth, short[] pDay, short[] pHour, short[] pMinute, short[] pSecond);</code> | ||
'''Description''' | '''Description''' | ||
Get UniKey Time’s real time | |||
Get the time from the UniKey Time’s real-time clock. | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<table | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 2,041: | Line 2,199: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pYear</td> | ||
<td>[out] 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> | <td>pMonth</td> | ||
<td>[out] Month</td> | <td>[out] Month</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pDay</td> | ||
<td>[out] Day</td> | <td>[out] Day</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHour</td> | ||
<td>[out] Hour</td> | <td>[out] Hour</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pMinute</td> | ||
<td>[out] Minute</td> | <td>[out] Minute</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pSecond</td> | ||
<td>[out] Second</td> | <td>[out] Second</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 2,085: | Line 2,244: | ||
<td>ERROR_UNIKEY_NEED_OPEN</td> | <td>ERROR_UNIKEY_NEED_OPEN</td> | ||
<td>212</td> | <td>212</td> | ||
<td>Need | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
| Line 2,094: | Line 2,253: | ||
</table> | </table> | ||
---- | |||
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> | ||
| Line 2,102: | Line 2,262: | ||
=== Set UniKey Time === | === Set UniKey Time === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Set_Time(short[] pHandle, int[] pYear, int[] pMonth, short[] pDay, short[] pHour, short[] pMinute, short[] pSecond);</code> | <code>public int UniKey_Set_Time(short[] pHandle, int[] pYear, int[] pMonth, short[] pDay, short[] pHour, short[] pMinute, short[] pSecond);</code> | ||
'''Description''' | '''Description''' | ||
'''Parameters''' | Set the time on the UniKey Time’s clock. | ||
<table | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 2,115: | Line 2,278: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pYear</td> | ||
<td>[in] Year (input or output is 10, which refers to 2010)</td> | <td>[in] Year (input or output is 10, which refers to 2010)</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pMonth</td> | ||
<td>[in] Month</td> | <td>[in] Month</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pDay</td> | ||
<td>[in] Day</td> | <td>[in] Day</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHour</td> | ||
<td>[in] Hour</td> | <td>[in] Hour</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pMinute</td> | ||
<td>[in] Minute</td> | <td>[in] Minute</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pSecond</td> | ||
<td>[in] Second</td> | <td>[in] Second</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 2,159: | Line 2,323: | ||
<td>ERROR_UNIKEY_NEED_OPEN</td> | <td>ERROR_UNIKEY_NEED_OPEN</td> | ||
<td>212</td> | <td>212</td> | ||
<td>Need | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
| Line 2,168: | Line 2,332: | ||
</table> | </table> | ||
You need verify all | ---- | ||
You need to verify all 4 passwords (vendor mode) to set the time of the UniKey Time's internal clock. | |||
---- | |||
<br> | <br> | ||
| Line 2,176: | Line 2,342: | ||
=== Set UniKey Time by Host’s Clock === | === Set UniKey Time by Host’s Clock === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Set_Time_Now(short[] pHandle);</code> | <code>public int UniKey_Set_Time_Now(short[] pHandle);</code> | ||
'''Description''' | '''Description''' | ||
Set UniKey Time’s real time | |||
Set the time of the UniKey Time’s real-time clock to the host computer’s clock. | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<table | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 2,189: | Line 2,358: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 2,209: | Line 2,379: | ||
<td>ERROR_UNIKEY_NEED_OPEN</td> | <td>ERROR_UNIKEY_NEED_OPEN</td> | ||
<td>212</td> | <td>212</td> | ||
<td>Need | <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_TIME</td> | ||
<td>231</td> | <td>231</td> | ||
<td> | <td>Set UniKey time error</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 2,222: | Line 2,392: | ||
=== Erase Real Time Module === | === Erase Real Time Module === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Erase_Time_Module(short[] pHandle, int[] pModule);</code> | <code>public int UniKey_Erase_Time_Module(short[] pHandle, int[] pModule);</code> | ||
'''Description''' | '''Description''' | ||
'''Parameters''' | Erase/Reset a real-time module, and all the information in the module will be erased including start, and end or duration. | ||
<table | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 2,235: | Line 2,408: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pModule</td> | ||
<td>[in] Real time module number (0-15)</td> | <td>[in] Real-time module number (0-15)</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 2,259: | Line 2,433: | ||
<td>ERROR_UNIKEY_NEED_OPEN</td> | <td>ERROR_UNIKEY_NEED_OPEN</td> | ||
<td>212</td> | <td>212</td> | ||
<td>Need | <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_TIME</td> | ||
<td>231</td> | <td>231</td> | ||
<td> | <td>Set UniKey time error</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
You need verify all | ---- | ||
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> | ||
| Line 2,276: | Line 2,451: | ||
=== Set a Real Time Module’s Start Time === | === Set a Real Time Module’s Start Time === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code> | |||
<code>public int UniKey_Set_Time_Module_Start_Time(short[] pHandle, int[] pModule, short[] pYear, short[] pMonth, short[] pDay, short[] pHour);</code> | |||
'''Description''' | |||
Set a real-time module’s start time. | |||
''' | '''Parameters''' | ||
<table class="wikitable"> | |||
<table | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 2,289: | Line 2,467: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<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> | <td>pYear</td> | ||
<td>[in] Year (input or output is 10, which refers to 2010)</td> | <td>[in] Year (input or output is 10, which refers to 2010)</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pMonth</td> | ||
<td>[in] Month</td> | <td>[in] Month</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pDay</td> | ||
<td>[in] Day</td> | <td>[in] Day</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHour</td> | ||
<td>[in] Hour</td> | <td>[in] Hour</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 2,329: | Line 2,508: | ||
<td>ERROR_UNIKEY_NEED_OPEN</td> | <td>ERROR_UNIKEY_NEED_OPEN</td> | ||
<td>212</td> | <td>212</td> | ||
<td>Need | <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> | <td>Set UniKey time error</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>ERROR_UNIKEY_TIME_MODULE_NOT_NULL</td> | <td>ERROR_UNIKEY_TIME_MODULE_NOT_NULL</td> | ||
<td>234</td> | <td>234</td> | ||
<td>The real time module is not null, this error is returned when write once flag is set</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> | ||
---- | |||
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> | ||
=== Set a Real Time Module’s Start Time by UniKey | === Set a Real Time Module’s Start Time by the UniKey's Internal Clock === | ||
'''API Prototype''' | |||
<code>public int UniKey_Set_Time_Module_Start_Time_Now(short[] pHandle, int[] pModule);</code> | <code>public int UniKey_Set_Time_Module_Start_Time_Now(short[] pHandle, int[] pModule);</code> | ||
'''Description''' | '''Description''' | ||
'''Parameters''' | Set a real-time module’s start time as the current time in the UniKey's internal clock. | ||
<table | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 2,364: | Line 2,547: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pModule</td> | ||
<td>[in] Real time module number (0-15)</td> | <td>[in] Real-time module number (0-15)</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 2,388: | Line 2,572: | ||
<td>ERROR_UNIKEY_NEED_OPEN</td> | <td>ERROR_UNIKEY_NEED_OPEN</td> | ||
<td>212</td> | <td>212</td> | ||
<td>Need | <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> | <td>Set UniKey time error</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>ERROR_UNIKEY_TIME_MODULE_NOT_NULL</td> | <td>ERROR_UNIKEY_TIME_MODULE_NOT_NULL</td> | ||
<td>234</td> | <td>234</td> | ||
<td>The real time module is not null, this error is returned when write once flag is set</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> | ||
| Line 2,406: | Line 2,590: | ||
=== Set a Real Time Module’s Start Time by Host’s Clock === | === Set a Real Time Module’s Start Time by Host’s Clock === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Set_Time_Module_Start_Time_Now_PC(short[] pHandle, int[] pModule);</code> | <code>public int UniKey_Set_Time_Module_Start_Time_Now_PC(short[] pHandle, int[] pModule);</code> | ||
'''Description''' | '''Description''' | ||
'''Parameters''' | Set a real time module’s start time as the current time of the host computer. | ||
<table | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 2,419: | Line 2,606: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pModule</td> | ||
<td>[in] Real time module number (0-15)</td> | <td>[in] Real-time module number (0-15)</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 2,443: | Line 2,631: | ||
<td>ERROR_UNIKEY_NEED_OPEN</td> | <td>ERROR_UNIKEY_NEED_OPEN</td> | ||
<td>212</td> | <td>212</td> | ||
<td>Need | <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> | <td>Set UniKey time error</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>ERROR_UNIKEY_TIME_MODULE_NOT_NULL</td> | <td>ERROR_UNIKEY_TIME_MODULE_NOT_NULL</td> | ||
<td>234</td> | <td>234</td> | ||
<td>The real time module is not null, this error is returned when write once flag is set</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> | ||
| Line 2,461: | Line 2,649: | ||
=== Set a Real Time Module’s End Time === | === Set a Real Time Module’s End Time === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Set_Time_Module_End_Time(short[] pHandle, int[] pModule, short[] pYear, short[] pMonth, short[] pDay, short[] pHour);</code> | <code>public int UniKey_Set_Time_Module_End_Time(short[] pHandle, int[] pModule, short[] pYear, short[] pMonth, short[] pDay, short[] pHour);</code> | ||
'''Description''' | '''Description''' | ||
Set a real time module’s end time. | |||
Set a real-time module’s end time. | |||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 2,474: | Line 2,665: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle </td> | ||
<td>[in] Real time module number (0-15)</td> | <td>[in] Real-time module number (0-15)</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pYear</td> | ||
<td>[in] Year (input or output is 10, which refers to 2010)</td> | <td>[in] Year (input or output is 10, which refers to 2010)</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pMonth</td> | ||
<td>[in] Month</td> | <td>[in] Month</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pDay</td> | ||
<td>[in] Day</td> | <td>[in] Day</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHour</td> | ||
<td>[in] Hour</td> | <td>[in] Hour</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 2,514: | Line 2,706: | ||
<td>ERROR_UNIKEY_NEED_OPEN</td> | <td>ERROR_UNIKEY_NEED_OPEN</td> | ||
<td>212</td> | <td>212</td> | ||
<td>Need | <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> | <td>Set UniKey time error</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 2,527: | Line 2,719: | ||
=== Set a Real Time Module’s Duration === | === Set a Real Time Module’s Duration === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Set_Time_Module_Duration(short[] pHandle, int[] pModule, int[] pDays, short[] pHours);</code> | <code>public int UniKey_Set_Time_Module_Duration(short[] pHandle, int[] pModule, int[] pDays, short[] pHours);</code> | ||
'''Description''' | '''Description''' | ||
'''Parameters''' | Set the duration for a specific real-time module. The total duration is (*pDay) * 24 + (*pHour) in hours. | ||
<table | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 2,540: | Line 2,735: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<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> | <td>pDay</td> | ||
<td>[in] Number of days</td> | <td>[in] Number of days</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHour</td> | ||
<td>[in] Number of hours</td> | <td>[in] Number of hours</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 2,572: | Line 2,768: | ||
<td>ERROR_UNIKEY_NEED_OPEN</td> | <td>ERROR_UNIKEY_NEED_OPEN</td> | ||
<td>212</td> | <td>212</td> | ||
<td>Need | <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> | <td>Set UniKey time error</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
You need verify all | ---- | ||
You need to verify all 4 passwords (vendor mode) to set the duration for a real-time module. | |||
---- | |||
<br> | <br> | ||
| Line 2,589: | Line 2,786: | ||
=== Check a UniKey Time License module === | === Check a UniKey Time License module === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Check_Time_Module(short[] pHandle, int[] pModule, short[] pYear, short[] pMonth, short[] pDay, short[] pHour);</code> | <code>public int UniKey_Check_Time_Module(short[] pHandle, int[] pModule, short[] pYear, short[] pMonth, short[] pDay, short[] pHour);</code> | ||
'''Description''' | '''Description''' | ||
Read the attributes of a specific UniKey Time license module. | Read the attributes of a specific UniKey Time license module. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 2,602: | Line 2,802: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pModule</td> | ||
<td>[in] License module Number</td> | <td>[in] License module Number</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pRemainDays</td> | ||
<td>[out] | <td>[out] Days remaining</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pYear</td> | ||
<td>[in] Year (input or output is 10 ,which refers to 2010)</td> | <td>[in] Year (input or output is 10, which refers to 2010)</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pMonth</td> | ||
<td>[in] Month</td> | <td>[in] Month</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pDay</td> | ||
<td>[in] Day</td> | <td>[in] Day</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHour</td> | ||
<td>[in] Hour</td> | <td>[in] Hour</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 2,645: | Line 2,846: | ||
<tr> | <tr> | ||
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td> | <td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td> | ||
<td> | <td>204</td> | ||
<td>Read/Write address or length | <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> | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
| Line 2,660: | Line 2,861: | ||
</table> | </table> | ||
A successful operation will result in | ---- | ||
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> | ||
| Line 2,668: | Line 2,872: | ||
=== Check a UniKey Time License Module Now === | === Check a UniKey Time License Module Now === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Check_Time_Module_Now(short[] pHandle, int[] pModule);</code> | |||
<code>public int UniKey_Check_Time_Module_Now(short[] pHandle, int[] pModule, int[] pRemainDays, short[] pRemainHours);</code> | |||
'''Description''' | '''Description''' | ||
'''Parameters''' | Read the attributes of a specific UniKey Time license module Now. | ||
<table | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 2,681: | Line 2,888: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pModule</td> | ||
<td>[in] License module | <td>[in] License module number</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pRemainDays</td> | ||
<td>[out] | <td>[out] Days remaining</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pRemainHours</td> | ||
<td>[out] | <td>[out] Hours remaining</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 2,712: | Line 2,920: | ||
<tr> | <tr> | ||
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td> | <td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td> | ||
<td> | <td>204</td> | ||
<td>Read/Write address or length | <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> | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
| Line 2,727: | Line 2,935: | ||
</table> | </table> | ||
A successful operation will result in | ---- | ||
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> | ||
| Line 2,735: | Line 2,946: | ||
=== Check a UniKey Time License Module Now PC === | === Check a UniKey Time License Module Now PC === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public int UniKey_Check_Time_Module_Now_PC(short[] pHandle, int[] pModule, int[] pRemainDays, short[] pRemainHours);</code> | |||
'''Parameters''' | '''Description''' | ||
<table | |||
Read the attributes of a specific UniKey Time license module Now PC. | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 2,748: | Line 2,962: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] Dongle handle</td> | <td>[in] Dongle handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pModule</td> | ||
<td>[in] License module | <td>[in] License module number</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pRemainDays</td> | ||
<td>[out] | <td>[out] Days remaining</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pRemainHours</td> | ||
<td>[out] | <td>[out] Hours remaining</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 2,779: | Line 2,994: | ||
<tr> | <tr> | ||
<td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td> | <td>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE</td> | ||
<td> | <td>204</td> | ||
<td>Read/Write address or length | <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> | <td>Need to log on to a dongle before running</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
| Line 2,794: | Line 3,009: | ||
</table> | </table> | ||
A successful operation will result in | ---- | ||
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> | ||
| Line 2,804: | Line 3,022: | ||
=== Initialize File System === | === Initialize File System === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public native int UniKeyFSInit(short[] pHandle, int[] pw1, int[] pw2, int[] pw3, int[] pw4);</code> | <code>public native int UniKeyFSInit(short[] pHandle, int[] pw1, int[] pw2, int[] pw3, int[] pw4);</code> | ||
'''Description''' | '''Description''' | ||
'''Parameters''' | 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. | ||
<table | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 2,817: | Line 3,038: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pw1</td> | ||
<td>[in] | <td>[in] Password 1</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pw2</td> | ||
<td>[in] | <td>[in] Password 2</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pw3</td> | ||
<td>[in] | <td>[in] Password 3</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pw4</td> | ||
<td>[in] | <td>[in] Password 4</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 2,853: | Line 3,075: | ||
<td>ERROR_UNIKEY_INVALID_PASSWORD_OR_ID</td> | <td>ERROR_UNIKEY_INVALID_PASSWORD_OR_ID</td> | ||
<td>202</td> | <td>202</td> | ||
<td> | <td>Wrong password or UniKey HID</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 2,859: | Line 3,081: | ||
<br> | <br> | ||
=== Format the | === Format the File System === | ||
'''API Prototype''' | |||
<code>public native int UniKeyFSFormat(short[] pHandle);</code> | <code>public native int UniKeyFSFormat(short[] pHandle);</code> | ||
'''Description''' | '''Description''' | ||
Format the file system. | Format the file system. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 2,874: | Line 3,099: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 2,894: | Line 3,120: | ||
<td>ERROR_UNIKEY_FS_FILE_EXIST</td> | <td>ERROR_UNIKEY_FS_FILE_EXIST</td> | ||
<td>245</td> | <td>245</td> | ||
<td>File already | <td>File already exists</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
---- | |||
Note: The user needs to initialize the file system successfully before calling other file system related functions. | Note: The user needs to initialize the file system successfully before calling other file system related functions. | ||
---- | |||
<br> | <br> | ||
=== Create | === Create Files === | ||
'''API Prototype''' | |||
<code>public native int UniKeyFSCreateFile(short[] pHandle, byte[] fileName);</code> | |||
''' | '''Description''' | ||
Create files. | Create files. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 2,919: | Line 3,149: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>filename</td> | ||
<td>[in/out]Input/Output file name</td> | <td>[in/out] Input/Output file name</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | ---- | ||
<table | 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> | ||
| Line 2,943: | Line 3,176: | ||
<td>0</td> | <td>0</td> | ||
<td>Success</td> | <td>Success</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>ERROR_UNIKEY_FS_FILE_NAME</td> | <td>ERROR_UNIKEY_FS_FILE_NAME</td> | ||
<td>240</td> | <td>240</td> | ||
<td>Wrong or invalid | <td>Wrong or invalid filename</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>ERROR_UNIKEY_FS_FILE_EXIST</td> | <td>ERROR_UNIKEY_FS_FILE_EXIST</td> | ||
<td>245</td> | <td>245</td> | ||
<td>The file | <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 2,963: | Line 3,196: | ||
<br> | <br> | ||
=== Delete | === Delete Files === | ||
'''API Prototype''' | |||
<code>public native int UniKeyFSDeleteFile(short[] pHandle, byte[] fileName);</code> | |||
''' | '''Description''' | ||
Delete files. | Delete files. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 2,979: | Line 3,214: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>filename</td> | ||
<td>[in/out]Input/Output file name</td> | <td>[in/out] Input/Output file name</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 2,999: | Line 3,235: | ||
<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> | ||
<tr> | <tr> | ||
<td>ERROR_UNIKEY_FS_ERR_SYS_UNINIT</td> | <td>ERROR_UNIKEY_FS_ERR_SYS_UNINIT</td> | ||
<td>246</td> | <td>246</td> | ||
<td>The file is not | <td>The file system is not initialized</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 3,014: | Line 3,250: | ||
<br> | <br> | ||
=== Open | === Open Files === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public native int UniKeyFSFileOpen(short[] pHandle, byte[] | |||
<code>public native int UniKeyFSFileOpen(short[] pHandle, byte[] fileName);</code> | |||
'''Description''' | |||
Open files. | Open files. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 3,029: | Line 3,268: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>filename</td> | ||
<td>[in]Input/Output file name</td> | <td>[in] Input/Output file name</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 3,053: | Line 3,293: | ||
<td>ERROR_UNIKEY_FS_NO_FILE</td> | <td>ERROR_UNIKEY_FS_NO_FILE</td> | ||
<td>241</td> | <td>241</td> | ||
<td>No such | <td>No such filename</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 3,059: | Line 3,299: | ||
<br> | <br> | ||
=== Get | === Get System Space === | ||
'''API Prototype''' | |||
<code>public native int UniKeyFSGetFreeSize(short[] pHandle, int[] usedsize, int[] freesize);</code> | <code>public native int UniKeyFSGetFreeSize(short[] pHandle, int[] usedsize, int[] freesize);</code> | ||
'''Description''' | '''Description''' | ||
Get system space. | |||
Get occupied and free system space. | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<table | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 3,074: | Line 3,317: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>usedsize</td> | ||
<td>[out]System | <td>[out] System memory that is in use</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>freesize</td> | ||
<td>[out] | <td>[out] Free system memory</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 3,103: | Line 3,347: | ||
<br> | <br> | ||
=== Modify | === Modify File Data === | ||
'''API Prototype''' | |||
<code>public native int UniKeyFSFileModifyData(short[] pHandle, int[] offset, int[] len, byte[] buffer);</code> | <code>public native int UniKeyFSFileModifyData(short[] pHandle, int[] offset, int[] len, byte[] buffer);</code> | ||
'''Description''' | '''Description''' | ||
Modify file data. | Modify file data. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 3,118: | Line 3,365: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>offset</td> | ||
<td>[in]Address to be modified</td> | <td>[in] Address to be modified</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>len</td> | ||
<td>[in] | <td>[in] Length of data to be modified</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>buffer</td> | ||
<td>[in] | <td>[in] Modified data</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 3,146: | 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> | ||
<tr> | <tr> | ||
<td>ERROR_UNIKEY_FS_ERR_OPEN_FILE</td> | <td>ERROR_UNIKEY_FS_ERR_OPEN_FILE</td> | ||
<td>247</td> | <td>247</td> | ||
<td> | <td>Failed to open file</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 3,161: | Line 3,409: | ||
<br> | <br> | ||
=== Append | === Append Data to the End-Of-File === | ||
'''API Prototype''' | |||
<code>public native int UniKeyFSFileAppendData(short[] pHandle, int[] len, byte[] buffer);</code> | <code>public native int UniKeyFSFileAppendData(short[] pHandle, int[] len, byte[] buffer);</code> | ||
'''Description''' | '''Description''' | ||
Append data to the end-of-file. | Append data to the end-of-file. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 3,176: | Line 3,427: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in] | <td>[in] Device handle</td> | ||
</tr> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>len</td> | ||
<td>[in] | <td>[in] The length of the data to be appended</td> | ||
</tr> | |||
<tr> | |||
<td>buffer</td> | |||
<td>[in] Data to append</td> | |||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 3,206: | Line 3,463: | ||
<br> | <br> | ||
=== Read | === Read File Data === | ||
'''API Prototype''' | |||
<code>public native int UniKeyFSFileReadData(short[] pHandle, int[] offset, int[] len, byte[] buffer);</code> | <code>public native int UniKeyFSFileReadData(short[] pHandle, int[] offset, int[] len, byte[] buffer);</code> | ||
'''Description''' | '''Description''' | ||
Read data | |||
Read file data. | |||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 3,221: | Line 3,481: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>offset</td> | ||
<td>[in]Read address</td> | <td>[in] Read address</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>len</td> | ||
<td>[in] | <td>[in] Length of data to be read</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>buffer</td> | ||
<td>[out]Read data</td> | <td>[out] Read data</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 3,249: | Line 3,510: | ||
<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> | ||
<tr> | <tr> | ||
<td>ERROR_UNIKEY_FS_ERR_OPEN_FILE</td> | <td>ERROR_UNIKEY_FS_ERR_OPEN_FILE</td> | ||
<td>247</td> | <td>247</td> | ||
<td> | <td>Failed to open file</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 3,264: | Line 3,525: | ||
<br> | <br> | ||
=== Close | === Close Files === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public native int | |||
<code>public native int UniKeyFSFileOpen(short[] pHandle, byte[] fileName);</code> | |||
'''Description''' | |||
Close files. | Close files. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 3,279: | Line 3,543: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>filename</td> | ||
<td>[in] | <td>[in] Filename</td> | ||
</tr> | </tr> | ||
</table> | |||
'''Return values''' | |||
<table class="wikitable"> | |||
</table> | |||
'''Return values''' | |||
<table | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 3,312: | Line 3,569: | ||
<br> | <br> | ||
=== Get | === Get File List === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public native int UniKeyFSFileGetList(short[] pHandle, int[] filecount, byte[] filelist);</code> | |||
'''Parameters''' | '''Description''' | ||
<table | |||
Get list of files on the UniKey Drive. | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 3,327: | Line 3,587: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>filecount</td> | ||
<td>[out]The number of files</td> | <td>[out] The number of files</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>filelist</td> | ||
<td>[out]</td> | <td>[out] File list</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 3,356: | Line 3,617: | ||
<br> | <br> | ||
=== Get | === Get File Size === | ||
'''API Prototype''' | |||
<code>public native int UniKeyFSFileGetSize(short[] pHandle, int[] filesize);</code> | <code>public native int UniKeyFSFileGetSize(short[] pHandle, int[] filesize);</code> | ||
'''Description''' | '''Description''' | ||
Get the file size. | Get the file size. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 3,371: | Line 3,635: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>filesize</td> | ||
<td>[out]The size of the file</td> | <td>[out] The size of the file</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 3,396: | Line 3,661: | ||
<br> | <br> | ||
=== | === User Reset File System Password === | ||
'''API Prototype''' | |||
<code>public native int UniKeyFSSetPassWord(short[] pHandle, int[] pw1, int[] pw2, int[] pw3, int[] pw4);</code> | <code>public native int UniKeyFSSetPassWord(short[] pHandle, int[] pw1, int[] pw2, int[] pw3, int[] pw4);</code> | ||
'''Description''' | '''Description''' | ||
'''Parameters''' | Allows a user to reset the file system password. | ||
<table | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 3,411: | Line 3,679: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>PW1</td> | ||
<td>[in]Password 1</td> | <td>[in] Password 1</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>PW2</td> | ||
<td>[in]Password 2</td> | <td>[in] Password 2</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>PW3</td> | ||
<td>[in]Password 3</td> | <td>[in] Password 3</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>PW4</td> | ||
<td>[in]Password 4</td> | <td>[in] Password 4</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 3,445: | Line 3,714: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>ERROR_UNIKEY_GENERATE_NEW_PASSWORD</td> | ||
<td>225 </td> | <td>225</td> | ||
<td> | <td>Error generating new password</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
---- | |||
A password reset can only be successfully done after initializing the file system. | |||
---- | |||
<br> | <br> | ||
=== Generate | === Generate RSA Key === | ||
'''API Prototype''' | |||
<code>public native int UniKeyRSAGenerateKey(short[] pHandle, int[] KeyIndex);</code> | |||
''' | '''Description''' | ||
UniKey Drive has encryption and decryption modules with 1024-bit RSA keys. Calling this function can generate a 1024-bit RSA key. | |||
UniKey Drive has encryption | |||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 3,472: | Line 3,745: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>KeyIndex</td> | ||
<td>[ | <td>[out] Return the handle generated key</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 3,494: | Line 3,768: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>ERROR_UNIKEY_KEY_INDEX</td> | ||
<td>239</td> | <td>239</td> | ||
<td>The handle of the key is invalid | <td>The handle of the key is invalid</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 3,504: | Line 3,778: | ||
=== Generate a DES Key === | === Generate a DES Key === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public native int UniKeyDESGenerateKey(short[] pHandle, int[] | |||
<code>public native int UniKeyDESGenerateKey(short[] pHandle, int[] KeyIndex);</code> | |||
'''Description''' | |||
Calling this function can generate a DES key. | Calling this function can generate a DES key. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 3,517: | Line 3,794: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>KeyIndex</td> | ||
<td>[ | <td>[out] Return the handle generated key</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 3,539: | Line 3,817: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>ERROR_UNIKEY_KEY_INDEX</td> | ||
<td>239</td> | <td>239</td> | ||
<td>The handle of the key is invalid | <td>The handle of the key is invalid</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 3,547: | Line 3,825: | ||
<br> | <br> | ||
=== RSA Get | === RSA Get Number of Generated Keys === | ||
'''API Prototype''' | |||
<code>public native int UniKeyRSAGetKeyCounts(short[] pHandle, int[] KeyIndex);</code> | |||
'''Description''' | |||
Get the number of RSA keys that are generated. | |||
''' | '''Parameters''' | ||
<table class="wikitable"> | |||
<table | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 3,562: | Line 3,843: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>KeyIndex</td> | ||
<td>[out] | <td>[out] Key count</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 3,584: | Line 3,866: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>ERROR_UNIKEY_KEY_INDEX</td> | ||
<td>239</td> | <td>239</td> | ||
<td>The handle of the key is invalid | <td>The handle of the key is invalid</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 3,592: | Line 3,874: | ||
<br> | <br> | ||
=== DES Get | === DES Get Number of Generated Keys === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public native int UniKeyDESGetKeyCounts(short[] pHandle, int[] KeyIndex);</code> | |||
'''Parameters''' | '''Description''' | ||
<table | |||
Get the number of DES keys that are generated. | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 3,607: | Line 3,892: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>KeyIndex</td> | ||
<td>[out] | <td>[out] Key count</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 3,629: | Line 3,915: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>ERROR_UNIKEY_KEY_INDEX</td> | ||
<td>239</td> | <td>239</td> | ||
<td>The handle of the key is invalid | <td>The handle of the key is invalid</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 3,637: | Line 3,923: | ||
<br> | <br> | ||
=== RSA | === RSA Encryption === | ||
'''API Prototype''' | |||
<code>public native int UniKeyRSAEncrypt(short[] pHandle, short[] pKeyNumber, int[] len, byte[] buffer);</code> | <code>public native int UniKeyRSAEncrypt(short[] pHandle, short[] pKeyNumber, int[] len, byte[] buffer);</code> | ||
'''Description''' | '''Description''' | ||
Encrypt data using RSA. | Encrypt data using RSA. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 3,652: | Line 3,941: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>KeyIndex</td> | ||
<td>[in]Encrypt | <td>[in] Encrypt and decrypt using the key handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>Encrypt_Len</td> | ||
<td>[in] | <td>[in] Data length to be encrypted</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>Buffer</td> | ||
<td>[in/out]Input | <td>[in/out] Input plain text and output encrypted text</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 3,684: | Line 3,974: | ||
<td>ERROR_UNIKEY_ENCRYPT_FAILED</td> | <td>ERROR_UNIKEY_ENCRYPT_FAILED</td> | ||
<td>228</td> | <td>228</td> | ||
<td> | <td>Could not encrypt data</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 3,690: | Line 3,980: | ||
<br> | <br> | ||
=== RSA | === RSA Decryption === | ||
'''API Prototype''' | |||
<code>public native int UniKeyRSADecrypt(short[] pHandle, short[] pKeyNumber, int[] len, byte[] buffer);</code> | <code>public native int UniKeyRSADecrypt(short[] pHandle, short[] pKeyNumber, int[] len, byte[] buffer);</code> | ||
'''Description''' | '''Description''' | ||
Decrypt data using RSA. | Decrypt data using RSA. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 3,705: | Line 3,998: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in]Device handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>KeyIndex</td> | ||
<td>[in]Encrypt | <td>[in] Encrypt and decrypt using the key handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>Decrypt_Len</td> | ||
<td>[in] | <td>[in] Length of data to be decrypted</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>Buffer</td> | ||
<td>[in/out]Input encrypted text and output plain text.</td> | <td>[in/out] Input encrypted text and output plain text.</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 3,735: | Line 4,029: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>ERROR_UNIKEY_DECRYPT_FAILED</td> | ||
<td> | <td>229</td> | ||
<td> | <td>Could not decrypt data</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>ERROR_UNIKEY_KEY_INDEX</td> | ||
<td> | <td>239</td> | ||
<td> | <td>The key handle is invalid</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 3,748: | Line 4,042: | ||
<br> | <br> | ||
=== DES | === DES Encryption === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public native int | <code> | ||
public native int UniKeyDES1Encrypt(short[] pHandle, short[] mode, short[] pKeyNumber, int[] len, byte[] buffer); | |||
public native int UniKeyDES1Decrypt(short[] pHandle, short[] mode, short[] pKeyNumber, int[] len, byte[] buffer); | |||
public native int UniKeyDES2Encrypt(short[] pHandle, short[] mode, short[] pKeyNumber, int[] len, byte[] buffer); | |||
</code> | |||
'''Description''' | |||
Encrypt data using DES. | Encrypt data using DES. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 3,767: | Line 4,066: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <tr> | ||
<td>[in] | <td>EncryptMode</td> | ||
<td>[in] Block cipher mode of operation</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>KeyIndex</td> | ||
<td>[in] | <td>[in] Encrypt and decrypt using the key handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>Len</td> | ||
<td>[in/out]Input | <td>[in] Length of data 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''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 3,797: | Line 4,102: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>ERROR_UNIKEY_ENCRYPT_FAILED</td> | ||
<td> | <td>228</td> | ||
<td> | <td>Could not encrypt data</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>ERROR_UNIKEY_KEY_INDEX</td> | ||
<td> | <td>239</td> | ||
<td> | <td>The key handle is invalid</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 3,810: | Line 4,115: | ||
<br> | <br> | ||
=== DES | === DES Decryption === | ||
'''API Prototype''' | '''API Prototype''' | ||
<code>public native int UniKeyDES2Decrypt(short[] pHandle, short[] mode, short[] pKeyNumber, int[] len, byte[] buffer); | <code> | ||
public native int UniKeyDES2Decrypt(short[] pHandle, short[] mode, short[] pKeyNumber, int[] len, byte[] buffer); | |||
public native int UniKeyDES3Encrypt(short[] pHandle, short[] mode, short[] pKeyNumber, int[] len, byte[] buffer); | |||
public native int UniKeyDES3Decrypt(short[] pHandle, short[] mode, short[] pKeyNumber, int[] len, byte[] buffer); | |||
</code> | |||
'''Description''' | |||
Encrypt data using DES. | Encrypt data using DES. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 3,829: | Line 4,139: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<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> | ||
<tr> | <tr> | ||
<td> | <td>KeyIndex</td> | ||
<td>[in]Encrypt | <td>[in] Encrypt and decrypt using the key handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>Len</td> | ||
<td>[in] | <td>[in] Length of data to be decrypted</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>Buffer</td> | ||
<td>[in/out]Input encrypted text and output plain text.</td> | <td>[in/out] Input encrypted text and output plain text.</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 3,859: | Line 4,175: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>ERROR_UNIKEY_DECRYPT_FAILED</td> | ||
<td> | <td>229</td> | ||
<td> | <td>Could not decrypt data</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>ERROR_UNIKEY_KEY_INDEX</td> | ||
<td> | <td>239</td> | ||
<td> | <td>The key handle is invalid</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 3,872: | Line 4,188: | ||
<br> | <br> | ||
=== Delete | === Delete RSA Key === | ||
'''API Prototype''' | |||
<code>public native int UniKeyRSADelKey(short[] pHandle, short[] KeyIndex);</code> | |||
<code>public native int UniKeyRSADelKey(short[] pHandle, short[] | |||
'''Description''' | '''Description''' | ||
'''Parameters''' | Delete a RSA key. | ||
<table | |||
'''Parameters''' | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 3,887: | Line 4,206: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>KeyIndex</td> | ||
<td>[in]The handle to be deleted</td> | <td>[in] The handle to be deleted</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 3,909: | Line 4,229: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>ERROR_UNIKEY_KEY_INDEX</td> | ||
<td>239</td> | <td>239</td> | ||
<td>The key | <td>The handle of the key is invalid<br>0 > KeyIndex > 3</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 3,917: | Line 4,237: | ||
<br> | <br> | ||
=== Delete | === Delete DES Key === | ||
'''API Prototype''' | |||
<code>public native int UniKeyDESDelKey(short[] pHandle, short[] KeyIndex);</code> | |||
'''Description''' | |||
Delete a DES key. | |||
''' | '''Parameters''' | ||
<table class="wikitable"> | |||
<table | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 3,932: | Line 4,255: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>KeyIndex</td> | ||
<td>[in] | <td>[in] Key handle to be deleted</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 3,954: | Line 4,278: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>ERROR_UNIKEY_KEY_INDEX</td> | ||
<td>239</td> | <td>239</td> | ||
<td>The key | <td>The handle of the key is invalid<br>0 > KeyIndex > 14</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 3,967: | Line 4,286: | ||
<br> | <br> | ||
=== Get | === Get User Counts === | ||
'''API Prototype''' | |||
<code>public native int UniKeyGetUserCount(short[] pHandle, short[] count);</code> | <code>public native int UniKeyGetUserCount(short[] pHandle, short[] count);</code> | ||
'''Description''' | '''Description''' | ||
UniKey Drive can enable 32 concurrent users to | |||
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"> | |||
<table | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 3,982: | Line 4,304: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>Count </td> | ||
<td>[ | <td>[out] Number of users logged in</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 4,002: | Line 4,325: | ||
<td>0</td> | <td>0</td> | ||
<td>Success</td> | <td>Success</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 4,012: | Line 4,330: | ||
<br> | <br> | ||
=== Only | === Only Allow One User to Log in === | ||
'''API Prototype''' | |||
<code>public native int UnikeyLogonSingle(short[] pHandle, int[] pPassword1, int[] pPassword2, int[] pPassword3, int[] pPassword4);</code> | <code>public native int UnikeyLogonSingle(short[] pHandle, int[] pPassword1, int[] pPassword2, int[] pPassword3, int[] pPassword4);</code> | ||
'''Description''' | '''Description''' | ||
After calling this function, UniKey Drive only | |||
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''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 4,027: | Line 4,348: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pPassword1</td> | ||
<td>[in]Password 1</td> | <td>[in] Password 1</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pPassword2</td> | ||
<td>[in]Password 2</td> | <td>[in] Password 2</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pPassword3</td> | ||
<td>[in]Password 3</td> | <td>[in] Password 3</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pPassword4</td> | ||
<td>[in]Password 4</td> | <td>[in] Password 4</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 4,063: | Line 4,385: | ||
<td>ERROR_UNIKEY_INVALID_PASSWORD_OR_ID</td> | <td>ERROR_UNIKEY_INVALID_PASSWORD_OR_ID</td> | ||
<td>202</td> | <td>202</td> | ||
<td> | <td>Wrong password or UniKey HID</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 4,069: | Line 4,391: | ||
<br> | <br> | ||
=== Log off the Active User === | |||
'''API Prototype''' | |||
<code>public int UniKey_Logoff(short[] pHandle);</code> | |||
'''Description''' | |||
After calling this function, the active user will be logged out, does not affect other users’ login status. | |||
''' | '''Parameters''' | ||
<table class="wikitable"> | |||
<table | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 4,084: | Line 4,409: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
| Line 4,104: | Line 4,430: | ||
<br> | <br> | ||
'''API Prototype''' | === Log off all Users === | ||
'''API Prototype''' | |||
<code>public native int UniKeyLogoffAll(short[] pHandle);</code> | <code>public native int UniKeyLogoffAll(short[] pHandle);</code> | ||
'''Description''' | '''Description''' | ||
After calling this function, all users will be logged off. | After calling this function, all users will be logged off. | ||
'''Parameters''' | '''Parameters''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Parameter</th> | <th>Parameter</th> | ||
| Line 4,120: | Line 4,449: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> | <td>pHandle</td> | ||
<td>[in]Device handle</td> | <td>[in] Device handle</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
'''Return values''' | '''Return values''' | ||
<table | |||
<table class="wikitable"> | |||
<tr> | <tr> | ||
<th>Result</th> | <th>Result</th> | ||
Latest revision as of 17:24, 13 July 2016
UniKey API Reference
Find a UniKey dongle
API Prototype
public int UniKey_Find(short[] pHandle, int[] pSetting1, int[] pSetting2);
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
public int UniKey_Find_Next(short[] pHandle, int[] pSetting1, int[] pSetting2);
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
public int UniKey_User_Logon(short[] pHandle, short[] pPassword1, short[] pPassword2);
For UniKey Drive, the API Prototype is
public native int UniKeyUserLogon(short[] pHandle, int[] pPassword1, int[] pPassword2);
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 |
|---|---|
| pHandle | [out] Dongle handle |
| pPassword1 | [in] Password 1 |
| pPassword2 | [in] Password 2 |
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
public int UniKey_Vender_Logon(short[] pHandle, short[] pPassword1, short[] pPassword2, short[] pPassword3, short[] pPassword4);
For UniKey Drive, the API Prototype is
public native int UniKeyVenderLogon(short[] pHandle, int[] pPassword1, int[] pPassword2, int[] pPassword3, int[] pPassword4);
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 |
|---|---|
| pHandle | [out] Dongle 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_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
public int UniKey_Logoff(short[] pHandle);
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
public int UniKey_Get_Type(short[] pHandle, int[] type);
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
public int UniKey_Read_Memory(short[] pHandle, short[] pStartAddress, short[] pBufferLength, byte[] pBuffer);
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 |
| pBufferLength | [in] Number of bytes to read |
| pBuffer | [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
public int UniKey_Write_Memory(short[] pHandle, short[] pStartAddress, short[] pBufferLength, byte[] pBuffer);
Description
Write data into memory; this API needs to be called after logging on to a UniKey dongle.
Parameters
| Parameter | Description |
|---|---|
| pHandle | [in] Dongle handle |
| pStartAddress | [in] Offset of the memory |
| pBufferLength | [in] Number of bytes to write |
| pBuffer | [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
public int UniKey_Random(short[] pHandle , short[] pReturn1, short[] pReturn2, short[] pReturn3, short[] pReturn4);
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 used 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
public int UniKey_Seed(short[] pHandle, int[] pSeed, short[] pReturn1, short[] pReturn2, short[] pReturn3, short[] pReturn4);
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
public int UniKey_Write_SoftID(short[] pHandle, int[] pSoftID);
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
public int UniKey_Read_SoftID(short[] pHandle, int[] pSoftID);
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
public int UniKey_Set_Module(short[] pHandle, short[] pModule, short[] pValue, short[] pDecrease);
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
long UniKey_Get_Module(WORD* pHandle, WORD* pModule, WORD* pValue);
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
public int UniKey_Check_Module(short[] pHandle, short[] pModule, short[] pValue, short[] pDecrease);
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
public int UniKey_Write_Arithmetic(short[] pHandle, short[] pStartAddress, byte[] pBuffer);
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
public int UniKey_Calculate1(short[] pHandle, int[] pStartAddress, int[] pModule, short[] pRegA, short[] pRegB, short[] pRegC, short[] pRegD);
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
public int UniKey_Calculate2(short[] pHandle, int[] pStartAddress, int[] pSeed, short[] pRegA, short[] pRegB, short[] pRegC, short[] pRegD);
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
public int UniKey_Calculate3(short[] pHandle, int[] pStartAddress, int[] pModule, short[] pRegA, short[] pRegB, short[] pRegC, short[] pRegD);
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
public int UniKey_Module_Decrease(short[] pHandle, short[] pModule);
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
public int UniKey_Generate_New_Password(short[] pHandle, int[] pSeed, short[] pPassword1, short[] pPassword2, short[] pPassword3, short[] pPassword4);
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!
- 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.
Generate a New Encryption Key
API Prototype
public int UniKey_Generate_Key(short[] pHandle, short[] pKeyNumber);
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 |
- This function will delete the original key in the key storage, and generate a new key.
- The data encrypted by the old key cannot be decrypted by the new key.
- Each key is 128-bits long.
Generate a New Encryption Key via Seed
API Prototype
long UniKey_Generate_Key_Via_Seed(WORD* pHandle, DWORD* pKeyNumber, WORD pSeed1, WORD pSeed2, WORD pSeed3, WORD pSeed4);
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 |
- 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.
Encrypt the Buffer with a Specific Encryption Key
API Prototype
public int UniKey_Encrypt(short[] pHandle, int[] pBufferLength, int[] pKeyNumber, byte[] pBuffer);
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
public int UniKey_Decrypt(short[] pHandle, int[] pBufferLength, int[] pKeyNumber, byte[] buffer);
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
public int UniKey_MD5(short[] pHandle, int[] pBufferLength, byte[] pBuffer);
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
public int UniKey_Read_UpdateTag(short[] pHandle, int[] pUpdateTag);
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
public int UniKey_Write_UpdateTag(short[] pHandle, int[] pUpdateTag);
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
public int UniKey_Get_Version(short[] pHandle, int[] pVersion);
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
public int UniKey_Get_Time(short[] pHandle, int[] pYear, int[] pMonth, short[] pDay, short[] pHour, short[] pMinute, short[] pSecond);
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
public int UniKey_Set_Time(short[] pHandle, int[] pYear, int[] pMonth, short[] pDay, short[] pHour, short[] pMinute, short[] pSecond);
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
public int UniKey_Set_Time_Now(short[] pHandle);
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
public int UniKey_Erase_Time_Module(short[] pHandle, int[] pModule);
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
public int UniKey_Set_Time_Module_Start_Time(short[] pHandle, int[] pModule, short[] pYear, short[] pMonth, short[] pDay, short[] pHour);
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
public int UniKey_Set_Time_Module_Start_Time_Now(short[] pHandle, int[] pModule);
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
public int UniKey_Set_Time_Module_Start_Time_Now_PC(short[] pHandle, int[] pModule);
Description
Set a real time module’s start time as the current time of the host computer.
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 End Time
API Prototype
public int UniKey_Set_Time_Module_End_Time(short[] pHandle, int[] pModule, short[] pYear, short[] pMonth, short[] pDay, short[] pHour);
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
public int UniKey_Set_Time_Module_Duration(short[] pHandle, int[] pModule, int[] pDays, short[] pHours);
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
public int UniKey_Check_Time_Module(short[] pHandle, int[] pModule, short[] pYear, short[] pMonth, short[] pDay, short[] pHour);
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
public int UniKey_Check_Time_Module_Now(short[] pHandle, int[] pModule, int[] pRemainDays, short[] pRemainHours);
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
public int UniKey_Check_Time_Module_Now_PC(short[] pHandle, int[] pModule, int[] pRemainDays, short[] pRemainHours);
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
public native int UniKeyFSInit(short[] pHandle, int[] pw1, int[] pw2, int[] pw3, int[] pw4);
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
public native int UniKeyFSFormat(short[] pHandle);
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
public native int UniKeyFSCreateFile(short[] pHandle, byte[] fileName);
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
public native int UniKeyFSDeleteFile(short[] pHandle, byte[] fileName);
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
public native int UniKeyFSFileOpen(short[] pHandle, byte[] fileName);
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
public native int UniKeyFSGetFreeSize(short[] pHandle, int[] usedsize, int[] freesize);
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
public native int UniKeyFSFileModifyData(short[] pHandle, int[] offset, int[] len, byte[] buffer);
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
public native int UniKeyFSFileAppendData(short[] pHandle, int[] len, byte[] buffer);
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
public native int UniKeyFSFileReadData(short[] pHandle, int[] offset, int[] len, byte[] buffer);
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
public native int UniKeyFSFileOpen(short[] pHandle, byte[] fileName);
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
public native int UniKeyFSFileGetList(short[] pHandle, int[] filecount, byte[] filelist);
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
public native int UniKeyFSFileGetSize(short[] pHandle, int[] filesize);
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
public native int UniKeyFSSetPassWord(short[] pHandle, int[] pw1, int[] pw2, int[] pw3, int[] pw4);
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
public native int UniKeyRSAGenerateKey(short[] pHandle, int[] KeyIndex);
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
public native int UniKeyDESGenerateKey(short[] pHandle, int[] KeyIndex);
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
public native int UniKeyRSAGetKeyCounts(short[] pHandle, int[] KeyIndex);
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
public native int UniKeyDESGetKeyCounts(short[] pHandle, int[] KeyIndex);
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
public native int UniKeyRSAEncrypt(short[] pHandle, short[] pKeyNumber, int[] len, byte[] buffer);
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
public native int UniKeyRSADecrypt(short[] pHandle, short[] pKeyNumber, int[] len, byte[] buffer);
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
public native int UniKeyDES1Encrypt(short[] pHandle, short[] mode, short[] pKeyNumber, int[] len, byte[] buffer);
public native int UniKeyDES1Decrypt(short[] pHandle, short[] mode, short[] pKeyNumber, int[] len, byte[] buffer);
public native int UniKeyDES2Encrypt(short[] pHandle, short[] mode, short[] pKeyNumber, int[] len, byte[] buffer);
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
public native int UniKeyDES2Decrypt(short[] pHandle, short[] mode, short[] pKeyNumber, int[] len, byte[] buffer);
public native int UniKeyDES3Encrypt(short[] pHandle, short[] mode, short[] pKeyNumber, int[] len, byte[] buffer);
public native int UniKeyDES3Decrypt(short[] pHandle, short[] mode, short[] pKeyNumber, int[] len, byte[] buffer);
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
public native int UniKeyRSADelKey(short[] pHandle, short[] KeyIndex);
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
public native int UniKeyDESDelKey(short[] pHandle, short[] KeyIndex);
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
public native int UniKeyGetUserCount(short[] pHandle, short[] count);
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
public native int UnikeyLogonSingle(short[] pHandle, int[] pPassword1, int[] pPassword2, int[] pPassword3, int[] pPassword4);
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
public int UniKey_Logoff(short[] pHandle);
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
public native int UniKeyLogoffAll(short[] pHandle);
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 |