UniKey API Reference for C Language: Difference between revisions

From SecuTech Wiki
Jump to navigationJump to search
Joseph (talk | contribs)
No edit summary
Joseph (talk | contribs)
No edit summary
Line 4: Line 4:


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


'''API Prototype'''<br>
'''API Prototype'''<br>
<code>
<code>long UniKey_Find( WORD* pHandle ,<br>DWORD* pSetting1 , <br>DWORD* pSetting2 )&nbsp;;</code>
long UniKey_Find( WORD* pHandle ,<br>DWORD* pSetting1 , <br>DWORD* pSetting2 )&nbsp;;  
</code>


'''Description'''<br>
'''Description'''<br>
Check if a specific UniKey is attached to the USB port. This is the first API to start a UniKey session.  
Check if a specific UniKey is attached to the USB port. This is the first API to start a UniKey session.  


'''Parameters'''
'''Parameters'''<br>
<br>Parameter Meaning<br>*pHandle [out] Dongle handle <br>*pSetting1 *[in] Working Mode (UniKey PRO only), useless for UniKey STD<br>[out] Hardware ID<br>*pSetting2 *[in] Access Mode (UniKey PRO only), useless for UniKey STD(UniKey PRO only)<br>[out] Number of dongle attached , useless for UniKey STD  
<table border="1">
<tr>
<td>Parameter</td>
<td>Meaning</td>
</tr>
<tr>
<td>*pHandle</td>
<td>[out] Dongle handle </td>
</tr>
<tr>
<td>*pSetting1</td>
<td>*[in] Working Mode (UniKey PRO only), useless for UniKey STD</td>
</tr>
<tr>
<td></td>
<td>[out] Hardware ID</td>
</tr>
<tr>
<td>*pSetting2</td>
<td>*[in] Access Mode (UniKey PRO only), useless for UniKey STD(UniKey PRO only)</td>
</tr>
<tr>
<td></td>
<td>[out] Number of dongle attached , useless for UniKey STD</td>
</tr>
</table>


'''Return values'''
'''Return values'''<br>
<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NO_UNIEKY 200 No UniKey dongle  
<table border="1">
<tr>
<td>Marco</td>
<td>Value</td>
<td>Meaning</td>
</tr>
<tr>
<td>SUCCESS</td>
<td>0</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_UNIKEY_NO_UNIEKY</td>
<td>200</td>
<td>No UniKey dongle</td>
</tr>
</table>


<br>
<br>
Line 25: Line 62:
== Find the Next UniKey dongle  ==
== Find the Next UniKey dongle  ==


&nbsp;
'''API Prototype'''<br>
<code>Long UniKey_Find_Next( WORD* pHandle ,<br>DWORD* pSetting1 , <br>DWORD* pSetting2 )&nbsp;;</code>


API Prototype<br>Long UniKey_Find_Next( WORD* pHandle ,<br>DWORD* pSetting1 , <br>DWORD* pSetting2 )&nbsp;;
'''Description'''<br>
 
Check if another UniKey is attached to the USB port.  
Description<br>Check if another UniKey is attached to the USB port.  


Parameters<br>Parameter Meaning<br>*pHandle [out] Dongle handle <br>*pSetting1 *[in] Working Mode (UniKey PRO only), useless for UniKey STD<br>[out] Hardware ID<br>*pSetting2 *[in] Access Mode (UniKey PRO only), useless for UniKey STD(UniKeyPro only)<br>[out] Number of dongle attached , useless for UniKey STD  
'''Parameters'''<br>
<table border="1">
<tr>
<td>Parameter</td>
<td>Meaning</td>
</tr>
<tr>
<td>*pHandle</td>
<td>[out] Dongle handle </td>
</tr>
<tr>
<td>*pSetting1</td>
<td>*[in] Working Mode (UniKey PRO only), useless for UniKey STD</td>
</tr>
<tr>
<td></td>
<td>[out] Hardware ID</td>
</tr>
<tr>
<td>*pSetting2</td>
<td>*[in] Access Mode (UniKey PRO only), useless for UniKey STD(UniKeyPro only)</td>
</tr>
<tr>
<td></td>
<td>[out] Number of dongle attached , useless for UniKey STD</td>
</tr>
</table>


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NOMORE 214 No more dongle<br>ERROR_UNIKEY_NEED_FIND 215 No Find before Find_Next
'''Return values'''<br>
<table border="1">
<tr>
<td>Marco</td>
<td>Value</td>
</tr>
<tr>
<td>SUCCESS</td>
<td>0</td>
</tr>
<tr>
<td>ERROR_UNIKEY_NOMORE </td>
<td>214</td>
</tr>
<tr>
<td>ERROR_UNIKEY_NEED_FIND</td>
<td>215</td>
</tr>
</table>


== <br>Logon UniKey Dongle  ==
== <br>Logon UniKey Dongle  ==
Line 39: Line 120:
&nbsp;
&nbsp;


API Prototype<br>long UniKey_User_Logon( WORD* pHandle , <br>WORD* pPassword1 , <br>WORD* pPassword2 )&nbsp;;<br>-------------------------------------------------------------------------------------------  
'''API Prototype'''<br><code>long UniKey_User_Logon( WORD* pHandle , <br>WORD* pPassword1 , <br>WORD* pPassword2 )&nbsp;;</code><br>-------------------------------------------------------------------------------------------  


For UniKey Drive, the API Prototype is UniKey_User_Logon (WORD* pHandle, DWORD* pPassword1, DWORD* pPassword2); <br>-------------------------------------------------------------------------------------------<br>Description <br>Logon a UniKey dongle with specified passwords. This API should be called in the released software in order to improve security.  
For UniKey Drive, the '''API Prototype''' is UniKey_User_Logon (WORD* pHandle, DWORD* pPassword1, DWORD* pPassword2); <br>-------------------------------------------------------------------------------------------<br>'''Description''' <br>Logon a UniKey dongle with specified passwords. This API should be called in the released software in order to improve security.  


Parameters<br>Parameter Meaning<br>*pPassword1 [in]Password 1<br>*pPassword2 [in]Password 2<br>*pHandle [out] Dongle handle  
'''Parameters'''<br>
<table border="1">
<tr>
<td>Parameter</td>
<td>Meaning</td>
</tr>
<tr>
<td>*pPassword1</td>
<td>[in]Password 1</td>
</tr>
<tr>
<td>*pPassword2</td>
<td>[in]Password 2</td>
</tr>
<tr>
<td>*pHandle</td>
<td>[out] Dongle handle</td>
</tr>
</table>


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NOT_FOUND 200 No UniKey dongle<br>ERROR_UNIKEY_INVALID_PASSWORD 201 UniKey dongle found, but Basic passwords are incorrect<br>ERROR_UNIKEY_INVALID_PASSWORD_OR_ID 202 Wrong password or UniKey HID <br>
'''Return values'''<br>
<table border="1">
<tr>
<td>Marco</td>
<td>Value</td>
<td>Meaning</td>
</tr>
<tr>
<td>SUCCESS</td>
<td>0</td>
<td>Success</td>
</tr>
<tr>
<td>ERROR_UNIKEY_NOT_FOUND</td>
<td>200</td>
<td>No UniKey dongle</td>
</tr>
<tr>
<td>ERROR_UNIKEY_INVALID_PASSWORD</td>
<td>201</td>
<td>UniKey dongle found, but Basic passwords are incorrect</td>
</tr>
<tr>
<td>ERROR_UNIKEY_INVALID_PASSWORD_OR_ID</td>
<td>202</td>
<td>Wrong password or UniKey HID</td>
</tr>
</table>


<br>
<br>
Line 51: Line 177:
== Logon UniKey Dongle in vendor mode  ==
== Logon UniKey Dongle in vendor mode  ==


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


Description <br>Logon a UniKey dongle in vendor mode with specified passwords. This API helps software vendors to logon the UniKey dongle in vendor mode, and get the full permission to UniKey dongle.<br>---------------------------------------------------------------------------------------------------<br>We do NOT advise you to enclose this API in the final released software. This API is only for software vendor’s usage.<br>--------------------------------------------------------------------------------------------------<br>If password3 or password4 is wrong while password1 and password2 is correct, the dongle is also logged on in user mode automatically. <br>---------------------------------------------------------------------------------------------------  
'''Description''' <br>Logon a UniKey dongle in vendor mode with specified passwords. This API helps software vendors to logon the UniKey dongle in vendor mode, and get the full permission to UniKey dongle.<br>---------------------------------------------------------------------------------------------------<br>We do NOT advise you to enclose this API in the final released software. This API is only for software vendor’s usage.<br>--------------------------------------------------------------------------------------------------<br>If password3 or password4 is wrong while password1 and password2 is correct, the dongle is also logged on in user mode automatically. <br>---------------------------------------------------------------------------------------------------  


Parameters<br>Parameter Meaning<br>*pPassword1 [in]Password 1<br>*pPassword2 [in]Password 2<br>*pPassword3 [in]Password 3<br>*pPassword4 [in]Password 4<br>*pHandle [out] Dongle handle  
'''Parameters'''<br>
<table border="1">
<tr>
<td>Parameter</td>
<td>Meaning</td>
</tr>
<tr>
<td>*pPassword1</td>
<td>[in]Password 1</td>
</tr>
<tr>
<td>*pPassword2</td>
<td>[in]Password 2</td>
</tr>
<tr>
<td>*pPassword3</td>
<td>[in]Password 3</td>
</tr>
<tr>
<td>*pPassword4</td>
<td>[in]Password 4</td>
</tr>
<tr>
<td>*pHandle</td>
<td>[out] Dongle handle</td>
</tr>
</table>


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NOT_FOUND 200 No UniKey dongle<br>ERROR_UNIKEY_INVALID_PASSWORD 201 Found UniKey dongle, but Basic passwords are incorrect<br>ERROR_UNIKEY_INVALID_PASSWORD_OR_ID 202 Wrong password or UniKey HID  
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NOT_FOUND 200 No UniKey dongle<br>ERROR_UNIKEY_INVALID_PASSWORD 201 Found UniKey dongle, but Basic passwords are incorrect<br>ERROR_UNIKEY_INVALID_PASSWORD_OR_ID 202 Wrong password or UniKey HID  


<br>
<br>
Line 63: Line 215:
== Logoff the UniKey dongle  ==
== Logoff the UniKey dongle  ==


<br>API Prototype<br>long UniKey_Logoff( WORD* pHandle )&nbsp;;  
<br>'''API Prototype'''<br><code>long UniKey_Logoff( WORD* pHandle )&nbsp;;</code>


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


Parameters<br>Parameter Meaning<br>*pHandle [in] Dongle handle  
'''Parameters'''<br>
<table border="1">
<tr>
<td>Parameter</td>
<td>Meaning</td>
</tr>
<tr>
<td>*pHandle</td>
<td>[in] Dongle handle</td>
</tr>
</table>


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NOT_FOUND 200 No UniKey dongle<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle  
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NOT_FOUND 200 No UniKey dongle<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle  


== <br>Get the UniKey dongle 's Type  ==
== <br>Get the UniKey dongle 's Type  ==


<br>API Prototype<br>long UniKey_Get_Type( WORD* pHandle , <br>DWORD* type )&nbsp;;  
<br>'''API Prototype'''<br><code>long UniKey_Get_Type( WORD* pHandle , <br>DWORD* type )&nbsp;;</code>


Description<br>UniKey_Get_Type can help you get the type of the UniKey dongle.<br>The return value of type will indicate the type of the UniKey dongle.<br>UNIKEY_TYPE_TIME 101<br>UNIKEY_TYPE_PRO 102<br>UNIKEY_TYPE_STD 103  
'''Description'''<br>UniKey_Get_Type can help you get the type of the UniKey dongle.<br>The return value of type will indicate the type of the UniKey dongle.<br>UNIKEY_TYPE_TIME 101<br>UNIKEY_TYPE_PRO 102<br>UNIKEY_TYPE_STD 103  


Parameters<br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*type [out] The value indicating the type of your UniKey dongle  
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*type [out] The value indicating the type of your UniKey dongle  


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_GET_TYPE 237 UniKey Get Type Error  
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_GET_TYPE 237 UniKey Get Type Error  


<br>
<br>
Line 85: Line 247:
== Read UniKey dongle memory  ==
== Read UniKey dongle memory  ==


<br>API Prototype<br>long UniKey_Read_Memory( WORD* pHandle ,<br>WORD* pStartAddress ,<br>WORD* pBufferLength , <br>BYTE* pBuffer )&nbsp;;  
<br>'''API Prototype'''<br><code>long UniKey_Read_Memory( WORD* pHandle ,<br>WORD* pStartAddress ,<br>WORD* pBufferLength , <br>BYTE* pBuffer )&nbsp;;</code>


<br>
<br>


Description <br>Read the contents of the Memory. This API needs to be called after logon of a UniKey dongle.  
'''Description''' <br>Read the contents of the Memory. This API needs to be called after logon of a UniKey dongle.  


Parameters<br>Parameter Meaning<br>*handle*pHandle [in] Dongle handle<br>*pStartAddress [in] Offset of Memory<br>*pBufferLenght [in] Number of bytes to read<br>pBbuffer [out] Pointer to the buffer containing the data to be read  
'''Parameters'''<br>Parameter Meaning<br>*handle*pHandle [in] Dongle handle<br>*pStartAddress [in] Offset of Memory<br>*pBufferLenght [in] Number of bytes to read<br>pBbuffer [out] Pointer to the buffer containing the data to be read  


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address or length is wrong<br>ERROR_UNIKEY_READ_MEMORY 207 Read Error<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_NEED_OPEN 215 No logon dongle before operating dongle  
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address or length is wrong<br>ERROR_UNIKEY_READ_MEMORY 207 Read Error<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_NEED_OPEN 215 No logon dongle before operating dongle  


<br>
<br>
Line 99: Line 261:
== Write to UniKey dongle memory  ==
== Write to UniKey dongle memory  ==


<br>API Prototype<br>long UniKey_Write_Memory( WORD* pHandle ,<br>WORD* pStartAddress , <br>WORD* pBufferLength , <br>BYTE* pBuffer )&nbsp;;  
<br>'''API Prototype'''<br><code>long UniKey_Write_Memory( WORD* pHandle ,<br>WORD* pStartAddress , <br>WORD* pBufferLength , <br>BYTE* pBuffer )&nbsp;;</code>


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


Parameters<br>Parameter Meaning<br>*handle*pHandle [in] Dongle handle<br>*pStartAddress [in] Offset of the memory<br>*pBufferLength [in] Number of bytes to write<br>pBbuffer [in] Pointer to the buffer containing the data to be written  
'''Parameters'''<br>Parameter Meaning<br>*handle*pHandle [in] Dongle handle<br>*pStartAddress [in] Offset of the memory<br>*pBufferLength [in] Number of bytes to write<br>pBbuffer [in] Pointer to the buffer containing the data to be written  


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address or length is wrong<br>ERROR_UNIKEY_WRITE_MEMORY 207 Write Error<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_VERIFY_ADV_PASSWORD 223 Advanced passwords (password3 and passowrd4) not verified  
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address or length is wrong<br>ERROR_UNIKEY_WRITE_MEMORY 207 Write Error<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_VERIFY_ADV_PASSWORD 223 Advanced passwords (password3 and passowrd4) not verified  


