UniToken API Reference: Difference between revisions
No edit summary |
No edit summary |
||
| Line 232: | Line 232: | ||
== UT_GetSoftID == | == UT_GetSoftID == | ||
'''Prototype '''<br>UT_RV UT_API UT_GetSoftID( <br>UT_HANDLE utHandle, <br> unsigned long* lpSoftID <br> ) <br> <br>'''Description''' <br>To get the Software ID of the specified device <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in]device handle <br>lpSoftID [out] Software ID <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br> <br>'''Sample '''<br>See also the sample of UT_SetSoftID <br> | '''Prototype '''<br>UT_RV UT_API UT_GetSoftID( <br>UT_HANDLE utHandle, <br> unsigned long* lpSoftID <br> ) <br> <br>'''Description''' <br>To get the Software ID of the specified device <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in]device handle <br>lpSoftID [out] Software ID <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br> <br>'''Sample '''<br>See also the sample of UT_SetSoftID <br> | ||
== UT_SetSoftID == | == UT_SetSoftID == | ||
'''Prototype '''<br>UT_RV UT_API UT_SetSoftID( <br>UT_HANDLE utHandle, <br> unsigned long SoftID <br> ) <br> <br>'''Description '''<br>To set the Software ID of the specified device <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in]device handle <br>SoftID [in] Software ID <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_NO_PERMISSION No permission <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>unsigned long SoftID = 0; <br>ret = UT_GetSoftID(utHandle,&SoftID); <br>ret = UT_SetSoftID(utHandle,SoftID);<br> | '''Prototype '''<br>UT_RV UT_API UT_SetSoftID( <br>UT_HANDLE utHandle, <br> unsigned long SoftID <br> ) <br> <br>'''Description '''<br>To set the Software ID of the specified device <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in]device handle <br>SoftID [in] Software ID <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_NO_PERMISSION No permission <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>unsigned long SoftID = 0; <br>ret = UT_GetSoftID(utHandle,&SoftID); <br>ret = UT_SetSoftID(utHandle,SoftID);<br> | ||
== UT_LED == | == UT_LED == | ||
'''Prototype '''<br>UT_RV UT_API UT_LED ( <br>UT_HANDLE utHandle, <br> unsigned char On <br> ) <br> <br>'''Description '''<br>To turn on/off LED <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in]device handle <br>On [in]the status of LED <br> | '''Prototype '''<br>UT_RV UT_API UT_LED ( <br>UT_HANDLE utHandle, <br> unsigned char On <br> ) <br> <br>'''Description '''<br>To turn on/off LED <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in]device handle <br>On [in]the status of LED <br> | ||
'''Notes: '''<br>The parameter on can be LED_ON or LED_OFF <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>ret = UT_LED(utHandle,LED_ON);<br> | '''Notes: '''<br>The parameter on can be LED_ON or LED_OFF <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>ret = UT_LED(utHandle,LED_ON);<br> | ||
== UT_SetAttemptCount == | == UT_SetAttemptCount == | ||
'''Prototype '''<br>UT_RV UT_API UT_SetAttemptCount( <br>UT_HANDLE utHandle, <br> unsigned long MaxAttempt <br> ) <br> <br>'''Description '''<br>To set the maximum times of PIN attempt <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in]device handle <br>MaxAttempt [in] maximum attempt times <br> | '''Prototype '''<br>UT_RV UT_API UT_SetAttemptCount( <br>UT_HANDLE utHandle, <br> unsigned long MaxAttempt <br> ) <br> <br>'''Description '''<br>To set the maximum times of PIN attempt <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in]device handle <br>MaxAttempt [in] maximum attempt times <br> | ||
<br> | <br> | ||
'''Notes: '''<br>The maximum times of attempt UniToken allows is 15 times. If a user types in <br>wrong PIN consecutively for 15 times, the UniToken will be locked. | '''Notes: '''<br>The maximum times of attempt UniToken allows is 15 times. If a user types in <br>wrong PIN consecutively for 15 times, the UniToken will be locked. | ||
<br> | <br> | ||
'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br> <br>'''Usage note '''<br>This function is used for unlocking the token. <br> <br>'''Sample '''<br>See also the sample of UT_GetAttemptCount <br> | '''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br> <br>'''Usage note '''<br>This function is used for unlocking the token. <br> <br>'''Sample '''<br>See also the sample of UT_GetAttemptCount <br> | ||
== UT_GetAttemptCount == | == UT_GetAttemptCount == | ||
'''Prototype '''<br>UT_RV UT_API UT_GetAttemptCount( <br>UT_HANDLE utHandle, <br> unsigned long* lpUserAttempt, <br> unsigned long* lpAdminAttempt <br> ) <br> <br>'''Description '''<br>To count the attempt times <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in]device handle <br>lpUserAttempt [out]User PIN attempt times <br>lpAdminAttempt [out]Admin PIN attempt times <br> | '''Prototype '''<br>UT_RV UT_API UT_GetAttemptCount( <br>UT_HANDLE utHandle, <br> unsigned long* lpUserAttempt, <br> unsigned long* lpAdminAttempt <br> ) <br> <br>'''Description '''<br>To count the attempt times <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in]device handle <br>lpUserAttempt [out]User PIN attempt times <br>lpAdminAttempt [out]Admin PIN attempt times <br> | ||
<br> | <br> | ||
'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>unsigned long UserAttempt; <br>unsigned long AdminAttempt; <br>ret = UT_SetAttemptCount(utHandle,15); <br>ret = UT_GetAttemptCount( <br> utHandle, <br> &UserAttempt, <br> &AdminAttempt <br>);<br> | '''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>unsigned long UserAttempt; <br>unsigned long AdminAttempt; <br>ret = UT_SetAttemptCount(utHandle,15); <br>ret = UT_GetAttemptCount( <br> utHandle, <br> &UserAttempt, <br> &AdminAttempt <br>);<br> | ||
== UT_Format == | == UT_Format == | ||
'''Prototype '''<br>UT_RV UT_API UT_Format(UT_HANDLE utHandle) <br> <br>'''Description '''<br>To format a UniToken <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in]device handle<br> | '''Prototype '''<br>UT_RV UT_API UT_Format(UT_HANDLE utHandle) <br> <br>'''Description '''<br>To format a UniToken <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in]device handle<br> | ||
<br> | <br> | ||
'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br> '''<br>Usage note '''<br>After formatting, the PINs of User and Admin are set back to the default ones as <br>well as the whole file system and all the keys inside. <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>ret = UT_Format(utHandle);<br> | '''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br> '''<br>Usage note '''<br>After formatting, the PINs of User and Admin are set back to the default ones as <br>well as the whole file system and all the keys inside. <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>ret = UT_Format(utHandle);<br> | ||
== UT_Rand == | == UT_Rand == | ||
'''Prototype '''<br>UT_RV UT_API UT_Rand( <br>UT_HANDLE utHandle, <br> unsigned long Length, <br> unsigned char* lpOut, <br> void* lpReserve <br> ) <br> <br>'''Description '''<br>To generate random numbers <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>Length [in]length of random number (in <br>byte) <br>lpOut [out] random number <br>lpReserve reserved for future usage <br> | '''Prototype '''<br>UT_RV UT_API UT_Rand( <br>UT_HANDLE utHandle, <br> unsigned long Length, <br> unsigned char* lpOut, <br> void* lpReserve <br> ) <br> <br>'''Description '''<br>To generate random numbers <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>Length [in]length of random number (in <br>byte) <br>lpOut [out] random number <br>lpReserve reserved for future usage <br> | ||
<br> | <br> | ||
'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>unsigned char OutRand[8]; <br>ret = UT_Rand(utHandle,8,OutRand,NULL);<br> | '''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>unsigned char OutRand[8]; <br>ret = UT_Rand(utHandle,8,OutRand,NULL);<br> | ||
== UT_DESGenerateKey == | == UT_DESGenerateKey == | ||
'''Prototype '''<br>UT_RV UT_API UT_DESGenerateKey( <br>UT_HANDLE utHandle, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To generate a DES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyHandle [out] key handle <br> <br>'''Note: '''<br>The length of generated DES key is 8 bytes.<br> | '''Prototype '''<br>UT_RV UT_API UT_DESGenerateKey( <br>UT_HANDLE utHandle, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To generate a DES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyHandle [out] key handle <br> <br>'''Note: '''<br>The length of generated DES key is 8 bytes.<br> | ||
<br> | <br> | ||
'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_FULL No more key can be generated <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_DESGenerateKey(utHandle,&KeyHandle);<br> | '''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_FULL No more key can be generated <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_DESGenerateKey(utHandle,&KeyHandle);<br> | ||
== UT_DESEncrypt == | == UT_DESEncrypt == | ||
'''Prototype '''<br>UT_RV UT_API UT_DESEncryptZ( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle, <br> unsigned char* lpData, <br> unsigned long DataLength, <br> unsigned char* lpEncryptedData, <br> unsigned long* lpEncryptedDataLength <br> ) <br> <br>'''Description '''<br>To encrypt data with DES <br> | '''Prototype '''<br>UT_RV UT_API UT_DESEncryptZ( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle, <br> unsigned char* lpData, <br> unsigned long DataLength, <br> unsigned char* lpEncryptedData, <br> unsigned long* lpEncryptedDataLength <br> ) <br> <br>'''Description '''<br>To encrypt data with DES <br> | ||
Parameters <br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle <br>lpData [in] plain text <br>DataLength [in]length of plain text <br>lpEncryptedData [out] cipher text <br>lpEncryptedDataLength [out] length of cipher text <br> <br>'''Notes: '''<br>DateLength is DES_DATA_LEN_8_BYTE <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned char Data[DES_DATA_LEN_8_BYTE]; <br>unsigned char EncryptedData[DES_DATA_LEN_8_BYTE]; <br>unsigned long EncryptedDataLength; <br>ret = UT_DESEncrypt( <br>utHandle, <br>keyHandle, <br>Data, <br> DES_DATA_LEN_8_BYTE, <br>EncryptedData, <br> &EncryptedDataLength);<br> | Parameters <br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle <br>lpData [in] plain text <br>DataLength [in]length of plain text <br>lpEncryptedData [out] cipher text <br>lpEncryptedDataLength [out] length of cipher text <br> <br>'''Notes: '''<br>DateLength is DES_DATA_LEN_8_BYTE <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned char Data[DES_DATA_LEN_8_BYTE]; <br>unsigned char EncryptedData[DES_DATA_LEN_8_BYTE]; <br>unsigned long EncryptedDataLength; <br>ret = UT_DESEncrypt( <br>utHandle, <br>keyHandle, <br>Data, <br> DES_DATA_LEN_8_BYTE, <br>EncryptedData, <br> &EncryptedDataLength);<br> | ||
== UT_DESDecrypt == | == UT_DESDecrypt == | ||
'''Prototype '''<br>UT_RV UT_API UT_DESDecrypt( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle, <br> unsigned char* lpEncryptedData, <br> unsigned long EncryptedDataLength, <br> unsigned char* lpData, <br> unsigned long* lpDataLength <br> ) <br> <br>'''Description '''<br>To decrypt data with DES <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle <br>lpEncryptedData [out] plain text <br>EncryptedDataLength [out] length of plain text <br>lpData [in] cipher text <br>lpDataLength [in]length of cipher text <br> <br>'''Notes: '''<br>EncryptedDataLength is DES_DATA_LEN_8_BYTE <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned char Data[DES_DATA_LEN_8_BYTE]; <br>unsigned char EncryptedData[DES_DATA_LEN_8_BYTE]; <br>unsigned long DataLength; <br>ret = UT_DESDecrypt( <br>utHandle, <br>KeyHandle, <br>EncryptedData, <br>DES_DATA_LEN_8_BYTE, <br>Data, <br>&DataLength <br>)<br> | '''Prototype '''<br>UT_RV UT_API UT_DESDecrypt( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle, <br> unsigned char* lpEncryptedData, <br> unsigned long EncryptedDataLength, <br> unsigned char* lpData, <br> unsigned long* lpDataLength <br> ) <br> <br>'''Description '''<br>To decrypt data with DES <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle <br>lpEncryptedData [out] plain text <br>EncryptedDataLength [out] length of plain text <br>lpData [in] cipher text <br>lpDataLength [in]length of cipher text <br> <br>'''Notes: '''<br>EncryptedDataLength is DES_DATA_LEN_8_BYTE <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned char Data[DES_DATA_LEN_8_BYTE]; <br>unsigned char EncryptedData[DES_DATA_LEN_8_BYTE]; <br>unsigned long DataLength; <br>ret = UT_DESDecrypt( <br>utHandle, <br>KeyHandle, <br>EncryptedData, <br>DES_DATA_LEN_8_BYTE, <br>Data, <br>&DataLength <br>)<br> | ||
== UT_DESImportKey == | == UT_DESImportKey == | ||
'''Prototype '''<br>UT_RV UT_API UT_DESImportKey( <br>UT_HANDLE utHandle, <br> unsigned char* lpKey, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To import a DES key to UniToken device <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKey [in] DES key <br>lpKeyHandle [out] key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_FULL No more key can be <br>generated <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned char Key[DES_KEY_LEN_8_BYTE]; <br>ret = UT_DESImportKey(utHandle,Key,&KeyHandle);<br> | '''Prototype '''<br>UT_RV UT_API UT_DESImportKey( <br>UT_HANDLE utHandle, <br> unsigned char* lpKey, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To import a DES key to UniToken device <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKey [in] DES key <br>lpKeyHandle [out] key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_FULL No more key can be <br>generated <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned char Key[DES_KEY_LEN_8_BYTE]; <br>ret = UT_DESImportKey(utHandle,Key,&KeyHandle);<br> | ||
== UT_DESDeleteKey == | == UT_DESDeleteKey == | ||
'''Prototype '''<br>UT_RV UT_API UT_DESDeleteKey( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle <br> ) <br> <br>'''Description '''<br>To delete a DES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_DESDeleteKey(utHandle,KeyHandle);<br> | '''Prototype '''<br>UT_RV UT_API UT_DESDeleteKey( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle <br> ) <br> <br>'''Description '''<br>To delete a DES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_DESDeleteKey(utHandle,KeyHandle);<br> | ||
== UT_DESGetKeyCount == | == UT_DESGetKeyCount == | ||
'''Prototype '''<br>UT_RV UT_API UT_DESGetKeyCount( <br>UT_HANDLE utHandle, <br> unsigned long* lpKeyCount <br> ) <br> <br>'''Description '''<br>To count DES keys <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyCount [out]the number of keys <br> <br>'''Notes: '''<br>The maximum number of DES keys is 16. <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>unsigned long KeyCount; <br>ret = UT_DESGetKeyCount(utHandle,&KeyCount);<br> | '''Prototype '''<br>UT_RV UT_API UT_DESGetKeyCount( <br>UT_HANDLE utHandle, <br> unsigned long* lpKeyCount <br> ) <br> <br>'''Description '''<br>To count DES keys <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyCount [out]the number of keys <br> <br>'''Notes: '''<br>The maximum number of DES keys is 16. <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>unsigned long KeyCount; <br>ret = UT_DESGetKeyCount(utHandle,&KeyCount);<br> | ||
== UT_DESGetFirstKeyHandle == | == UT_DESGetFirstKeyHandle == | ||
'''Prototype '''<br>UT_RV UT_API UT_DESGetFirstKeyHandle( <br>UT_HANDLE utHandle, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To get the handle of the first DES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyHandle [out] key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br> <br>'''Sample '''<br>See also the sample of UT_DESGetNextKeyHandle<br> | '''Prototype '''<br>UT_RV UT_API UT_DESGetFirstKeyHandle( <br>UT_HANDLE utHandle, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To get the handle of the first DES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyHandle [out] key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br> <br>'''Sample '''<br>See also the sample of UT_DESGetNextKeyHandle<br> | ||
== UT_DESGetNextKeyHandle == | == UT_DESGetNextKeyHandle == | ||
'''Prototype '''<br>UT_RV UT_API UT_DESGetNextKeyHandle( <br>UT_HANDLE utHandle, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To get the handle of the next DES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyHandle [out] key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br>UT_OPERATE_INVALID Invalid operation <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_DESGetFirstKeyHandle(utHandle,&KeyHandle); <br>ret = UT_DESGetNextKeyHandle(utHandle,&KeyHandle);<br> | '''Prototype '''<br>UT_RV UT_API UT_DESGetNextKeyHandle( <br>UT_HANDLE utHandle, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To get the handle of the next DES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyHandle [out] key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br>UT_OPERATE_INVALID Invalid operation <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_DESGetFirstKeyHandle(utHandle,&KeyHandle); <br>ret = UT_DESGetNextKeyHandle(utHandle,&KeyHandle);<br> | ||
== UT_DES3GenerateKey == | == UT_DES3GenerateKey == | ||
'''Prototype '''<br>UT_RV UT_API UT_DES3GenerateKey( <br>UT_HANDLE utHandle, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To generate a 3DES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyHandle [out]key handle <br> <br>'''Note: '''<br>The length of generated 3DES key is 24 bytes. <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_FULL No more key can be <br>generated <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_DES3GenerateKey(utHandle,&KeyHandle);<br> | '''Prototype '''<br>UT_RV UT_API UT_DES3GenerateKey( <br>UT_HANDLE utHandle, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To generate a 3DES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyHandle [out]key handle <br> <br>'''Note: '''<br>The length of generated 3DES key is 24 bytes. <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_FULL No more key can be <br>generated <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_DES3GenerateKey(utHandle,&KeyHandle);<br> | ||
== UT_DES3Encrypt == | == UT_DES3Encrypt == | ||
'''Prototype '''<br>UT_RV UT_API UT_DES3Encrypt( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle, <br> unsigned char* lpData, <br> unsigned long DataLength, <br> unsigned char* lpEncryptedData, <br> unsigned long* lpEncryptedDataLength <br> ) <br> <br>'''Description '''<br>To encrypt data with 3DES <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle <br>lpData [in] plain text <br>DataLength [in]length of plain text <br>lpEncryptedData [out] cipher text <br>lpEncryptedDataLength [out] length of cipher text <br> <br>'''Notes: '''<br>DateLength is DES_DATA_LEN_8_BYTE <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned char Data[DES_DATA_LEN_8_BYTE]; <br>unsigned char EncryptedData[DES_DATA_LEN_8_BYTE]; <br>unsigned long EncryptedDataLength; <br>ret = UT_DES3Encrypt( <br>utHandle, <br>keyHandle, <br>Data, <br> DES_DATA_LEN_8_BYTE, <br>EncryptedData, <br> &EncryptedDataLength <br>);<br> | '''Prototype '''<br>UT_RV UT_API UT_DES3Encrypt( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle, <br> unsigned char* lpData, <br> unsigned long DataLength, <br> unsigned char* lpEncryptedData, <br> unsigned long* lpEncryptedDataLength <br> ) <br> <br>'''Description '''<br>To encrypt data with 3DES <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle <br>lpData [in] plain text <br>DataLength [in]length of plain text <br>lpEncryptedData [out] cipher text <br>lpEncryptedDataLength [out] length of cipher text <br> <br>'''Notes: '''<br>DateLength is DES_DATA_LEN_8_BYTE <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned char Data[DES_DATA_LEN_8_BYTE]; <br>unsigned char EncryptedData[DES_DATA_LEN_8_BYTE]; <br>unsigned long EncryptedDataLength; <br>ret = UT_DES3Encrypt( <br>utHandle, <br>keyHandle, <br>Data, <br> DES_DATA_LEN_8_BYTE, <br>EncryptedData, <br> &EncryptedDataLength <br>);<br> | ||
== UT_DES3Decrypt == | == UT_DES3Decrypt == | ||
'''Prototype '''<br>UT_RV UT_API UT_DES3Decrypt( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle, <br> unsigned char* lpEncryptedData , <br> unsigned long EncryptedDataLength, <br> unsigned char* lpData, <br> unsigned long* lpDataLength <br> ) <br> <br>'''Description '''<br>To decrypt data with 3DES <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle <br>lpEncryptedData [in] cipher text <br>EncryptedDataLength [in]length of cipher text <br>lpData [out] plain text <br>lpDataLength [out] length of plain text <br> <br>'''Notes: '''<br>EncryptedDataLength is DES_DATA_LEN_8_BYTE <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned char Data[DES_DATA_LEN_8_BYTE]; <br>unsigned char EncryptedData[DES_DATA_LEN_8_BYTE]; <br>unsigned long DataLength; <br>ret = UT_DES3Decrypt( <br>utHandle, <br>keyHandle, <br>EncryptedData, <br> DES_DATA_LEN_8_BYTE, <br>Data, <br>&DataLength <br>);<br> | '''Prototype '''<br>UT_RV UT_API UT_DES3Decrypt( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle, <br> unsigned char* lpEncryptedData , <br> unsigned long EncryptedDataLength, <br> unsigned char* lpData, <br> unsigned long* lpDataLength <br> ) <br> <br>'''Description '''<br>To decrypt data with 3DES <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle <br>lpEncryptedData [in] cipher text <br>EncryptedDataLength [in]length of cipher text <br>lpData [out] plain text <br>lpDataLength [out] length of plain text <br> <br>'''Notes: '''<br>EncryptedDataLength is DES_DATA_LEN_8_BYTE <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned char Data[DES_DATA_LEN_8_BYTE]; <br>unsigned char EncryptedData[DES_DATA_LEN_8_BYTE]; <br>unsigned long DataLength; <br>ret = UT_DES3Decrypt( <br>utHandle, <br>keyHandle, <br>EncryptedData, <br> DES_DATA_LEN_8_BYTE, <br>Data, <br>&DataLength <br>);<br> | ||
== UT_DES3ImportKey == | == UT_DES3ImportKey == | ||
'''Prototype '''<br>UT_RV UT_API UT_DES3ImportKey( <br>UT_HANDLE utHandle, <br> unsigned char* lpKey, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To import 3DES keys to UniToken device <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKey [in] 3DES key <br>lpKeyHandle [out] key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_FULL No more key can be <br>generated <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned char Key[DES3_KEY_LEN_24_BYTE]; <br>ret = UT_DES3ImportKey(utHandle,Key,&KeyHandle);<br> | '''Prototype '''<br>UT_RV UT_API UT_DES3ImportKey( <br>UT_HANDLE utHandle, <br> unsigned char* lpKey, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To import 3DES keys to UniToken device <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKey [in] 3DES key <br>lpKeyHandle [out] key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_FULL No more key can be <br>generated <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned char Key[DES3_KEY_LEN_24_BYTE]; <br>ret = UT_DES3ImportKey(utHandle,Key,&KeyHandle);<br> | ||
== UT_DES3DeleteKey == | == UT_DES3DeleteKey == | ||
'''Prototype '''<br>UT_RV UT_API UT_DES3DeleteKey( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle <br> ) <br> <br>'''Description '''<br>To delete a 3DES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle <br> <br>'''Returned value: '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_DES3DeleteKey(utHandle,KeyHandle);<br> | '''Prototype '''<br>UT_RV UT_API UT_DES3DeleteKey( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle <br> ) <br> <br>'''Description '''<br>To delete a 3DES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle <br> <br>'''Returned value: '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_DES3DeleteKey(utHandle,KeyHandle);<br> | ||
== UT_DES3GetKeyCount == | == UT_DES3GetKeyCount == | ||
'''Prototype '''<br>UT_RV UT_API UT_DES3GetKeyCount( <br>UT_HANDLE utHandle, <br> unsigned long* lpKeyCount <br> ) <br> <br>'''Description '''<br>To count 3DES keys <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyCount [out]the number of keys <br> <br>'''Notes: '''<br>The maximum number of 3DES keys is 16. <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>unsigned long KeyCount; <br>ret = UT_DES3GetKeyCount(utHandle,&KeyCount);<br> | '''Prototype '''<br>UT_RV UT_API UT_DES3GetKeyCount( <br>UT_HANDLE utHandle, <br> unsigned long* lpKeyCount <br> ) <br> <br>'''Description '''<br>To count 3DES keys <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyCount [out]the number of keys <br> <br>'''Notes: '''<br>The maximum number of 3DES keys is 16. <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>unsigned long KeyCount; <br>ret = UT_DES3GetKeyCount(utHandle,&KeyCount);<br> | ||
== UT_DES3GetFirstKeyHandle == | == UT_DES3GetFirstKeyHandle == | ||
'''Prototype '''<br>UT_RV UT_API UT_DES3GetFirstKeyHandle( <br>UT_HANDLE utHandle, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To get the handle of the first 3DES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyHandle [out] key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br> <br>'''Sample '''<br>See also the samples of UT_DES3GetNextKeyHandle<br> | '''Prototype '''<br>UT_RV UT_API UT_DES3GetFirstKeyHandle( <br>UT_HANDLE utHandle, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To get the handle of the first 3DES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyHandle [out] key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br> <br>'''Sample '''<br>See also the samples of UT_DES3GetNextKeyHandle<br> | ||
== UT_DES3GetNextKeyHandle == | == UT_DES3GetNextKeyHandle == | ||
'''Prototype '''<br>UT_RV UT_API UT_DES3GetNextKeyHandle( <br>UT_HANDLE utHandle, <br>KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To get the handle of the next 3DES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyHandle [in] key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br>UT_OPERATE_INVALID Invalid operation <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_DES3GetFirstKeyHandle(utHandle,&KeyHandle); <br>ret = UT_DES3GetNextKeyHandle(utHandle,&KeyHandle);<br> | '''Prototype '''<br>UT_RV UT_API UT_DES3GetNextKeyHandle( <br>UT_HANDLE utHandle, <br>KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To get the handle of the next 3DES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyHandle [in] key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br>UT_OPERATE_INVALID Invalid operation <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_DES3GetFirstKeyHandle(utHandle,&KeyHandle); <br>ret = UT_DES3GetNextKeyHandle(utHandle,&KeyHandle);<br> | ||
== UT_AESGenerateKey == | == UT_AESGenerateKey == | ||
'''Prototype '''<br>UT_RV UT_API UT_AESGenerateKey( <br>UT_HANDLE utHandle, <br> unsigned long KeyLength, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To generate an AES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyLength [in]key length <br>lpKeyHandle [out] key handle <br> <br>'''Notes: '''<br>KeyLength can be AES_KEY_LEN_128_BIT or AES_KEY_LEN_192_BIT<br> | '''Prototype '''<br>UT_RV UT_API UT_AESGenerateKey( <br>UT_HANDLE utHandle, <br> unsigned long KeyLength, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To generate an AES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyLength [in]key length <br>lpKeyHandle [out] key handle <br> <br>'''Notes: '''<br>KeyLength can be AES_KEY_LEN_128_BIT or AES_KEY_LEN_192_BIT<br> | ||
<br> | <br> | ||
'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_FULL No more key can be <br>generated <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_AESGenerateKey( <br>utHandle, <br>AES_KEY_LEN_128_BIT, <br> &KeyHandle <br>);<br> | '''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_FULL No more key can be <br>generated <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_AESGenerateKey( <br>utHandle, <br>AES_KEY_LEN_128_BIT, <br> &KeyHandle <br>);<br> | ||
== UT_AESEncrypt == | == UT_AESEncrypt == | ||
'''Prototype '''<br>UT_RV UT_API UT_AESEncrypt( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle, <br> unsigned char* lpData, <br> unsigned long DataLength, <br> unsigned char* lpEncryptedData, <br> unsigned long* lpEncryptedDataLength <br> ) <br> <br>'''Description '''<br>To encrypt data with AES <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle <br>lpData [in] plaintext <br>DataLength [in]length of plaintext <br>lpEncryptedData [out] cipher text <br>lpEncryptedDataLength [out] length of cipher text <br> <br>'''Notes: '''<br>DateLength is AES_DATA_LEN_16_BYTE <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned char Data[AES_DATA_LEN_16_BYTE]; <br>unsigned char EncryptedData[AES_DATA_LEN_16_BYTE]; <br>unsigned long EncryptedDataLength; <br>ret = UT_AESEncrypt( <br>utHandle, <br>KeyHandle, <br>Data, <br> AES_DATA_LEN_16_BYTE, <br>EncryptedData, <br> &EncryptedDataLength <br>);<br> | '''Prototype '''<br>UT_RV UT_API UT_AESEncrypt( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle, <br> unsigned char* lpData, <br> unsigned long DataLength, <br> unsigned char* lpEncryptedData, <br> unsigned long* lpEncryptedDataLength <br> ) <br> <br>'''Description '''<br>To encrypt data with AES <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle <br>lpData [in] plaintext <br>DataLength [in]length of plaintext <br>lpEncryptedData [out] cipher text <br>lpEncryptedDataLength [out] length of cipher text <br> <br>'''Notes: '''<br>DateLength is AES_DATA_LEN_16_BYTE <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned char Data[AES_DATA_LEN_16_BYTE]; <br>unsigned char EncryptedData[AES_DATA_LEN_16_BYTE]; <br>unsigned long EncryptedDataLength; <br>ret = UT_AESEncrypt( <br>utHandle, <br>KeyHandle, <br>Data, <br> AES_DATA_LEN_16_BYTE, <br>EncryptedData, <br> &EncryptedDataLength <br>);<br> | ||
== UT_AESDecrypt == | == UT_AESDecrypt == | ||
'''Prototype '''<br>UT_RV UT_API UT_AESDecrypt( <br> ANDLE utHandle, <br> KEY_HANDLE KeyHandle, <br> unsigned char* lpEncryptedData, <br> nsigned long EncryptedDataLength, <br> unsigned char* lpData, <br> unsigned long* lpDataLength <br> ) <br> <br>'''Description '''<br>To decrypt data with AES <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle <br>lpEncryptedData [in] cipher text <br>EncryptedDataLength [in]length of cipher text <br>lpData [out] plaintext <br>lpDataLength [out] length of plain text <br> <br>'''Notes: '''<br>DateLength is AES_DATA_LEN_16_BYTE <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned char Data[AES_DATA_LEN_16_BYTE]; <br>unsigned char EncryptedData[AES_DATA_LEN_16_BYTE]; <br>unsigned long DataLength; <br>ret = UT_AESDecrypt( <br>ndle, <br>KeyHandle, <br>EncryptedData, <br> AES_DATA_LEN_16_BYTE, <br>Data, <br> &DataLength <br>);<br> | '''Prototype '''<br>UT_RV UT_API UT_AESDecrypt( <br> ANDLE utHandle, <br> KEY_HANDLE KeyHandle, <br> unsigned char* lpEncryptedData, <br> nsigned long EncryptedDataLength, <br> unsigned char* lpData, <br> unsigned long* lpDataLength <br> ) <br> <br>'''Description '''<br>To decrypt data with AES <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle <br>lpEncryptedData [in] cipher text <br>EncryptedDataLength [in]length of cipher text <br>lpData [out] plaintext <br>lpDataLength [out] length of plain text <br> <br>'''Notes: '''<br>DateLength is AES_DATA_LEN_16_BYTE <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned char Data[AES_DATA_LEN_16_BYTE]; <br>unsigned char EncryptedData[AES_DATA_LEN_16_BYTE]; <br>unsigned long DataLength; <br>ret = UT_AESDecrypt( <br>ndle, <br>KeyHandle, <br>EncryptedData, <br> AES_DATA_LEN_16_BYTE, <br>Data, <br> &DataLength <br>);<br> | ||
== UT_AESImportKey == | == UT_AESImportKey == | ||
'''Prototype '''<br>UT_RV UT_API UT_AESImportKey( <br> ANDLE utHandle, <br> unsigned char* lpKey, <br> unsigned long KeyLength, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To import AES key to UniToken device <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKey [in] AES key <br>KeyLength [in]key length <br>lpKeyHandle [out] key handle <br> <br>'''Notes: '''<br>KeyLength can be AES_KEY_LEN_128_BIT or AES_KEY_LEN_192_BIT <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_FULL No more key can be <br>generated <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned char key[AES_KEY_LEN_128_BIT]; <br>Ret = UT_AESImportKey( <br>utHandle, <br>key, <br>AES_KEY_LEN_128_BIT, <br>&KeyHandle <br>);<br> | '''Prototype '''<br>UT_RV UT_API UT_AESImportKey( <br> ANDLE utHandle, <br> unsigned char* lpKey, <br> unsigned long KeyLength, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To import AES key to UniToken device <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKey [in] AES key <br>KeyLength [in]key length <br>lpKeyHandle [out] key handle <br> <br>'''Notes: '''<br>KeyLength can be AES_KEY_LEN_128_BIT or AES_KEY_LEN_192_BIT <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_FULL No more key can be <br>generated <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned char key[AES_KEY_LEN_128_BIT]; <br>Ret = UT_AESImportKey( <br>utHandle, <br>key, <br>AES_KEY_LEN_128_BIT, <br>&KeyHandle <br>);<br> | ||
== UT_AESDeleteKey == | == UT_AESDeleteKey == | ||
| Line 374: | Line 374: | ||
'''Prototype '''<br>UT_RV UT_API UT_AESDeleteKey( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle <br> ) <br> <br>'''Description '''<br>To delete an AES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle | '''Prototype '''<br>UT_RV UT_API UT_AESDeleteKey( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle <br> ) <br> <br>'''Description '''<br>To delete an AES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle | ||
Returned value <br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_AESDeleteKey(utHandle,KeyHandle);<br> | Returned value <br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_AESDeleteKey(utHandle,KeyHandle);<br> | ||
== UT_AESGetKeyCount == | == UT_AESGetKeyCount == | ||
'''Prototype '''<br>UT_RV UT_API UT_AESGetKeyCount( <br>UT_HANDLE utHandle, <br> unsigned long* lpKeyCount <br> ) <br> <br>'''Description '''<br>To count AES keys <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyCount [out]the number of keys <br> <br>'''Notes: '''<br>The maximum number of 3DES keys is 32. <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>unsigned long KeyCount; <br>ret = UT_AESGetKeyCount(utHandle,&KeyCount);<br> | '''Prototype '''<br>UT_RV UT_API UT_AESGetKeyCount( <br>UT_HANDLE utHandle, <br> unsigned long* lpKeyCount <br> ) <br> <br>'''Description '''<br>To count AES keys <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyCount [out]the number of keys <br> <br>'''Notes: '''<br>The maximum number of 3DES keys is 32. <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>unsigned long KeyCount; <br>ret = UT_AESGetKeyCount(utHandle,&KeyCount);<br> | ||
== UT_AESGetKeyLen == | == UT_AESGetKeyLen == | ||
'''Prototype '''<br>UT_RV UT_API UT_AESGetKeyLen( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle, <br> unsigned long* lpKeyLength <br> ) <br> <br>'''Description '''<br>To get the length of AES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle <br>lpKeyLength [out] key length <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned long KeyLength; <br>ret = UT_AESGetKeyLen(utHandle,KeyHandle,&KeyLength);<br> | '''Prototype '''<br>UT_RV UT_API UT_AESGetKeyLen( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle, <br> unsigned long* lpKeyLength <br> ) <br> <br>'''Description '''<br>To get the length of AES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle <br>lpKeyLength [out] key length <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned long KeyLength; <br>ret = UT_AESGetKeyLen(utHandle,KeyHandle,&KeyLength);<br> | ||
== UT_AESGetFirstKeyHandle == | == UT_AESGetFirstKeyHandle == | ||
'''Prototype '''<br>UT_RV UT_API UT_AESGetFirstKeyHandle( <br>UT_HANDLE utHandle, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To get the handle of the first AES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyHandle [out] key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br> <br>'''Sample '''<br>See also the sample of UT_AESGetNextKeyHandle<br> | '''Prototype '''<br>UT_RV UT_API UT_AESGetFirstKeyHandle( <br>UT_HANDLE utHandle, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To get the handle of the first AES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyHandle [out] key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br> <br>'''Sample '''<br>See also the sample of UT_AESGetNextKeyHandle<br> | ||
== UT_AESGetNextKeyHandle == | == UT_AESGetNextKeyHandle == | ||
'''Prototype '''<br>UT_RV UT_API UT_AESGetNextKeyHandle( <br>UT_HANDLE utHandle, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To get the handle of the next AES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyHandle [out] key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br>UT_OPERATE_INVALID Invalid operation <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_AESGetFirstKeyHandle(utHandle,&KeyHandle); <br>ret = UT_AESGetNextKeyHandle(utHandle,&KeyHandle);<br> | '''Prototype '''<br>UT_RV UT_API UT_AESGetNextKeyHandle( <br>UT_HANDLE utHandle, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To get the handle of the next AES key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyHandle [out] key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br>UT_OPERATE_INVALID Invalid operation <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_AESGetFirstKeyHandle(utHandle,&KeyHandle); <br>ret = UT_AESGetNextKeyHandle(utHandle,&KeyHandle);<br> | ||
== UT_RSAGenerateKeyPair == | == UT_RSAGenerateKeyPair == | ||
'''Prototype '''<br>UT_RV UT_API UT_RSAGenerateKeyPair( <br>UT_HANDLE utHandle, <br> unsigned long ModulusBits, <br> unsigned long PubExp, <br> KEY_HANDLE_PTR lpPubKeyHandle, <br> KEY_HANDLE_PTR lpPriKeyHandle <br> ) <br> <br>'''Description '''<br>To generate RSA key pair <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>ModulusBits [in] modulus length <br>PubExp [in]public exponent <br>lpPubKeyHandle [out] public key handle <br>lpPriKeyHandle [out] private key handle <br> <br>'''Notes: '''<br>1. UniToken device can store as many as 16 RSA key pairs <br>2. ModulusBits can be RSA_MODULUS_LEN_1024_BIT or <br>RSA_MODULUS_LEN_2048_BIT <br>3. PubExp is RSA_PUBEXP_LEN_65537_BIT <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_FULL No more key can be <br>generated <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE PubKeyHandle; <br>KEY_HANDLE PriKeyHandle; <br>ret = UT_RSAGenerateKeyPair( <br>utHandle, <br>RSA_KEY_LEN_1024_BIT, <br> RSA_PUBEXP_LEN_65537_BIT, <br>&PubKeyHandle, <br>&PriKeyHandle <br>);<br> | '''Prototype '''<br>UT_RV UT_API UT_RSAGenerateKeyPair( <br>UT_HANDLE utHandle, <br> unsigned long ModulusBits, <br> unsigned long PubExp, <br> KEY_HANDLE_PTR lpPubKeyHandle, <br> KEY_HANDLE_PTR lpPriKeyHandle <br> ) <br> <br>'''Description '''<br>To generate RSA key pair <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>ModulusBits [in] modulus length <br>PubExp [in]public exponent <br>lpPubKeyHandle [out] public key handle <br>lpPriKeyHandle [out] private key handle <br> <br>'''Notes: '''<br>1. UniToken device can store as many as 16 RSA key pairs <br>2. ModulusBits can be RSA_MODULUS_LEN_1024_BIT or <br>RSA_MODULUS_LEN_2048_BIT <br>3. PubExp is RSA_PUBEXP_LEN_65537_BIT <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_FULL No more key can be <br>generated <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE PubKeyHandle; <br>KEY_HANDLE PriKeyHandle; <br>ret = UT_RSAGenerateKeyPair( <br>utHandle, <br>RSA_KEY_LEN_1024_BIT, <br> RSA_PUBEXP_LEN_65537_BIT, <br>&PubKeyHandle, <br>&PriKeyHandle <br>);<br> | ||
== UT_RSAPubKeyEncrypt == | == UT_RSAPubKeyEncrypt == | ||
'''Prototype '''<br>UT_RV UT_API UT_RSAPubKeyEncrypt( <br>UT_HANDLE utHandle, <br> KEY_HANDLE PubKeyHandle, <br> unsigned char* lpData, <br> unsigned long DataLength, <br> unsigned char* lpEncryptedData, <br> unsigned long* lpEncryptedDataLength <br> ) <br> <br>'''Description '''<br>To encrypt data with RSA public key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>PubKeyHandle [in] public key handle <br>lpData [in] plain text <br>DataLength [in]length of plain text <br>lpEncryptedData [out] cipher text <br>lpEncryptedDataLength [out] length of cipher text <br> <br>'''Notes: '''<br>DataLength can be RSA_DATA_LEN_1024_BIT or SA_DATA_LEN_2048_BIT <br> '''<br>Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Usage note '''<br>The handle of public key should be gotten by UT_RSAGetPubKeyByPriKey <br>instead of manually input. A 1024-bit RSA public key can only encrypt 1024-bit <br>data. It is also true for 2048-bit RSA public keys. <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE PubKeyHandle; <br>unsigned char Data[RSA_DATA_LEN_1024_BIT]; <br>unsigned char EncryptedData[RSA_DATA_LEN_1024_BIT]; <br>unsigned long EncryptedDataLength; <br> <br>ret = UT_RSAPubKeyEncrypt( <br>utHandle, <br>PubKeyHandle, <br>Data, <br> RSA_DATA_LEN_1024_BIT, <br> EncryptedData, <br>&EncryptedDataLength <br>);<br> | '''Prototype '''<br>UT_RV UT_API UT_RSAPubKeyEncrypt( <br>UT_HANDLE utHandle, <br> KEY_HANDLE PubKeyHandle, <br> unsigned char* lpData, <br> unsigned long DataLength, <br> unsigned char* lpEncryptedData, <br> unsigned long* lpEncryptedDataLength <br> ) <br> <br>'''Description '''<br>To encrypt data with RSA public key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>PubKeyHandle [in] public key handle <br>lpData [in] plain text <br>DataLength [in]length of plain text <br>lpEncryptedData [out] cipher text <br>lpEncryptedDataLength [out] length of cipher text <br> <br>'''Notes: '''<br>DataLength can be RSA_DATA_LEN_1024_BIT or SA_DATA_LEN_2048_BIT <br> '''<br>Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Usage note '''<br>The handle of public key should be gotten by UT_RSAGetPubKeyByPriKey <br>instead of manually input. A 1024-bit RSA public key can only encrypt 1024-bit <br>data. It is also true for 2048-bit RSA public keys. <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE PubKeyHandle; <br>unsigned char Data[RSA_DATA_LEN_1024_BIT]; <br>unsigned char EncryptedData[RSA_DATA_LEN_1024_BIT]; <br>unsigned long EncryptedDataLength; <br> <br>ret = UT_RSAPubKeyEncrypt( <br>utHandle, <br>PubKeyHandle, <br>Data, <br> RSA_DATA_LEN_1024_BIT, <br> EncryptedData, <br>&EncryptedDataLength <br>);<br> | ||
== UT_RSAPriKeyDecrypt == | == UT_RSAPriKeyDecrypt == | ||
'''Prototype '''<br>UT_RV UT_API UT_RSAPriKeyDecrypt( <br>UT_HANDLE utHandle, <br> KEY_HANDLE PriKeyHandle, <br> unsigned char* lpEncryptedData, <br> unsigned long EncryptedDataLength, <br> unsigned char* lpData, <br> unsigned long* lpDataLength <br> ) <br> <br>'''Description '''<br>To decrypt data with RSA private key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>PriKeyHandle [in] private key handle <br>lpEncryptedData [in] cipher text <br>EncryptedDataLength [in]length of cipher text <br>lpData [out] plaintext <br>lpDataLength [out] length of plain text <br> <br>'''Notes: '''<br>DataLength can be RSA_DATA_LEN_1024_BIT or SA_DATA_LEN_2048_BIT <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Usage note '''<br>The handle of private key should be gotten by RSAGetPriKeyByPubKey instead <br>of manually input. A 1024-bit RSA private key can only decrypt 1024-bit data. It <br>is also true for 2048-bit RSA private keys. <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE PriKeyHandle; <br>unsigned char Data[RSA_DATA_LEN_1024_BIT]; <br>unsigned char EncryptedData[RSA_DATA_LEN_1024_BIT]; <br>unsigned long DataLength; <br>ret = UT_RSAPriKeyDecrypt( <br>utHandle, <br>PriKeyHandle, <br> EncryptedData, <br> RSA_DATA_LEN_1024_BIT,Data, <br> &DataLength <br>);<br> | '''Prototype '''<br>UT_RV UT_API UT_RSAPriKeyDecrypt( <br>UT_HANDLE utHandle, <br> KEY_HANDLE PriKeyHandle, <br> unsigned char* lpEncryptedData, <br> unsigned long EncryptedDataLength, <br> unsigned char* lpData, <br> unsigned long* lpDataLength <br> ) <br> <br>'''Description '''<br>To decrypt data with RSA private key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>PriKeyHandle [in] private key handle <br>lpEncryptedData [in] cipher text <br>EncryptedDataLength [in]length of cipher text <br>lpData [out] plaintext <br>lpDataLength [out] length of plain text <br> <br>'''Notes: '''<br>DataLength can be RSA_DATA_LEN_1024_BIT or SA_DATA_LEN_2048_BIT <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Usage note '''<br>The handle of private key should be gotten by RSAGetPriKeyByPubKey instead <br>of manually input. A 1024-bit RSA private key can only decrypt 1024-bit data. It <br>is also true for 2048-bit RSA private keys. <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE PriKeyHandle; <br>unsigned char Data[RSA_DATA_LEN_1024_BIT]; <br>unsigned char EncryptedData[RSA_DATA_LEN_1024_BIT]; <br>unsigned long DataLength; <br>ret = UT_RSAPriKeyDecrypt( <br>utHandle, <br>PriKeyHandle, <br> EncryptedData, <br> RSA_DATA_LEN_1024_BIT,Data, <br> &DataLength <br>);<br> | ||
== UT_RSAPriKeyEncrypt == | == UT_RSAPriKeyEncrypt == | ||
'''Prototype '''<br>UT_RV UT_API UT_RSAPriKeyEncrypt( <br>UT_HANDLE utHandle, <br> KEY_HANDLE PriKeyHandle, <br> unsigned char* lpData, <br> unsigned long DataLength, <br> unsigned char* lpEncryptedData, <br> unsigned long* lpEncryptedDataLength <br> ) <br> <br>'''Description '''<br>To encrypt data with RSA private key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>PriKeyHandle [in] private key handle <br>lpData [in] plain text <br>DataLength [in]length of plain text <br>lpEncryptedData [out] cipher text <br>lpEncryptedDataLength [out] length of cipher text <br> <br>'''Notes: '''<br>DataLength can be RSA_DATA_LEN_1024_BIT or SA_DATA_LEN_2048_BIT <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Usage note '''<br>The handle of private key should be gotten by UT_RSAGetPriKeyByPubKey <br>instead of manually input. A 1024-bit RSA private key can only encrypt 1024-bit <br>data. It is also true for 2048-bit RSA private keys. <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE PriKeyHandle; <br>unsigned char Data[RSA_DATA_LEN_1024_BIT]; <br>unsigned char EncryptedData[RSA_DATA_LEN_1024_BIT]; <br>unsigned long EncryptedDataLength; <br>ret = UT_RSAPriKeyEncrypt( <br>utHandle, <br>PriKeyHandle,Data, <br> RSA_DATA_LEN_1024_BIT, <br>EncryptedData, <br> &EncryptedDataLength <br>);<br> | '''Prototype '''<br>UT_RV UT_API UT_RSAPriKeyEncrypt( <br>UT_HANDLE utHandle, <br> KEY_HANDLE PriKeyHandle, <br> unsigned char* lpData, <br> unsigned long DataLength, <br> unsigned char* lpEncryptedData, <br> unsigned long* lpEncryptedDataLength <br> ) <br> <br>'''Description '''<br>To encrypt data with RSA private key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>PriKeyHandle [in] private key handle <br>lpData [in] plain text <br>DataLength [in]length of plain text <br>lpEncryptedData [out] cipher text <br>lpEncryptedDataLength [out] length of cipher text <br> <br>'''Notes: '''<br>DataLength can be RSA_DATA_LEN_1024_BIT or SA_DATA_LEN_2048_BIT <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Usage note '''<br>The handle of private key should be gotten by UT_RSAGetPriKeyByPubKey <br>instead of manually input. A 1024-bit RSA private key can only encrypt 1024-bit <br>data. It is also true for 2048-bit RSA private keys. <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE PriKeyHandle; <br>unsigned char Data[RSA_DATA_LEN_1024_BIT]; <br>unsigned char EncryptedData[RSA_DATA_LEN_1024_BIT]; <br>unsigned long EncryptedDataLength; <br>ret = UT_RSAPriKeyEncrypt( <br>utHandle, <br>PriKeyHandle,Data, <br> RSA_DATA_LEN_1024_BIT, <br>EncryptedData, <br> &EncryptedDataLength <br>);<br> | ||
== UT_RSAPubKeyDecrypt == | == UT_RSAPubKeyDecrypt == | ||
'''Prototype '''<br>UT_RV UT_API UT_RSAPubKeyDecrypt( <br>UT_HANDLE utHandle, <br> KEY_HANDLE PubKeyHandle, <br> unsigned char* lpEncryptedData, <br> unsigned long EncryptedDataLength, <br> unsigned char* lpData, <br> unsigned long* lpDataLength <br> ) <br> <br>'''Description '''<br>To decrypt data with RSA public key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>PubKeyHandle [in] public key handle <br>lpEncryptedData [in] cipher text <br>EncryptedDataLength [in]length of cipher text <br>lpData [out] plain text <br>lpDataLength [out] length of plain text <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Usage note '''<br>The handle of public key should be gotten by UT_RSAGetPubKeyByPriKey <br>instead of manually input. A 1024-bit RSA public key can only decrypt 1024-bit <br>data. It is also true for 2048-bit RSA public keys. <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE PubKeyHandle; <br>unsigned char Data[RSA_DATA_LEN_1024_BIT]; <br>unsigned char EncryptedData[RSA_DATA_LEN_1024_BIT]; <br>unsigned long DataLength; <br>ret = UT_RSAPubKeyDecrypt( <br>utHandle, <br>PubKeyHandle, <br>EncryptedData, <br> RSA_DATA_LEN_1024_BIT, <br>Data, <br> &DataLength <br> );<br> | '''Prototype '''<br>UT_RV UT_API UT_RSAPubKeyDecrypt( <br>UT_HANDLE utHandle, <br> KEY_HANDLE PubKeyHandle, <br> unsigned char* lpEncryptedData, <br> unsigned long EncryptedDataLength, <br> unsigned char* lpData, <br> unsigned long* lpDataLength <br> ) <br> <br>'''Description '''<br>To decrypt data with RSA public key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>PubKeyHandle [in] public key handle <br>lpEncryptedData [in] cipher text <br>EncryptedDataLength [in]length of cipher text <br>lpData [out] plain text <br>lpDataLength [out] length of plain text <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Usage note '''<br>The handle of public key should be gotten by UT_RSAGetPubKeyByPriKey <br>instead of manually input. A 1024-bit RSA public key can only decrypt 1024-bit <br>data. It is also true for 2048-bit RSA public keys. <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE PubKeyHandle; <br>unsigned char Data[RSA_DATA_LEN_1024_BIT]; <br>unsigned char EncryptedData[RSA_DATA_LEN_1024_BIT]; <br>unsigned long DataLength; <br>ret = UT_RSAPubKeyDecrypt( <br>utHandle, <br>PubKeyHandle, <br>EncryptedData, <br> RSA_DATA_LEN_1024_BIT, <br>Data, <br> &DataLength <br> );<br> | ||
== UT_RSAGetKeyPairCount == | == UT_RSAGetKeyPairCount == | ||
'''Prototype '''<br>UT_RV UT_API UT_RSAGetKeyPairCount( <br>UT_HANDLE utHandle, <br> unsigned long* lpKeyCount <br> ) <br> <br>'''Description '''<br>To count RSA keys <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyCount [out] the number of key pairs <br> <br>'''Notes: '''<br>The maximum number of RSA key pairs is 16. <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>unsigned long KeyCount; <br>ret = UT_RSAGetKeyPairCount(utHandle,&KeyCount);<br> | '''Prototype '''<br>UT_RV UT_API UT_RSAGetKeyPairCount( <br>UT_HANDLE utHandle, <br> unsigned long* lpKeyCount <br> ) <br> <br>'''Description '''<br>To count RSA keys <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyCount [out] the number of key pairs <br> <br>'''Notes: '''<br>The maximum number of RSA key pairs is 16. <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>unsigned long KeyCount; <br>ret = UT_RSAGetKeyPairCount(utHandle,&KeyCount);<br> | ||
== UT_RSAGetFirstKeyPairHandle == | == UT_RSAGetFirstKeyPairHandle == | ||
'''Prototype '''<br>UT_RV UT_API UT_RSAGetFirstKeyPairHandle( <br>UT_HANDLE utHandle, <br> KEY_HANDLE_PTR lpPubKeyHandle, <br> KEY_HANDLE_PTR lpPriKeyHandle <br> ) <br> <br>'''Description '''<br>To get the handles of the first RSA key pair <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpPubKeyHandle [out] public key handle <br>lpPriKeyHandle [out] private key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br> <br>'''Sample '''<br>See also the sample of UT_RSAGetNextKeyPairHandle<br> | '''Prototype '''<br>UT_RV UT_API UT_RSAGetFirstKeyPairHandle( <br>UT_HANDLE utHandle, <br> KEY_HANDLE_PTR lpPubKeyHandle, <br> KEY_HANDLE_PTR lpPriKeyHandle <br> ) <br> <br>'''Description '''<br>To get the handles of the first RSA key pair <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpPubKeyHandle [out] public key handle <br>lpPriKeyHandle [out] private key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br> <br>'''Sample '''<br>See also the sample of UT_RSAGetNextKeyPairHandle<br> | ||
== UT_RSAGetNextKeyPairHandle == | == UT_RSAGetNextKeyPairHandle == | ||
'''Prototype '''<br>UT_RV UT_API UT_RSAGetNextKeyPairHandle( <br>UT_HANDLE utHandle, <br> KEY_HANDLE_PTR lpPubKeyHandle, <br> KEY_HANDLE_PTR lpPriKeyHandle <br> ) <br> <br>'''Description '''<br>To get the handles of the next RSA key pair <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpPubKeyHandle [out] public key handle <br>lpPriKeyHandle [out] private key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br>UT_OPERATE_INVALID Invalid operation <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE PubKeyHandle; <br>KEY_HANDLE PriKeyHandle; <br>ret = UT_RSAGetFirstKeyPairHandle( <br>utHandle, <br>&PubKeyHandle, <br>&PriKeyHandle <br> ); <br>ret = UT_RSAGetNextKeyPairHandle( <br>utHandle, <br>&PubKeyHandle, <br>&PriKeyHandle <br> );<br> | '''Prototype '''<br>UT_RV UT_API UT_RSAGetNextKeyPairHandle( <br>UT_HANDLE utHandle, <br> KEY_HANDLE_PTR lpPubKeyHandle, <br> KEY_HANDLE_PTR lpPriKeyHandle <br> ) <br> <br>'''Description '''<br>To get the handles of the next RSA key pair <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpPubKeyHandle [out] public key handle <br>lpPriKeyHandle [out] private key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br>UT_OPERATE_INVALID Invalid operation <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE PubKeyHandle; <br>KEY_HANDLE PriKeyHandle; <br>ret = UT_RSAGetFirstKeyPairHandle( <br>utHandle, <br>&PubKeyHandle, <br>&PriKeyHandle <br> ); <br>ret = UT_RSAGetNextKeyPairHandle( <br>utHandle, <br>&PubKeyHandle, <br>&PriKeyHandle <br> );<br> | ||
== UT_RSAPubKeyImport == | == UT_RSAPubKeyImport == | ||
'''Prototype '''<br>UT_RV UT_API UT_RSAPubKeyImport( <br>UT_HANDLE utHandle, <br> UT_RSA* lpRsaKey, <br> KEY_HANDLE PriKeyHandle, <br> KEY_HANDLE_PTR lpPubKeyHandle <br> ) <br> <br>'''Description '''<br>To import RSA public key to UniToken device <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpRsaKey [in] RSA key <br>PriKeyHandle [in] private key handle <br>lpPubKeyHandle [out] public key handle <br> <br>'''Notes: '''<br>PriKeyHandle can be the existing private key handle or RSA_IMPORT_NEW <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br>UT_KEY_EXIST Key already exists <br>UT_KEY_FULL No more key can be generated <br> <br>'''Usage note '''<br>In this function, the public key can be imported either by the corresponding private key handle or by creating a new key pair (if there’s enough memory). If the key pair already exists, import the public key and return the handle of the public key; if there’s no corresponding key pair in the device, return UT_KEY_HANDLE_INVALID. If PriKeyHandle is RSA_IMPORT_NEW, create a new key pair and import the public key. <br>Besides, UniToken device can store 16 RSA key pairs. If there’re already 16 key pairs inside, calling this function, return UT_KEY_FULL. <br> <br>'''Sample '''<br>See also the sample of UT_RSAPriKeyImport<br> | '''Prototype '''<br>UT_RV UT_API UT_RSAPubKeyImport( <br>UT_HANDLE utHandle, <br> UT_RSA* lpRsaKey, <br> KEY_HANDLE PriKeyHandle, <br> KEY_HANDLE_PTR lpPubKeyHandle <br> ) <br> <br>'''Description '''<br>To import RSA public key to UniToken device <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpRsaKey [in] RSA key <br>PriKeyHandle [in] private key handle <br>lpPubKeyHandle [out] public key handle <br> <br>'''Notes: '''<br>PriKeyHandle can be the existing private key handle or RSA_IMPORT_NEW <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br>UT_KEY_EXIST Key already exists <br>UT_KEY_FULL No more key can be generated <br> <br>'''Usage note '''<br>In this function, the public key can be imported either by the corresponding private key handle or by creating a new key pair (if there’s enough memory). If the key pair already exists, import the public key and return the handle of the public key; if there’s no corresponding key pair in the device, return UT_KEY_HANDLE_INVALID. If PriKeyHandle is RSA_IMPORT_NEW, create a new key pair and import the public key. <br>Besides, UniToken device can store 16 RSA key pairs. If there’re already 16 key pairs inside, calling this function, return UT_KEY_FULL. <br> <br>'''Sample '''<br>See also the sample of UT_RSAPriKeyImport<br> | ||
== UT_RSAPriKeyImport == | == UT_RSAPriKeyImport == | ||
'''Prototype '''<br>UT_RV UT_API UT_RSAPriKeyImport( <br>UT_HANDLE utHandle, <br> UT_RSA* lpRsaKey, <br> KEY_HANDLE PubKeyHandle, <br> KEY_HANDLE_PTR lpPriKeyHandle <br> ) <br> <br>'''Description '''<br>To import RSA private key to UniToken device <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpRsaKey [in] RSA key <br>PubKeyHandle [in] public key handle <br>lpPriKeyHandle [out] private key handle <br> <br>'''Notes: '''<br>PubKeyHandle can be the existing public key handle or RSA_IMPORT_NEW <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br>UT_KEY_EXIST Key already exists <br>UT_KEY_FULL No more key can be <br>generated <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>UT_RSA RsaKey; <br>KEY_HANDLE PubKeyHandle; <br>KEY_HANDLE PriKeyHandle; <br>ret = UT_RSAPubKeyImport( <br>utHandle, <br>&RsaKey, <br>RSA_IMPORT_NEW, <br>&PubKeyHandle <br>); <br>ret = UT_RSAPriKeyImport( <br>utHandle, <br>&RsaKey, <br>PubKeyHandle, <br>&PriKeyHandle <br> );<br> | '''Prototype '''<br>UT_RV UT_API UT_RSAPriKeyImport( <br>UT_HANDLE utHandle, <br> UT_RSA* lpRsaKey, <br> KEY_HANDLE PubKeyHandle, <br> KEY_HANDLE_PTR lpPriKeyHandle <br> ) <br> <br>'''Description '''<br>To import RSA private key to UniToken device <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpRsaKey [in] RSA key <br>PubKeyHandle [in] public key handle <br>lpPriKeyHandle [out] private key handle <br> <br>'''Notes: '''<br>PubKeyHandle can be the existing public key handle or RSA_IMPORT_NEW <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br>UT_KEY_EXIST Key already exists <br>UT_KEY_FULL No more key can be <br>generated <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>UT_RSA RsaKey; <br>KEY_HANDLE PubKeyHandle; <br>KEY_HANDLE PriKeyHandle; <br>ret = UT_RSAPubKeyImport( <br>utHandle, <br>&RsaKey, <br>RSA_IMPORT_NEW, <br>&PubKeyHandle <br>); <br>ret = UT_RSAPriKeyImport( <br>utHandle, <br>&RsaKey, <br>PubKeyHandle, <br>&PriKeyHandle <br> );<br> | ||
== UT_RSAPubKeyExport == | == UT_RSAPubKeyExport == | ||
'''Prototype '''<br>UT_RV UT_API UT_RSAPubKeyExport( <br>UT_HANDLE utHandle, <br> KEY_HANDLE PubKeyHandle, <br> unsigned long* lpModulusBits, <br> UT_RSA* lpRsaKey <br> ) <br> <br>'''Description '''<br>To export RSA public key from UniToken device <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>PubKeyHandle [in] public key handle <br>lpModulusBits [out]modulus length <br>lpRsaKey [out] RSA public key structure <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br>UT_KEY_EXIST Key already exists <br>UT_KEY_FULL No more key can be <br>generated <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>UT_RSA RsaKey; <br>KEY_HANDLE PubKeyHandle; <br>unsigned long ModulusBits; <br>ret = UT_RSAPubKeyExport( <br>utHandle, <br>PubKeyHandle, <br>&ModulusBits, <br>&RsaKey <br> );<br> | '''Prototype '''<br>UT_RV UT_API UT_RSAPubKeyExport( <br>UT_HANDLE utHandle, <br> KEY_HANDLE PubKeyHandle, <br> unsigned long* lpModulusBits, <br> UT_RSA* lpRsaKey <br> ) <br> <br>'''Description '''<br>To export RSA public key from UniToken device <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>PubKeyHandle [in] public key handle <br>lpModulusBits [out]modulus length <br>lpRsaKey [out] RSA public key structure <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br>UT_KEY_EXIST Key already exists <br>UT_KEY_FULL No more key can be <br>generated <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>UT_RSA RsaKey; <br>KEY_HANDLE PubKeyHandle; <br>unsigned long ModulusBits; <br>ret = UT_RSAPubKeyExport( <br>utHandle, <br>PubKeyHandle, <br>&ModulusBits, <br>&RsaKey <br> );<br> | ||
== UT_RSAGetPubKeyHandle == | == UT_RSAGetPubKeyHandle == | ||
'''Prototype '''<br>UT_RV UT_API UT_RSAGetPubKeyHandle( <br>UT_HANDLE utHandle, <br> KEY_HANDLE PriKeyHandle, <br> KEY_HANDLE_PTR lpPubKeyHandle <br> ) <br> <br>'''Description '''<br>To get the public key handle by the corresponding private key handle <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>PriKeyHandle [in] private key handle <br>lpPubKeyHandle [out]the corresponding public <br>key handle<br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_KEY_HANDLE_INVALID Invalid key handle <br>UT_NO_KEY No key found <br> <br>'''Sample'''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE PubKeyHandle; <br>KEY_HANDLE PriKeyHandle; <br>ret = UT_RSAGetPubKeyHandle( <br>utHandle, <br>PriKeyHandle, <br>&PubKeyHandle <br>);<br> | |||
== UT_RSAGetPriKeyHandle == | == UT_RSAGetPriKeyHandle == | ||
'''Prototype '''<br>UT_RV UT_API UT_RSAGetPriKeyHandle( <br>UT_HANDLE utHandle, <br> KEY_HANDLE PubKeyHandle, <br> KEY_HANDLE_PTR lpPriKeyHandle <br> ) <br> <br>'''Description '''<br>To get the public key handle by the corresponding private key handle <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>PubKeyHandle [in] public key handle <br>lpPriKeyHandle [out]the corresponding private key <br>handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_KEY_HANDLE_INVALID Invalid key handle <br>UT_NO_KEY No key found <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE PubKeyHandle; <br>KEY_HANDLE PriKeyHandle; <br>ret = UT_RSAGetPriKeyHandle( <br>utHandle, <br>PubKeyHandle, <br>&PriKeyHandle <br>);<br> | |||
== UT_RSAGetKeyPairModulus == | == UT_RSAGetKeyPairModulus == | ||
'''Prototype '''<br>UT_RV UT_API UT_RSAGetKeyPairModulus( <br>UT_HANDLE utHandle, <br> KEY_HANDLE PubKeyHandle, <br> unsigned long* lpModulusBits <br> ) <br> <br>'''Description '''<br>To get RSA key pair modulus <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>PubKeyHandle [in] public key handle <br>lpModulusBits [out]modulus length <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE PubKeyHandle; <br>unsigned long ModulusBits; <br>ret = UT_RSAGetKeyPairModulus( <br>utHandle, <br>PubKeyHandle, <br>&ModulusBits <br> );<br> | |||
== UT_RSADeleteKeyPair == | == UT_RSADeleteKeyPair == | ||
'''Prototype '''<br>UT_RV UT_API UT_RSADeleteKeyPair( <br>UT_HANDLE utHandle, <br> KEY_HANDLE PubKeyHandle, <br> KEY_HANDLE PriKeyHandle <br> ) <br> <br>'''Description '''<br>To delete the RSA key pair <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>PubKeyHandle [in] public key handle <br>PriKeyHandle [in] private key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Usage note '''<br>In this function, the handles of a key pair are required. If the handles belong to <br>the keys from different key pairs, return UT_KEY_HANDLE_INVALID; if only <br>one key handle provided, the other key handle must be 0 to delete the key pair. <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE PubKeyHandle; <br>KEY_HANDLE PriKeyHandle; <br>ret = UT_RSADeleteKeyPair( <br>utHandle, <br>PubKeyHandle, <br>PriKeyHandle <br> );<br> | |||
== UT_MD5HMACGenerateKey == | == UT_MD5HMACGenerateKey == | ||
'''Prototype '''<br>UT_RV UT_API UT_MD5HMACGenerateKey( <br>UT_HANDLE utHandle, <br> unsigned long KeyLength, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To generate HMAC-MD5 key <br> <br>'''Parameters:'''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyLength [in] key length <br>lpKeyHandle [out] key handle <br> <br>'''Notes: '''<br>the length of key< = 128 bytes <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_FULL No more key can be <br>generated <br> <br>'''Usage note '''<br>UniToken device can store as many as 8 HMAC-MD5 keys. If there are already <br>8 keys in the device, calling the function, return UT_KEY_FULL. <br> '''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_MD5HMACGenerateKey(utHandle,128,&KeyHandle); <br> | |||
== UT_MD5HMAC == | == UT_MD5HMAC == | ||
'''Prototype '''<br>UT_RV UT_API UT_MD5HMAC( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle, <br> unsigned char* lpData, <br> unsigned long DataLength, <br> unsigned char* lpDigest <br> ) <br> <br>'''Description '''<br>To run HMAC-MD5 algorithm <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle <br>lpData [in] data to be digested <br>DataLength [in]data length <br>lpDigest [out] the digested data <br> <br>'''Notes: '''<br>DataLength is 1~128 bytes <br>lpDigest is 16 bytes <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned char Data[128]; <br>unsigned char Digest[16]; <br>ret = UT_MD5HMAC(utHandle,KeyHandle,Data,128,Digest);<br> | |||
== UT_MD5 == | == UT_MD5 == | ||
'''Prototype'''<br>UT_RV UT_API UT_MD5( <br>UT_HANDLE utHandle, <br> unsigned char* lpData, <br> unsigned long DataLength, <br> unsigned char* lpDigest <br> ) <br> <br>'''Description'''<br>To run MD5 algorithm <br> <br>'''Parameters'''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpData [in] data to be digested <br>DataLength [in]data length <br>lpDigest [out] the digested data <br> <br>'''Notes'''<br>DataLength is 1~128 bytes <br>lpDigest is 16 bytes <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>unsigned char Data[128]; <br>unsigned char Digest[16]; <br>ret = UT_MD5(utHandle,Data,128,Digest);<br> | |||
== UT_MD5GetKeyCount == | == UT_MD5GetKeyCount == | ||
'''Prototype '''<br>UT_RV UT_API UT_MD5GetKeyCount( <br>UT_HANDLE utHandle, <br> unsigned long* lpKeyCount <br>) <br> <br>'''Description '''<br>To count HMAC-MD5 keys <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyCount [out] the number of keys <br> <br>'''Notes: '''<br>The maximum number of MD5 keys is 8. <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>unsigned long KeyCount; <br>ret = UT_MD5GetKeyCount(utHandle,&KeyCount);<br> | |||
== UT_MD5GetKeyLen == | == UT_MD5GetKeyLen == | ||
'''Prototype '''<br>UT_RV UT_API UT_MD5GetKeyLen( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle, <br> unsigned long* lpKeyLength <br> ) <br> <br>'''Description '''<br>To get the length of HMAC-MD5 key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle <br>lpKeyLength [out] key length <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned long KeyLength; <br>ret = UT_MD5GetKeyLen(utHandle,KeyHandle,&KeyLength);<br> | |||
== UT_MD5GetFirstKeyHandle == | == UT_MD5GetFirstKeyHandle == | ||
'''Prototype '''<br>UT_RV UT_API UT_MD5GetFirstKeyHandle( <br>UT_HANDLE utHandle, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To get the handle of the first HMAC-MD5 key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyHandle [out]key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br> <br>'''Sample '''<br>See also the samples of UT_MD5GetNextKeyHandle<br> | |||
== UT_MD5GetNextKeyHandle == | == UT_MD5GetNextKeyHandle == | ||
'''Prototype '''<br>UT_RV UT_API UT_MD5GetNextKeyHandle( <br>UT_HANDLE utHandle, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To get the handle of the next HMAC-MD5 key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyHandle [out]key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br>UT_OPERATE_INVALID Invalid operation <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_MD5GetFirstKeyHandle(utHandle,&KeyHandle); <br>ret = UT_MD5GetNextKeyHandle(utHandle,&KeyHandle);<br> | |||
== UT_MD5DeleteKey == | == UT_MD5DeleteKey == | ||
'''Prototype '''<br>UT_RV UT_API UT_MD5DeleteKey( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle <br>) <br> <br>'''Description '''<br>To delete HMAC-MD5 key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in]key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_MD5DeleteKey(utHandle,KeyHandle);<br> | |||
== UT_MD5ImportKey == | == UT_MD5ImportKey == | ||
'''Prototype '''<br>UT_RV UT_API UT_MD5ImportKey( <br>UT_HANDLE utHandle, <br> unsigned char* lpKey, <br> unsigned long KeyLength, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To import HMAC-MD5 key to UniToken device <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKey [in]key <br>KeyLength [in]key length <br>lpKeyHandle [out] key handle <br> <br>'''Notes: '''<br>KeyLength is 1~128 bytes <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_FULL No more key can be generated <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned char Key[128]; <br>ret = UT_MD5ImportKey(utHandle,Key,128,&KeyHandle);<br> | |||
== UT_SHA1HMACGenerateKey == | == UT_SHA1HMACGenerateKey == | ||
'''Prototype '''<br>UT_RV UT_API UT_SHA1HMACGenerateKey( <br>UT_HANDLE utHandle, <br> unsigned long KeyLength, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To generate HMAC-SHA1 key <br> <br>'''Parameters''' <br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyLength [in] key length <br>lpKeyHandle [out] key handle <br> <br>'''Notes: '''<br>the length of key < =128 bytes <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_FULL No more key can be generated <br> <br>'''Usage note '''<br>UniToken device can store as many as 8 HMAC-SHA1 keys. If there are already <br>8 keys in the device, calling the function, return UT_KEY_FULL. <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_SHA1HMACGenerateKey(utHandle,128,&KeyHandle); <br> | |||
== UT_SHA1HMAC == | == UT_SHA1HMAC == | ||
'''Prototype '''<br>UT_RV UT_API UT_SHA1HMAC( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle, <br> unsigned char* lpData, <br> unsigned long DataLength, <br> unsigned char* lpDigest <br> ) <br> <br>'''Description '''<br>To run HMAC-SHA1algorithm <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle <br>lpData [in] data to be digested <br>DataLength [in]data length <br>lpDigest [out]the digested data <br> <br>'''Notes: '''<br>DataLength is 1~128 bytes <br>lpDigest is 20 bytes <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned char Data[128]; <br>unsigned char Digest[20]; <br>ret = UT_SHA1HMAC(utHandle,KeyHandle,Data,128,Digest);<br> | |||
== UT_SHA1 == | == UT_SHA1 == | ||
'''Prototype '''<br>UT_RV UT_API UT_SHA1( <br>UT_HANDLE utHandle, <br> unsigned char* lpData, <br> unsigned long DataLength, <br> unsigned char* lpDigest <br> ) <br> <br>'''Description '''<br>To run SHA1 algorithm <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpData [in] data to be digested <br>DataLength [in]data length <br>lpDigest [out] the digested data <br> <br>'''Notes: '''<br>DataLength is 1~128 bytes <br>lpDigest is 20 bytes <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>unsigned char Data[128]; <br>unsigned char Digest[20]; <br>ret = UT_SHA1(utHandle,Data,128,Digest);<br> | |||
== UT_SHA1GetKeyCount == | == UT_SHA1GetKeyCount == | ||
'''Prototype '''<br>UT_RV UT_API UT_SHA1GetKeyCount( <br>UT_HANDLE utHandle, <br>unsigned long* lpKeyCount <br>) <br> <br>'''Description '''<br>To count HMAC-SHA1 keys <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyCount [out] the number of keys <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>unsigned long KeyCount; <br>ret = UT_SHA1GetKeyCount(utHandle,&KeyCount);<br> | |||
== UT_SHA1GetKeyLen == | == UT_SHA1GetKeyLen == | ||
'''Prototype '''<br>UT_RV UT_API UT_SHA1GetKeyLen( <br>UT_HANDLE utHandle, <br> KEY_HANDLE KeyHandle, <br> unsigned long* lpKeyLength <br> ) <br> <br>'''Description '''<br>To get the length of HMAC-SHA1 key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>KeyHandle [in] key handle <br>lpKeyLength [out] key length <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned long KeyLength; <br>ret = UT_SHA1GetKeyLen(utHandle,KeyHandle,&KeyLength);<br> | |||
== UT_SHA1GetFirstKeyHandle == | == UT_SHA1GetFirstKeyHandle == | ||
'''Prototype '''<br>UT_RV UT_API UT_SHA1GetFirstKeyHandle( <br>UT_HANDLE utHandle, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) <br> <br>'''Description '''<br>To get the handle of the first HMAC-SHA1 key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKeyHandle [out]key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br> <br>'''Sample '''<br>See also the sample of UT_SHA1GetNextKeyHandle<br> | |||
== UT_SHA1GetNextKeyHandle == | == UT_SHA1GetNextKeyHandle == | ||
'''Prototype '''<br>UT_RV UT_API UT_SHA1GetNextKeyHandle( <br>UT_HANDLE utHandle, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) | |||
'''Description '''<br>To get the handle of the next HMAC-SHA1 key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpkeyHandle [out]key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_KEY No key found <br>UT_OPERATE_INVALID Invalid operation <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_SHA1GetFirstKeyHandle(utHandle,&KeyHandle); <br>ret = UT_SHA1GetNextKeyHandle(utHandle,&KeyHandle);<br> | |||
== UT_SHA1DeleteKey == | == UT_SHA1DeleteKey == | ||
'''Prototype '''<br>UT_RV UT_API UT_SHA1DeleteKey( <br>UT_HANDLE utHandle, <br>KEY_HANDLE KeyHandle <br>) <br> <br>'''Description '''<br>To delete HMAC-SHA1 key <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>keyHandle [in] key handle <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_HANDLE_INVALID Invalid key handle <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>ret = UT_SHA1DeleteKey(utHandle,KeyHandle);<br> | |||
== UT_SHA1ImportKey == | == UT_SHA1ImportKey == | ||
'''Prototype '''<br>UT_RV UT_API UT_SHA1ImportKey( <br>UT_HANDLE utHandle, <br> unsigned char* lpKey, <br> unsigned long KeyLength, <br> KEY_HANDLE_PTR lpKeyHandle <br> ) | |||
'''Description '''<br>To import HMAC-SHA1 key to UniToken device <br> <br>'''Parameters '''<br>PARAMETERS DESCRIPTION <br>utHandle [in] device handle <br>lpKey [in]SHA1 key <br>KeyLength [in]key length <br>lpKeyHandle [out] key handle <br> <br>'''Notes: '''<br>KeyLength is 1~128 bytes <br> <br>'''Returned value '''<br>RETURNED VALUE DESCRIPTION <br>UT_OK Successful operation <br>UT_NOT_INITIALIZE Library not initialized <br>UT_ARGUMENTS_BAD Invalid argument <br>UT_TOKEN_HANDLE_INVALID Invalid token handle <br>UT_NO_PERMISSION No permission <br>UT_KEY_FULL No more key can be <br>generated <br> <br>'''Sample '''<br>UT_RV ret; <br>UT_HANDLE utHandle; <br>KEY_HANDLE KeyHandle; <br>unsigned char Key[128]; <br>ret = UT_SHA1ImportKey(utHandle,Key,128,&KeyHandle); <br> | |||
== UT_FS_GetSpace == | == UT_FS_GetSpace == | ||
Revision as of 16:51, 12 April 2012
UT_GetLibraryVersion
API Prototype
unsigned long UT_API UT_GetLibraryVersion().
Description
To get the version of the present library
Parameters
n/a
Returned value
| RETURNED VALUE | DESCRIPTION |
| Library version | the version of the current library |
Sample
unsigned long ulLibraryVersion;
ulLibraryVersion = UT_GetLibraryVersion();
UT_Initialize
API Prototype
UT_RV UT_API UT_Initialize()
Description
To initialize the UniToken. It should be called before all the other functions except UT_GetLibraryVersion.
Parameters
n/a
Returned value
| RETURNED VALUE | DESCRIPTION |
| UT_OK | Successful operation |
| UT_ALREADY_INITIALIZE | Library already initialized |
Sample
UT_RV ret;
ret = UT_Initialize();
UT_Finalize
API Prototype
UT_RV UT_API UT_Finalize()
Description
Call this function to end any interaction with UniToken and free the memory.
Parameters
n/a
Returned value
| RETURNED VALUE | DESCRIPTION |
| UT_OK | Successful operation |
| UT_NOT_INITIALIZE | Library not initialized |
Sample
UT_RV ret;
ret = UT_Finalize();
UT_GetTokenList
API Prototype
UT_RV UT_API UT_GetTokenList(UT_SLOT_ID* lpSlotID, unsigned long* lpTokenCount)
Description
To get the list of Slot ID and the number of Slot ID
Parameters
| PARAMETERS | DESCRIPTION |
| lpSlotID | [out] slot ID list |
| lpTokenCount | [in] size of buffer (0~32 bytes) [out]number of token |
Returned value
| RETURNED VALUE | DESCRIPTION |
| UT_OK | Successful operation |
| UT_NOT_INITIALIZE | Library not initialized |
Sample
UT_RV ret;
UT_HANDLE utHandle;
UT_SLOT_ID* lpSlotID = NULL;
unsigned long ulTokenCount = 0;
ret = UT_GetTokenList(lpSlotID,&ulTokenCount);
if (ret == UT_BUFFER_TOO_SMALL){
lpSlotID = new UT_SLOT_ID[ulTokenCount];
ret = UT_GetTokenList(lpSlotID,&ulTokenCount);
}
ret = UT_OpenDevice(lpSlotID[0],&utHandle);
ret = UT_GetHandle(lpSlotID[0],&utHandle);
ret = UT_GetSlotID(utHandle,&lpSlotID[0]);
ret = UT_CloseDevice(utHandle);
UT_OpenDevice
Prototype
UT_RV UT_API UT_OpenDevice(
UT_SLOT_ID SlotID,
UT_HANDLE* lputHandle
)
Description
To open the device in the specified slot
Parameters
PARAMETERS DESCRIPTION
SlotID [in] the specified slot
lputHandle [out] device handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_SLOT_ID_INVALUD Invalid slot ID
Usage note
SlotID should be gotten from UT_GetTokenList instead of manually input.
Therefore, this function cannot be called before UT_GetTokenList.
Sample
See also the sample of UT_GetTokenList
UT_CloseDevice
Prototype
UT_RV UT_API UT_CloseDevice(UT_HANDLE utHandle)
Description
To close the specified device
Parameters
n/a
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_TOKEN_HANDLE_INVALID Invalid token handle
Sample
See also the sample of UT_GetTokenList
UT_GetHandle
Prototype
UT_RV UT_API UT_GetHandle(
UT_SLOT_ID SlotID,
UT_HANDLE* lputHandle
)
Description
To get device handle by Slot ID
Parameters
PARAMETERS DESCRIPTION
SlotID [in] the specified slot
lputHandle [out] device handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
Sample
See also the sample of UT_GetTokenList
UT_GetSlotID
Prototype
UT_RV UT_API UT_GetSlotID(
UT_HANDLE utHandle,
UT_SLOT_ID* lpSlotID
)
Description
To get Slot ID by device handle
Parameters
PARAMETERS DESCRIPTION
utHandle [in] the specified handle
lpSlotID [out] Slot ID
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
Sample
See also the sample of UT_GetTokenList
UT_GetSlotStatus
Prototype
UT_RV UT_API UT_GetSlotStatus(
UT_STATUS* lpStatus,
UT_SLOT_ID* lpSlotID
)
Description
To get the status of Slot
Parameters
PARAMETERS DESCRIPTION
lpStatus [out]the current status of slot
lpSlotID [out] Slot ID
Notes:
lpStatus can be
a. Inserted, when UniToken is inserted into the slot;
b. Removed, when UniToken is removed from the slot;
c. No change, when there’s no change to the status of slot. In this case, lpSlotID is undefined.
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
Sample
UT_RV rv;
UT_STATUS status;
UT_SLOT_ID slotID;
rv = UT_GetSlotStatus(&status,& slotID);
if ( rv == UT_OK ){
if ( status == TOKEN_NO_EVENT ) {
// no change of status
} else if ( status == TOKEN_INSERT ) {
// token inserted
} else if ( status == TOKEN_REMOVE ) {
// token removed
}
}
UT_GetTokenType
Prototype
UT_RV UT_API UT_GetTokenType(
UT_HANDLE utHandle,
char* lpszTokenType
)
Description
To get the type of the current device, e.g. UniToken STD, PRO
Parameters
PARAMETERS DESCRIPTION
utHandle [in]device handle
lpszTokenType [out]UniToken type (string, 32
bytes)
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
char TokenType[33]={0};
ret = UT_GetTokenType(utHandle,(char *)TokenType);
UT_GetFirmwareVersion
Prototype
UT_RV UT_API UT_GetFirmwareVersion(
UT_HANDLE utHandle,
unsigned long* lpVersion
)
Description
To get the version of firmware
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpVersion [out] firmware version
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
unsigned long Version;
ret = UT_GetFirmwareVersion(utHandle,&Version);
UT_Logoff
Prototype
UT_RV UT_API UT_Logoff(UT_HANDLE utHandle)
Description
To log off the specified Token
Parameters
PARAMETERS DESCRIPTION
utHandle [in]device handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_TOKEN_HANDLE_INVALID Invalid token handle
Sample
See also the sample of UT_Logon
UT_Logon
Prototype
UT_RV UT_API UT_Logon(
UT_HANDLE utHandle,
unsigned long UserLevel,
unsigned char* lpszPin
)
Description
To logon the specified token
Parameters
PARAMETERS DESCRIPTION
utHandle [in]device handle
UserLevel [in] levels of permission
lpszPin [in]the corresponding password with
certain permission level
Note:
lpszPin is made up with strings, and the minimum size is 1 byte.
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_PIN_ERROR Wrong password
UT_USER_FULL No more sessions
allowed
UT_USER_LOCKED Token locked
Usage note
UniToken provides three levels of user permission: GUEST permission, USER
permission and ADMIN permission.
The default permission is GUEST. To log on as USER or ADMIN, the
corresponding PINs are required.
Sample
UT_RV ret;
UT_HANDLE utHandle;
unsigned char Pin[] = UT_DEFAULT_USER;
unsigned long UserLevel;
ret = UT_Logon(
utHandle,
UT_USER_LEVEL_USER,
(unsigned char*)Pin
);
ret = UT_GetCurrentUserLevel(utHandle,&UserLevel);
ret = UT_Logoff(utHandle);
UT_GetCurrentUserLevel
Prototype
UT_RV UT_API UT_GetCurrentUserLevel(
UT_HANDLE utHandle,
unsigned long* lpUserLevel
)
Description
To get the current permission level
Parameters
PARAMETERS DESCRIPTION
utHandle [in]device handle
lpUserLevel [out] permission level
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
Sample
See also the sample of UT_Logon
UT_ChangePin
Prototype
UT_RV UT_API UT_ChangePin(
UT_HANDLE utHandle,
unsigned char UserLevel,
unsigned long ChangeMode,
unsigned char* OldPin,
unsigned char* NewPin
)
Description
To change password
Parameters
PARAMETERS DESCRIPTION
utHandle [in]device handle
UserLevel [in]permission level
ChangeMode [in]mode of changing
OldPin [in] old PIN
NewPin [in]new PIN
Notes:
Change Mode an be UT_CHANGE_PIN_MODE_BYSELF or
UT_CHANGE_PIN_MODE_ADMIN_CHANGE_USER
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NOT_ALLOWED Operation not allowed
Usage note
Two ways of changing password:
1. User/Admin changes his own password
Log on as USER or ADMIN and type in the old password and the new one.
Here, the mode of changing PIN is UT_CHANGE_PIN_MODE_BYSELF
2. Admin resets user password
Log on as ADMIN and type in new password of USER. Here, the mode of changing PIN is UT_CHANGE_PIN_MODE_ADMIN_CHANGE_USER.In this case, OldPin is not required.
Sample
UT_RV ret;
UT_HANDLE utHandle;
unsigned char Pin[] = UT_DEFAULT_USER;
unsigned char NewPin[] = "1234";
unsigned long UserLevel;
ret = UT_Logon(
utHandle,
UT_USER_LEVEL_USER,
(unsigned char*)Pin
);
ret = UT_ChangePin(
utHandle,
UT_USER_LEVEL_USER,
UT_CHANGE_PIN_MODE_BYSELF,
(unsigned char*)Pin,
(unsigned char*)newPin
);
UT_GetID
Prototype
UT_RV UT_API UT_GetID(
UT_HANDLE utHandle,
char* lpszId
)
Description
To get the token ID of specified device
Parameters
PARAMETERS DESCRIPTION
utHandle [in]device handle
lpszId [out] UniToken ID (string, 32
bytes)
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
Sample
See also the sample of UT_SetID
UT_SetID
Prototype
UT_RV UT_API UT_SetID(
UT_HANDLE utHandle,
char* lpszId
)
Description
To set the token ID of the specified device
Parameters
PARAMETERS DESCRIPTION
utHandle [in]device handle
lpszId [out] UniToken ID (string, 32
bytes)
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
char Id[33] = "UniTokenPRO";
unsigned long UserLevel;
ret = UT_SetID(utHandle,Id);
ret = UT_GetID(utHandle,Id);
UT_GetHID
Prototype
UT_RV UT_API UT_GetHID(
UT_HANDLE utHandle,
unsigned long* lpHid
)
Description
To get the Hardware ID of the specified device
Parameters
PARAMETERS DESCRIPTION
utHandle [in]device handle
lpHid [out] Hardware ID
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
unsigned long Hid;
ret = UT_GetHID(utHandle,&Hid);
UT_GetSoftID
Prototype
UT_RV UT_API UT_GetSoftID(
UT_HANDLE utHandle,
unsigned long* lpSoftID
)
Description
To get the Software ID of the specified device
Parameters
PARAMETERS DESCRIPTION
utHandle [in]device handle
lpSoftID [out] Software ID
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
Sample
See also the sample of UT_SetSoftID
UT_SetSoftID
Prototype
UT_RV UT_API UT_SetSoftID(
UT_HANDLE utHandle,
unsigned long SoftID
)
Description
To set the Software ID of the specified device
Parameters
PARAMETERS DESCRIPTION
utHandle [in]device handle
SoftID [in] Software ID
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_NO_PERMISSION No permission
UT_TOKEN_HANDLE_INVALID Invalid token handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
unsigned long SoftID = 0;
ret = UT_GetSoftID(utHandle,&SoftID);
ret = UT_SetSoftID(utHandle,SoftID);
UT_LED
Prototype
UT_RV UT_API UT_LED (
UT_HANDLE utHandle,
unsigned char On
)
Description
To turn on/off LED
Parameters
PARAMETERS DESCRIPTION
utHandle [in]device handle
On [in]the status of LED
Notes:
The parameter on can be LED_ON or LED_OFF
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_TOKEN_HANDLE_INVALID Invalid token handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
ret = UT_LED(utHandle,LED_ON);
UT_SetAttemptCount
Prototype
UT_RV UT_API UT_SetAttemptCount(
UT_HANDLE utHandle,
unsigned long MaxAttempt
)
Description
To set the maximum times of PIN attempt
Parameters
PARAMETERS DESCRIPTION
utHandle [in]device handle
MaxAttempt [in] maximum attempt times
Notes:
The maximum times of attempt UniToken allows is 15 times. If a user types in
wrong PIN consecutively for 15 times, the UniToken will be locked.
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
Usage note
This function is used for unlocking the token.
Sample
See also the sample of UT_GetAttemptCount
UT_GetAttemptCount
Prototype
UT_RV UT_API UT_GetAttemptCount(
UT_HANDLE utHandle,
unsigned long* lpUserAttempt,
unsigned long* lpAdminAttempt
)
Description
To count the attempt times
Parameters
PARAMETERS DESCRIPTION
utHandle [in]device handle
lpUserAttempt [out]User PIN attempt times
lpAdminAttempt [out]Admin PIN attempt times
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
unsigned long UserAttempt;
unsigned long AdminAttempt;
ret = UT_SetAttemptCount(utHandle,15);
ret = UT_GetAttemptCount(
utHandle,
&UserAttempt,
&AdminAttempt
);
UT_Format
Prototype
UT_RV UT_API UT_Format(UT_HANDLE utHandle)
Description
To format a UniToken
Parameters
PARAMETERS DESCRIPTION
utHandle [in]device handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
Usage note
After formatting, the PINs of User and Admin are set back to the default ones as
well as the whole file system and all the keys inside.
Sample
UT_RV ret;
UT_HANDLE utHandle;
ret = UT_Format(utHandle);
UT_Rand
Prototype
UT_RV UT_API UT_Rand(
UT_HANDLE utHandle,
unsigned long Length,
unsigned char* lpOut,
void* lpReserve
)
Description
To generate random numbers
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
Length [in]length of random number (in
byte)
lpOut [out] random number
lpReserve reserved for future usage
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
unsigned char OutRand[8];
ret = UT_Rand(utHandle,8,OutRand,NULL);
UT_DESGenerateKey
Prototype
UT_RV UT_API UT_DESGenerateKey(
UT_HANDLE utHandle,
KEY_HANDLE_PTR lpKeyHandle
)
Description
To generate a DES key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpKeyHandle [out] key handle
Note:
The length of generated DES key is 8 bytes.
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_FULL No more key can be generated
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
ret = UT_DESGenerateKey(utHandle,&KeyHandle);
UT_DESEncrypt
Prototype
UT_RV UT_API UT_DESEncryptZ(
UT_HANDLE utHandle,
KEY_HANDLE KeyHandle,
unsigned char* lpData,
unsigned long DataLength,
unsigned char* lpEncryptedData,
unsigned long* lpEncryptedDataLength
)
Description
To encrypt data with DES
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
KeyHandle [in] key handle
lpData [in] plain text
DataLength [in]length of plain text
lpEncryptedData [out] cipher text
lpEncryptedDataLength [out] length of cipher text
Notes:
DateLength is DES_DATA_LEN_8_BYTE
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_HANDLE_INVALID Invalid key handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
unsigned char Data[DES_DATA_LEN_8_BYTE];
unsigned char EncryptedData[DES_DATA_LEN_8_BYTE];
unsigned long EncryptedDataLength;
ret = UT_DESEncrypt(
utHandle,
keyHandle,
Data,
DES_DATA_LEN_8_BYTE,
EncryptedData,
&EncryptedDataLength);
UT_DESDecrypt
Prototype
UT_RV UT_API UT_DESDecrypt(
UT_HANDLE utHandle,
KEY_HANDLE KeyHandle,
unsigned char* lpEncryptedData,
unsigned long EncryptedDataLength,
unsigned char* lpData,
unsigned long* lpDataLength
)
Description
To decrypt data with DES
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
KeyHandle [in] key handle
lpEncryptedData [out] plain text
EncryptedDataLength [out] length of plain text
lpData [in] cipher text
lpDataLength [in]length of cipher text
Notes:
EncryptedDataLength is DES_DATA_LEN_8_BYTE
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_HANDLE_INVALID Invalid key handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
unsigned char Data[DES_DATA_LEN_8_BYTE];
unsigned char EncryptedData[DES_DATA_LEN_8_BYTE];
unsigned long DataLength;
ret = UT_DESDecrypt(
utHandle,
KeyHandle,
EncryptedData,
DES_DATA_LEN_8_BYTE,
Data,
&DataLength
)
UT_DESImportKey
Prototype
UT_RV UT_API UT_DESImportKey(
UT_HANDLE utHandle,
unsigned char* lpKey,
KEY_HANDLE_PTR lpKeyHandle
)
Description
To import a DES key to UniToken device
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpKey [in] DES key
lpKeyHandle [out] key handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_FULL No more key can be
generated
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
unsigned char Key[DES_KEY_LEN_8_BYTE];
ret = UT_DESImportKey(utHandle,Key,&KeyHandle);
UT_DESDeleteKey
Prototype
UT_RV UT_API UT_DESDeleteKey(
UT_HANDLE utHandle,
KEY_HANDLE KeyHandle
)
Description
To delete a DES key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
KeyHandle [in] key handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_HANDLE_INVALID Invalid key handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
ret = UT_DESDeleteKey(utHandle,KeyHandle);
UT_DESGetKeyCount
Prototype
UT_RV UT_API UT_DESGetKeyCount(
UT_HANDLE utHandle,
unsigned long* lpKeyCount
)
Description
To count DES keys
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpKeyCount [out]the number of keys
Notes:
The maximum number of DES keys is 16.
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_KEY No key found
Sample
UT_RV ret;
UT_HANDLE utHandle;
unsigned long KeyCount;
ret = UT_DESGetKeyCount(utHandle,&KeyCount);
UT_DESGetFirstKeyHandle
Prototype
UT_RV UT_API UT_DESGetFirstKeyHandle(
UT_HANDLE utHandle,
KEY_HANDLE_PTR lpKeyHandle
)
Description
To get the handle of the first DES key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpKeyHandle [out] key handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_KEY No key found
Sample
See also the sample of UT_DESGetNextKeyHandle
UT_DESGetNextKeyHandle
Prototype
UT_RV UT_API UT_DESGetNextKeyHandle(
UT_HANDLE utHandle,
KEY_HANDLE_PTR lpKeyHandle
)
Description
To get the handle of the next DES key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpKeyHandle [out] key handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_KEY No key found
UT_OPERATE_INVALID Invalid operation
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
ret = UT_DESGetFirstKeyHandle(utHandle,&KeyHandle);
ret = UT_DESGetNextKeyHandle(utHandle,&KeyHandle);
UT_DES3GenerateKey
Prototype
UT_RV UT_API UT_DES3GenerateKey(
UT_HANDLE utHandle,
KEY_HANDLE_PTR lpKeyHandle
)
Description
To generate a 3DES key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpKeyHandle [out]key handle
Note:
The length of generated 3DES key is 24 bytes.
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_FULL No more key can be
generated
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
ret = UT_DES3GenerateKey(utHandle,&KeyHandle);
UT_DES3Encrypt
Prototype
UT_RV UT_API UT_DES3Encrypt(
UT_HANDLE utHandle,
KEY_HANDLE KeyHandle,
unsigned char* lpData,
unsigned long DataLength,
unsigned char* lpEncryptedData,
unsigned long* lpEncryptedDataLength
)
Description
To encrypt data with 3DES
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
KeyHandle [in] key handle
lpData [in] plain text
DataLength [in]length of plain text
lpEncryptedData [out] cipher text
lpEncryptedDataLength [out] length of cipher text
Notes:
DateLength is DES_DATA_LEN_8_BYTE
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_HANDLE_INVALID Invalid key handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
unsigned char Data[DES_DATA_LEN_8_BYTE];
unsigned char EncryptedData[DES_DATA_LEN_8_BYTE];
unsigned long EncryptedDataLength;
ret = UT_DES3Encrypt(
utHandle,
keyHandle,
Data,
DES_DATA_LEN_8_BYTE,
EncryptedData,
&EncryptedDataLength
);
UT_DES3Decrypt
Prototype
UT_RV UT_API UT_DES3Decrypt(
UT_HANDLE utHandle,
KEY_HANDLE KeyHandle,
unsigned char* lpEncryptedData ,
unsigned long EncryptedDataLength,
unsigned char* lpData,
unsigned long* lpDataLength
)
Description
To decrypt data with 3DES
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
KeyHandle [in] key handle
lpEncryptedData [in] cipher text
EncryptedDataLength [in]length of cipher text
lpData [out] plain text
lpDataLength [out] length of plain text
Notes:
EncryptedDataLength is DES_DATA_LEN_8_BYTE
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_HANDLE_INVALID Invalid key handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
unsigned char Data[DES_DATA_LEN_8_BYTE];
unsigned char EncryptedData[DES_DATA_LEN_8_BYTE];
unsigned long DataLength;
ret = UT_DES3Decrypt(
utHandle,
keyHandle,
EncryptedData,
DES_DATA_LEN_8_BYTE,
Data,
&DataLength
);
UT_DES3ImportKey
Prototype
UT_RV UT_API UT_DES3ImportKey(
UT_HANDLE utHandle,
unsigned char* lpKey,
KEY_HANDLE_PTR lpKeyHandle
)
Description
To import 3DES keys to UniToken device
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpKey [in] 3DES key
lpKeyHandle [out] key handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_FULL No more key can be
generated
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
unsigned char Key[DES3_KEY_LEN_24_BYTE];
ret = UT_DES3ImportKey(utHandle,Key,&KeyHandle);
UT_DES3DeleteKey
Prototype
UT_RV UT_API UT_DES3DeleteKey(
UT_HANDLE utHandle,
KEY_HANDLE KeyHandle
)
Description
To delete a 3DES key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
KeyHandle [in] key handle
Returned value:
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_HANDLE_INVALID Invalid key handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
ret = UT_DES3DeleteKey(utHandle,KeyHandle);
UT_DES3GetKeyCount
Prototype
UT_RV UT_API UT_DES3GetKeyCount(
UT_HANDLE utHandle,
unsigned long* lpKeyCount
)
Description
To count 3DES keys
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpKeyCount [out]the number of keys
Notes:
The maximum number of 3DES keys is 16.
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_KEY No key found
Sample
UT_RV ret;
UT_HANDLE utHandle;
unsigned long KeyCount;
ret = UT_DES3GetKeyCount(utHandle,&KeyCount);
UT_DES3GetFirstKeyHandle
Prototype
UT_RV UT_API UT_DES3GetFirstKeyHandle(
UT_HANDLE utHandle,
KEY_HANDLE_PTR lpKeyHandle
)
Description
To get the handle of the first 3DES key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpKeyHandle [out] key handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_KEY No key found
Sample
See also the samples of UT_DES3GetNextKeyHandle
UT_DES3GetNextKeyHandle
Prototype
UT_RV UT_API UT_DES3GetNextKeyHandle(
UT_HANDLE utHandle,
KEY_HANDLE_PTR lpKeyHandle
)
Description
To get the handle of the next 3DES key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpKeyHandle [in] key handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_KEY No key found
UT_OPERATE_INVALID Invalid operation
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
ret = UT_DES3GetFirstKeyHandle(utHandle,&KeyHandle);
ret = UT_DES3GetNextKeyHandle(utHandle,&KeyHandle);
UT_AESGenerateKey
Prototype
UT_RV UT_API UT_AESGenerateKey(
UT_HANDLE utHandle,
unsigned long KeyLength,
KEY_HANDLE_PTR lpKeyHandle
)
Description
To generate an AES key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
KeyLength [in]key length
lpKeyHandle [out] key handle
Notes:
KeyLength can be AES_KEY_LEN_128_BIT or AES_KEY_LEN_192_BIT
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_FULL No more key can be
generated
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
ret = UT_AESGenerateKey(
utHandle,
AES_KEY_LEN_128_BIT,
&KeyHandle
);
UT_AESEncrypt
Prototype
UT_RV UT_API UT_AESEncrypt(
UT_HANDLE utHandle,
KEY_HANDLE KeyHandle,
unsigned char* lpData,
unsigned long DataLength,
unsigned char* lpEncryptedData,
unsigned long* lpEncryptedDataLength
)
Description
To encrypt data with AES
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
KeyHandle [in] key handle
lpData [in] plaintext
DataLength [in]length of plaintext
lpEncryptedData [out] cipher text
lpEncryptedDataLength [out] length of cipher text
Notes:
DateLength is AES_DATA_LEN_16_BYTE
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_HANDLE_INVALID Invalid key handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
unsigned char Data[AES_DATA_LEN_16_BYTE];
unsigned char EncryptedData[AES_DATA_LEN_16_BYTE];
unsigned long EncryptedDataLength;
ret = UT_AESEncrypt(
utHandle,
KeyHandle,
Data,
AES_DATA_LEN_16_BYTE,
EncryptedData,
&EncryptedDataLength
);
UT_AESDecrypt
Prototype
UT_RV UT_API UT_AESDecrypt(
ANDLE utHandle,
KEY_HANDLE KeyHandle,
unsigned char* lpEncryptedData,
nsigned long EncryptedDataLength,
unsigned char* lpData,
unsigned long* lpDataLength
)
Description
To decrypt data with AES
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
KeyHandle [in] key handle
lpEncryptedData [in] cipher text
EncryptedDataLength [in]length of cipher text
lpData [out] plaintext
lpDataLength [out] length of plain text
Notes:
DateLength is AES_DATA_LEN_16_BYTE
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_HANDLE_INVALID Invalid key handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
unsigned char Data[AES_DATA_LEN_16_BYTE];
unsigned char EncryptedData[AES_DATA_LEN_16_BYTE];
unsigned long DataLength;
ret = UT_AESDecrypt(
ndle,
KeyHandle,
EncryptedData,
AES_DATA_LEN_16_BYTE,
Data,
&DataLength
);
UT_AESImportKey
Prototype
UT_RV UT_API UT_AESImportKey(
ANDLE utHandle,
unsigned char* lpKey,
unsigned long KeyLength,
KEY_HANDLE_PTR lpKeyHandle
)
Description
To import AES key to UniToken device
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpKey [in] AES key
KeyLength [in]key length
lpKeyHandle [out] key handle
Notes:
KeyLength can be AES_KEY_LEN_128_BIT or AES_KEY_LEN_192_BIT
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_FULL No more key can be
generated
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
unsigned char key[AES_KEY_LEN_128_BIT];
Ret = UT_AESImportKey(
utHandle,
key,
AES_KEY_LEN_128_BIT,
&KeyHandle
);
UT_AESDeleteKey
Prototype
UT_RV UT_API UT_AESDeleteKey(
UT_HANDLE utHandle,
KEY_HANDLE KeyHandle
)
Description
To delete an AES key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
KeyHandle [in] key handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_HANDLE_INVALID Invalid key handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
ret = UT_AESDeleteKey(utHandle,KeyHandle);
UT_AESGetKeyCount
Prototype
UT_RV UT_API UT_AESGetKeyCount(
UT_HANDLE utHandle,
unsigned long* lpKeyCount
)
Description
To count AES keys
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpKeyCount [out]the number of keys
Notes:
The maximum number of 3DES keys is 32.
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_KEY No key found
Sample
UT_RV ret;
UT_HANDLE utHandle;
unsigned long KeyCount;
ret = UT_AESGetKeyCount(utHandle,&KeyCount);
UT_AESGetKeyLen
Prototype
UT_RV UT_API UT_AESGetKeyLen(
UT_HANDLE utHandle,
KEY_HANDLE KeyHandle,
unsigned long* lpKeyLength
)
Description
To get the length of AES key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
KeyHandle [in] key handle
lpKeyLength [out] key length
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_KEY_HANDLE_INVALID Invalid key handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
unsigned long KeyLength;
ret = UT_AESGetKeyLen(utHandle,KeyHandle,&KeyLength);
UT_AESGetFirstKeyHandle
Prototype
UT_RV UT_API UT_AESGetFirstKeyHandle(
UT_HANDLE utHandle,
KEY_HANDLE_PTR lpKeyHandle
)
Description
To get the handle of the first AES key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpKeyHandle [out] key handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_KEY No key found
Sample
See also the sample of UT_AESGetNextKeyHandle
UT_AESGetNextKeyHandle
Prototype
UT_RV UT_API UT_AESGetNextKeyHandle(
UT_HANDLE utHandle,
KEY_HANDLE_PTR lpKeyHandle
)
Description
To get the handle of the next AES key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpKeyHandle [out] key handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_KEY No key found
UT_OPERATE_INVALID Invalid operation
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
ret = UT_AESGetFirstKeyHandle(utHandle,&KeyHandle);
ret = UT_AESGetNextKeyHandle(utHandle,&KeyHandle);
UT_RSAGenerateKeyPair
Prototype
UT_RV UT_API UT_RSAGenerateKeyPair(
UT_HANDLE utHandle,
unsigned long ModulusBits,
unsigned long PubExp,
KEY_HANDLE_PTR lpPubKeyHandle,
KEY_HANDLE_PTR lpPriKeyHandle
)
Description
To generate RSA key pair
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
ModulusBits [in] modulus length
PubExp [in]public exponent
lpPubKeyHandle [out] public key handle
lpPriKeyHandle [out] private key handle
Notes:
1. UniToken device can store as many as 16 RSA key pairs
2. ModulusBits can be RSA_MODULUS_LEN_1024_BIT or
RSA_MODULUS_LEN_2048_BIT
3. PubExp is RSA_PUBEXP_LEN_65537_BIT
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_FULL No more key can be
generated
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE PubKeyHandle;
KEY_HANDLE PriKeyHandle;
ret = UT_RSAGenerateKeyPair(
utHandle,
RSA_KEY_LEN_1024_BIT,
RSA_PUBEXP_LEN_65537_BIT,
&PubKeyHandle,
&PriKeyHandle
);
UT_RSAPubKeyEncrypt
Prototype
UT_RV UT_API UT_RSAPubKeyEncrypt(
UT_HANDLE utHandle,
KEY_HANDLE PubKeyHandle,
unsigned char* lpData,
unsigned long DataLength,
unsigned char* lpEncryptedData,
unsigned long* lpEncryptedDataLength
)
Description
To encrypt data with RSA public key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
PubKeyHandle [in] public key handle
lpData [in] plain text
DataLength [in]length of plain text
lpEncryptedData [out] cipher text
lpEncryptedDataLength [out] length of cipher text
Notes:
DataLength can be RSA_DATA_LEN_1024_BIT or SA_DATA_LEN_2048_BIT
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_HANDLE_INVALID Invalid key handle
Usage note
The handle of public key should be gotten by UT_RSAGetPubKeyByPriKey
instead of manually input. A 1024-bit RSA public key can only encrypt 1024-bit
data. It is also true for 2048-bit RSA public keys.
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE PubKeyHandle;
unsigned char Data[RSA_DATA_LEN_1024_BIT];
unsigned char EncryptedData[RSA_DATA_LEN_1024_BIT];
unsigned long EncryptedDataLength;
ret = UT_RSAPubKeyEncrypt(
utHandle,
PubKeyHandle,
Data,
RSA_DATA_LEN_1024_BIT,
EncryptedData,
&EncryptedDataLength
);
UT_RSAPriKeyDecrypt
Prototype
UT_RV UT_API UT_RSAPriKeyDecrypt(
UT_HANDLE utHandle,
KEY_HANDLE PriKeyHandle,
unsigned char* lpEncryptedData,
unsigned long EncryptedDataLength,
unsigned char* lpData,
unsigned long* lpDataLength
)
Description
To decrypt data with RSA private key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
PriKeyHandle [in] private key handle
lpEncryptedData [in] cipher text
EncryptedDataLength [in]length of cipher text
lpData [out] plaintext
lpDataLength [out] length of plain text
Notes:
DataLength can be RSA_DATA_LEN_1024_BIT or SA_DATA_LEN_2048_BIT
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_HANDLE_INVALID Invalid key handle
Usage note
The handle of private key should be gotten by RSAGetPriKeyByPubKey instead
of manually input. A 1024-bit RSA private key can only decrypt 1024-bit data. It
is also true for 2048-bit RSA private keys.
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE PriKeyHandle;
unsigned char Data[RSA_DATA_LEN_1024_BIT];
unsigned char EncryptedData[RSA_DATA_LEN_1024_BIT];
unsigned long DataLength;
ret = UT_RSAPriKeyDecrypt(
utHandle,
PriKeyHandle,
EncryptedData,
RSA_DATA_LEN_1024_BIT,Data,
&DataLength
);
UT_RSAPriKeyEncrypt
Prototype
UT_RV UT_API UT_RSAPriKeyEncrypt(
UT_HANDLE utHandle,
KEY_HANDLE PriKeyHandle,
unsigned char* lpData,
unsigned long DataLength,
unsigned char* lpEncryptedData,
unsigned long* lpEncryptedDataLength
)
Description
To encrypt data with RSA private key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
PriKeyHandle [in] private key handle
lpData [in] plain text
DataLength [in]length of plain text
lpEncryptedData [out] cipher text
lpEncryptedDataLength [out] length of cipher text
Notes:
DataLength can be RSA_DATA_LEN_1024_BIT or SA_DATA_LEN_2048_BIT
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_HANDLE_INVALID Invalid key handle
Usage note
The handle of private key should be gotten by UT_RSAGetPriKeyByPubKey
instead of manually input. A 1024-bit RSA private key can only encrypt 1024-bit
data. It is also true for 2048-bit RSA private keys.
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE PriKeyHandle;
unsigned char Data[RSA_DATA_LEN_1024_BIT];
unsigned char EncryptedData[RSA_DATA_LEN_1024_BIT];
unsigned long EncryptedDataLength;
ret = UT_RSAPriKeyEncrypt(
utHandle,
PriKeyHandle,Data,
RSA_DATA_LEN_1024_BIT,
EncryptedData,
&EncryptedDataLength
);
UT_RSAPubKeyDecrypt
Prototype
UT_RV UT_API UT_RSAPubKeyDecrypt(
UT_HANDLE utHandle,
KEY_HANDLE PubKeyHandle,
unsigned char* lpEncryptedData,
unsigned long EncryptedDataLength,
unsigned char* lpData,
unsigned long* lpDataLength
)
Description
To decrypt data with RSA public key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
PubKeyHandle [in] public key handle
lpEncryptedData [in] cipher text
EncryptedDataLength [in]length of cipher text
lpData [out] plain text
lpDataLength [out] length of plain text
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_HANDLE_INVALID Invalid key handle
Usage note
The handle of public key should be gotten by UT_RSAGetPubKeyByPriKey
instead of manually input. A 1024-bit RSA public key can only decrypt 1024-bit
data. It is also true for 2048-bit RSA public keys.
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE PubKeyHandle;
unsigned char Data[RSA_DATA_LEN_1024_BIT];
unsigned char EncryptedData[RSA_DATA_LEN_1024_BIT];
unsigned long DataLength;
ret = UT_RSAPubKeyDecrypt(
utHandle,
PubKeyHandle,
EncryptedData,
RSA_DATA_LEN_1024_BIT,
Data,
&DataLength
);
UT_RSAGetKeyPairCount
Prototype
UT_RV UT_API UT_RSAGetKeyPairCount(
UT_HANDLE utHandle,
unsigned long* lpKeyCount
)
Description
To count RSA keys
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpKeyCount [out] the number of key pairs
Notes:
The maximum number of RSA key pairs is 16.
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_KEY No key found
Sample
UT_RV ret;
UT_HANDLE utHandle;
unsigned long KeyCount;
ret = UT_RSAGetKeyPairCount(utHandle,&KeyCount);
UT_RSAGetFirstKeyPairHandle
Prototype
UT_RV UT_API UT_RSAGetFirstKeyPairHandle(
UT_HANDLE utHandle,
KEY_HANDLE_PTR lpPubKeyHandle,
KEY_HANDLE_PTR lpPriKeyHandle
)
Description
To get the handles of the first RSA key pair
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpPubKeyHandle [out] public key handle
lpPriKeyHandle [out] private key handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_KEY No key found
Sample
See also the sample of UT_RSAGetNextKeyPairHandle
UT_RSAGetNextKeyPairHandle
Prototype
UT_RV UT_API UT_RSAGetNextKeyPairHandle(
UT_HANDLE utHandle,
KEY_HANDLE_PTR lpPubKeyHandle,
KEY_HANDLE_PTR lpPriKeyHandle
)
Description
To get the handles of the next RSA key pair
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpPubKeyHandle [out] public key handle
lpPriKeyHandle [out] private key handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_KEY No key found
UT_OPERATE_INVALID Invalid operation
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE PubKeyHandle;
KEY_HANDLE PriKeyHandle;
ret = UT_RSAGetFirstKeyPairHandle(
utHandle,
&PubKeyHandle,
&PriKeyHandle
);
ret = UT_RSAGetNextKeyPairHandle(
utHandle,
&PubKeyHandle,
&PriKeyHandle
);
UT_RSAPubKeyImport
Prototype
UT_RV UT_API UT_RSAPubKeyImport(
UT_HANDLE utHandle,
UT_RSA* lpRsaKey,
KEY_HANDLE PriKeyHandle,
KEY_HANDLE_PTR lpPubKeyHandle
)
Description
To import RSA public key to UniToken device
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpRsaKey [in] RSA key
PriKeyHandle [in] private key handle
lpPubKeyHandle [out] public key handle
Notes:
PriKeyHandle can be the existing private key handle or RSA_IMPORT_NEW
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_HANDLE_INVALID Invalid key handle
UT_KEY_EXIST Key already exists
UT_KEY_FULL No more key can be generated
Usage note
In this function, the public key can be imported either by the corresponding private key handle or by creating a new key pair (if there’s enough memory). If the key pair already exists, import the public key and return the handle of the public key; if there’s no corresponding key pair in the device, return UT_KEY_HANDLE_INVALID. If PriKeyHandle is RSA_IMPORT_NEW, create a new key pair and import the public key.
Besides, UniToken device can store 16 RSA key pairs. If there’re already 16 key pairs inside, calling this function, return UT_KEY_FULL.
Sample
See also the sample of UT_RSAPriKeyImport
UT_RSAPriKeyImport
Prototype
UT_RV UT_API UT_RSAPriKeyImport(
UT_HANDLE utHandle,
UT_RSA* lpRsaKey,
KEY_HANDLE PubKeyHandle,
KEY_HANDLE_PTR lpPriKeyHandle
)
Description
To import RSA private key to UniToken device
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpRsaKey [in] RSA key
PubKeyHandle [in] public key handle
lpPriKeyHandle [out] private key handle
Notes:
PubKeyHandle can be the existing public key handle or RSA_IMPORT_NEW
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_HANDLE_INVALID Invalid key handle
UT_KEY_EXIST Key already exists
UT_KEY_FULL No more key can be
generated
Sample
UT_RV ret;
UT_HANDLE utHandle;
UT_RSA RsaKey;
KEY_HANDLE PubKeyHandle;
KEY_HANDLE PriKeyHandle;
ret = UT_RSAPubKeyImport(
utHandle,
&RsaKey,
RSA_IMPORT_NEW,
&PubKeyHandle
);
ret = UT_RSAPriKeyImport(
utHandle,
&RsaKey,
PubKeyHandle,
&PriKeyHandle
);
UT_RSAPubKeyExport
Prototype
UT_RV UT_API UT_RSAPubKeyExport(
UT_HANDLE utHandle,
KEY_HANDLE PubKeyHandle,
unsigned long* lpModulusBits,
UT_RSA* lpRsaKey
)
Description
To export RSA public key from UniToken device
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
PubKeyHandle [in] public key handle
lpModulusBits [out]modulus length
lpRsaKey [out] RSA public key structure
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_HANDLE_INVALID Invalid key handle
UT_KEY_EXIST Key already exists
UT_KEY_FULL No more key can be
generated
Sample
UT_RV ret;
UT_HANDLE utHandle;
UT_RSA RsaKey;
KEY_HANDLE PubKeyHandle;
unsigned long ModulusBits;
ret = UT_RSAPubKeyExport(
utHandle,
PubKeyHandle,
&ModulusBits,
&RsaKey
);
UT_RSAGetPubKeyHandle
Prototype
UT_RV UT_API UT_RSAGetPubKeyHandle(
UT_HANDLE utHandle,
KEY_HANDLE PriKeyHandle,
KEY_HANDLE_PTR lpPubKeyHandle
)
Description
To get the public key handle by the corresponding private key handle
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
PriKeyHandle [in] private key handle
lpPubKeyHandle [out]the corresponding public
key handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_KEY_HANDLE_INVALID Invalid key handle
UT_NO_KEY No key found
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE PubKeyHandle;
KEY_HANDLE PriKeyHandle;
ret = UT_RSAGetPubKeyHandle(
utHandle,
PriKeyHandle,
&PubKeyHandle
);
UT_RSAGetPriKeyHandle
Prototype
UT_RV UT_API UT_RSAGetPriKeyHandle(
UT_HANDLE utHandle,
KEY_HANDLE PubKeyHandle,
KEY_HANDLE_PTR lpPriKeyHandle
)
Description
To get the public key handle by the corresponding private key handle
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
PubKeyHandle [in] public key handle
lpPriKeyHandle [out]the corresponding private key
handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_KEY_HANDLE_INVALID Invalid key handle
UT_NO_KEY No key found
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE PubKeyHandle;
KEY_HANDLE PriKeyHandle;
ret = UT_RSAGetPriKeyHandle(
utHandle,
PubKeyHandle,
&PriKeyHandle
);
UT_RSAGetKeyPairModulus
Prototype
UT_RV UT_API UT_RSAGetKeyPairModulus(
UT_HANDLE utHandle,
KEY_HANDLE PubKeyHandle,
unsigned long* lpModulusBits
)
Description
To get RSA key pair modulus
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
PubKeyHandle [in] public key handle
lpModulusBits [out]modulus length
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_KEY_HANDLE_INVALID Invalid key handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE PubKeyHandle;
unsigned long ModulusBits;
ret = UT_RSAGetKeyPairModulus(
utHandle,
PubKeyHandle,
&ModulusBits
);
UT_RSADeleteKeyPair
Prototype
UT_RV UT_API UT_RSADeleteKeyPair(
UT_HANDLE utHandle,
KEY_HANDLE PubKeyHandle,
KEY_HANDLE PriKeyHandle
)
Description
To delete the RSA key pair
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
PubKeyHandle [in] public key handle
PriKeyHandle [in] private key handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_HANDLE_INVALID Invalid key handle
Usage note
In this function, the handles of a key pair are required. If the handles belong to
the keys from different key pairs, return UT_KEY_HANDLE_INVALID; if only
one key handle provided, the other key handle must be 0 to delete the key pair.
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE PubKeyHandle;
KEY_HANDLE PriKeyHandle;
ret = UT_RSADeleteKeyPair(
utHandle,
PubKeyHandle,
PriKeyHandle
);
UT_MD5HMACGenerateKey
Prototype
UT_RV UT_API UT_MD5HMACGenerateKey(
UT_HANDLE utHandle,
unsigned long KeyLength,
KEY_HANDLE_PTR lpKeyHandle
)
Description
To generate HMAC-MD5 key
Parameters:
PARAMETERS DESCRIPTION
utHandle [in] device handle
KeyLength [in] key length
lpKeyHandle [out] key handle
Notes:
the length of key< = 128 bytes
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_FULL No more key can be
generated
Usage note
UniToken device can store as many as 8 HMAC-MD5 keys. If there are already
8 keys in the device, calling the function, return UT_KEY_FULL.
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
ret = UT_MD5HMACGenerateKey(utHandle,128,&KeyHandle);
UT_MD5HMAC
Prototype
UT_RV UT_API UT_MD5HMAC(
UT_HANDLE utHandle,
KEY_HANDLE KeyHandle,
unsigned char* lpData,
unsigned long DataLength,
unsigned char* lpDigest
)
Description
To run HMAC-MD5 algorithm
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
KeyHandle [in] key handle
lpData [in] data to be digested
DataLength [in]data length
lpDigest [out] the digested data
Notes:
DataLength is 1~128 bytes
lpDigest is 16 bytes
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_HANDLE_INVALID Invalid key handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
unsigned char Data[128];
unsigned char Digest[16];
ret = UT_MD5HMAC(utHandle,KeyHandle,Data,128,Digest);
UT_MD5
Prototype
UT_RV UT_API UT_MD5(
UT_HANDLE utHandle,
unsigned char* lpData,
unsigned long DataLength,
unsigned char* lpDigest
)
Description
To run MD5 algorithm
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpData [in] data to be digested
DataLength [in]data length
lpDigest [out] the digested data
Notes
DataLength is 1~128 bytes
lpDigest is 16 bytes
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
unsigned char Data[128];
unsigned char Digest[16];
ret = UT_MD5(utHandle,Data,128,Digest);
UT_MD5GetKeyCount
Prototype
UT_RV UT_API UT_MD5GetKeyCount(
UT_HANDLE utHandle,
unsigned long* lpKeyCount
)
Description
To count HMAC-MD5 keys
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpKeyCount [out] the number of keys
Notes:
The maximum number of MD5 keys is 8.
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_KEY No key found
Sample
UT_RV ret;
UT_HANDLE utHandle;
unsigned long KeyCount;
ret = UT_MD5GetKeyCount(utHandle,&KeyCount);
UT_MD5GetKeyLen
Prototype
UT_RV UT_API UT_MD5GetKeyLen(
UT_HANDLE utHandle,
KEY_HANDLE KeyHandle,
unsigned long* lpKeyLength
)
Description
To get the length of HMAC-MD5 key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
KeyHandle [in] key handle
lpKeyLength [out] key length
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_KEY_HANDLE_INVALID Invalid key handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
unsigned long KeyLength;
ret = UT_MD5GetKeyLen(utHandle,KeyHandle,&KeyLength);
UT_MD5GetFirstKeyHandle
Prototype
UT_RV UT_API UT_MD5GetFirstKeyHandle(
UT_HANDLE utHandle,
KEY_HANDLE_PTR lpKeyHandle
)
Description
To get the handle of the first HMAC-MD5 key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpKeyHandle [out]key handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_KEY No key found
Sample
See also the samples of UT_MD5GetNextKeyHandle
UT_MD5GetNextKeyHandle
Prototype
UT_RV UT_API UT_MD5GetNextKeyHandle(
UT_HANDLE utHandle,
KEY_HANDLE_PTR lpKeyHandle
)
Description
To get the handle of the next HMAC-MD5 key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpKeyHandle [out]key handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_KEY No key found
UT_OPERATE_INVALID Invalid operation
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
ret = UT_MD5GetFirstKeyHandle(utHandle,&KeyHandle);
ret = UT_MD5GetNextKeyHandle(utHandle,&KeyHandle);
UT_MD5DeleteKey
Prototype
UT_RV UT_API UT_MD5DeleteKey(
UT_HANDLE utHandle,
KEY_HANDLE KeyHandle
)
Description
To delete HMAC-MD5 key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
KeyHandle [in]key handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_HANDLE_INVALID Invalid key handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
ret = UT_MD5DeleteKey(utHandle,KeyHandle);
UT_MD5ImportKey
Prototype
UT_RV UT_API UT_MD5ImportKey(
UT_HANDLE utHandle,
unsigned char* lpKey,
unsigned long KeyLength,
KEY_HANDLE_PTR lpKeyHandle
)
Description
To import HMAC-MD5 key to UniToken device
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpKey [in]key
KeyLength [in]key length
lpKeyHandle [out] key handle
Notes:
KeyLength is 1~128 bytes
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_FULL No more key can be generated
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
unsigned char Key[128];
ret = UT_MD5ImportKey(utHandle,Key,128,&KeyHandle);
UT_SHA1HMACGenerateKey
Prototype
UT_RV UT_API UT_SHA1HMACGenerateKey(
UT_HANDLE utHandle,
unsigned long KeyLength,
KEY_HANDLE_PTR lpKeyHandle
)
Description
To generate HMAC-SHA1 key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
KeyLength [in] key length
lpKeyHandle [out] key handle
Notes:
the length of key < =128 bytes
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_FULL No more key can be generated
Usage note
UniToken device can store as many as 8 HMAC-SHA1 keys. If there are already
8 keys in the device, calling the function, return UT_KEY_FULL.
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
ret = UT_SHA1HMACGenerateKey(utHandle,128,&KeyHandle);
UT_SHA1HMAC
Prototype
UT_RV UT_API UT_SHA1HMAC(
UT_HANDLE utHandle,
KEY_HANDLE KeyHandle,
unsigned char* lpData,
unsigned long DataLength,
unsigned char* lpDigest
)
Description
To run HMAC-SHA1algorithm
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
KeyHandle [in] key handle
lpData [in] data to be digested
DataLength [in]data length
lpDigest [out]the digested data
Notes:
DataLength is 1~128 bytes
lpDigest is 20 bytes
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_HANDLE_INVALID Invalid key handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
unsigned char Data[128];
unsigned char Digest[20];
ret = UT_SHA1HMAC(utHandle,KeyHandle,Data,128,Digest);
UT_SHA1
Prototype
UT_RV UT_API UT_SHA1(
UT_HANDLE utHandle,
unsigned char* lpData,
unsigned long DataLength,
unsigned char* lpDigest
)
Description
To run SHA1 algorithm
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpData [in] data to be digested
DataLength [in]data length
lpDigest [out] the digested data
Notes:
DataLength is 1~128 bytes
lpDigest is 20 bytes
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
unsigned char Data[128];
unsigned char Digest[20];
ret = UT_SHA1(utHandle,Data,128,Digest);
UT_SHA1GetKeyCount
Prototype
UT_RV UT_API UT_SHA1GetKeyCount(
UT_HANDLE utHandle,
unsigned long* lpKeyCount
)
Description
To count HMAC-SHA1 keys
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpKeyCount [out] the number of keys
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_KEY No key found
Sample
UT_RV ret;
UT_HANDLE utHandle;
unsigned long KeyCount;
ret = UT_SHA1GetKeyCount(utHandle,&KeyCount);
UT_SHA1GetKeyLen
Prototype
UT_RV UT_API UT_SHA1GetKeyLen(
UT_HANDLE utHandle,
KEY_HANDLE KeyHandle,
unsigned long* lpKeyLength
)
Description
To get the length of HMAC-SHA1 key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
KeyHandle [in] key handle
lpKeyLength [out] key length
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_KEY_HANDLE_INVALID Invalid key handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
unsigned long KeyLength;
ret = UT_SHA1GetKeyLen(utHandle,KeyHandle,&KeyLength);
UT_SHA1GetFirstKeyHandle
Prototype
UT_RV UT_API UT_SHA1GetFirstKeyHandle(
UT_HANDLE utHandle,
KEY_HANDLE_PTR lpKeyHandle
)
Description
To get the handle of the first HMAC-SHA1 key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpKeyHandle [out]key handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_KEY No key found
Sample
See also the sample of UT_SHA1GetNextKeyHandle
UT_SHA1GetNextKeyHandle
Prototype
UT_RV UT_API UT_SHA1GetNextKeyHandle(
UT_HANDLE utHandle,
KEY_HANDLE_PTR lpKeyHandle
)
Description
To get the handle of the next HMAC-SHA1 key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpkeyHandle [out]key handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_KEY No key found
UT_OPERATE_INVALID Invalid operation
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
ret = UT_SHA1GetFirstKeyHandle(utHandle,&KeyHandle);
ret = UT_SHA1GetNextKeyHandle(utHandle,&KeyHandle);
UT_SHA1DeleteKey
Prototype
UT_RV UT_API UT_SHA1DeleteKey(
UT_HANDLE utHandle,
KEY_HANDLE KeyHandle
)
Description
To delete HMAC-SHA1 key
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
keyHandle [in] key handle
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_HANDLE_INVALID Invalid key handle
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
ret = UT_SHA1DeleteKey(utHandle,KeyHandle);
UT_SHA1ImportKey
Prototype
UT_RV UT_API UT_SHA1ImportKey(
UT_HANDLE utHandle,
unsigned char* lpKey,
unsigned long KeyLength,
KEY_HANDLE_PTR lpKeyHandle
)
Description
To import HMAC-SHA1 key to UniToken device
Parameters
PARAMETERS DESCRIPTION
utHandle [in] device handle
lpKey [in]SHA1 key
KeyLength [in]key length
lpKeyHandle [out] key handle
Notes:
KeyLength is 1~128 bytes
Returned value
RETURNED VALUE DESCRIPTION
UT_OK Successful operation
UT_NOT_INITIALIZE Library not initialized
UT_ARGUMENTS_BAD Invalid argument
UT_TOKEN_HANDLE_INVALID Invalid token handle
UT_NO_PERMISSION No permission
UT_KEY_FULL No more key can be
generated
Sample
UT_RV ret;
UT_HANDLE utHandle;
KEY_HANDLE KeyHandle;
unsigned char Key[128];
ret = UT_SHA1ImportKey(utHandle,Key,128,&KeyHandle);
UT_FS_GetSpace
UT_FS_GetFileCount
UT_FS_GetFirstFileName
UT_FS_GetNextFileName
UT_FS_GetFileSize
UT_FS_GetFilePermission
UT_FS_CreatFile
UT_FS_DeleteFile
UT_FS_OpenFile
UT_FS_WriteFile
UT_FS_ReadFile
UT_FS_CloseFile
<a _fcknotitle="true" href="Category:UniToken_APIs">UniToken_APIs</a>