----
----


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


UniKey_Read_Memory and UniKey_Write_Memory provide basic reading and writing functions to the dongle. You can store general information via such functions. And various levels of security can be applied too.<br>--------------------------------------------------------------------------------------------------  
UniKey_Read_Memory and UniKey_Write_Memory provide basic reading and writing functions to the dongle. You can store general information via such functions. And various levels of security can be applied too.<br>--------------------------------------------------------------------------------------------------  
Line 115: Line 277:
== <br>Generate a Random Number  ==
== <br>Generate a Random Number  ==


<br>API Prototype<br>long UniKey_Random( WORD* pHandle ,<br>WORD* pReturn1 ,<br>WORD* pReturn2 ,<br>WORD* pReturn3 , <br>WORD* pReturn4 )&nbsp;;  
<br>'''API Prototype'''<br><code>long UniKey_Random( WORD* pHandle ,<br>WORD* pReturn1 ,<br>WORD* pReturn2 ,<br>WORD* pReturn3 , <br>WORD* pReturn4 )&nbsp;;</code>


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


Parameters<br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pReturn1 [out] Random number<br>*pReturn2 [out] Random number<br>*pReturn3 [out] Random number<br>*pReturn4 [out] Random number  
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pReturn1 [out] Random number<br>*pReturn2 [out] Random number<br>*pReturn3 [out] Random number<br>*pReturn4 [out] Random number  


Return values <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_RANDOM 209 Random number Error  
'''Return values''' <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_RANDOM 209 Random number Error  


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


== <br>Generate Seed Code Return Values ==
== <br>Generate Seed Code '''Return values''' ==


<br>API Prototype<br>long UniKey_Seed( WORD* pHandle ,<br>DWORD* pSeed ,<br>WORD* pReturn1 , <br>WORD* pReturn2 , <br>WORD* pReturn3 , <br>WORD* pReturn4 )&nbsp;;  
<br>'''API Prototype'''<br><code>long UniKey_Seed( WORD* pHandle ,<br>DWORD* pSeed ,<br>WORD* pReturn1 , <br>WORD* pReturn2 , <br>WORD* pReturn3 , <br>WORD* pReturn4 )&nbsp;;</code>


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


Parameters<br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pSeed [in] Seed Code<br>*pReturn1 [out] Return Code 1<br>*pReturn2 [out] Return Code 2<br>*pReturn3 [out] Return Code 3<br>*pReturn4 [out] Return Code 4  
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pSeed [in] Seed Code<br>*pReturn1 [out] Return Code 1<br>*pReturn2 [out] Return Code 2<br>*pReturn3 [out] Return Code 3<br>*pReturn4 [out] Return Code 4  


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_SEED 210 Seed code Error  
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_SEED 210 Seed code Error  


----
----
Line 143: Line 305:
== <br>Write the Soft ID  ==
== <br>Write the Soft ID  ==


<br>API Prototype<br>long UniKey_Write_SoftID( WORD* pHandle , <br>DWORD* pSoftID )&nbsp;;  
<br>'''API Prototype'''<br><code>long UniKey_Write_SoftID( WORD* pHandle , <br>DWORD* pSoftID )&nbsp;;</code>


Description <br>Write the vendor defined SoftID.  
'''Description''' <br>Write the vendor defined SoftID.  


Parameters <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pSoftID [in] Soft ID  
'''Parameters''' <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pSoftID [in] Soft ID  


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_SET_SOFTID 203 Set UniKey ID wrong<br>---------------------------------------------------------------------------------------------------  
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_SET_SOFTID 203 Set UniKey ID wrong<br>---------------------------------------------------------------------------------------------------  


You need to verify all 4 passwords (vendor mode) to write the SoftID.<br>---------------------------------------------------------------------------------------------------  
You need to verify all 4 passwords (vendor mode) to write the SoftID.<br>---------------------------------------------------------------------------------------------------  


Read Soft ID <br>API Prototype<br>long UniKey_Read_SoftID( WORD* pHandle ,<br>DWORD* pSoftID )&nbsp;;  
Read Soft ID <br>'''API Prototype'''<br><code>long UniKey_Read_SoftID( WORD* pHandle ,<br>DWORD* pSoftID )&nbsp;;</code>


Description<br>Read the user defined SoftID.  
'''Description'''<br>Read the user defined SoftID.  


Parameters <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pSoftID [out] Soft ID  
'''Parameters''' <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pSoftID [out] Soft ID  


Return values <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle  
'''Return values''' <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle  


----
----
Line 167: Line 329:
== Set a UniKey License module  ==
== Set a UniKey License module  ==


<br>API Prototype<br>long UniKey_Set_Module( WORD* pHandle ,<br>WORD* pModule ,<br>WORD* pValue , <br>WORD* pDecrease )&nbsp;;  
<br>'''API Prototype'''<br><code>long UniKey_Set_Module( WORD* pHandle ,<br>WORD* pModule ,<br>WORD* pValue , <br>WORD* pDecrease )&nbsp;;</code>


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


Parameters <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pModule [in] License module Number<br>*pValue [in] License module Unit Value<br>*pDecrease [in] Decreasing attribute. If decreasing is allowed (1 = allowed, 0 = not allowed)  
'''Parameters''' <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pModule [in] License module Number<br>*pValue [in] License module Unit Value<br>*pDecrease [in] Decreasing attribute. If decreasing is allowed (1 = allowed, 0 = not allowed)  


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 202 Read/Write address or length is wrong<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_MODULE 216 License module error  
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 202 Read/Write address or length is wrong<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_MODULE 216 License module error  


----
----
Line 187: Line 349:
== Get a UniKey License module  ==
== Get a UniKey License module  ==


<br>API Prototype<br>long UniKey_Get_Module( WORD* pHandle ,<br>WORD* pModule , <br>WORD* pValue )&nbsp;;  
<br>'''API Prototype'''<br><code>long UniKey_Get_Module( WORD* pHandle ,<br>WORD* pModule , <br>WORD* pValue )&nbsp;;</code>


Description<br>Get a value from a specific UniKey license module.  
'''Description'''<br>Get a value from a specific UniKey license module.  


Parameters <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pModule [in] Module Number<br>*pValue [out] Return the value in module  
'''Parameters''' <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pModule [in] Module Number<br>*pValue [out] Return the value in module  


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 202 Read/Write address or length is wrong<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_MODULE 216 License module error  
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 202 Read/Write address or length is wrong<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_MODULE 216 License module error  


----
----
Line 203: Line 365:
== Check a UniKey License module  ==
== Check a UniKey License module  ==


<br>API Prototype<br>long UniKey_Check_Module( WORD* pHandle ,<br>WORD* pModule ,<br>WORD* pValue , <br>WORD* pDecrease )&nbsp;;  
<br>'''API Prototype'''<br><code>long UniKey_Check_Module( WORD* pHandle ,<br>WORD* pModule ,<br>WORD* pValue , <br>WORD* pDecrease )&nbsp;;</code>


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


Parameters <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pModule [in] License module Number<br>*pValue [out] Validity (1 = license module value is not zero)<br>*pDecrease [out] Decrement attribute (1 = license module can be decreased)  
'''Parameters''' <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pModule [in] License module Number<br>*pValue [out] Validity (1 = license module value is not zero)<br>*pDecrease [out] Decrement attribute (1 = license module can be decreased)  


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 202 Read/Write address or length is wrong<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_MODULE 216 License module error<br>---------------------------------------------------------------------------------------------------<br>A successful operation will result in “*pValue” with value from the Validity (1 = license module value is not zero), and “*pDecrease” with the value from the Decrement attribute (1 = license module can be decreased).  
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 202 Read/Write address or length is wrong<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_MODULE 216 License module error<br>---------------------------------------------------------------------------------------------------<br>A successful operation will result in “*pValue” with value from the Validity (1 = license module value is not zero), and “*pDecrease” with the value from the Decrement attribute (1 = license module can be decreased).  


The value of a license module cannot be read out directly and it is invisible to end users. <br>---------------------------------------------------------------------------------------------------<br>---------------------------------------------------------------------------------------------------<br>UniKey_Set_Module and UniKey_Check_Module provide an easy mean to implement software limitation. For example, if you want to set a software can be only executed 3 times, so you can call UNIKEY_SET_MODULE to set a license module (let us say license module 0) as 3. And when each execution, we decrease the license module, if the license module is invalid (zero), we stop the software. Apart from this, we can implement a module-selling model with help of license module functions. For example, the software has four function modules, A, B, C and D. And we can map the function modules to the license module in the UniKey dongle. Let us say the function module A is mapped to license module 0, B to 1, C to 2 and D to 3. If a customer only buys function A, B, you just need to enable the license module 0 and 1, and leave 2 and 3 as zero. So only function module A and B can be executed. If the customer buys more function, you can use UniKey remote update function to update the dongle remotely. <br>--------------------------------------------------------------------------------------------------  
The value of a license module cannot be read out directly and it is invisible to end users. <br>---------------------------------------------------------------------------------------------------<br>---------------------------------------------------------------------------------------------------<br>UniKey_Set_Module and UniKey_Check_Module provide an easy mean to implement software limitation. For example, if you want to set a software can be only executed 3 times, so you can call UNIKEY_SET_MODULE to set a license module (let us say license module 0) as 3. And when each execution, we decrease the license module, if the license module is invalid (zero), we stop the software. Apart from this, we can implement a module-selling model with help of license module functions. For example, the software has four function modules, A, B, C and D. And we can map the function modules to the license module in the UniKey dongle. Let us say the function module A is mapped to license module 0, B to 1, C to 2 and D to 3. If a customer only buys function A, B, you just need to enable the license module 0 and 1, and leave 2 and 3 as zero. So only function module A and B can be executed. If the customer buys more function, you can use UniKey remote update function to update the dongle remotely. <br>--------------------------------------------------------------------------------------------------  
Line 215: Line 377:
== <br>Write Arithmetic  ==
== <br>Write Arithmetic  ==


<br>API Prototype<br>long UniKey_Write_Arithmetic( WORD* pHandle , <br>WORD* pStartAddress , <br>BYTE* pBuffer )&nbsp;;  
<br>'''API Prototype'''<br><code>long UniKey_Write_Arithmetic( WORD* pHandle , <br>WORD* pStartAddress , <br>BYTE* pBuffer )&nbsp;;</code>


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


Parameters <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pStartAddress [in] Offset of first instruction <br>*pBuffer [in] Pointer to the algorithm command string  
'''Parameters''' <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pStartAddress [in] Offset of first instruction <br>*pBuffer [in] Pointer to the algorithm command string  


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address or length is wrong<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_AR_BAD_COMMAND 217 Arithmetic instruction Error<br>ERROR_UNIKEY_AR_UNKNOWN_OPCODE 218 Arithmetic operator Error<br>ERROR_UNIKEY_AR_WRON_GBEGIN 219 Const number can't use on first arithmetic instruction<br>ERROR_UNIKEY_AR_WRONG_END 220 Const number can't use on last arithmetic instruction<br>ERROR_UNIKEY_AR_VALUE_OVERFLOW 221 Const number &gt; 63<br>
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address or length is wrong<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_AR_BAD_COMMAND 217 Arithmetic instruction Error<br>ERROR_UNIKEY_AR_UNKNOWN_OPCODE 218 Arithmetic operator Error<br>ERROR_UNIKEY_AR_WRON_GBEGIN 219 Const number can't use on first arithmetic instruction<br>ERROR_UNIKEY_AR_WRONG_END 220 Const number can't use on last arithmetic instruction<br>ERROR_UNIKEY_AR_VALUE_OVERFLOW 221 Const number &gt; 63<br>


<br>---------------------------------------------------------------------------------------------------<br>A successful operation will result in the user-defined algorithm populated with the algorithm command string from the buffer. <br>--------------------------------------------------------------------------------------------------  
<br>---------------------------------------------------------------------------------------------------<br>A successful operation will result in the user-defined algorithm populated with the algorithm command string from the buffer. <br>--------------------------------------------------------------------------------------------------  
Line 231: Line 393:
== <br>User-defined Algorithm Calculate 1  ==
== <br>User-defined Algorithm Calculate 1  ==


<br>API Prototype<br>long UniKey_Calculate1( WORD* pHandle , <br>DWORD* pStartAddress , <br>DWORD* pModule ,<br>WORD* pRegA , <br>WORD* pRegB , <br>WORD* pRegC ,<br>WORD* pRegD )&nbsp;;  
<br>'''API Prototype'''<br><code>long UniKey_Calculate1( WORD* pHandle , <br>DWORD* pStartAddress , <br>DWORD* pModule ,<br>WORD* pRegA , <br>WORD* pRegB , <br>WORD* pRegC ,<br>WORD* pRegD )&nbsp;;</code>


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


Parameters <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pStartAddress [in] Start point of calculation<br>*pModule [in] License module number<br>*p1 [in, out] Register A<br>*p2 [in, out] Register B<br>*p3 [in, out] Register C<br>*p4 [in, out] Register D  
'''Parameters''' <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pStartAddress [in] Start point of calculation<br>*pModule [in] License module number<br>*p1 [in, out] Register A<br>*p2 [in, out] Register B<br>*p3 [in, out] Register C<br>*p4 [in, out] Register D  


Return value<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address or length is wrong<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_AR_BAD_COMMAND 217 Arithmetic instruction Error<br>ERROR_UNIKEY_AR_UNKNOWN_OPCODE 218 Arithmetic operator Error<br>ERROR_UNIKEY_AR_WRON_GBEGIN 219 Const number can't use on first arithmetic instruction<br>ERROR_UNIKEY_AR_WRONG_END 220 Const number can't use on last arithmetic instruction<br>ERROR_UNIKEY_AR_VALUE_OVERFLOW 221 Const number &gt; 63  
Return value<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address or length is wrong<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_AR_BAD_COMMAND 217 Arithmetic instruction Error<br>ERROR_UNIKEY_AR_UNKNOWN_OPCODE 218 Arithmetic operator Error<br>ERROR_UNIKEY_AR_WRON_GBEGIN 219 Const number can't use on first arithmetic instruction<br>ERROR_UNIKEY_AR_WRONG_END 220 Const number can't use on last arithmetic instruction<br>ERROR_UNIKEY_AR_VALUE_OVERFLOW 221 Const number &gt; 63  
Line 245: Line 407:
== <br>User-defined Algorithm Calculate 2  ==
== <br>User-defined Algorithm Calculate 2  ==


<br>API Prototype<br>long UniKey_Calculate2( WORD* pHandle ,<br>DWORD* pStartAddress ,<br>DWORD* pSeed ,<br>WORD* pRegA ,<br>WORD* pRegB , <br>WORD* pRegC , <br>WORD* pRegD )&nbsp;;  
<br>'''API Prototype'''<br><code>long UniKey_Calculate2( WORD* pHandle ,<br>DWORD* pStartAddress ,<br>DWORD* pSeed ,<br>WORD* pRegA ,<br>WORD* pRegB , <br>WORD* pRegC , <br>WORD* pRegD )&nbsp;;</code>


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


Parameters<br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pStartAddress [in] Start point of calculation<br>*pSeed [in] Seed Code (32-bit)<br>*p1 [in, out] Register A<br>*p2 [in, out] Register B<br>*p3 [in, out] Register C<br>*p4 [in, out] Register D  
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pStartAddress [in] Start point of calculation<br>*pSeed [in] Seed Code (32-bit)<br>*p1 [in, out] Register A<br>*p2 [in, out] Register B<br>*p3 [in, out] Register C<br>*p4 [in, out] Register D  


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address or length is wrong<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_AR_BAD_COMMAND 217 Arithmetic instruction Error<br>ERROR_UNIKEY_AR_UNKNOWN_OPCODE 218 Arithmetic operator Error<br>ERROR_UNIKEY_AR_WRON_GBEGIN 219 Const number can't use on first arithmetic instruction<br>ERROR_UNIKEY_AR_WRONG_END 220 Const number can't use on last arithmetic instruction<br>ERROR_UNIKEY_AR_VALUE_OVERFLOW 221 Const number &gt; 63  
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address or length is wrong<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_AR_BAD_COMMAND 217 Arithmetic instruction Error<br>ERROR_UNIKEY_AR_UNKNOWN_OPCODE 218 Arithmetic operator Error<br>ERROR_UNIKEY_AR_WRON_GBEGIN 219 Const number can't use on first arithmetic instruction<br>ERROR_UNIKEY_AR_WRONG_END 220 Const number can't use on last arithmetic instruction<br>ERROR_UNIKEY_AR_VALUE_OVERFLOW 221 Const number &gt; 63  


----
----


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


Internal Register Meaning<br>E Seed Result 1<br>F Seed Result 2<br>G Seed Result 3<br>H Seed Result 4  
Internal Register Meaning<br>E Seed Result 1<br>F Seed Result 2<br>G Seed Result 3<br>H Seed Result 4  
Line 263: Line 425:
== User-defined Algorithm Calculate 3  ==
== User-defined Algorithm Calculate 3  ==


<br>API Prototype<br>long UniKey_Calculate3( WORD* pHandle ,<br>DWORD* pStartAddress ,<br>DWORD* pModule , <br>WORD* pRegA , <br>WORD* pRegB , <br>WORD* pRegC , <br>WORD* pRegD )&nbsp;;  
<br>'''API Prototype'''<br><code>long UniKey_Calculate3( WORD* pHandle ,<br>DWORD* pStartAddress ,<br>DWORD* pModule , <br>WORD* pRegA , <br>WORD* pRegB , <br>WORD* pRegC , <br>WORD* pRegD )&nbsp;;</code>


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


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


Return value <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address or length is wrong<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_AR_BAD_COMMAND 217 Arithmetic instruction Error<br>ERROR_UNIKEY_AR_UNKNOWN_OPCODE 218 Arithmetic operator Error<br>ERROR_UNIKEY_AR_WRON_GBEGIN 219 Const number can't use on first arithmetic instruction<br>ERROR_UNIKEY_AR_WRONG_END 220 Const number can't use on last arithmetic instruction<br>ERROR_UNIKEY_AR_VALUE_OVERFLOW 221 Const number &gt; 63  
Return value <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address or length is wrong<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_AR_BAD_COMMAND 217 Arithmetic instruction Error<br>ERROR_UNIKEY_AR_UNKNOWN_OPCODE 218 Arithmetic operator Error<br>ERROR_UNIKEY_AR_WRON_GBEGIN 219 Const number can't use on first arithmetic instruction<br>ERROR_UNIKEY_AR_WRONG_END 220 Const number can't use on last arithmetic instruction<br>ERROR_UNIKEY_AR_VALUE_OVERFLOW 221 Const number &gt; 63  
Line 285: Line 447:
== Decrease A License module ==
== Decrease A License module ==


<br>API Prototype<br>long UniKey_Module_Decrease( WORD* pHandle ,<br>WORD* pModule ) ;
<br>'''API Prototype'''<br><code>long UniKey_Module_Decrease( WORD* pHandle ,<br>WORD* pModule ) ;</code>


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


Parameters <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pModule [in] License module number
'''Parameters''' <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pModule [in] License module number


Return values <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address or length is wrong<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_MODULE 216 License module error
'''Return values''' <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address or length is wrong<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_MODULE 216 License module error


---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
Line 299: Line 461:
== <br>Generate a New Password ==
== <br>Generate a New Password ==


<br>API Prototype<br>long UniKey_Generate_New_Password( WORD* pHandle ,<br>DWORD* pSeed ,<br>WORD* pPassword1 , <br>WORD* pPassword2 , <br>WORD* pPassword3 , <br>WORD* pPassword4 ) ;
<br>'''API Prototype'''<br><code>long UniKey_Generate_New_Password( WORD* pHandle ,<br>DWORD* pSeed ,<br>WORD* pPassword1 , <br>WORD* pPassword2 , <br>WORD* pPassword3 , <br>WORD* pPassword4 ) ;</code>


Description<br>Generate a new password via a seed code; the mapping from the seed code to the password is only one way. Without the seed, you cannot generate the same password.
'''Description'''<br>Generate a new password via a seed code; the mapping from the seed code to the password is only one way. Without the seed, you cannot generate the same password.


Parameters <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pSeed [in] Seed Code (32-bit)<br>*pPassword1 [out] New password 1<br>*pPassword2 [out] New password 2<br>*pPassword3 [out] New password 3<br>*pPassword4 [out] New password 4
'''Parameters''' <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pSeed [in] Seed Code (32-bit)<br>*pPassword1 [out] New password 1<br>*pPassword2 [out] New password 2<br>*pPassword3 [out] New password 3<br>*pPassword4 [out] New password 4


Return values <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_VERIFY_ADV_PASSWORD 223 Advanced passwords (password3 and passowrd4) not verified<br>ERROR_UNIKEY_GENERATE_NEW_PASSWORD 225 Generate new password Error
'''Return values''' <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_VERIFY_ADV_PASSWORD 223 Advanced passwords (password3 and passowrd4) not verified<br>ERROR_UNIKEY_GENERATE_NEW_PASSWORD 225 Generate new password Error


---------------------------------------------------------------------------------------------------<br>A file recording the new SEED and PASSWORDs will be created in the working path, and help the software vendor to recall everything. The passwords can be distributed to ordinary developers! <br>---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------<br>A file recording the new SEED and PASSWORDs will be created in the working path, and help the software vendor to recall everything. The passwords can be distributed to ordinary developers! <br>---------------------------------------------------------------------------------------------------
Line 313: Line 475:
== <br>Generate a New Encryption Key ==
== <br>Generate a New Encryption Key ==


<br>API Prototype<br>long UniKey_Generate_Key( WORD* pHandle , <br>DWORD* pKeyNumber ) ;
<br>'''API Prototype'''<br><code>long UniKey_Generate_Key( WORD* pHandle , <br>DWORD* pKeyNumber ) ;</code>


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


Parameters <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pKeyNumber [in] Key Storage Number
'''Parameters''' <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pKeyNumber [in] Key Storage Number


Return values <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_INVALID_KEY_STORE 224 Wrong key storage number
'''Return values''' <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_INVALID_KEY_STORE 224 Wrong key storage number


---------------------------------------------------------------------------------------------------<br>1. This function will delete the original key in the key storage, and generate a new key. <br>2. The data encrypted by the old key cannot be decrypted by the new key. <br>3. Each key is 128-bit long. <br>----------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------<br>1. This function will delete the original key in the key storage, and generate a new key. <br>2. The data encrypted by the old key cannot be decrypted by the new key. <br>3. Each key is 128-bit long. <br>----------------------------------------------------------------------------------------------------
Line 325: Line 487:
== <br>Generate a New Encryption Key Via Seed ==
== <br>Generate a New Encryption Key Via Seed ==


<br>API Prototype<br>long UniKey_Generate_Key_Via_Seed( WORD* pHandle , <br>DWORD* pKeyNumber , <br>WORD pSeed1 , <br>WORD pSeed2 , <br>WORD pSeed3 , <br>WORD pSeed4 ) ;
<br>'''API Prototype'''<br><code>long UniKey_Generate_Key_Via_Seed( WORD* pHandle , <br>DWORD* pKeyNumber , <br>WORD pSeed1 , <br>WORD pSeed2 , <br>WORD pSeed3 , <br>WORD pSeed4 ) ;</code>


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


Parameters <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pKeyNumber [in] Key Storage Number<br>*pSeed1 [in] Seed1<br>*pSeed2 [in] Seed2<br>*pSeed3 [in] Seed3<br>*pSeed4 [in] Seed4
'''Parameters''' <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pKeyNumber [in] Key Storage Number<br>*pSeed1 [in] Seed1<br>*pSeed2 [in] Seed2<br>*pSeed3 [in] Seed3<br>*pSeed4 [in] Seed4


Return values <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_INVALID_KEY_STORE 224 Wrong key storage number
'''Return values''' <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_INVALID_KEY_STORE 224 Wrong key storage number




Line 341: Line 503:
== Encrypt the Buffer with a Specific Encryption Key ==
== Encrypt the Buffer with a Specific Encryption Key ==


<br>API Prototype<br>long UniKey_Encrypt( WORD* pHandle ,<br>DWORD* pBufferLength ,<br>DWORD* pKeyNumber , <br>BYTE* pBuffer ) ;
<br>'''API Prototype'''<br><code>long UniKey_Encrypt( WORD* pHandle ,<br>DWORD* pBufferLength ,<br>DWORD* pKeyNumber , <br>BYTE* pBuffer ) ;</code>


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


Parameters<br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pBufferLength [in] Number of bytes to encrypt<br>*pKeyNumber [in] Key Storage Number<br>*pBuffer [in] Pointer to the data to be encrypted<br>[out] Pointer to the encrypted data
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pBufferLength [in] Number of bytes to encrypt<br>*pKeyNumber [in] Key Storage Number<br>*pBuffer [in] Pointer to the data to be encrypted<br>[out] Pointer to the encrypted data


Return values <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_INVALID_KEY_STORE 224 Wrong key storage number<br>ERROR_UNIKEY_ENCRYPT_FAILED 228 Encrypt data error
'''Return values''' <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_INVALID_KEY_STORE 224 Wrong key storage number<br>ERROR_UNIKEY_ENCRYPT_FAILED 228 Encrypt data error




Line 357: Line 519:
== <br>Decrypt the Buffer with a Specific Encryption Key ==
== <br>Decrypt the Buffer with a Specific Encryption Key ==


<br>API Prototype<br>long UniKey_Decrypt( WORD* pHandle , <br>DWORD* pBufferLength , <br>DWORD* pKeyNumber , <br>BYTE* pBuffer ) ;
<br>'''API Prototype'''<br><code>long UniKey_Decrypt( WORD* pHandle , <br>DWORD* pBufferLength , <br>DWORD* pKeyNumber , <br>BYTE* pBuffer ) ;</code>


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


Parameters <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pBufferLength [in] Number of bytes to encrypt<br>*pKeyNumber [in] Key Storage Number<br>*pBuffer [in] Pointer to the data to be decrypted<br>[out] Pointer to the decrypted data
'''Parameters''' <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pBufferLength [in] Number of bytes to encrypt<br>*pKeyNumber [in] Key Storage Number<br>*pBuffer [in] Pointer to the data to be decrypted<br>[out] Pointer to the decrypted data


Return values <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 Not logon dongle before operating dongle<br>ERROR_UNIKEY_INVALID_KEY_STORE 224 Wrong key storage number<br>ERROR_UNIKEY_DECRYPT_FAILED 229 Decrypt data error
'''Return values''' <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 Not logon dongle before operating dongle<br>ERROR_UNIKEY_INVALID_KEY_STORE 224 Wrong key storage number<br>ERROR_UNIKEY_DECRYPT_FAILED 229 Decrypt data error


---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
Line 377: Line 539:
&nbsp;
&nbsp;


API Prototype<br>long UniKey_MD5( WORD* pHandle , <br>DWORD* pBufferLength ,<br>DWORD* pType , <br>BYTE* pBuffer ) ;
'''API Prototype'''<br><code>long UniKey_MD5( WORD* pHandle , <br>DWORD* pBufferLength ,<br>DWORD* pType , <br>BYTE* pBuffer ) ;</code>


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


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


Return values <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
'''Return values''' <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle


&nbsp;
&nbsp;
Line 389: Line 551:
== Read UpdateTag  ==
== Read UpdateTag  ==


<br>API Prototype<br>long UniKey_Read_UpdateTag( WORD* pHandle ,<br>DWORD* pUpdateTag ) ;
<br>'''API Prototype'''<br><code>long UniKey_Read_UpdateTag( WORD* pHandle ,<br>DWORD* pUpdateTag ) ;</code>


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


Parameters <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pUpdateTag [out] UpdateTag
'''Parameters''' <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pUpdateTag [out] UpdateTag


Return values <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_READ_UPDATETAG 226 Read UpdateTag error
'''Return values''' <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_READ_UPDATETAG 226 Read UpdateTag error


&nbsp;
&nbsp;
Line 401: Line 563:
== Write UpdateTag ==
== Write UpdateTag ==


<br>API Prototype<br>long UniKey_Write_UpdateTag( WORD* pHandle , <br>DWORD* pUpdateTag ) ;
<br>'''API Prototype'''<br><code>long UniKey_Write_UpdateTag( WORD* pHandle , <br>DWORD* pUpdateTag ) ;</code>


Description<br>Write UpdateTag into a specific dongle.
'''Description'''<br>Write UpdateTag into a specific dongle.


Parameters <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pUpdateTag [in] UpdateTag
'''Parameters''' <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pUpdateTag [in] UpdateTag


Return values <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_WRITE_UPDATETAG 227 Write UpdateTag error
'''Return values''' <br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_WRITE_UPDATETAG 227 Write UpdateTag error


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


API Prototype<br>long UniKey_Get_Version( WORD* pHandle ,<br>DWORD* pVersion ) ;
'''API Prototype'''<br><code>long UniKey_Get_Version( WORD* pHandle ,<br>DWORD* pVersion ) ;</code>


Description <br>Get the current UniKey library version.
'''Description''' <br>Get the current UniKey library version.


Parameters<br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pVersion [out] UniKey library version<br>
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pVersion [out] UniKey library version<br>




Line 425: Line 587:
== Get UniKey Time  ==
== Get UniKey Time  ==


<br>API Prototype<br>long UniKey_Get_Time( WORD* pHandle , <br>DWORD* pYear ,<br>DWORD* pMonth ,<br>WORD* pDay , <br>WORD* pHour , <br>WORD* pMinute ,<br>WORD* pSecond ) ;
<br>'''API Prototype'''<br><code>long UniKey_Get_Time( WORD* pHandle , <br>DWORD* pYear ,<br>DWORD* pMonth ,<br>WORD* pDay , <br>WORD* pHour , <br>WORD* pMinute ,<br>WORD* pSecond ) ;</code>


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


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


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle<br>ERROR_UNIKEY_READ_TIME 230 Get UniKey time error
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle<br>ERROR_UNIKEY_READ_TIME 230 Get UniKey time error


---------------------------------------------------------------------------------------------------<br>We can call UniKey_Check_Time to check if the UniKey dongle is a real time dongle. If we get ERROR_UNIKEY_READ_TIME, then the dongle is not a real time dongle. <br>---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------<br>We can call UniKey_Check_Time to check if the UniKey dongle is a real time dongle. If we get ERROR_UNIKEY_READ_TIME, then the dongle is not a real time dongle. <br>---------------------------------------------------------------------------------------------------
Line 437: Line 599:
== <br>Set UniKey Time  ==
== <br>Set UniKey Time  ==


<br>API Prototype<br>long UniKey_Set_Time( WORD* pHandle ,<br>DWORD* pYear , <br>DWORD* pMonth , <br>WORD* pDay , <br>WORD* pHour , <br>WORD* pMinute , <br>WORD* pSecond ) ;
<br>'''API Prototype'''<br><code>long UniKey_Set_Time( WORD* pHandle ,<br>DWORD* pYear , <br>DWORD* pMonth , <br>WORD* pDay , <br>WORD* pHour , <br>WORD* pMinute , <br>WORD* pSecond ) ;</code>


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


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


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle<br>ERROR_UNIKEY_READ_TIME 230 Get UniKey time error<br>---------------------------------------------------------------------------------------------------
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle<br>ERROR_UNIKEY_READ_TIME 230 Get UniKey time error<br>---------------------------------------------------------------------------------------------------


You need verify all the 4 passwords (vendor mode) to set the time for UniKey internal clock. <br>-------------------------------------------------------------------------------------------------
You need verify all the 4 passwords (vendor mode) to set the time for UniKey internal clock. <br>-------------------------------------------------------------------------------------------------
Line 451: Line 613:
== Set UniKey Time by Host’s Clock  ==
== Set UniKey Time by Host’s Clock  ==


<br>API Prototype<br>long UniKey_Set_Time_Now( WORD* pHandle ) ;
<br>'''API Prototype'''<br><code>long UniKey_Set_Time_Now( WORD* pHandle ) ;</code>


Description <br>Set UniKey Time’s real time clock’s time by the host computer’s clock.<br><br>Parameters<br>Parameter Meaning<br>*pHandle [in] Dongle handle
'''Description''' <br>Set UniKey Time’s real time clock’s time by the host computer’s clock.<br><br>'''Parameters'''<br>Parameter Meaning<br>*pHandle [in] Dongle handle


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle<br>ERROR_UNIKEY_WRITE_TIME 231 Write UniKey time error
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle<br>ERROR_UNIKEY_WRITE_TIME 231 Write UniKey time error




Line 461: Line 623:
== Erase Real Time Module  ==
== Erase Real Time Module  ==


<br>API Prototype<br>long UniKey_Erase_Time_Module( WORD* pHandle ,<br>DWORD* pModule ) ;
<br>'''API Prototype'''<br><code>long UniKey_Erase_Time_Module( WORD* pHandle ,<br>DWORD* pModule ) ;</code>


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


Parameters<br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pModule [in] Real time module number (0-15)
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pModule [in] Real time module number (0-15)


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle<br>ERROR_UNIKEY_WRITE_TIME 231 Write UniKey time error
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle<br>ERROR_UNIKEY_WRITE_TIME 231 Write UniKey time error




Line 477: Line 639:
== Set a Real Time Module’s Start Time ==
== Set a Real Time Module’s Start Time ==


<br>API Prototype<br>long UniKey_Set_Time_Module_Start_Time( WORD* pHandle , <br>DWORD* pModule , <br>WORD* pYear , <br>WORD* pMonth , <br>WORD* pDay , <br>WORD* pHour ) ;
<br>'''API Prototype'''<br><code>long UniKey_Set_Time_Module_Start_Time( WORD* pHandle , <br>DWORD* pModule , <br>WORD* pYear , <br>WORD* pMonth , <br>WORD* pDay , <br>WORD* pHour ) ;</code>


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


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


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle<br>ERROR_UNIKEY_WRITE_TIME_MODULE 231 Write time module error<br>ERROR_UNIKEY_TIME_MODULE_NOT_NULL 234 The real time module is not null, this error is returned when write once flag is set
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle<br>ERROR_UNIKEY_WRITE_TIME_MODULE 231 Write time module error<br>ERROR_UNIKEY_TIME_MODULE_NOT_NULL 234 The real time module is not null, this error is returned when write once flag is set


---------------------------------------------------------------------------------------------------<br>Write Once flag is very useful for setting the Start for a real time module. If write once flag is set, only the first START_TIME call can set the start time for a module. All the later START_TIME will not work and return an ERROR_UNIKEY_TIME_MODULE_NOT_NULL. Software vendors may use this flag when the start for a module is not clear. <br>---------------------------------------------------------------------------------------------------<br>
---------------------------------------------------------------------------------------------------<br>Write Once flag is very useful for setting the Start for a real time module. If write once flag is set, only the first START_TIME call can set the start time for a module. All the later START_TIME will not work and return an ERROR_UNIKEY_TIME_MODULE_NOT_NULL. Software vendors may use this flag when the start for a module is not clear. <br>---------------------------------------------------------------------------------------------------<br>
Line 491: Line 653:
== Set a Real Time Module’s Start Time by UniKey Dongle’s Clock  ==
== Set a Real Time Module’s Start Time by UniKey Dongle’s Clock  ==


<br>API Prototype<br>Long UniKey_Set_Time_Module_Start_Time_Now( WORD* pHandle ,<br>DWORD* pModule);
<br>'''API Prototype'''<br><code>Long UniKey_Set_Time_Module_Start_Time_Now( WORD* pHandle ,<br>DWORD* pModule);</code>


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


Parameters<br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pModule [in] Real time module number (0-15)
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pModule [in] Real time module number (0-15)


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle<br>ERROR_UNIKEY_WRITE_TIME_MODULE 231 Write time module error<br>ERROR_UNIKEY_TIME_MODULE_NOT_NULL 234 The real time module is not null, this error is returned when write once flag is set
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle<br>ERROR_UNIKEY_WRITE_TIME_MODULE 231 Write time module error<br>ERROR_UNIKEY_TIME_MODULE_NOT_NULL 234 The real time module is not null, this error is returned when write once flag is set


&nbsp;
&nbsp;
Line 503: Line 665:
== Set a Real Time Module’s Start Time by Host’s Clock ==
== Set a Real Time Module’s Start Time by Host’s Clock ==


<br>API Prototype<br>long UniKey_Set_Time_Module_Start_Time_Now_PC( <br>WORD* pHandle , <br>DWORD* pModule ) ;
<br>'''API Prototype'''<br><code>long UniKey_Set_Time_Module_Start_Time_Now_PC( <br>WORD* pHandle , <br>DWORD* pModule ) ;</code>


Description <br>Set a real time module’s start time as the now time in host computer.
'''Description''' <br>Set a real time module’s start time as the now time in host computer.


Parameters<br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pHandle [in] Real time module number (0-15)
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pHandle [in] Real time module number (0-15)


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle<br>ERROR_UNIKEY_WRITE_TIME_MODULE 231 Write time module error<br>ERROR_UNIKEY_TIME_MODULE_NOT_NULL 234 The real time module is not null, this error is returned when write once flag is set
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle<br>ERROR_UNIKEY_WRITE_TIME_MODULE 231 Write time module error<br>ERROR_UNIKEY_TIME_MODULE_NOT_NULL 234 The real time module is not null, this error is returned when write once flag is set


&nbsp;
&nbsp;
Line 515: Line 677:
== Set a Real Time Module’s End Time ==
== Set a Real Time Module’s End Time ==


<br>API Prototype<br>long UniKey_Set_Time_Module_End_Time( WORD* pHandle , <br>DWORD* pModule ,<br>WORD* pYear , <br>WORD* pMonth , <br>WORD* pDay , <br>WORD* pHour ) ;
<br>'''API Prototype'''<br><code>long UniKey_Set_Time_Module_End_Time( WORD* pHandle , <br>DWORD* pModule ,<br>WORD* pYear , <br>WORD* pMonth , <br>WORD* pDay , <br>WORD* pHour ) ;</code>


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


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


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle<br>ERROR_UNIKEY_WRITE_TIME_MODULE 231 Write time module error
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle<br>ERROR_UNIKEY_WRITE_TIME_MODULE 231 Write time module error


&nbsp;
&nbsp;
Line 527: Line 689:
== Set a Real Time Module’s Duration ==
== Set a Real Time Module’s Duration ==


<br>API Prototype<br>long UniKey_Set_Time_Module_Duration( WORD* pHandle , <br>DWORD* pModule ,<br>DWORD* pDay , <br>WORD* pHour ) ;
<br>'''API Prototype'''<br><code>long UniKey_Set_Time_Module_Duration( WORD* pHandle , <br>DWORD* pModule ,<br>DWORD* pDay , <br>WORD* pHour ) ;</code>


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


Parameters<br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pModule [in] Real time module number (0-15)<br>*pDay [in] Number of days<br>*pHour [in] Number of hours
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pModule [in] Real time module number (0-15)<br>*pDay [in] Number of days<br>*pHour [in] Number of hours


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle<br>ERROR_UNIKEY_WRITE_TIME_MODULE 231 Write time module error
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle<br>ERROR_UNIKEY_WRITE_TIME_MODULE 231 Write time module error




Line 545: Line 707:
== Check a UniKey Time License module ==
== Check a UniKey Time License module ==


<br>API Prototype<br>long UniKey_Check_Time_Module( WORD* pHandle ,<br>DWORD* pModule ,<br>DWORD* pRemainDays ,<br>WORD* pYear ,<br>WORD* pMonth ,<br>WORD* pDay , <br>WORD* pHour ) ;
<br>'''API Prototype'''<br><code>long UniKey_Check_Time_Module( WORD* pHandle ,<br>DWORD* pModule ,<br>DWORD* pRemainDays ,<br>WORD* pYear ,<br>WORD* pMonth ,<br>WORD* pDay , <br>WORD* pHour ) ;</code>


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


Parameters <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pModule [in] License module Number<br>*pRemainDays [out] Remain days<br>*pYear [in] Year (input or output is 10 ,which refers to 2010)<br>*pMonth [in] Month<br>*pDay [in] Day<br>*pHour [in] Hour
'''Parameters''' <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pModule [in] License module Number<br>*pRemainDays [out] Remain days<br>*pYear [in] Year (input or output is 10 ,which refers to 2010)<br>*pMonth [in] Month<br>*pDay [in] Day<br>*pHour [in] Hour


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 202 Read/Write address or length is wrong<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_MODULE 216 License module error
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 202 Read/Write address or length is wrong<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_MODULE 216 License module error


---------------------------------------------------------------------------------------------------<br>A successful operation will result in “*pValue” with value from the Validity (1 = license module value is not zero). <br>The value of a license module cannot be read out directly and it is invisible to end users. <br>---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------<br>A successful operation will result in “*pValue” with value from the Validity (1 = license module value is not zero). <br>The value of a license module cannot be read out directly and it is invisible to end users. <br>---------------------------------------------------------------------------------------------------
Line 559: Line 721:
== Check a UniKey Time License module Now ==
== Check a UniKey Time License module Now ==


<br>API Prototype<br>long UniKey_Check_Time_Module_Now( WORD* pHandle ,<br>DWORD* pModule ,<br>DWORD* pRemainDays ,<br>WORD* pRemainHours ) ;
<br>'''API Prototype'''<br><code>long UniKey_Check_Time_Module_Now( WORD* pHandle ,<br>DWORD* pModule ,<br>DWORD* pRemainDays ,<br>WORD* pRemainHours ) ;</code>


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


Parameters <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pModule [in] License module Number<br>*pRemainDays [out] Remain days<br>*pRemainHours [out] Remain hours
'''Parameters''' <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pModule [in] License module Number<br>*pRemainDays [out] Remain days<br>*pRemainHours [out] Remain hours


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 202 Read/Write address or length is wrong<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_MODULE 216 License module error
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 202 Read/Write address or length is wrong<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_MODULE 216 License module error


---------------------------------------------------------------------------------------------------<br>A successful operation will result in “*pValue” with value from the Validity (1 = license module value is not zero).  
---------------------------------------------------------------------------------------------------<br>A successful operation will result in “*pValue” with value from the Validity (1 = license module value is not zero).  
Line 573: Line 735:
== <br>Check a UniKey Time License module Now PC ==
== <br>Check a UniKey Time License module Now PC ==


<br>API Prototype<br>long UniKey_Check_Time_Module_Now_PC( WORD* pHandle ,<br>DWORD* pModule ,<br>DWORD* pRemainDays ,<br>WORD* pRemainHours) ;
<br>'''API Prototype'''<br><code>long UniKey_Check_Time_Module_Now_PC( WORD* pHandle ,<br>DWORD* pModule ,<br>DWORD* pRemainDays ,<br>WORD* pRemainHours) ;</code>


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


Parameters <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pModule [in] License module Number<br>*pRemainDays [out] Remain days<br>*pRemainHours [out] Remain hours
'''Parameters''' <br>Parameter Meaning<br>*pHandle [in] Dongle handle<br>*pModule [in] License module Number<br>*pRemainDays [out] Remain days<br>*pRemainHours [out] Remain hours


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 202 Read/Write address or length is wrong<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_MODULE 216 License module error
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 202 Read/Write address or length is wrong<br>ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle<br>ERROR_UNIKEY_MODULE 216 License module error


---------------------------------------------------------------------------------------------------<br>A successful operation will result in “*pValue” with value from the Validity (1 = license module value is not zero).  
---------------------------------------------------------------------------------------------------<br>A successful operation will result in “*pValue” with value from the Validity (1 = license module value is not zero).  
Line 589: Line 751:
== Initialize File System ==
== Initialize File System ==


<br>API Prototype<br>long __stdcall UniKey_FS_Init( WORD* handle ,<br>DWORD* PW1 ,<br>DWORD* PW2 ,<br>DWORD* PW3 ,<br>DWORD* PW4 ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_FS_Init( WORD* handle ,<br>DWORD* PW1 ,<br>DWORD* PW2 ,<br>DWORD* PW3 ,<br>DWORD* PW4 ) ;</code>


Description<br>The user needs to call this function to initialize the file system before calling other file system related functions. The password of the file system is 12345678.
'''Description'''<br>The user needs to call this function to initialize the file system before calling other file system related functions. The password of the file system is 12345678.


Parameters<br>Parameter Meaning<br>*pHandle [in]Device handle<br>* pPassword1 [in]Password1<br>* pPassword2 [in]Password2<br>* pPassword3 [in]Password3<br>* pPassword4 [in]Password4
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in]Device handle<br>* pPassword1 [in]Password1<br>* pPassword2 [in]Password2<br>* pPassword3 [in]Password3<br>* pPassword4 [in]Password4


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_PASSWORD_OR_ID 202 Invalid password or ID results in an error.
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_PASSWORD_OR_ID 202 Invalid password or ID results in an error.




Line 601: Line 763:
== Format the file system ==
== Format the file system ==


<br>API Prototype<br>long __stdcall UniKey_FS_Format( WORD* handle ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_FS_Format( WORD* handle ) ;</code>


Description<br>Format the file system.
'''Description'''<br>Format the file system.


Parameters<br>Parameter Meaning<br>*pHandle [in]Device handle
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in]Device handle


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_FS_FILE_EXIST 245 File already existed.
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_FS_FILE_EXIST 245 File already existed.


---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
Line 615: Line 777:
== <br>Create files ==
== <br>Create files ==


<br>API Prototype<br>long __stdcall UniKey_FS_CreateFile( WORD* handle ,<br>BYTE* filename ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_FS_CreateFile( WORD* handle ,<br>BYTE* filename ) ;</code>


Description<br>Create files.  
'''Description'''<br>Create files.  


Parameters<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*filename [in/out]Input/Output file name<br>---------------------------------------------------------------------------------------------------
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*filename [in/out]Input/Output file name<br>---------------------------------------------------------------------------------------------------


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


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_FS_ERR_SYS_UNINIT 246 The file system is not initialized.<br>ERROR_UNIKEY_FS_FILE_NAME 240 Wrong or invalid file name<br>ERROR_UNIKEY_FS_FILE_EXIST 245 The file already existed.
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_FS_ERR_SYS_UNINIT 246 The file system is not initialized.<br>ERROR_UNIKEY_FS_FILE_NAME 240 Wrong or invalid file name<br>ERROR_UNIKEY_FS_FILE_EXIST 245 The file already existed.




Line 629: Line 791:
== Delete files ==
== Delete files ==


<br>API Prototype<br>long __stdcall UniKey_FS_DeleteFile( WORD* handle , <br>BYTE* filename ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_FS_DeleteFile( WORD* handle , <br>BYTE* filename ) ;</code>


Description<br>Delete files.  
'''Description'''<br>Delete files.  


Parameters<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*filename [in/out]Input/Output file name
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*filename [in/out]Input/Output file name


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_FS_ERR_SYS_UNINIT 246 The file is not yet initialized.<br>ERROR_UNIKEY_FS_NO_FILE 241 No such file name.
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_FS_ERR_SYS_UNINIT 246 The file is not yet initialized.<br>ERROR_UNIKEY_FS_NO_FILE 241 No such file name.




Line 641: Line 803:
== Open files ==
== Open files ==


<br>API Prototype<br>long __stdcall UniKey_FS_File_Open( WORD* handle ,<br>BYTE* filename ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_FS_File_Open( WORD* handle ,<br>BYTE* filename ) ;</code>


Description<br>Open files.  
'''Description'''<br>Open files.  


Parameters<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*filename [in]Input/Output file name
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*filename [in]Input/Output file name


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_FS_NO_FILE 241 No such file name
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_FS_NO_FILE 241 No such file name




Line 653: Line 815:
== Get system space ==
== Get system space ==


<br>API Prototype<br>long __stdcall UniKey_FS_Get_Free_Size( WORD* handle , <br>DWORD* usedsize ,<br>DWORD* freesize ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_FS_Get_Free_Size( WORD* handle , <br>DWORD* usedsize ,<br>DWORD* freesize ) ;</code>


Description<br>Get system space.  
'''Description'''<br>Get system space.  


Parameters<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*usedsize [out]System space size which has already been used<br>*freesize [out]System space size that hasn’t been used
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*usedsize [out]System space size which has already been used<br>*freesize [out]System space size that hasn’t been used


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success




Line 665: Line 827:
== Modify file data ==
== Modify file data ==


<br>API Prototype<br>long __stdcall UniKey_FS_File_Modify_Data( <br>WORD* handle , <br>DWORD* offset ,<br>DWORD* len ,<br>BYTE* buffer ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_FS_File_Modify_Data( <br>WORD* handle , <br>DWORD* offset ,<br>DWORD* len ,<br>BYTE* buffer ) ;</code>


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


Parameters<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*offset [in]Address to be modified<br>*len [in]Modify the data length<br>*buffer [in]Modify the data
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*offset [in]Address to be modified<br>*len [in]Modify the data length<br>*buffer [in]Modify the data


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_FS_ERR_OPEN_FILE 247 The file to be modified hasn’t been opened yet.<br>ERROR_UNIKEY_FS_FILE_OFFSET 242 Offset of file error
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_FS_ERR_OPEN_FILE 247 The file to be modified hasn’t been opened yet.<br>ERROR_UNIKEY_FS_FILE_OFFSET 242 Offset of file error




Line 677: Line 839:
== Append data to the end-of-file ==
== Append data to the end-of-file ==


<br>API Prototype<br>long __stdcall UniKey_FS_File_Append_Data( WORD* handle ,<br>DWORD* len ,<br>BYTE* buffer ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_FS_File_Append_Data( WORD* handle ,<br>DWORD* len ,<br>BYTE* buffer ) ;</code>


Description<br>Append data to the end-of-file.
'''Description'''<br>Append data to the end-of-file.


Parameters<br>Parameter Meaning<br>*len [in]The length of the append data<br>*buffer [in]Append data
'''Parameters'''<br>Parameter Meaning<br>*len [in]The length of the append data<br>*buffer [in]Append data


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_FS_NO_MEMORY 244 Not enough free memory
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_FS_NO_MEMORY 244 Not enough free memory




Line 689: Line 851:
== Read file data ==
== Read file data ==


<br>API Prototype<br>long__stdcall UniKey_FS_File_Read_Data( WORD* handle ,<br>DWORD * offset ,<br>DWORD* len ,<br>BYTE* buffer ) ;
<br>'''API Prototype'''<br><code>long__stdcall UniKey_FS_File_Read_Data( WORD* handle ,<br>DWORD * offset ,<br>DWORD* len ,<br>BYTE* buffer ) ;</code>


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


Parameters<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*offset [in]Read address<br>*len [in]Read the data length<br>*buffer [out]Read data
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*offset [in]Read address<br>*len [in]Read the data length<br>*buffer [out]Read data


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_FS_ERR_OPEN_FILE 247 The file to be modified is not opened yet.<br>ERROR_UNIKEY_FS_FILE_OFFSET 242 Offset of file error.
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_FS_ERR_OPEN_FILE 247 The file to be modified is not opened yet.<br>ERROR_UNIKEY_FS_FILE_OFFSET 242 Offset of file error.


== <br>Close files ==
== <br>Close files ==


<br>API Prototype<br>long __stdcall UniKey_FS_File_Close( WORD* handle , <br>BYTE* filename ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_FS_File_Close( WORD* handle , <br>BYTE* filename ) ;</code>


Description<br>Close files.
'''Description'''<br>Close files.


Parameters<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*filename [in]file name<br>*len [in]Read the data length<br>*buffer [in]Read data
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*filename [in]file name<br>*len [in]Read the data length<br>*buffer [in]Read data


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success




Line 711: Line 873:
== Get file list ==
== Get file list ==


<br>API Prototype<br>long __stdcall UniKey_FS_File_Get_List( WORD* handle ,<br>DWORD* filecount ,<br>BYTE* filelist ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_FS_File_Get_List( WORD* handle ,<br>DWORD* filecount ,<br>BYTE* filelist ) ;</code>


Description<br>Get file list.
'''Description'''<br>Get file list.


Parameters<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*filecount [out]The number of files<br>*filelist [out]  
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*filecount [out]The number of files<br>*filelist [out]  


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success




Line 723: Line 885:
== Get the file size ==
== Get the file size ==


<br>API Prototype<br>long __stdcall UniKey_FS_File_Get_Size(WORD* handle, <br>DWORD* filesize);
<br>'''API Prototype'''<br><code>long __stdcall UniKey_FS_File_Get_Size(WORD* handle, <br>DWORD* filesize);</code>


<br>Description<br>Get the file size.
<br>'''Description'''<br>Get the file size.


Parameters<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*filesize [out]The size of the file
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*filesize [out]The size of the file


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success




Line 735: Line 897:
== Users reset file system password ==
== Users reset file system password ==


<br>API Prototype<br>long __stdcall UniKey_FS_Set_Password( WORD* handle ,<br>DWORD* PW1 ,<br>DWORD* PW2 ,<br>DWORD* PW3 ,<br>DWORD* PW4 ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_FS_Set_Password( WORD* handle ,<br>DWORD* PW1 ,<br>DWORD* PW2 ,<br>DWORD* PW3 ,<br>DWORD* PW4 ) ;</code>


Description<br>Users reset the password to the file system.
'''Description'''<br>Users reset the password to the file system.


Parameters<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*pPassword1 [in]Password 1<br>*pPassword2 [in]Password 2<br>*pPassword3 [in]Password 3<br>*pPassword4 [in]Password 4
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*pPassword1 [in]Password 1<br>*pPassword2 [in]Password 2<br>*pPassword3 [in]Password 3<br>*pPassword4 [in]Password 4


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_GENERATE_NEW_PASSWORD 225 Fail to generate new password.<br><br>---------------------------------------------------------------------------------------------------
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_GENERATE_NEW_PASSWORD 225 Fail to generate new password.<br><br>---------------------------------------------------------------------------------------------------


The reset of the password can only be successfully done after initializing the file system successfully.<br>-----------------------------------------------------------------------------------------------------
The reset of the password can only be successfully done after initializing the file system successfully.<br>-----------------------------------------------------------------------------------------------------
Line 749: Line 911:
== Generate a RSA Key ==
== Generate a RSA Key ==


<br>API Prototype<br>long __stdcall UniKey_RSA_Generate_Key( WORD* handle ,<br>WORD* KeyIndex ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_RSA_Generate_Key( WORD* handle ,<br>WORD* KeyIndex ) ;</code>


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


Parameters<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*KeyIndex [in]Return the handle generated Key<br>` <br>Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_KEY_INDEX 239 The handle of the key is invalid.
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*KeyIndex [in]Return the handle generated Key<br>` <br>'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_KEY_INDEX 239 The handle of the key is invalid.




Line 759: Line 921:
== Generate a DES Key ==
== Generate a DES Key ==


<br>API Prototype<br>long __stdcall UniKey_DES_Generate_Key( WORD* handle ,<br>DWORD* KeyIndex ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_DES_Generate_Key( WORD* handle ,<br>DWORD* KeyIndex ) ;</code>


Description<br>Calling this function can generate a DES key.
'''Description'''<br>Calling this function can generate a DES key.


Parameters<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*KeyIndex [in]Return the handle generated Key
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*KeyIndex [in]Return the handle generated Key


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_KEY_INDEX 239 The handle of the key is invalid.
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_KEY_INDEX 239 The handle of the key is invalid.




Line 771: Line 933:
== RSA Get key counts generated  ==
== RSA Get key counts generated  ==


<br>API Prototype<br>long __stdcall UniKey_RSA_Get_Key_Counts( WORD* handle ,<br>DWORD* KeyIndexs ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_RSA_Get_Key_Counts( WORD* handle ,<br>DWORD* KeyIndexs ) ;</code>


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


Parameters<br>Parameter Meaning<br>*Phandle [in]Device handle<br>*KeyIndex [out]The key counts returned
'''Parameters'''<br>Parameter Meaning<br>*Phandle [in]Device handle<br>*KeyIndex [out]The key counts returned


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_KEY_INDEX 239 The handle of the key is invalid.
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_KEY_INDEX 239 The handle of the key is invalid.


DES Get key counts generated <br>API Prototype<br>long __stdcall UniKey_DES_Get_Key_Counts( WORD* handle ,<br>DWORD* KeyIndexs ) ;
DES Get key counts generated <br>'''API Prototype'''<br><code>long __stdcall UniKey_DES_Get_Key_Counts( WORD* handle ,<br>DWORD* KeyIndexs ) ;</code>


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


<br>Parameters<br>Parameter Meaning<br>*Phandle [in]Device handle<br>*KeyIndex [out]The key counts returned
<br>'''Parameters'''<br>Parameter Meaning<br>*Phandle [in]Device handle<br>*KeyIndex [out]The key counts returned


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_KEY_INDEX 239 The handle of the key is invalid.
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_KEY_INDEX 239 The handle of the key is invalid.




Line 791: Line 953:
== RSA encryption  ==
== RSA encryption  ==


<br>API Prototype<br>long __stdcall UniKey_RSA_Encrypt( WORD* handle ,<br>WORD* KeyIndex ,<br>DWORD* Encrypt_Len ,<br>BYTE* Buffer ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_RSA_Encrypt( WORD* handle ,<br>WORD* KeyIndex ,<br>DWORD* Encrypt_Len ,<br>BYTE* Buffer ) ;</code>


Description<br>Encrypt data using RSA.
'''Description'''<br>Encrypt data using RSA.


Parameters<br>Parameter Meaning<br>*Phandle [in]Device handle<br>*KeyIndex [in]Encrypt &amp; decrypt using the key handle<br>*Len [in]The length of encryption &amp; decryption data<br>*Buffer [in/out]Input encrypted text and output plain text.
'''Parameters'''<br>Parameter Meaning<br>*Phandle [in]Device handle<br>*KeyIndex [in]Encrypt &amp; decrypt using the key handle<br>*Len [in]The length of encryption &amp; decryption data<br>*Buffer [in/out]Input encrypted text and output plain text.


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_ENCRYPT_FAILED 228 Encryption failed.
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_ENCRYPT_FAILED 228 Encryption failed.


== <br>RSA decryption  ==
== <br>RSA decryption  ==


<br>API Prototype<br>long __stdcall UniKey_RSA_Decrypt( WORD* handle ,<br>WORD* KeyIndex ,<br>DWORD* Decrypt_Len ,<br>BYTE* Buffer ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_RSA_Decrypt( WORD* handle ,<br>WORD* KeyIndex ,<br>DWORD* Decrypt_Len ,<br>BYTE* Buffer ) ;</code>


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


Parameters<br>Parameter Meaning<br>*Phandle [in]Device handle<br>*KeyIndex [in]Encrypt &amp; decrypt using the key handle<br>*Len [in]The length of encryption &amp; decryption data<br>*Buffer [in/out]Input encrypted text and output plain text.
'''Parameters'''<br>Parameter Meaning<br>*Phandle [in]Device handle<br>*KeyIndex [in]Encrypt &amp; decrypt using the key handle<br>*Len [in]The length of encryption &amp; decryption data<br>*Buffer [in/out]Input encrypted text and output plain text.


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_KEY_INDEX 239 The key handle is invalid. <br>ERROR_UNIKEY_DECRYPT_FAILED 229 Decryption failed.
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_KEY_INDEX 239 The key handle is invalid. <br>ERROR_UNIKEY_DECRYPT_FAILED 229 Decryption failed.


== <br>DES encryption  ==
== <br>DES encryption  ==


<br>API Prototype<br>long __stdcall UniKey_DES1_Encrypt( WORD* handle ,<br>WORD* EncryptMode ,<br>WORD* KeyIndex ,<br>DWORD* Len ,<br>BYTE* Buffer ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_DES1_Encrypt( WORD* handle ,<br>WORD* EncryptMode ,<br>WORD* KeyIndex ,<br>DWORD* Len ,<br>BYTE* Buffer ) ;</code>


long __stdcall UniKey_DES2_Encrypt( <br>WORD* handle ,<br>WORD* EncryptMode ,<br>WORD* KeyIndex ,<br>DWORD* Len ,<br>BYTE* Buffer ) ;
long __stdcall UniKey_DES2_Encrypt( <br>WORD* handle ,<br>WORD* EncryptMode ,<br>WORD* KeyIndex ,<br>DWORD* Len ,<br>BYTE* Buffer ) ;</code>


long __stdcall UniKey_DES3_Encrypt( WORD* handle ,<br>WORD* EncryptMode ,<br>WORD* KeyIndex ,<br>DWORD* Len ,<br>BYTE* Buffer ) ;
long __stdcall UniKey_DES3_Encrypt( WORD* handle ,<br>WORD* EncryptMode ,<br>WORD* KeyIndex ,<br>DWORD* Len ,<br>BYTE* Buffer ) ;</code>


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


Parameters<br>Parameter Meaning<br>*Phandle [in]Device handle<br>*KeyIndex [in]Encrypt &amp; decrypt using the key handle<br>*Len [in]The length of encryption &amp; decryption data<br>*Buffer [in/out]Input encrypted text and output plain text.
'''Parameters'''<br>Parameter Meaning<br>*Phandle [in]Device handle<br>*KeyIndex [in]Encrypt &amp; decrypt using the key handle<br>*Len [in]The length of encryption &amp; decryption data<br>*Buffer [in/out]Input encrypted text and output plain text.


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_KEY_INDEX 239 The key handle is invalid. <br>ERROR_UNIKEY_ENCRYPT_FAILED 228 Encryption failed.
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_KEY_INDEX 239 The key handle is invalid. <br>ERROR_UNIKEY_ENCRYPT_FAILED 228 Encryption failed.




Line 827: Line 989:
== DES decryption  ==
== DES decryption  ==


<br>API Prototype<br>long __stdcall UniKey_DES1_Decrypt( <br>WORD* handle ,<br>WORD* DecryptMode ,<br>WORD* KeyIndex ,<br>DWORD *Len ,<br>BYTE* Buffer ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_DES1_Decrypt( <br>WORD* handle ,<br>WORD* DecryptMode ,<br>WORD* KeyIndex ,<br>DWORD *Len ,<br>BYTE* Buffer ) ;</code>


long __stdcall UniKey_DES2_Decrypt( WORD* handle ,<br>WORD* DecryptMode ,<br>WORD* KeyIndex ,<br>DWORD* Len ,<br>BYTE* Buffer ) ;
long __stdcall UniKey_DES2_Decrypt( WORD* handle ,<br>WORD* DecryptMode ,<br>WORD* KeyIndex ,<br>DWORD* Len ,<br>BYTE* Buffer ) ;</code>


long __stdcall UniKey_DES3_Decrypt( WORD* handle ,<br>WORD* DecryptMode ,<br>WORD* KeyIndex ,<br>DWORD* Len ,<br>BYTE* Buffer ) ;
long __stdcall UniKey_DES3_Decrypt( WORD* handle ,<br>WORD* DecryptMode ,<br>WORD* KeyIndex ,<br>DWORD* Len ,<br>BYTE* Buffer ) ;</code>


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


Parameters<br>Parameter Meaning<br>*Phandle [in]Device handle<br>*KeyIndex [in]Encrypt &amp; decrypt using the key handle<br>*Len [in]The length of encryption &amp; decryption data<br>*Buffer [in/out]Input encrypted text and output plain text.
'''Parameters'''<br>Parameter Meaning<br>*Phandle [in]Device handle<br>*KeyIndex [in]Encrypt &amp; decrypt using the key handle<br>*Len [in]The length of encryption &amp; decryption data<br>*Buffer [in/out]Input encrypted text and output plain text.


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_KEY_INDEX 239 The key handle is invalid. <br>ERROR_UNIKEY_DECRYPT_FAILED 229 Decryption failed.
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_KEY_INDEX 239 The key handle is invalid. <br>ERROR_UNIKEY_DECRYPT_FAILED 229 Decryption failed.




Line 843: Line 1,005:
== Delete key 1  ==
== Delete key 1  ==


<br>API Prototype<br>long __stdcall UniKey_RSA_Del_Key( WORD* handle ,<br>WORD* KeyIndex ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_RSA_Del_Key( WORD* handle ,<br>WORD* KeyIndex ) ;</code>


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


Parameters<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*KeyIndex [in]The handle to be deleted
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*KeyIndex [in]The handle to be deleted


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_KEY_INDEX 239 The key handle is invalid.<br>KeyIndex &lt;0 or KeyIndex &gt; 3.
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_KEY_INDEX 239 The key handle is invalid.<br>KeyIndex &lt;0 or KeyIndex &gt; 3.




Line 855: Line 1,017:
== Delete key 2 ==
== Delete key 2 ==


<br>API Prototype<br>long __stdcall UniKey_DES_Del_Key( WORD* handle ,<br>WORD* KeyIndex ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_DES_Del_Key( WORD* handle ,<br>WORD* KeyIndex ) ;</code>


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


Parameters<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*KeyIndex [in]The handle to be deleted
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*KeyIndex [in]The handle to be deleted


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_KEY_INDEX 239 The key handle is invalid.<br>KeyIndex &lt;0 or KeyIndex &gt; 14.
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_KEY_INDEX 239 The key handle is invalid.<br>KeyIndex &lt;0 or KeyIndex &gt; 14.




Line 867: Line 1,029:
== Get user counts ==
== Get user counts ==


<br>API Prototype<br>long __stdcall UniKey_Get_UserCount( WORD* handle ,<br>WORD* Count ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_Get_UserCount( WORD* handle ,<br>WORD* Count ) ;</code>


Description<br>UniKey Drive can enable 32 concurrent users to logon. This function can be called to get the number of logon users.
'''Description'''<br>UniKey Drive can enable 32 concurrent users to logon. This function can be called to get the number of logon users.


Parameters<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*Count [in]Number of logon users returned
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*Count [in]Number of logon users returned


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_KEY_INDEX 239 The key handle is invalid.<br>KeyIndex &lt;0 or KeyIndex &gt; 14.
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_KEY_INDEX 239 The key handle is invalid.<br>KeyIndex &lt;0 or KeyIndex &gt; 14.




Line 879: Line 1,041:
== Only allow one user to logon ==
== Only allow one user to logon ==


<br>API Prototype<br>long __stdcall UniKey_Logon_Single( WORD* pHandle , <br>DWORD* pPassword1 ,<br>DWORD* pPassword2 , <br>DWORD* pPassword3 , <br>DWORD* pPassword4 ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_Logon_Single( WORD* pHandle , <br>DWORD* pPassword1 ,<br>DWORD* pPassword2 , <br>DWORD* pPassword3 , <br>DWORD* pPassword4 ) ;</code>


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


Parameters<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*pPassword1 [in]Password 1<br>*pPassword2 [in]Password 2<br>*pPassword3 [in]Password 3<br>*pPassword4 [in]Password 4
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in]Device handle<br>*pPassword1 [in]Password 1<br>*pPassword2 [in]Password 2<br>*pPassword3 [in]Password 3<br>*pPassword4 [in]Password 4


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_PASSWORD_OR_ID 202 The password or ID is invalid.
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success<br>ERROR_UNIKEY_INVALID_PASSWORD_OR_ID 202 The password or ID is invalid.


== <br>Logoff the active user ==
== <br>Logoff the active user ==


<br>API Prototype<br>long __stdcall UniKey_Logoff( WORD* pHandle ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_Logoff( WORD* pHandle ) ;</code>


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


Parameters<br>Parameter Meaning<br>*pHandle [in]Device handle
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in]Device handle


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success


== <br>Logoff all the users ==
== <br>Logoff all the users ==


<br>API Prototype<br>long __stdcall UniKey_Logoff_All( WORD* pHandle ) ;
<br>'''API Prototype'''<br><code>long __stdcall UniKey_Logoff_All( WORD* pHandle ) ;</code>


Description<br>After calling this function, all the users will be logoff.
'''Description'''<br>After calling this function, all the users will be logoff.


Parameters<br>Parameter Meaning<br>*pHandle [in]Device handle
'''Parameters'''<br>Parameter Meaning<br>*pHandle [in]Device handle


Return values<br>Marco Value Meaning<br>SUCCESS 0 Success&nbsp;  
'''Return values'''<br>Marco Value Meaning<br>SUCCESS 0 Success&nbsp;  


<br>&lt;a _fcknotitle="true" href="Category:UniKey_APIs"&gt;UniKey_APIs&lt;/a&gt;  
<br>&lt;a _fcknotitle="true" href="Category:UniKey_APIs"&gt;UniKey_APIs&lt;/a&gt;  


<br>
<br>

Revision as of 14:37, 26 June 2012



Find a UniKey dongle

API Prototype
long UniKey_Find( WORD* pHandle ,
DWORD* pSetting1 ,
DWORD* pSetting2 ) ;

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

Parameters

Parameter Meaning
*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(UniKey PRO only)
[out] Number of dongle attached , useless for UniKey STD

Return values

Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NO_UNIEKY 200 No UniKey dongle


Find the Next UniKey dongle

API Prototype
Long UniKey_Find_Next( WORD* pHandle ,
DWORD* pSetting1 ,
DWORD* pSetting2 ) ;

Description
Check if another UniKey is attached to the USB port.

Parameters

Parameter Meaning
*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(UniKeyPro only)
[out] Number of dongle attached , useless for UniKey STD

Return values

Marco Value
SUCCESS 0
ERROR_UNIKEY_NOMORE 214
ERROR_UNIKEY_NEED_FIND 215


Logon UniKey Dongle

 

API Prototype
long UniKey_User_Logon( WORD* pHandle ,
WORD* pPassword1 ,
WORD* pPassword2 ) ;

-------------------------------------------------------------------------------------------

For UniKey Drive, the API Prototype is UniKey_User_Logon (WORD* pHandle, DWORD* pPassword1, DWORD* pPassword2);
-------------------------------------------------------------------------------------------
Description
Logon a UniKey dongle with specified passwords. This API should be called in the released software in order to improve security.

Parameters

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

Return values

Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NOT_FOUND 200 No UniKey dongle
ERROR_UNIKEY_INVALID_PASSWORD 201 UniKey dongle found, but Basic passwords are incorrect
ERROR_UNIKEY_INVALID_PASSWORD_OR_ID 202 Wrong password or UniKey HID


Logon UniKey Dongle in vendor mode


API Prototype
long UniKey_Vender_Logon( WORD* pHandle ,
WORD* pPassword1 ,
WORD* pPassword2 ,
WORD* pPassword3 ,
WORD* pPassword4 ) ;

---------------------------------------------------------------------------------------------------
For UniKey Drive, the API Prototype is UniKey_Vender_Logon(WORD* pHandle, DWORD* pPassword1, DWORD* pPassword2, DWORD* pPassword3, DWORD* pPassword4);
---------------------------------------------------------------------------------------------------

Description
Logon a UniKey dongle in vendor mode with specified passwords. This API helps software vendors to logon the UniKey dongle in vendor mode, and get the full permission to UniKey dongle.
---------------------------------------------------------------------------------------------------
We do NOT advise you to enclose this API in the final released software. This API is only for software vendor’s usage.
--------------------------------------------------------------------------------------------------
If password3 or password4 is wrong while password1 and password2 is correct, the dongle is also logged on in user mode automatically.
---------------------------------------------------------------------------------------------------

Parameters

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

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NOT_FOUND 200 No UniKey dongle
ERROR_UNIKEY_INVALID_PASSWORD 201 Found UniKey dongle, but Basic passwords are incorrect
ERROR_UNIKEY_INVALID_PASSWORD_OR_ID 202 Wrong password or UniKey HID


Logoff the UniKey dongle


API Prototype
long UniKey_Logoff( WORD* pHandle ) ;

Description
Logoff a UniKey dongle with a specific handle. This API should be called at the end of UniKey session.

Parameters

Parameter Meaning
*pHandle [in] Dongle handle

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NOT_FOUND 200 No UniKey dongle
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle


Get the UniKey dongle 's Type


API Prototype
long UniKey_Get_Type( WORD* pHandle ,
DWORD* type ) ;

Description
UniKey_Get_Type can help you get the type of the UniKey dongle.
The return value of type will indicate the type of the UniKey dongle.
UNIKEY_TYPE_TIME 101
UNIKEY_TYPE_PRO 102
UNIKEY_TYPE_STD 103

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

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_GET_TYPE 237 UniKey Get Type Error


Read UniKey dongle memory


API Prototype
long UniKey_Read_Memory( WORD* pHandle ,
WORD* pStartAddress ,
WORD* pBufferLength ,
BYTE* pBuffer ) ;


Description
Read the contents of the Memory. This API needs to be called after logon of a UniKey dongle.

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

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address or length is wrong
ERROR_UNIKEY_READ_MEMORY 207 Read Error
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
ERROR_UNIKEY_NEED_OPEN 215 No logon dongle before operating dongle


Write to UniKey dongle memory


API Prototype
long UniKey_Write_Memory( WORD* pHandle ,
WORD* pStartAddress ,
WORD* pBufferLength ,
BYTE* pBuffer ) ;

Description
Write data into the memory. This API needs to be called after logging on to a UniKey dongle.

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

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address or length is wrong
ERROR_UNIKEY_WRITE_MEMORY 207 Write Error
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
ERROR_UNIKEY_VERIFY_ADV_PASSWORD 223 Advanced passwords (password3 and passowrd4) not verified



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

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
long UniKey_Random( WORD* pHandle ,
WORD* pReturn1 ,
WORD* pReturn2 ,
WORD* pReturn3 ,
WORD* pReturn4 ) ;

Description
Generate a random number from the dongle.

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

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
ERROR_UNIKEY_RANDOM 209 Random number Error



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


Generate Seed Code Return values


API Prototype
long UniKey_Seed( WORD* pHandle ,
DWORD* pSeed ,
WORD* pReturn1 ,
WORD* pReturn2 ,
WORD* pReturn3 ,
WORD* pReturn4 ) ;

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

Parameters
Parameter Meaning
*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
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
ERROR_UNIKEY_SEED 210 Seed code Error



UniKey_Seed generate a set of seed codes. All of these seed codes are based on the password. It provides another method to verify the password and check the insertion of the dongle. Apart from this, the seed codes can be used to involve in other computation, for example, you use the seed returned as a 64-bit long encryption key.
---------------------------------------------------------------------------------------------------


Write the Soft ID


API Prototype
long UniKey_Write_SoftID( WORD* pHandle ,
DWORD* pSoftID ) ;

Description
Write the vendor defined SoftID.

Parameters
Parameter Meaning
*pHandle [in] Dongle handle
*pSoftID [in] Soft ID

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
ERROR_UNIKEY_SET_SOFTID 203 Set UniKey ID wrong
---------------------------------------------------------------------------------------------------

You need to verify all 4 passwords (vendor mode) to write the SoftID.
---------------------------------------------------------------------------------------------------

Read Soft ID
API Prototype
long UniKey_Read_SoftID( WORD* pHandle ,
DWORD* pSoftID ) ;

Description
Read the user defined SoftID.

Parameters
Parameter Meaning
*pHandle [in] Dongle handle
*pSoftID [out] Soft ID

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle



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
long UniKey_Set_Module( WORD* pHandle ,
WORD* pModule ,
WORD* pValue ,
WORD* pDecrease ) ;

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

Parameters
Parameter Meaning
*pHandle [in] Dongle handle
*pModule [in] License module Number
*pValue [in] License module Unit Value
*pDecrease [in] Decreasing attribute. If decreasing is allowed (1 = allowed, 0 = not allowed)

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 202 Read/Write address or length is wrong
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
ERROR_UNIKEY_MODULE 216 License module error



A successful operation will result in license module unit # “*pModule” storing value “*pValue” and the Decrement attribute set to “0” or “1”
---------------------------------------------------------------------------------------------------


You need verify 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 Meaning
*pHandle [in] Dongle handle
*pModule [in] Module Number
*pValue [out] Return the value in module

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 202 Read/Write address or length is wrong
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
ERROR_UNIKEY_MODULE 216 License module error


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

 

Check a UniKey License module


API Prototype
long UniKey_Check_Module( WORD* pHandle ,
WORD* pModule ,
WORD* pValue ,
WORD* pDecrease ) ;

Description
Read the attributes of a specific UniKey license module.

Parameters
Parameter Meaning
*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
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 202 Read/Write address or length is wrong
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
ERROR_UNIKEY_MODULE 216 License module error
---------------------------------------------------------------------------------------------------
A successful operation will result in “*pValue” with value from the Validity (1 = license module value is not zero), and “*pDecrease” with the value from the Decrement attribute (1 = license module can be decreased).

The value of a license module cannot be read out directly and it is invisible to end users.
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
UniKey_Set_Module and UniKey_Check_Module provide an easy mean to implement software limitation. For example, if you want to set a software can be only executed 3 times, so you can call UNIKEY_SET_MODULE to set a license module (let us say license module 0) as 3. And when each execution, we decrease the license module, if the license module is invalid (zero), we stop the software. Apart from this, we can implement a module-selling model with help of license module functions. For example, the software has four function modules, A, B, C and D. And we can map the function modules to the license module in the UniKey dongle. Let us say the function module A is mapped to license module 0, B to 1, C to 2 and D to 3. If a customer only buys function A, B, you just need to enable the license module 0 and 1, and leave 2 and 3 as zero. So only function module A and B can be executed. If the customer buys more function, you can use UniKey remote update function to update the dongle remotely.
--------------------------------------------------------------------------------------------------


Write Arithmetic


API Prototype
long UniKey_Write_Arithmetic( WORD* pHandle ,
WORD* pStartAddress ,
BYTE* pBuffer ) ;

Description
Write user-defined mathematical algorithms.

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

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address or length is wrong
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
ERROR_UNIKEY_AR_BAD_COMMAND 217 Arithmetic instruction Error
ERROR_UNIKEY_AR_UNKNOWN_OPCODE 218 Arithmetic operator Error
ERROR_UNIKEY_AR_WRON_GBEGIN 219 Const number can't use on first arithmetic instruction
ERROR_UNIKEY_AR_WRONG_END 220 Const number can't use on last arithmetic instruction
ERROR_UNIKEY_AR_VALUE_OVERFLOW 221 Const number > 63


---------------------------------------------------------------------------------------------------
A successful operation will result in the user-defined algorithm populated with 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 at software vendor side. For example, if you have a serial number generate algorithm, and you want to perform this algorithm inside the dongle, you need to call UniKey_Write_Arithmetic.
--------------------------------------------------------------------------------------------------


User-defined Algorithm Calculate 1


API Prototype
long UniKey_Calculate1( WORD* pHandle ,
DWORD* pStartAddress ,
DWORD* pModule ,
WORD* pRegA ,
WORD* pRegB ,
WORD* pRegC ,
WORD* pRegD ) ;

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

Parameters
Parameter Meaning
*pHandle [in] Dongle handle
*pStartAddress [in] Start point of calculation
*pModule [in] License module number
*p1 [in, out] Register A
*p2 [in, out] Register B
*p3 [in, out] Register C
*p4 [in, out] Register D

Return value
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address or length is wrong
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
ERROR_UNIKEY_AR_BAD_COMMAND 217 Arithmetic instruction Error
ERROR_UNIKEY_AR_UNKNOWN_OPCODE 218 Arithmetic operator Error
ERROR_UNIKEY_AR_WRON_GBEGIN 219 Const number can't use on first arithmetic instruction
ERROR_UNIKEY_AR_WRONG_END 220 Const number can't use on last arithmetic instruction
ERROR_UNIKEY_AR_VALUE_OVERFLOW 221 Const number > 63



When the calculation starts, the values of other internal registers are listed in the table below.
E and F are reversed hardware ID byte wisely. For example, if the hardware is 0x12345678 (in Hex), and E will be 0x7856, and F will be 0x3412.
---------------------------------------------------------------------------------------------------
Internal Register Meaning
E HiWord of reversed hardware ID
F LoWord 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 *p1 = *p2 + *p3.
For example: The internal algorithm is A = A + G; If *p1 = 0, then when returning you may guess the content of license module *p1 = *pModule. Though you cannot read the content of modules directly, you may determine the content by algorithm. If possible, you had better check the content with an algorithm, not only comparing it in the program.
---------------------------------------------------------------------------------------------------


User-defined Algorithm Calculate 2


API Prototype
long UniKey_Calculate2( WORD* pHandle ,
DWORD* pStartAddress ,
DWORD* pSeed ,
WORD* pRegA ,
WORD* pRegB ,
WORD* pRegC ,
WORD* pRegD ) ;

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

Parameters
Parameter Meaning
*pHandle [in] Dongle handle
*pStartAddress [in] Start point of calculation
*pSeed [in] Seed Code (32-bit)
*p1 [in, out] Register A
*p2 [in, out] Register B
*p3 [in, out] Register C
*p4 [in, out] Register D

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address or length is wrong
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
ERROR_UNIKEY_AR_BAD_COMMAND 217 Arithmetic instruction Error
ERROR_UNIKEY_AR_UNKNOWN_OPCODE 218 Arithmetic operator Error
ERROR_UNIKEY_AR_WRON_GBEGIN 219 Const number can't use on first arithmetic instruction
ERROR_UNIKEY_AR_WRONG_END 220 Const number can't use on last arithmetic instruction
ERROR_UNIKEY_AR_VALUE_OVERFLOW 221 Const number > 63



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

Internal Register Meaning
E Seed Result 1
F Seed Result 2
G Seed Result 3
H Seed Result 4

 

User-defined Algorithm Calculate 3


API Prototype
long UniKey_Calculate3( WORD* pHandle ,
DWORD* pStartAddress ,
DWORD* pModule ,
WORD* pRegA ,
WORD* pRegB ,
WORD* pRegC ,
WORD* pRegD ) ;

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

Parameters
Parameter Meaning
*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 value
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address or length is wrong
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
ERROR_UNIKEY_AR_BAD_COMMAND 217 Arithmetic instruction Error
ERROR_UNIKEY_AR_UNKNOWN_OPCODE 218 Arithmetic operator Error
ERROR_UNIKEY_AR_WRON_GBEGIN 219 Const number can't use on first arithmetic instruction
ERROR_UNIKEY_AR_WRONG_END 220 Const number can't use on last arithmetic instruction
ERROR_UNIKEY_AR_VALUE_OVERFLOW 221 Const number > 63



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

Internal Register Meaning
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 calls 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 algorithms and get the return of the formula.
---------------------------------------------------------------------------------------------------

 

Decrease A License module


API Prototype
long UniKey_Module_Decrease( WORD* pHandle ,
WORD* pModule ) ;

Description
Decrease the value in a specified UniKey license module by “1”.

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

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 204 Read/Write address or length is wrong
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
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
long UniKey_Generate_New_Password( WORD* pHandle ,
DWORD* pSeed ,
WORD* pPassword1 ,
WORD* pPassword2 ,
WORD* pPassword3 ,
WORD* pPassword4 ) ;

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

Parameters
Parameter Meaning
*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
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
ERROR_UNIKEY_VERIFY_ADV_PASSWORD 223 Advanced passwords (password3 and passowrd4) not verified
ERROR_UNIKEY_GENERATE_NEW_PASSWORD 225 Generate new password Error



A file recording the new SEED and PASSWORDs will be created in the working path, and help the software vendor to recall everything. The passwords can be distributed to ordinary developers!
---------------------------------------------------------------------------------------------------



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


Generate a New Encryption Key


API Prototype
long UniKey_Generate_Key( WORD* pHandle ,
DWORD* pKeyNumber ) ;

Description
Generate a new key in the specific key storage.

Parameters
Parameter Meaning
*pHandle [in] Dongle handle
*pKeyNumber [in] Key Storage Number

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
ERROR_UNIKEY_INVALID_KEY_STORE 224 Wrong key storage number



1. This function will delete the original key in the key storage, and generate a new key.
2. The data encrypted by the old key cannot be decrypted by the new key.
3. Each key is 128-bit 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 seed.

Parameters
Parameter Meaning
*pHandle [in] Dongle handle
*pKeyNumber [in] Key Storage Number
*pSeed1 [in] Seed1
*pSeed2 [in] Seed2
*pSeed3 [in] Seed3
*pSeed4 [in] Seed4

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
ERROR_UNIKEY_INVALID_KEY_STORE 224 Wrong key storage number




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

 

Encrypt the Buffer with a Specific Encryption Key


API Prototype
long UniKey_Encrypt( WORD* pHandle ,
DWORD* pBufferLength ,
DWORD* 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
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
ERROR_UNIKEY_INVALID_KEY_STORE 224 Wrong key storage number
ERROR_UNIKEY_ENCRYPT_FAILED 228 Encrypt data error



---------------------------------------------------------------------------------------------------

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


Decrypt the Buffer with a Specific Encryption Key


API Prototype
long UniKey_Decrypt( WORD* pHandle ,
DWORD* pBufferLength ,
DWORD* 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 decrypted
[out] Pointer to the decrypted data

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Not logon dongle before operating dongle
ERROR_UNIKEY_INVALID_KEY_STORE 224 Wrong key storage number
ERROR_UNIKEY_DECRYPT_FAILED 229 Decrypt data error


Please use the key that encrypted data to decrypt the data; otherwise you cannot 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 the credential before saving it into the UniKey’s memory.
---------------------------------------------------------------------------------------------------

 

Make an MD5 Digest for a Certain Content

 

API Prototype
long UniKey_MD5( WORD* pHandle ,
DWORD* pBufferLength ,
DWORD* pType ,
BYTE* pBuffer ) ;

Description
Make an MD5 digest for a mount 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
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle

 

Read UpdateTag


API Prototype
long UniKey_Read_UpdateTag( WORD* pHandle ,
DWORD* pUpdateTag ) ;

Description
Read UpdateTag from a specific dongle

Parameters
Parameter Meaning
*pHandle [in] Dongle handle
*pUpdateTag [out] UpdateTag

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
ERROR_UNIKEY_READ_UPDATETAG 226 Read UpdateTag error

 

Write UpdateTag


API Prototype
long UniKey_Write_UpdateTag( WORD* pHandle ,
DWORD* pUpdateTag ) ;

Description
Write UpdateTag into a specific dongle.

Parameters
Parameter Meaning
*pHandle [in] Dongle handle
*pUpdateTag [in] UpdateTag

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
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 the software, software vendors may use the UpdateTag as an ID which shows if the dongle needs to update or has been updated. You can also use this Tag as a tracking ID for each update.
----------------------------------------------------------------------------------------------------


Get UniKey Library Version

 

API Prototype
long UniKey_Get_Version( WORD* pHandle ,
DWORD* pVersion ) ;

Description
Get the current UniKey library version.

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


Get UniKey Time


API Prototype
long UniKey_Get_Time( WORD* pHandle ,
DWORD* pYear ,
DWORD* pMonth ,
WORD* pDay ,
WORD* pHour ,
WORD* pMinute ,
WORD* pSecond ) ;

Description
Get UniKey Time’s real time clock’s time.

Parameters
Parameter Meaning
*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
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle
ERROR_UNIKEY_READ_TIME 230 Get UniKey time error



We can call UniKey_Check_Time to check if the UniKey dongle is a real time dongle. If we get ERROR_UNIKEY_READ_TIME, then the dongle is not a real time dongle.
---------------------------------------------------------------------------------------------------


Set UniKey Time


API Prototype
long UniKey_Set_Time( WORD* pHandle ,
DWORD* pYear ,
DWORD* pMonth ,
WORD* pDay ,
WORD* pHour ,
WORD* pMinute ,
WORD* pSecond ) ;

Description
Set UniKey Time’s real time clock’s time.

Parameters
Parameter Meaning
*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
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle
ERROR_UNIKEY_READ_TIME 230 Get UniKey time error
---------------------------------------------------------------------------------------------------

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


Set UniKey Time by Host’s Clock


API Prototype
long UniKey_Set_Time_Now( WORD* pHandle ) ;

Description
Set UniKey Time’s real time clock’s time by the host computer’s clock.

Parameters
Parameter Meaning
*pHandle [in] Dongle handle

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle
ERROR_UNIKEY_WRITE_TIME 231 Write UniKey time error


Erase Real Time Module


API Prototype
long UniKey_Erase_Time_Module( WORD* pHandle ,
DWORD* pModule ) ;

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

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

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle
ERROR_UNIKEY_WRITE_TIME 231 Write UniKey time error




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


Set a Real Time Module’s Start Time


API Prototype
long UniKey_Set_Time_Module_Start_Time( WORD* pHandle ,
DWORD* pModule ,
WORD* pYear ,
WORD* pMonth ,
WORD* pDay ,
WORD* pHour ) ;

Description
Set a real time module’s start time.

Parameters
Parameter Meaning
*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
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle
ERROR_UNIKEY_WRITE_TIME_MODULE 231 Write time module error
ERROR_UNIKEY_TIME_MODULE_NOT_NULL 234 The real time module is not null, this error is returned when write once flag is set



Write Once flag is very useful for setting the Start for a real time module. If write once flag is set, only the first START_TIME call can set the start time for a module. All the later START_TIME will not work and return an ERROR_UNIKEY_TIME_MODULE_NOT_NULL. Software vendors may use this flag when the start for a module is not clear.
---------------------------------------------------------------------------------------------------

 

Set a Real Time Module’s Start Time by UniKey Dongle’s Clock


API Prototype
Long UniKey_Set_Time_Module_Start_Time_Now( WORD* pHandle ,
DWORD* pModule);

Description
Set a real time module’s start time as the now time in UniKey dongle’s clock.

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

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle
ERROR_UNIKEY_WRITE_TIME_MODULE 231 Write time module error
ERROR_UNIKEY_TIME_MODULE_NOT_NULL 234 The real time module is not null, this error is returned when write once flag is set

 

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


API Prototype
long UniKey_Set_Time_Module_Start_Time_Now_PC(
WORD* pHandle ,
DWORD* pModule ) ;

Description
Set a real time module’s start time as the now time in host computer.

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

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle
ERROR_UNIKEY_WRITE_TIME_MODULE 231 Write time module error
ERROR_UNIKEY_TIME_MODULE_NOT_NULL 234 The real time module is not null, this error is returned when write once flag is set

 

Set a Real Time Module’s End Time


API Prototype
long UniKey_Set_Time_Module_End_Time( WORD* pHandle ,
DWORD* pModule ,
WORD* pYear ,
WORD* pMonth ,
WORD* pDay ,
WORD* pHour ) ;

Description
Set a real time module’s end time.

Parameters
Parameter Meaning
*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
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle
ERROR_UNIKEY_WRITE_TIME_MODULE 231 Write time module error

 

Set a Real Time Module’s Duration


API Prototype
long UniKey_Set_Time_Module_Duration( WORD* pHandle ,
DWORD* pModule ,
DWORD* pDay ,
WORD* pHour ) ;

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

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

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_NEED_OPEN 212 Need open dongle before operating dongle
ERROR_UNIKEY_WRITE_TIME_MODULE 231 Write time module error



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

 

Check a UniKey Time License module


API Prototype
long UniKey_Check_Time_Module( WORD* pHandle ,
DWORD* pModule ,
DWORD* pRemainDays ,
WORD* pYear ,
WORD* pMonth ,
WORD* pDay ,
WORD* pHour ) ;

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

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

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 202 Read/Write address or length is wrong
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
ERROR_UNIKEY_MODULE 216 License module error



A successful operation will result in “*pValue” with value from the Validity (1 = license module value is not zero).
The value of a license module cannot be read out directly and it is invisible to end users.
---------------------------------------------------------------------------------------------------

 

Check a UniKey Time License module Now


API Prototype
long UniKey_Check_Time_Module_Now( WORD* pHandle ,
DWORD* pModule ,
DWORD* pRemainDays ,
WORD* pRemainHours ) ;


Description
Read the attributes of a specific UniKey Time license module now.

Parameters
Parameter Meaning
*pHandle [in] Dongle handle
*pModule [in] License module Number
*pRemainDays [out] Remain days
*pRemainHours [out] Remain hours

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 202 Read/Write address or length is wrong
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
ERROR_UNIKEY_MODULE 216 License module error



A successful operation will result in “*pValue” with value from the Validity (1 = license module value is not zero).

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


Check a UniKey Time License module Now PC


API Prototype
long UniKey_Check_Time_Module_Now_PC( WORD* pHandle ,
DWORD* pModule ,
DWORD* pRemainDays ,
WORD* pRemainHours) ;

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

Parameters
Parameter Meaning
*pHandle [in] Dongle handle
*pModule [in] License module Number
*pRemainDays [out] Remain days
*pRemainHours [out] Remain hours

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_ADDR_OR_SIZE 202 Read/Write address or length is wrong
ERROR_UNIKEY_NEED_OPEN 212 No logon dongle before operating dongle
ERROR_UNIKEY_MODULE 216 License module error



A successful operation will result in “*pValue” with value from the Validity (1 = license module value is not zero).

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

 

Initialize File System


API Prototype
long __stdcall UniKey_FS_Init( WORD* handle ,
DWORD* PW1 ,
DWORD* PW2 ,
DWORD* PW3 ,
DWORD* PW4 ) ;

Description
The user needs to call this function to initialize the file system before calling other file system related functions. The password of the file system is 12345678.

Parameters
Parameter Meaning
*pHandle [in]Device handle
* pPassword1 [in]Password1
* pPassword2 [in]Password2
* pPassword3 [in]Password3
* pPassword4 [in]Password4

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_PASSWORD_OR_ID 202 Invalid password or ID results in an error.


Format the file system


API Prototype
long __stdcall UniKey_FS_Format( WORD* handle ) ;

Description
Format the file system.

Parameters
Parameter Meaning
*pHandle [in]Device handle

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_FS_FILE_EXIST 245 File already existed.


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


Create files


API Prototype
long __stdcall UniKey_FS_CreateFile( WORD* handle ,
BYTE* filename ) ;

Description
Create files.

Parameters
Parameter Meaning
*pHandle [in]Device handle
*filename [in/out]Input/Output file name
---------------------------------------------------------------------------------------------------

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

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_FS_ERR_SYS_UNINIT 246 The file system is not initialized.
ERROR_UNIKEY_FS_FILE_NAME 240 Wrong or invalid file name
ERROR_UNIKEY_FS_FILE_EXIST 245 The file already existed.


Delete files


API Prototype
long __stdcall UniKey_FS_DeleteFile( WORD* handle ,
BYTE* filename ) ;

Description
Delete files.

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

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_FS_ERR_SYS_UNINIT 246 The file is not yet initialized.
ERROR_UNIKEY_FS_NO_FILE 241 No such file name.


Open files


API Prototype
long __stdcall UniKey_FS_File_Open( WORD* handle ,
BYTE* filename ) ;

Description
Open files.

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

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_FS_NO_FILE 241 No such file name


Get system space


API Prototype
long __stdcall UniKey_FS_Get_Free_Size( WORD* handle ,
DWORD* usedsize ,
DWORD* freesize ) ;

Description
Get system space.

Parameters
Parameter Meaning
*pHandle [in]Device handle
*usedsize [out]System space size which has already been used
*freesize [out]System space size that hasn’t been used

Return values
Marco Value Meaning
SUCCESS 0 Success


Modify file data


API Prototype
long __stdcall UniKey_FS_File_Modify_Data(
WORD* handle ,
DWORD* offset ,
DWORD* len ,
BYTE* buffer ) ;


Description
Modify file data.

Parameters
Parameter Meaning
*pHandle [in]Device handle
*offset [in]Address to be modified
*len [in]Modify the data length
*buffer [in]Modify the data

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_FS_ERR_OPEN_FILE 247 The file to be modified hasn’t been opened yet.
ERROR_UNIKEY_FS_FILE_OFFSET 242 Offset of file error


Append data to the end-of-file


API Prototype
long __stdcall UniKey_FS_File_Append_Data( WORD* handle ,
DWORD* len ,
BYTE* buffer ) ;

Description
Append data to the end-of-file.

Parameters
Parameter Meaning
*len [in]The length of the append data
*buffer [in]Append data

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_FS_NO_MEMORY 244 Not enough free memory


Read file data


API Prototype
long__stdcall UniKey_FS_File_Read_Data( WORD* handle ,
DWORD * offset ,
DWORD* len ,
BYTE* buffer ) ;

Description
Read data file.

Parameters
Parameter Meaning
*pHandle [in]Device handle
*offset [in]Read address
*len [in]Read the data length
*buffer [out]Read data

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_FS_ERR_OPEN_FILE 247 The file to be modified is not opened yet.
ERROR_UNIKEY_FS_FILE_OFFSET 242 Offset of file error.


Close files


API Prototype
long __stdcall UniKey_FS_File_Close( WORD* handle ,
BYTE* filename ) ;

Description
Close files.

Parameters
Parameter Meaning
*pHandle [in]Device handle
*filename [in]file name
*len [in]Read the data length
*buffer [in]Read data

Return values
Marco Value Meaning
SUCCESS 0 Success


Get file list


API Prototype
long __stdcall UniKey_FS_File_Get_List( WORD* handle ,
DWORD* filecount ,
BYTE* filelist ) ;

Description
Get file list.

Parameters
Parameter Meaning
*pHandle [in]Device handle
*filecount [out]The number of files
*filelist [out]

Return values
Marco Value Meaning
SUCCESS 0 Success


Get the file size


API Prototype
long __stdcall UniKey_FS_File_Get_Size(WORD* handle,
DWORD* filesize);


Description
Get the file size.

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

Return values
Marco Value Meaning
SUCCESS 0 Success


Users reset file system password


API Prototype
long __stdcall UniKey_FS_Set_Password( WORD* handle ,
DWORD* PW1 ,
DWORD* PW2 ,
DWORD* PW3 ,
DWORD* PW4 ) ;

Description
Users reset the password to the file system.

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

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_GENERATE_NEW_PASSWORD 225 Fail to generate new password.

---------------------------------------------------------------------------------------------------

The reset of the password can only be successfully done after initializing the file system successfully.
-----------------------------------------------------------------------------------------------------


Generate a RSA Key


API Prototype
long __stdcall UniKey_RSA_Generate_Key( WORD* handle ,
WORD* KeyIndex ) ;

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

Parameters
Parameter Meaning
*pHandle [in]Device handle
*KeyIndex [in]Return the handle generated Key
`
Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_KEY_INDEX 239 The handle of the key is invalid.


Generate a DES Key


API Prototype
long __stdcall UniKey_DES_Generate_Key( WORD* handle ,
DWORD* KeyIndex ) ;

Description
Calling this function can generate a DES key.

Parameters
Parameter Meaning
*pHandle [in]Device handle
*KeyIndex [in]Return the handle generated Key

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_KEY_INDEX 239 The handle of the key is invalid.


RSA Get key counts generated


API Prototype
long __stdcall UniKey_RSA_Get_Key_Counts( WORD* handle ,
DWORD* KeyIndexs ) ;

Description
Get the number of keys that are generated.

Parameters
Parameter Meaning
*Phandle [in]Device handle
*KeyIndex [out]The key counts returned

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_KEY_INDEX 239 The handle of the key is invalid.

DES Get key counts generated
API Prototype
long __stdcall UniKey_DES_Get_Key_Counts( WORD* handle ,
DWORD* KeyIndexs ) ;

Description
Get the number of keys that are generated.


Parameters
Parameter Meaning
*Phandle [in]Device handle
*KeyIndex [out]The key counts returned

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_KEY_INDEX 239 The handle of the key is invalid.


RSA encryption


API Prototype
long __stdcall UniKey_RSA_Encrypt( WORD* handle ,
WORD* KeyIndex ,
DWORD* Encrypt_Len ,
BYTE* Buffer ) ;

Description
Encrypt data using RSA.

Parameters
Parameter Meaning
*Phandle [in]Device handle
*KeyIndex [in]Encrypt & decrypt using the key handle
*Len [in]The length of encryption & decryption data
*Buffer [in/out]Input encrypted text and output plain text.

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_ENCRYPT_FAILED 228 Encryption failed.


RSA decryption


API Prototype
long __stdcall UniKey_RSA_Decrypt( WORD* handle ,
WORD* KeyIndex ,
DWORD* Decrypt_Len ,
BYTE* Buffer ) ;

Description
Decrypt data using RSA.

Parameters
Parameter Meaning
*Phandle [in]Device handle
*KeyIndex [in]Encrypt & decrypt using the key handle
*Len [in]The length of encryption & decryption data
*Buffer [in/out]Input encrypted text and output plain text.

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_KEY_INDEX 239 The key handle is invalid.
ERROR_UNIKEY_DECRYPT_FAILED 229 Decryption failed.


DES encryption


API Prototype
long __stdcall UniKey_DES1_Encrypt( WORD* handle ,
WORD* EncryptMode ,
WORD* KeyIndex ,
DWORD* Len ,
BYTE* Buffer ) ;

long __stdcall UniKey_DES2_Encrypt(
WORD* handle ,
WORD* EncryptMode ,
WORD* KeyIndex ,
DWORD* Len ,
BYTE* Buffer ) ;

long __stdcall UniKey_DES3_Encrypt( WORD* handle ,
WORD* EncryptMode ,
WORD* KeyIndex ,
DWORD* Len ,
BYTE* Buffer ) ;

Description
Encrypt data using DES.

Parameters
Parameter Meaning
*Phandle [in]Device handle
*KeyIndex [in]Encrypt & decrypt using the key handle
*Len [in]The length of encryption & decryption data
*Buffer [in/out]Input encrypted text and output plain text.

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_KEY_INDEX 239 The key handle is invalid.
ERROR_UNIKEY_ENCRYPT_FAILED 228 Encryption failed.


DES decryption


API Prototype
long __stdcall UniKey_DES1_Decrypt(
WORD* handle ,
WORD* DecryptMode ,
WORD* KeyIndex ,
DWORD *Len ,
BYTE* Buffer ) ;

long __stdcall UniKey_DES2_Decrypt( WORD* handle ,
WORD* DecryptMode ,
WORD* KeyIndex ,
DWORD* Len ,
BYTE* Buffer ) ;

long __stdcall UniKey_DES3_Decrypt( WORD* handle ,
WORD* DecryptMode ,
WORD* KeyIndex ,
DWORD* Len ,
BYTE* Buffer ) ;

Description
Encrypt data using DES.

Parameters
Parameter Meaning
*Phandle [in]Device handle
*KeyIndex [in]Encrypt & decrypt using the key handle
*Len [in]The length of encryption & decryption data
*Buffer [in/out]Input encrypted text and output plain text.

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_KEY_INDEX 239 The key handle is invalid.
ERROR_UNIKEY_DECRYPT_FAILED 229 Decryption failed.


Delete key 1


API Prototype
long __stdcall UniKey_RSA_Del_Key( WORD* handle ,
WORD* KeyIndex ) ;

Description
Delete a key.

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

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_KEY_INDEX 239 The key handle is invalid.
KeyIndex <0 or KeyIndex > 3.


Delete key 2


API Prototype
long __stdcall UniKey_DES_Del_Key( WORD* handle ,
WORD* KeyIndex ) ;

Description
Delete a key.

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

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_KEY_INDEX 239 The key handle is invalid.
KeyIndex <0 or KeyIndex > 14.


Get user counts


API Prototype
long __stdcall UniKey_Get_UserCount( WORD* handle ,
WORD* Count ) ;

Description
UniKey Drive can enable 32 concurrent users to logon. This function can be called to get the number of logon users.

Parameters
Parameter Meaning
*pHandle [in]Device handle
*Count [in]Number of logon users returned

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_KEY_INDEX 239 The key handle is invalid.
KeyIndex <0 or KeyIndex > 14.


Only allow one user to logon


API Prototype
long __stdcall UniKey_Logon_Single( WORD* pHandle ,
DWORD* pPassword1 ,
DWORD* pPassword2 ,
DWORD* pPassword3 ,
DWORD* pPassword4 ) ;

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

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

Return values
Marco Value Meaning
SUCCESS 0 Success
ERROR_UNIKEY_INVALID_PASSWORD_OR_ID 202 The password or ID is invalid.


Logoff the active user


API Prototype
long __stdcall UniKey_Logoff( WORD* pHandle ) ;


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

Parameters
Parameter Meaning
*pHandle [in]Device handle

Return values
Marco Value Meaning
SUCCESS 0 Success


Logoff all the users


API Prototype
long __stdcall UniKey_Logoff_All( WORD* pHandle ) ;

Description
After calling this function, all the users will be logoff.

Parameters
Parameter Meaning
*pHandle [in]Device handle

Return values
Marco Value Meaning
SUCCESS 0 Success 


<a _fcknotitle="true" href="Category:UniKey_APIs">UniKey_APIs</a>