UniToken API Reference: Difference between revisions
mNo edit summary |
|||
| (18 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
[[ | [[category:UniToken_API]] | ||
== UT_GetLibraryVersion == | == UT_GetLibraryVersion == | ||
<b>API Prototype</b> | |||
<code>unsigned long UT_API UT_GetLibraryVersion()</code> | |||
< | |||
<b>Description</b> | |||
To get the version of the present library. | |||
<b>Parameters</b> | |||
n/a | |||
<b>Returned Value</b> | |||
< | <table class="wikitable"> | ||
unsigned long ulLibraryVersion; | <tr> | ||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>Library version</td> | |||
<td>the version of the current library</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
unsigned long ulLibraryVersion; | |||
ulLibraryVersion = UT_GetLibraryVersion(); | ulLibraryVersion = UT_GetLibraryVersion(); | ||
</ | </source> | ||
== UT_Initialize == | |||
<b>API Prototype</b> | |||
<code>UT_RV UT_API UT_Initialize()</code> | |||
<b>Description</b> | |||
To initialize the UniToken. This should be called before any other function, with the exception <code>UT_GetLibraryVersion</code> | |||
<b>Parameters</b> | |||
n/a | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ALREADY_INITIALIZE</td> | |||
<td>Library already initialized</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
ret = UT_Initialize(); | |||
</source> | |||
== UT_Finalize == | |||
<b>API Prototype</b> | |||
<code>UT_RV UT_API UT_Finalize()</code> | |||
<b>Description</b> | |||
Call this function to end any interaction with UniToken and free the memory. | |||
<b>Parameters</b> | |||
n/a | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
ret = UT_Finalize(); | |||
</source> | |||
== UT_GetTokenList == | |||
<b>API Prototype</b> | |||
UT_RV UT_API UT_GetTokenList(UT_SLOT_ID* lpSlotID, unsigned long* lpTokenCount) | |||
<b>Description</b> | |||
To get the list of Slot ID and the number of Slot ID. | |||
<b>Parameters</b> | |||
= | <table class="wikitable"> | ||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>lpSlotID</td> | |||
<td>[out] slot ID list</td> | |||
</tr> | |||
<tr> | |||
<td>lpTokenCount</td> | |||
<td> | |||
* [in] size of buffer (0~32 bytes) | |||
* [out]number of token | |||
</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
== UT_GetTokenList == | <table class="wikitable"> | ||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
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); | |||
</source> | |||
== UT_OpenDevice == | == UT_OpenDevice == | ||
== UT_CloseDevice == | <b>Prototype</b> | ||
<source lang="C"> | |||
UT_RV UT_API UT_OpenDevice( | |||
UT_SLOT_ID SlotID, | |||
UT_HANDLE* lputHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To open the device in the specified slot. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>SlotID</td> | |||
<td>[in] the specified slot</td> | |||
</tr> | |||
<tr> | |||
<td>lputHandle</td> | |||
<td>[out] device handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_SLOT_ID_INVALUD</td> | |||
<td>Invalid slot ID</td> | |||
</tr> | |||
</table> | |||
<b>Usage Note</b> | |||
SlotID should be retrieved from <code>UT_GetTokenList</code> instead manually entered. Therefore, this function cannot be called before <code>UT_GetTokenList</code> | |||
<b>Sample</b> | |||
See the sample of <code>UT_GetTokenList</code> | |||
== UT_CloseDevice == | |||
<b>Prototype</b> | |||
<code>UT_RV UT_API UT_CloseDevice(UT_HANDLE utHandle);</code> | |||
<b>Description</b> | |||
To close the specified device. | |||
<b>Parameters</b> | |||
n/a | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
See also the sample of <code>UT_GetTokenList</code> | |||
== UT_GetHandle == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_GetHandle( | |||
UT_SLOT_ID SlotID, | |||
UT_HANDLE* lputHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get device handle by Slot ID. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>SlotID [in]</td> | |||
<td>the specified slot</td> | |||
</tr> | |||
<tr> | |||
<td>lputHandle [out]</td> | |||
<td>device handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
See the sample of <code>UT_GetTokenList</code> | |||
== UT_GetSlotID == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_GetSlotID( | |||
UT_HANDLE utHandle, | |||
UT_SLOT_ID* lpSlotID | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get Slot ID by device handle. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>the specified handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpSlotID [out]</td> | |||
<td>Slot ID</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALIDM</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
See the sample of <code>UT_GetTokenList</code> | |||
== UT_GetSlotStatus == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_GetSlotStatus( | |||
UT_STATUS* lpStatus, | |||
UT_SLOT_ID* lpSlotID | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get the status of Slot. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>lpStatus [out]</td> | |||
<td>the current status of slot</td> | |||
</tr> | |||
<tr> | |||
<td>lpSlotID [out]</td> | |||
<td>Slot ID</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
lpStatus can be: | |||
# Inserted, when UniToken is inserted into the slot; | |||
# removed, when UniToken is removed from the slot; | |||
# no change, when there’s no change to the status of slot. In this case, lpSlotID is undefined. | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
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 | |||
} | |||
} | |||
</source> | |||
== UT_GetTokenType == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_GetTokenType( | |||
UT_HANDLE utHandle, | |||
char* lpszTokenType | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get the type of the current device, e.g. UniToken STD, PRO. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpszTokenType [out]</td> | |||
<td>UniToken type (string, 32 bytes)</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
char TokenType[33] = {0}; | |||
ret = UT_GetTokenType(utHandle, (char *)TokenType); | |||
</source> | |||
== UT_GetFirmwareVersion == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_GetFirmwareVersion( | |||
UT_HANDLE utHandle, | |||
unsigned long* lpVersion | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get the version of firmware. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpVersion [out]</td> | |||
<td>firmware version</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
unsigned long Version; | |||
ret = UT_GetFirmwareVersion(utHandle, &Version); | |||
</source> | |||
== UT_Logoff == | |||
<b>Prototype</b> | |||
<code>UT_RV UT_API UT_Logoff(UT_HANDLE utHandle);</code> | |||
<b>Description</b> | |||
To log off the specified Token. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
See the sample of <code>UT_Logon</code> | |||
== UT_Logon == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_Logon( | |||
UT_HANDLE utHandle, | |||
unsigned long UserLevel, | |||
unsigned char* lpszPin | |||
); | |||
</source> | |||
<b>Description</b> | |||
To logon the specified token. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>UserLevel [in]</td> | |||
<td>levels of permission</td> | |||
</tr> | |||
<tr> | |||
<td>lpszPin [in]</td> | |||
<td>the corresponding password with certain permission level</td> | |||
</tr> | |||
</table> | |||
<b>Note:</b> | |||
lpszPin is made up with strings, and the minimum size is 1 byte. | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_PIN_ERROR</td> | |||
<td>Wrong password</td> | |||
</tr> | |||
<tr> | |||
<td>UT_USER_FULL</td> | |||
<td>No more sessions allowed</td> | |||
</tr> | |||
<tr> | |||
<td>UT_USER_LOCKED</td> | |||
<td>Token locked</td> | |||
</tr> | |||
</table> | |||
<b>Usage Note</b> | |||
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. | |||
<b>Sample</b> | |||
<source lang="C"> | |||
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); | |||
</source> | |||
== UT_GetCurrentUserLevel == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_GetCurrentUserLevel( | |||
UT_HANDLE utHandle, | |||
unsigned long* lpUserLevel | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get the current permission level. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpUserLevel [out]</td> | |||
<td>Permission level</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
See the sample of UT_Logon. | |||
== UT_ChangePin == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_ChangePin( | |||
UT_HANDLE utHandle, | |||
unsigned char UserLevel, | |||
unsigned long ChangeMode, | |||
unsigned char* OldPin, | |||
unsigned char* NewPin | |||
); | |||
</source> | |||
<b>Description</b> | |||
To change the PIN. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>UserLevel [in]</td> | |||
<td>permission level</td> | |||
</tr> | |||
<tr> | |||
<td>ChangeMode [in]</td> | |||
<td>mode to change to</td> | |||
</tr> | |||
<tr> | |||
<td>OldPIN [in]</td> | |||
<td>old PIN</td> | |||
</tr> | |||
<tr> | |||
<td>NewPin [in]</td> | |||
<td>new PIN</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
Change Mode can be <code>UT_CHANGE_PIN_MODE_BYSELF</code> or <code>UT_CHANGE_PIN_MODE_ADMIN_CHANGE_USER</code> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_ALLOWED</td> | |||
<td>Operation not allowed</td> | |||
</tr> | |||
</table> | |||
<b>Usage Note</b> | |||
Two ways of changing password: | |||
# 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 <code>UT_CHANGE_PIN_MODE_BYSELF</code> | |||
# Admin resets user password. Log on as ADMIN and type in new password of USER. Here, the mode of changing PIN is <code>UT_CHANGE_PIN_MODE_ADMIN_CHANGE_USER</code> In this case, OldPin is not required. | |||
<b>Sample</b> | |||
<source lang="C"> | |||
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); | |||
</source> | |||
== UT_GetID == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_GetID( | |||
UT_HANDLE utHandle, | |||
char* lpszId | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get the token ID of specified device. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpszId [out]</td> | |||
<td>UniToken ID (string, 32 bytes)</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
See the sample of <code>UT_SetID</code> | |||
== UT_SetID == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_SetID( | |||
UT_HANDLE utHandle, | |||
char* lpszId | |||
); | |||
</source> | |||
<b>Description</b> | |||
To set the token ID of the specified device | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpszId [out]</td> | |||
<td>UniToken ID (string, 32 bytes)</td> | |||
</tr> | |||
</table> | |||
<b>Returned value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
char Id[33] = "UniTokenPRO"; | |||
unsigned long UserLevel; | |||
ret = UT_SetID(utHandle, Id); | |||
ret = UT_GetID(utHandle, Id); | |||
</source> | |||
== UT_GetHID == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_GetHID( | |||
UT_HANDLE utHandle, | |||
unsigned long* lpHid | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get the Hardware ID of the specified device | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpHid [out]</td> | |||
<td>Hardware ID</td> | |||
</tr> | |||
</table> | |||
<b>Returned value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
unsigned long Hid; | |||
ret = UT_GetHID(utHandle, &Hid); | |||
</source> | |||
== UT_GetSoftID == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_GetSoftID( | |||
UT_HANDLE utHandle, | |||
unsigned long* lpSoftID | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get the Software ID of the specified device | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpSoftID [out]</td> | |||
<td>Software ID</td> | |||
</tr> | |||
</table> | |||
<b>Returned value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
See also the sample of <code>UT_SetSoftID</code> | |||
== UT_SetSoftID == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_SetSoftID( | |||
UT_HANDLE utHandle, | |||
unsigned long SoftID | |||
); | |||
</source> | |||
<b>Description</b> | |||
To set the Software ID of the specified device. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpSoftID [out]</td> | |||
<td>Software ID</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
unsigned long SoftID = 0; | |||
ret = UT_GetSoftID(utHandle, &SoftID); | |||
ret = UT_SetSoftID(utHandle, SoftID); | |||
</source> | |||
== UT_LED == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_LED( | |||
UT_HANDLE utHandle, | |||
unsigned char On | |||
); | |||
</source> | |||
<b>Description</b> | |||
To turn on/off LED. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>On [in]</td> | |||
<td>the status of the LED</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
The parameter On can be <code>LED_ON</code> or <code>LED_OFF</code> | |||
<b>Returned value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
ret = UT_LED(utHandle, LED_ON); | |||
</source> | |||
== UT_SetAttemptCount == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_SetAttemptCount( | |||
UT_HANDLE utHandle, | |||
unsigned long MaxAttempt | |||
); | |||
</source> | |||
<b>Description</b> | |||
To set the maximum times of PIN attempt | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>MaxAttempt [in]</td> | |||
<td>maximum attempt times</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
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. | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
</table> | |||
<b>Usage Note</b> | |||
This function is used for unlocking the token. | |||
<b>Sample</b> | |||
See the sample of <code>UT_GetAttemptCount</code> | |||
== UT_GetAttemptCount == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_GetAttemptCount( | |||
UT_HANDLE utHandle, | |||
unsigned long* lpUserAttempt, | |||
unsigned long* lpAdminAttempt | |||
); | |||
</source> | |||
<b>Description</b> | |||
To count the number of failed login attempts. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpUserAttempt [out]</td> | |||
<td>User PIN attempt times</td> | |||
</tr> | |||
<tr> | |||
<td>lpAdminAttempt [out]</td> | |||
<td>Admin PIN attempt times</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
unsigned long UserAttempt; | |||
unsigned long AdminAttempt; | |||
ret = UT_SetAttemptCount(utHandle, 15); | |||
ret = UT_GetAttemptCount(utHandle, &UserAttempt, &AdminAttempt); | |||
</source> | |||
== UT_Format == | |||
<b>Prototype</b> | |||
<code>UT_RV UT_API UT_Format(UT_HANDLE utHandle);</code> | |||
<b>Description</b> | |||
To format a UniToken. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
</table> | |||
<b>Usage Note:</b> | |||
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. | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
ret = UT_Format(utHandle); | |||
</source> | |||
== UT_Rand == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_Rand( | |||
UT_HANDLE utHandle, | |||
unsigned long Length, | |||
unsigned char* lpOut, | |||
void* lpReserve | |||
); | |||
</source> | |||
<b>Description</b> | |||
To generate random numbers. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>Length [in]</td> | |||
<td>length of random number (in bytes)</td> | |||
</tr> | |||
<tr> | |||
<td>lpOut [out]</td> | |||
<td>random number</td> | |||
</tr> | |||
<tr> | |||
<td>lpReserve</td> | |||
<td>reserved for future use</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
unsigned char OutRand[8]; | |||
ret = UT_Rand(utHandle, 8, OutRand, NULL); | |||
</source> | |||
== UT_DESGenerateKey == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_DESGenerateKey( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE_PTR lpKeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To generate a DES key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyHandle [out]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Note:</b> | |||
The length of generated DES key is 8 bytes. | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_FULL</td> | |||
<td>no more keys can be generated</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE KeyHandle; | |||
ret = UT_DESGenerateKey(utHandle, &KeyHandle); | |||
</source> | |||
== UT_DESEncrypt == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_DESEncryptZ( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE KeyHandle, | |||
unsigned char* lpData, | |||
unsigned long DataLength, | |||
unsigned char* lpEncryptedData, | |||
unsigned long* lpEncryptedDataLength | |||
); | |||
</source> | |||
<b>Description</b> | |||
To encrypt data with DES. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyHandle [in]</td> | |||
<td>key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpData [in]</td> | |||
<td>plaintext</td> | |||
</tr> | |||
<tr> | |||
<td>DataLength [in]</td> | |||
<td>length of plaintext in bytes</td> | |||
</tr> | |||
<tr> | |||
<td>lpEncryptedData [out]</td> | |||
<td>ciphertext</td> | |||
</tr> | |||
<tr> | |||
<td>lpEncryptedDataLength [out]</td> | |||
<td>length of ciphertext</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
DateLength is <code>DES_DATA_LEN_8_BYTE</code> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
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 | |||
); | |||
</source> | |||
== UT_DESDecrypt == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_DESDecrypt( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE KeyHandle, | |||
unsigned char* lpEncryptedData, | |||
unsigned long EncryptedDataLength, | |||
unsigned char* lpData, | |||
unsigned long* lpDataLength | |||
); | |||
</source> | |||
<b>Description</b> | |||
To decrypt data with DES. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyHandle [in]</td> | |||
<td>key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpEncryptedData [in]</td> | |||
<td>ciphertext</td> | |||
</tr> | |||
<tr> | |||
<td>EncryptedDataLength [in]</td> | |||
<td>length of ciphertext in bytes</td> | |||
</tr> | |||
<tr> | |||
<td>lpData [out]</td> | |||
<td>plaintext</td> | |||
</tr> | |||
<tr> | |||
<td>lpDataLength [out]</td> | |||
<td>length of plaintext</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
EncryptedDataLength is <code>DES_DATA_LEN_8_BYTE</code> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
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 | |||
); | |||
</source> | |||
== UT_DESImportKey == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_DESImportKey( | |||
UT_HANDLE utHandle, | |||
unsigned char* lpKey, | |||
KEY_HANDLE_PTR lpKeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To import a DES key to UniToken device. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKey [in]</td> | |||
<td>DES key</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyHandle [out]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_FULL</td> | |||
<td>No more keys can be generated</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE KeyHandle; | |||
unsigned char Key[DES_KEY_LEN_8_BYTE]; | |||
ret = UT_DESImportKey(utHandle, Key, &KeyHandle); | |||
</source> | |||
== UT_DESDeleteKey == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_DESDeleteKey( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE KeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To delete a DES key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyHandle [in]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE KeyHandle; | |||
ret = UT_DESDeleteKey(utHandle, KeyHandle); | |||
</source> | |||
== UT_DESGetKeyCount == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_DESGetKeyCount( | |||
UT_HANDLE utHandle, | |||
unsigned long* lpKeyCount | |||
); | |||
</source> | |||
<b>Description</b> | |||
To count DES keys. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyCount [out]</td> | |||
<td>the number of keys</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
The maximum number of DES keys is 16. | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_KEY</td> | |||
<td>No key found</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
unsigned long KeyCount; | |||
ret = UT_DESGetKeyCount(utHandle, &KeyCount); | |||
</source> | |||
== UT_DESGetFirstKeyHandle == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_DESGetFirstKeyHandle( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE_PTR lpKeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get the handle of the first DES key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyHandle [out]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_KEY</td> | |||
<td>No key found</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
See also the sample of <code>UT_DESGetNextKeyHandle</code> | |||
== UT_DESGetNextKeyHandle == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_DESGetNextKeyHandle( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE_PTR lpKeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get the handle of the next DES key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyHandle [out]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_KEY</td> | |||
<td>No key found</td> | |||
</tr> | |||
<tr> | |||
<td>UT_OPERATE_INVALID</td> | |||
<td>Invalid operation</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE KeyHandle; | |||
ret = UT_DESGetFirstKeyHandle(utHandle, &KeyHandle); | |||
ret = UT_DESGetNextKeyHandle(utHandle, &KeyHandle); | |||
</source> | |||
== UT_DES3GenerateKey == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_DES3GenerateKey( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE_PTR lpKeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To generate a 3DES key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyHandle [out]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Note:</b> | |||
The length of generated 3DES key is 24 bytes. | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_FULL</td> | |||
<td>no more keys can be generated</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE KeyHandle; | |||
ret = UT_DES3GenerateKey(utHandle, &KeyHandle); | |||
</source> | |||
== UT_DES3Encrypt == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_DES3Encrypt( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE KeyHandle, | |||
unsigned char* lpData, | |||
unsigned long DataLength, | |||
unsigned char* lpEncryptedData, | |||
unsigned long* lpEncryptedDataLength | |||
); | |||
</source> | |||
<b>Description</b> | |||
To encrypt data with 3DES. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyHandle [in]</td> | |||
<td>key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpData [in]</td> | |||
<td>plaintext</td> | |||
</tr> | |||
<tr> | |||
<td>DataLength [in]</td> | |||
<td>length of plaintext</td> | |||
</tr> | |||
<tr> | |||
<td>lpEncryptedData [out]</td> | |||
<td>ciphertext</td> | |||
</tr> | |||
<tr> | |||
<td>lpEncryptedDataLength [out]</td> | |||
<td>length of ciphertext</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
DateLength is <code>DES_DATA_LEN_8_BYTE</code> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
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 | |||
); | |||
</source> | |||
== UT_DES3Decrypt == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_DES3Decrypt( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE KeyHandle, | |||
unsigned char* lpEncryptedData, | |||
unsigned long EncryptedDataLength, | |||
unsigned char* lpData, | |||
unsigned long* lpDataLength | |||
); | |||
</source> | |||
<b>Description</b> | |||
To decrypt data with 3DES. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyHandle [in]</td> | |||
<td>key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpEncryptedData [in]</td> | |||
<td>ciphertext</td> | |||
</tr> | |||
<tr> | |||
<td>EncryptedDataLength [in]</td> | |||
<td>length of ciphertext</td> | |||
</tr> | |||
<tr> | |||
<td>lpData [out]</td> | |||
<td>plaintext</td> | |||
</tr> | |||
<tr> | |||
<td>lpDataLength [out]</td> | |||
<td>length of plaintext</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
EncryptedDataLength is <code>DES_DATA_LEN_8_BYTE</code> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
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 | |||
); | |||
</source> | |||
== UT_DES3ImportKey == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_DES3ImportKey( | |||
UT_HANDLE utHandle, | |||
unsigned char* lpKey, | |||
KEY_HANDLE_PTR lpKeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To import 3DES keys to UniToken device. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKey [in]</td> | |||
<td>3DES key</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyHandle [out]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_FULL</td> | |||
<td>No more keys can be generated</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE KeyHandle; | |||
unsigned char Key[DES3_KEY_LEN_24_BYTE]; | |||
ret = UT_DES3ImportKey(utHandle, Key, &KeyHandle); | |||
</source> | |||
== UT_DES3DeleteKey == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_DES3DeleteKey( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE KeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To delete a 3DES key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyHandle [in]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE KeyHandle; | |||
ret = UT_DES3DeleteKey(utHandle, KeyHandle); | |||
</source> | |||
== UT_DES3GetKeyCount == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_DES3GetKeyCount( | |||
UT_HANDLE utHandle, | |||
unsigned long* lpKeyCount | |||
); | |||
</source> | |||
<b>Description</b> | |||
To count 3DES keys. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyCount [out]</td> | |||
<td>the number of keys</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
The maximum number of 3DES keys is 16. | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_KEY</td> | |||
<td>No key found</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
unsigned long KeyCount; | |||
ret = UT_DES3GetKeyCount(utHandle, &KeyCount); | |||
</source> | |||
== UT_DES3GetFirstKeyHandle == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_DES3GetFirstKeyHandle( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE_PTR lpKeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get the handle of the first 3DES key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyHandle [out]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_KEY</td> | |||
<td>No key found</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
See also the samples of <code>UT_DES3GetNextKeyHandle</code> | |||
== UT_DES3GetNextKeyHandle == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_DES3GetNextKeyHandle( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE_PTR lpKeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get the handle of the next 3DES key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyHandle [out]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_KEY</td> | |||
<td>No key found</td> | |||
</tr> | |||
<tr> | |||
<td>UT_OPERATE_INVALID</td> | |||
<td>Invalid operation</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE KeyHandle; | |||
ret = UT_DES3GetFirstKeyHandle(utHandle, &KeyHandle); | |||
ret = UT_DES3GetNextKeyHandle(utHandle, &KeyHandle); | |||
</source> | |||
== UT_AESGenerateKey == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_AESGenerateKey( | |||
UT_HANDLE utHandle, | |||
unsigned long KeyLength, | |||
KEY_HANDLE_PTR lpKeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To generate an AES key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyLength [in]</td> | |||
<td>key length</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyHandle [out]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
KeyLength can be <code>AES_KEY_LEN_128_BIT</code> or <code>AES_KEY_LEN_192_BIT</code> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_FULL</td> | |||
<td>No more keys can be generated</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE KeyHandle; | |||
ret = UT_AESGenerateKey(utHandle, AES_KEY_LEN_128_BIT, &KeyHandle); | |||
</source> | |||
== UT_AESEncrypt == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_AESEncrypt( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE KeyHandle, | |||
unsigned char* lpData, | |||
unsigned long DataLength, | |||
unsigned char* lpEncryptedData, | |||
unsigned long* lpEncryptedDataLength | |||
); | |||
</source> | |||
<b>Description</b> | |||
To encrypt data with AES. | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyHandle [in]</td> | |||
<td>key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpData [in]</td> | |||
<td>plaintext</td> | |||
</tr> | |||
<tr> | |||
<td>DataLength [in]</td> | |||
<td>length of plaintext</td> | |||
</tr> | |||
<tr> | |||
<td>lpEncryptedData [out]</td> | |||
<td>ciphertext</td> | |||
</tr> | |||
<tr> | |||
<td>lpEncryptedDataLength [out]</td> | |||
<td>length of ciphertext</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
DateLength is <code>AES_DATA_LEN_16_BYTE</code> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
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 | |||
); | |||
</source> | |||
== UT_AESDecrypt == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_AESDecrypt( | |||
HANDLE utHandle, | |||
KEY_HANDLE KeyHandle, | |||
unsigned char* lpEncryptedData, | |||
unsigned long EncryptedDataLength, | |||
unsigned char* lpData, | |||
unsigned long* lpDataLength | |||
); | |||
</source> | |||
<b>Description</b> | |||
To decrypt data with AES. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyHandle [in]</td> | |||
<td>key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpEncryptedData [in]</td> | |||
<td>ciphertext</td> | |||
</tr> | |||
<tr> | |||
<td>EncryptedDataLength [in]</td> | |||
<td>length of ciphertext</td> | |||
</tr> | |||
<tr> | |||
<td>lpData [out]</td> | |||
<td>plaintext</td> | |||
</tr> | |||
<tr> | |||
<td>lpDataLength [out]</td> | |||
<td>length of plaintext</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
DateLength is <code>AES_DATA_LEN_16_BYTE</code> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
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(handle, | |||
KeyHandle, | |||
EncryptedData, | |||
AES_DATA_LEN_16_BYTE, | |||
Data, | |||
&DataLength | |||
); | |||
</source> | |||
== UT_AESImportKey == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_AESImportKey( | |||
HANDLE utHandle, | |||
unsigned char* lpKey, | |||
unsigned long KeyLength, | |||
KEY_HANDLE_PTR lpKeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To import AES key to UniToken device. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyLength [in]</td> | |||
<td>key length</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyHandle [out]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
KeyLength can be <code>AES_KEY_LEN_128_BIT</code> or <code>AES_KEY_LEN_192_BIT</code> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_FULL</td> | |||
<td>No more keys can be generated</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
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); | |||
</source> | |||
== UT_AESDeleteKey == | |||
<b>Prototype</b> | |||
<code>UT_RV UT_API UT_AESDeleteKey(UT_HANDLE utHandle, KEY_HANDLE KeyHandle);</code> | |||
<b>Description</b> | |||
To delete an AES key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyHandle [in]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE KeyHandle; | |||
ret = UT_AESDeleteKey(utHandle, KeyHandle); | |||
</source> | |||
== UT_AESGetKeyCount == | |||
<b>Prototype</b> | |||
<code>UT_RV UT_API UT_AESGetKeyCount(UT_HANDLE utHandle, unsigned long* lpKeyCount);</code> | |||
<b>Description</b> | |||
To count AES keys. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyCount [out]</td> | |||
<td>the number of keys</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
The maximum number of 3DES keys is 32. | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_KEY</td> | |||
<td>No key found</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
unsigned long KeyCount; | |||
ret = UT_AESGetKeyCount(utHandle, &KeyCount); | |||
</source> | |||
== UT_AESGetKeyLen == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_AESGetKeyLen( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE KeyHandle, | |||
unsigned long* lpKeyLength | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get the length of AES key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyHandle [out]</td> | |||
<td>key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyLength [out]</td> | |||
<td>key length</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE KeyHandle; | |||
unsigned long KeyLength; | |||
ret = UT_AESGetKeyLen(utHandle, KeyHandle, &KeyLength); | |||
</source> | |||
== UT_AESGetFirstKeyHandle == | |||
<b>Prototype</b> | |||
<code>UT_RV UT_API UT_AESGetFirstKeyHandle(UT_HANDLE utHandle, KEY_HANDLE_PTR lpKeyHandle);</code> | |||
<b>Description</b> | |||
To get the handle of the first AES key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyHandle [out]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_KEY</td> | |||
<td>No key found</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
See also the sample of <code>UT_AESGetNextKeyHandle</code> | |||
== UT_AESGetNextKeyHandle == | |||
<b>Prototype</b> | |||
<code>UT_RV UT_API UT_AESGetNextKeyHandle(UT_HANDLE utHandle, KEY_HANDLE_PTR lpKeyHandle);</code> | |||
<b>Description</b> | |||
To get the handle of the next AES key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyHandle [out]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_KEY</td> | |||
<td>No key found</td> | |||
</tr> | |||
<tr> | |||
<td>UT_OPERATE_INVALID</td> | |||
<td>Invalid operation</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE KeyHandle; | |||
ret = UT_AESGetFirstKeyHandle(utHandle, &KeyHandle); | |||
ret = UT_AESGetNextKeyHandle(utHandle, &KeyHandle); | |||
</source> | |||
== UT_RSAGenerateKeyPair == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_RSAGenerateKeyPair( | |||
UT_HANDLE utHandle, | |||
unsigned long ModulusBits, | |||
unsigned long PubExp, | |||
KEY_HANDLE_PTR lpPubKeyHandle, | |||
KEY_HANDLE_PTR lpPriKeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To generate RSA key pair. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>ModulusBits [in]</td> | |||
<td>modulus length</td> | |||
</tr> | |||
<tr> | |||
<td>PubExp [in]</td> | |||
<td>public exponent</td> | |||
</tr> | |||
<tr> | |||
<td>lpPubKeyHandle [out]</td> | |||
<td>public key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpPriKeyHandle [out]</td> | |||
<td>private key handle</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
# UniToken device can store as many as 16 RSA key pairs | |||
# ModulusBits can be <code>RSA_MODULUS_LEN_1024_BIT</code> or <code>RSA_MODULUS_LEN_2048_BIT</code> | |||
# PubExp is <code>RSA_PUBEXP_LEN_65537_BIT</code> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_FULL</td> | |||
<td>No more keys can be generated</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
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 | |||
); | |||
</source> | |||
== UT_RSAPubKeyEncrypt == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_RSAPubKeyEncrypt( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE PubKeyHandle, | |||
unsigned char* lpData, | |||
unsigned long DataLength, | |||
unsigned char* lpEncryptedData, | |||
unsigned long* lpEncryptedDataLength | |||
); | |||
</source> | |||
<b>Description</b> | |||
To encrypt data with RSA public key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyHandle [in]</td> | |||
<td>key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpData [in]</td> | |||
<td>plaintext</td> | |||
</tr> | |||
<tr> | |||
<td>lpDataLength [in]</td> | |||
<td>length of plaintext</td> | |||
</tr> | |||
<tr> | |||
<td>lpEncryptedData [out]</td> | |||
<td>ciphertext</td> | |||
</tr> | |||
<tr> | |||
<td>EncryptedDataLength [out]</td> | |||
<td>length of ciphertext</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
DataLength can be <code>RSA_DATA_LEN_1024_BIT</code> or <code>SA_DATA_LEN_2048_BIT</code> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Usage Note</b> | |||
The handle of public key should be retrieved with <code>UT_RSAGetPubKeyByPriKey</code> instead manually entered. A 1024-bit RSA public key can only encrypt 1024-bit data. It is also true for 2048-bit RSA public keys. | |||
<b>Sample</b> | |||
<source lang="C"> | |||
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 | |||
); | |||
</source> | |||
== UT_RSAPriKeyDecrypt == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_RSAPriKeyDecrypt( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE PriKeyHandle, | |||
unsigned char* lpEncryptedData, | |||
unsigned long EncryptedDataLength, | |||
unsigned char* lpData, | |||
unsigned long* lpDataLength | |||
); | |||
</source> | |||
<b>Description</b> | |||
To decrypt data with RSA private key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyHandle [in]</td> | |||
<td>key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpEncryptedData [in]</td> | |||
<td>ciphertext</td> | |||
</tr> | |||
<tr> | |||
<td>EncryptedDataLength [in]</td> | |||
<td>length of ciphertext</td> | |||
</tr> | |||
<tr> | |||
<td>lpData [out]</td> | |||
<td>plaintext</td> | |||
</tr> | |||
<tr> | |||
<td>lpDataLength [out]</td> | |||
<td>length of plaintext</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
DataLength can be <code>RSA_DATA_LEN_1024_BIT</code> or <code>SA_DATA_LEN_2048_BIT</code> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Usage Note</b> | |||
The handle of private key should be retrieved with <code>RSAGetPriKeyByPubKey</code> 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. | |||
<b>Sample</b> | |||
<source lang="C"> | |||
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 | |||
); | |||
</source> | |||
== UT_RSAPriKeyEncrypt == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_RSAPriKeyEncrypt( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE PriKeyHandle, | |||
unsigned char* lpData, | |||
unsigned long DataLength, | |||
unsigned char* lpEncryptedData, | |||
unsigned long* lpEncryptedDataLength | |||
); | |||
</source> | |||
<b>Description</b> | |||
To encrypt data with RSA private key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyHandle [in]</td> | |||
<td>key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpData [in]</td> | |||
<td>plaintext</td> | |||
</tr> | |||
<tr> | |||
<td>lpDataLength [in]</td> | |||
<td>length of plaintext</td> | |||
</tr> | |||
<tr> | |||
<td>lpEncryptedData [out]</td> | |||
<td>ciphertext</td> | |||
</tr> | |||
<tr> | |||
<td>EncryptedDataLength [out]</td> | |||
<td>length of ciphertext</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
DataLength can be <code>RSA_DATA_LEN_1024_BIT</code> or <code>SA_DATA_LEN_2048_BIT</code> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Usage Note</b> | |||
The handle of private key should be retrieved with <code>UT_RSAGetPriKeyByPubKey</code> instead manually entered. A 1024-bit RSA private key can only encrypt 1024-bit data. It is also true for 2048-bit RSA private keys. | |||
<b>Sample</b> | |||
<source lang="C"> | |||
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 | |||
); | |||
</source> | |||
== UT_RSAPubKeyDecrypt == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_RSAPubKeyDecrypt( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE PubKeyHandle, | |||
unsigned char* lpEncryptedData, | |||
unsigned long EncryptedDataLength, | |||
unsigned char* lpData, | |||
unsigned long* lpDataLength | |||
); | |||
</source> | |||
<b>Description</b> | |||
To decrypt data with RSA public key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyHandle [in]</td> | |||
<td>key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpEncryptedData [in]</td> | |||
<td>ciphertext</td> | |||
</tr> | |||
<tr> | |||
<td>EncryptedDataLength [in]</td> | |||
<td>length of ciphertext</td> | |||
</tr> | |||
<tr> | |||
<td>lpData [out]</td> | |||
<td>plaintext</td> | |||
</tr> | |||
<tr> | |||
<td>lpDataLength [out]</td> | |||
<td>length of plaintext</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Usage Note</b> | |||
The handle of public key should be retrieved with <code>UT_RSAGetPubKeyByPriKey</code> instead manually entered. A 1024-bit RSA public key can only decrypt 1024-bit data. It is also true for 2048-bit RSA public keys. | |||
<b>Sample</b> | |||
<source lang="C"> | |||
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 | |||
); | |||
</source> | |||
== UT_RSAGetKeyPairCount == | |||
<b>Prototype</b> | |||
<code>UT_RV UT_API UT_RSAGetKeyPairCount(UT_HANDLE utHandle, unsigned long* lpKeyCount);</code> | |||
<b>Description</b> | |||
To count RSA keys. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyCount [out]</td> | |||
<td>the number of key pairs</td> | |||
</tr> | |||
</table> | |||
<b>Notes</b> | |||
The maximum number of RSA key pairs is 16. | |||
<b>Returned value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_KEY</td> | |||
<td>No key found</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
unsigned long KeyCount; | |||
ret = UT_RSAGetKeyPairCount(utHandle, &KeyCount); | |||
</source> | |||
== UT_RSAGetFirstKeyPairHandle == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_RSAGetFirstKeyPairHandle( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE_PTR lpPubKeyHandle, | |||
KEY_HANDLE_PTR lpPriKeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get the handles of the first RSA key pair. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpPubKeyHandle [out]</td> | |||
<td>public key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpPriKeyHandle [out]</td> | |||
<td>private key handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_KEY</td> | |||
<td>No key found</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
See also the sample of <code>UT_RSAGetNextKeyPairHandle</code> | |||
== UT_RSAGetNextKeyPairHandle == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_RSAGetNextKeyPairHandle( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE_PTR lpPubKeyHandle, | |||
KEY_HANDLE_PTR lpPriKeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get the handles of the next RSA key pair. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpPubKeyHandle [out]</td> | |||
<td>public key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpPriKeyHandle [out]</td> | |||
<td>private key handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_KEY</td> | |||
<td>No key found</td> | |||
</tr> | |||
<tr> | |||
<td>UT_OPERATE_INVALID</td> | |||
<td>Invalid operation</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE PubKeyHandle; | |||
KEY_HANDLE PriKeyHandle; | |||
ret = UT_RSAGetFirstKeyPairHandle(utHandle, &PubKeyHandle, &PriKeyHandle); | |||
ret = UT_RSAGetNextKeyPairHandle(utHandle, &PubKeyHandle, &PriKeyHandle); | |||
</source> | |||
== UT_RSAPubKeyImport == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_RSAPubKeyImport( | |||
UT_HANDLE utHandle, | |||
UT_RSA* lpRsaKey, | |||
KEY_HANDLE PriKeyHandle, | |||
KEY_HANDLE_PTR lpPubKeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To import RSA public key to UniToken device. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>PriKeyHandle [in]</td> | |||
<td>private key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpPubKeyHandle [out]</td> | |||
<td>public key handle</td> | |||
</tr> | |||
</table> | |||
<b>Notes</b> | |||
PriKeyHandle can be the existing private key handle or <code>RSA_IMPORT_NEW</code> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_EXIST</td> | |||
<td>Key already exists</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_FULL</td> | |||
<td>No more keys can be generated</td> | |||
</tr> | |||
</table> | |||
<b>Usage Note</b> | |||
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 <code>UT_KEY_HANDLE_INVALID</code> If PriKeyHandle is <code>RSA_IMPORT_NEW</code> create a new key pair and import the public key. The UniToken device can store up to 16 RSA key pairs; if there arere already 16 key pairs stored, calling this function will return <code>UT_KEY_FULL</code> | |||
<b>Sample</b> | |||
See the sample of <code>UT_RSAPriKeyImport</code> | |||
== UT_RSAPriKeyImport == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_RSAPriKeyImport( | |||
UT_HANDLE utHandle, | |||
UT_RSA* lpRsaKey, | |||
KEY_HANDLE PubKeyHandle, | |||
KEY_HANDLE_PTR lpPriKeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To import RSA private key to UniToken device. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>PubKeyHandle [in]</td> | |||
<td>public key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpPriKeyHandle [out]</td> | |||
<td>private key handle</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
PubKeyHandle can be the existing public key handle or <code>RSA_IMPORT_NEW</code> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_EXIST</td> | |||
<td>Key already exists</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_FULL</td> | |||
<td>No more keys can be generated</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
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 | |||
); | |||
</source> | |||
== UT_RSAPubKeyExport == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_RSAPubKeyExport( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE PubKeyHandle, | |||
unsigned long* lpModulusBits, | |||
UT_RSA* lpRsaKey | |||
); | |||
</source> | |||
<b>Description</b> | |||
To export RSA public key from UniToken device. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>PubKeyHandle [in]</td> | |||
<td>public key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpModulusBits [out]</td> | |||
<td>modulus length</td> | |||
</tr> | |||
<tr> | |||
<td>lpRsaKey [out]</td> | |||
<td>RSA public key structure</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_EXIST</td> | |||
<td>Key already exists</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_FULL</td> | |||
<td>No more keys can be generated</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
UT_RSA RsaKey; | |||
KEY_HANDLE PubKeyHandle; | |||
unsigned long ModulusBits; | |||
ret = UT_RSAPubKeyExport(utHandle, PubKeyHandle, &ModulusBits, &RsaKey); | |||
</source> | |||
== UT_RSAGetPubKeyHandle == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_RSAGetPubKeyHandle( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE PriKeyHandle, | |||
KEY_HANDLE_PTR lpPubKeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get the public key handle by the corresponding private key handle. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>PriKeyHandle [in]</td> | |||
<td>private key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpPubKeyHandle [out]</td> | |||
<td>the corresponding public key handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_KEY</td> | |||
<td>No key found</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE PubKeyHandle; | |||
KEY_HANDLE PriKeyHandle; | |||
ret = UT_RSAGetPubKeyHandle(utHandle, PriKeyHandle, &PubKeyHandle); | |||
</source> | |||
== UT_RSAGetPriKeyHandle == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_RSAGetPriKeyHandle( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE PubKeyHandle, | |||
KEY_HANDLE_PTR lpPriKeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get the public key handle by the corresponding private key handle. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>PubKeyHandle [in]</td> | |||
<td>public key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpPriKeyHandle [out]</td> | |||
<td>the corresponding private key handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_KEY</td> | |||
<td>No key found</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE PubKeyHandle; | |||
KEY_HANDLE PriKeyHandle; | |||
ret = UT_RSAGetPriKeyHandle(utHandle, PubKeyHandle, &PriKeyHandle); | |||
</source> | |||
== UT_RSAGetKeyPairModulus == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_RSAGetKeyPairModulus( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE PubKeyHandle, | |||
unsigned long* lpModulusBits | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get RSA key pair modulus. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>PubKeyHandle [in]</td> | |||
<td>public key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpModulusBits [out]</td> | |||
<td>modulus length</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE PubKeyHandle; | |||
unsigned long ModulusBits; | |||
ret = UT_RSAGetKeyPairModulus(utHandle, PubKeyHandle, &ModulusBits); | |||
</source> | |||
== UT_RSADeleteKeyPair == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_RSADeleteKeyPair( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE PubKeyHandle, | |||
KEY_HANDLE PriKeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To delete the RSA key pair. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>PubKeyHandle [in]</td> | |||
<td>public key handle</td> | |||
</tr> | |||
<tr> | |||
<td>PriKeyHandle [in]</td> | |||
<td>private key handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Usage Note</b> | |||
In this function, the handles of a key pair are required. If the handles belong to the keys from different key pairs, return <code>UT_KEY_HANDLE_INVALID</code> if only one key handle provided, the other key handle must be 0 to delete the key pair. | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE PubKeyHandle; | |||
KEY_HANDLE PriKeyHandle; | |||
ret = UT_RSADeleteKeyPair(utHandle, PubKeyHandle, PriKeyHandle); | |||
</source> | |||
== UT_MD5HMACGenerateKey == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_MD5HMACGenerateKey( | |||
UT_HANDLE utHandle, | |||
unsigned long KeyLength, | |||
KEY_HANDLE_PTR lpKeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To generate HMAC-MD5 key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyLength [in]</td> | |||
<td>key length</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyHandle [out]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
The length of key is <= 128 bytes | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_FULL</td> | |||
<td>No more keys can be generated</td> | |||
</tr> | |||
</table> | |||
<b>Usage Note</b> | |||
UniToken device can store as many as 8 HMAC-MD5 keys. If there are already 8 keys in the device, calling the function will return <code>UT_KEY_FULL</code> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE KeyHandle; | |||
ret = UT_MD5HMACGenerateKey(utHandle, 128, &KeyHandle); | |||
</source> | |||
== UT_MD5HMAC == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_MD5HMAC( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE KeyHandle, | |||
unsigned char* lpData, | |||
unsigned long DataLength, | |||
unsigned char* lpDigest | |||
); | |||
</source> | |||
<b>Description</b> | |||
To run HMAC-MD5 algorithm. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyHandle [in]</td> | |||
<td>key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpData [in]</td> | |||
<td>data to be digested</td> | |||
</tr> | |||
<tr> | |||
<td>DataLength [in]</td> | |||
<td>data length</td> | |||
</tr> | |||
<tr> | |||
<td>lpDigest [out]</td> | |||
<td>digested data</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
DataLength is 1~128 bytes. lpDigest is 16 bytes | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
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); | |||
</source> | |||
== UT_MD5 == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_MD5( | |||
UT_HANDLE utHandle, | |||
unsigned char* lpData, | |||
unsigned long DataLength, | |||
unsigned char* lpDigest | |||
); | |||
</source> | |||
<b>Description</b> | |||
To run MD5 algorithm. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpData [in]</td> | |||
<td>data to be digested</td> | |||
</tr> | |||
<tr> | |||
<td>DataLength [in]</td> | |||
<td>data length</td> | |||
</tr> | |||
<tr> | |||
<td>lpDigest [out]</td> | |||
<td>digested data</td> | |||
</tr> | |||
</table> | |||
<b>Notes</b> | |||
DataLength is 1~128 bytes. lpDigest is 16 bytes | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
unsigned char Data[128]; | |||
unsigned char Digest[16]; | |||
ret = UT_MD5(utHandle, Data, 128, Digest); | |||
</source> | |||
== UT_MD5GetKeyCount == | |||
<b>Prototype</b> | |||
<code>UT_RV UT_API UT_MD5GetKeyCount(UT_HANDLE utHandle, unsigned long* lpKeyCount);</code> | |||
<b>Description</b> | |||
To count HMAC-MD5 keys. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyCount [out]</td> | |||
<td>the number of keys</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
The maximum number of MD5 keys is 8. | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_KEY</td> | |||
<td>No key found</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
unsigned long KeyCount; | |||
ret = UT_MD5GetKeyCount(utHandle, &KeyCount); | |||
</source> | |||
== UT_MD5GetKeyLen == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_MD5GetKeyLen( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE KeyHandle, | |||
unsigned long* lpKeyLength | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get the length of HMAC-MD5 key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyHandle [in]</td> | |||
<td>key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyLength [out]</td> | |||
<td>key length</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE KeyHandle; | |||
unsigned long KeyLength; | |||
ret = UT_MD5GetKeyLen(utHandle, KeyHandle, &KeyLength); | |||
</source> | |||
== UT_MD5GetFirstKeyHandle == | |||
<b>Prototype</b> | |||
<code>UT_RV UT_API UT_MD5GetFirstKeyHandle(UT_HANDLE utHandle, KEY_HANDLE_PTR lpKeyHandle);</code> | |||
<b>Description</b> | |||
To get the handle of the first HMAC-MD5 key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyHandle [out]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_KEY</td> | |||
<td>No key found</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
See the samples of <code>UT_MD5GetNextKeyHandle</code> | |||
== UT_MD5GetNextKeyHandle == | |||
<b>Prototype</b> | |||
<code>UT_RV UT_API UT_MD5GetNextKeyHandle(UT_HANDLE utHandle, KEY_HANDLE_PTR lpKeyHandle);</code> | |||
<b>Description</b> | |||
To get the handle of the next HMAC-MD5 key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyHandle [out]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_KEY</td> | |||
<td>No key found</td> | |||
</tr> | |||
<tr> | |||
<td>UT_OPERATE_INVALID</td> | |||
<td>Invalid operation</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE KeyHandle; | |||
ret = UT_MD5GetFirstKeyHandle(utHandle, &KeyHandle); | |||
ret = UT_MD5GetNextKeyHandle(utHandle, &KeyHandle); | |||
</source> | |||
== UT_MD5DeleteKey == | |||
<b>Prototype</b> | |||
<code>UT_RV UT_API UT_MD5DeleteKey(UT_HANDLE utHandle, KEY_HANDLE KeyHandle);</code> | |||
<b>Description</b> | |||
To delete HMAC-MD5 key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyHandle [in]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE KeyHandle; | |||
ret = UT_MD5DeleteKey(utHandle, KeyHandle); | |||
</source> | |||
== UT_MD5ImportKey == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_MD5ImportKey( | |||
UT_HANDLE utHandle, | |||
unsigned char* lpKey, | |||
unsigned long KeyLength, | |||
KEY_HANDLE_PTR lpKeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To import HMAC-MD5 key to UniToken device. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyLength [in]</td> | |||
<td>key length</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyHandle [out]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
KeyLength is 1~128 bytes. | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_FULL</td> | |||
<td>No more keys can be generated</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE KeyHandle; | |||
unsigned char Key[128]; | |||
ret = UT_MD5ImportKey(utHandle, Key, 128, &KeyHandle); | |||
</source> | |||
== UT_SHA1HMACGenerateKey == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_SHA1HMACGenerateKey( | |||
UT_HANDLE utHandle, | |||
unsigned long KeyLength, | |||
KEY_HANDLE_PTR lpKeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To generate HMAC-SHA1 key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyLength [in]</td> | |||
<td>key length</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyHandle [out]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
The length of key is <=128 bytes. | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_FULL</td> | |||
<td>No more keys can be generated</td> | |||
</tr> | |||
</table> | |||
<b>Usage Note</b> | |||
UniToken device can store as many as 8 HMAC-SHA1 keys. If there are already 8 keys in the device, calling the function will return <code>UT_KEY_FULL</code> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE KeyHandle; | |||
ret = UT_SHA1HMACGenerateKey(utHandle, 128, &KeyHandle); | |||
</source> | |||
== UT_SHA1HMAC == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_SHA1HMAC( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE KeyHandle, | |||
unsigned char* lpData, | |||
unsigned long DataLength, | |||
unsigned char* lpDigest | |||
); | |||
</source> | |||
<b>Description</b> | |||
To run HMAC-SHA1 algorithm. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyHandle [in]</td> | |||
<td>key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpData [in]</td> | |||
<td>data to be digested</td> | |||
</tr> | |||
<tr> | |||
<td>DataLength [in]</td> | |||
<td>data length</td> | |||
</tr> | |||
<tr> | |||
<td>lpDigest [out]</td> | |||
<td>digested data</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
DataLength is 1~128 bytes. lpDigest is 20 bytes. | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
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); | |||
</source> | |||
== UT_SHA1 == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_SHA1( | |||
UT_HANDLE utHandle, | |||
unsigned char* lpData, | |||
unsigned long DataLength, | |||
unsigned char* lpDigest | |||
); | |||
</source> | |||
<b>Description</b> | |||
To run SHA1 algorithm. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpData [in]</td> | |||
<td>data to be digested</td> | |||
</tr> | |||
<tr> | |||
<td>DataLength [in]</td> | |||
<td>data length</td> | |||
</tr> | |||
<tr> | |||
<td>lpDigest [out]</td> | |||
<td>digested data</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
DataLength is 1~128 bytes. lpDigest is 20 bytes. | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
unsigned char Data[128]; | |||
unsigned char Digest[20]; | |||
ret = UT_SHA1(utHandle, Data, 128, Digest); | |||
</source> | |||
== UT_SHA1GetKeyCount == | |||
<b>Prototype</b> | |||
<code>UT_RV UT_API UT_SHA1GetKeyCount(UT_HANDLE utHandle, unsigned long* lpKeyCount);</code> | |||
<b>Description</b> | |||
To count HMAC-SHA1 keys | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyCount [out]</td> | |||
<td>the number of keys</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_KEY</td> | |||
<td>No key found</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
unsigned long KeyCount; | |||
ret = UT_SHA1GetKeyCount(utHandle, &KeyCount); | |||
</source> | |||
== UT_SHA1GetKeyLen == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_SHA1GetKeyLen( | |||
UT_HANDLE utHandle, | |||
KEY_HANDLE KeyHandle, | |||
unsigned long* lpKeyLength | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get the length of HMAC-SHA1 key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyHandle [in]</td> | |||
<td>key handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyLength [out]</td> | |||
<td>key length</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE KeyHandle; | |||
unsigned long KeyLength; | |||
ret = UT_SHA1GetKeyLen(utHandle, KeyHandle, &KeyLength); | |||
</source> | |||
== UT_SHA1GetFirstKeyHandle == | |||
<b>Prototype</b> | |||
<code>UT_RV UT_API UT_SHA1GetFirstKeyHandle(UT_HANDLE utHandle, KEY_HANDLE_PTR lpKeyHandle);</code> | |||
<b>Description</b> | |||
To get the handle of the first HMAC-SHA1 key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyHandle [out]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_KEY</td> | |||
<td>No key found</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
See also the sample of <code>UT_SHA1GetNextKeyHandle</code> | |||
== UT_SHA1GetNextKeyHandle == | |||
<b>Prototype</b> | |||
<code>UT_RV UT_API UT_SHA1GetNextKeyHandle(UT_HANDLE utHandle, KEY_HANDLE_PTR lpKeyHandle);</code> | |||
<b>Description</b> | |||
To get the handle of the next HMAC-SHA1 key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyHandle [out]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_KEY</td> | |||
<td>No key found</td> | |||
</tr> | |||
<tr> | |||
<td>UT_OPERATE_INVALID</td> | |||
<td>Invalid operation</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE KeyHandle; | |||
ret = UT_SHA1GetFirstKeyHandle(utHandle, &KeyHandle); | |||
ret = UT_SHA1GetNextKeyHandle(utHandle, &KeyHandle); | |||
</source> | |||
== UT_SHA1DeleteKey == | |||
<b>Prototype</b> | |||
<code>UT_RV UT_API UT_SHA1DeleteKey(UT_HANDLE utHandle, KEY_HANDLE KeyHandle);</code> | |||
<b>Description</b> | |||
To delete HMAC-SHA1 key. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>KeyHandle [in]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_HANDLE_INVALID</td> | |||
<td>Invalid key handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE KeyHandle; | |||
ret = UT_SHA1DeleteKey(utHandle, KeyHandle); | |||
</source> | |||
== UT_SHA1ImportKey == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_SHA1ImportKey( | |||
UT_HANDLE utHandle, | |||
unsigned char* lpKey, | |||
unsigned long KeyLength, | |||
KEY_HANDLE_PTR lpKeyHandle | |||
); | |||
</source> | |||
<b>Description</b> | |||
To import HMAC-SHA1 key to UniToken device. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpKey [in]</td> | |||
<td>SHA1 key</td> | |||
</tr> | |||
<tr> | |||
<td>KeyLength [in]</td> | |||
<td>key length</td> | |||
</tr> | |||
<tr> | |||
<td>lpKeyHandle [out]</td> | |||
<td>key handle</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
KeyLength is 1~128 bytes. | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_KEY_FULL</td> | |||
<td>No more keys can be generated</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
KEY_HANDLE KeyHandle; | |||
unsigned char Key[128]; | |||
ret = UT_SHA1ImportKey(utHandle, Key, 128, &KeyHandle); | |||
</source> | |||
== UT_FS_GetSpace == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_FS_GetSpace( | |||
UT_HANDLE utHandle, | |||
unsigned long* UsedSpace, | |||
unsigned long* FreeSpace | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get the size of the free memory. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UsedSize [out]</td> | |||
<td>size of used memory</td> | |||
</tr> | |||
<tr> | |||
<td>FreeSize [out]</td> | |||
<td>size of free memory</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
unsigned long UsedSpace; | |||
unsigned long FreeSpace; | |||
ret = UT_FS_GetSpace(utHandle, &UsedSpace, &FreeSpace); | |||
</source> | |||
== UT_FS_GetFileCount == | |||
<b>Prototype</b> | |||
<code>UT_RV UT_API UT_FS_GetFileCount(UT_HANDLE utHandle, unsigned long* lpFileCount);</code> | |||
<b>Description</b> | |||
To get the number of files. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpFileCount [out]</td> | |||
<td>the number of files</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_FS_NO_FILE</td> | |||
<td>No file found</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
unsigned long FileCount; | |||
ret = UT_FS_GetFileCount(utHandle, &FileCount); | |||
</source> | |||
== UT_FS_GetFirstFileName == | |||
<b>Prototype</b> | |||
<code>UT_RV UT_API UT_FS_GetFirstFileName(UT_HANDLE utHandle, char* lpszFileName);</code> | |||
<b>Description</b> | |||
To get the name of the first file. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpszFileName [out]</td> | |||
<td>filename (string, 16 bytes)</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_FS_NO_FILE</td> | |||
<td>No file found</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
See also the sample of <code>UT_GetNextFileName</code> | |||
== UT_FS_GetNextFileName == | |||
<b>Prototype</b> | |||
<code>UT_RV UT_API UT_FS_GetNextFileName(UT_HANDLE utHandle, char* lpszFileName);</code> | |||
<b>Description</b> | |||
To get the name of the next file. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpszFileName [out]</td> | |||
<td>filename (string, 16 bytes)</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_FS_LIST_END</td> | |||
<td>End of fire list</td> | |||
</tr> | |||
<tr> | |||
<td>UT_OPERATE_INVALID</td> | |||
<td>Invalid operation</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
char FileName[17]; | |||
ret = UT_FS_GetFirstFileName(utHandle, FileName); | |||
ret = UT_FS_GetNextFileName(utHandle, FileName); | |||
</source> | |||
== UT_FS_GetFileSize == | |||
<b>Prototype</b> | |||
<source lang="C"> | |||
UT_RV UT_API UT_FS_GetFileSize( | |||
UT_HANDLE utHandle, | |||
char* lpszFileName, | |||
unsigned long* lpFileSize | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get the file size. | |||
<b>Parameters</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpszFileName [in]</td> | |||
<td>filename (string, 16 bytes)</td> | |||
</tr> | |||
<tr> | |||
<td>lpFileSize [out]</td> | |||
<td>size of file</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
<table class="wikitable"> | |||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_FS_NAME_LEN_RANGE</td> | |||
<td>Filename too long</td> | |||
</tr> | |||
<tr> | |||
<td>UT_FS_NO_FILE</td> | |||
<td>No file found</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
<source lang="C"> | |||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
char FileName[17]; | |||
unsigned long FileSize; | |||
ret = UT_FS_GetFileSize(utHandle, FileName, &FileSize); | |||
</source> | |||
== UT_FS_GetFilePermission == | |||
<b>Prototype</b> | |||
= | <source lang="C"> | ||
UT_RV UT_API UT_FS_GetFilePermission( | |||
UT_HANDLE utHandle, | |||
char* lpszFileName, | |||
unsigned char* lpFilePermission | |||
); | |||
</source> | |||
<b>Description</b> | |||
To get the file permission of the specified file. | |||
<b>Parameters</b> | |||
= | <table class="wikitable"> | ||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpszFileName [in]</td> | |||
<td>filename (string, 16 bytes)</td> | |||
</tr> | |||
<tr> | |||
<td>lpFilePermission [out]</td> | |||
<td>file permission</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
= | <table class="wikitable"> | ||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_FS_NAME_LEN_RANGE</td> | |||
<td>Filename too long</td> | |||
</tr> | |||
<tr> | |||
<td>UT_FS_NO_FILE</td> | |||
<td>No file found</td> | |||
</tr> | |||
</table> | |||
<b>Sample</b> | |||
== | <source lang="C"> | ||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
char FileName[17]; | |||
unsigned char FilePermission; | |||
ret = UT_FS_GetFilePermission(utHandle, FileName, &FilePermission); | |||
</source> | |||
== | == UT_FS_CreatFile == | ||
<b>Prototype</b> | |||
= | <source lang="C"> | ||
UT_RV UT_API UT_FS_CreateFile( | |||
UT_HANDLE utHandle, | |||
char* lpszFileName, | |||
unsigned long FileSize, | |||
unsigned char FilePermission | |||
); | |||
</source> | |||
<b>Description</b> | |||
To create a file. | |||
<b>Parameters</b> | |||
= | <table class="wikitable"> | ||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpszFileName [in]</td> | |||
<td>filename (string, 16 bytes)</td> | |||
</tr> | |||
<tr> | |||
<td>FileSize [in]</td> | |||
<td>size of file</td> | |||
</tr> | |||
<tr> | |||
<td>FilePermission [in]</td> | |||
<td>file permission</td> | |||
</tr> | |||
</table> | |||
<b>Notes:</b> | |||
# The max. File size is 262112 bytes; | |||
# FilePermission can be FILE_PERMISSION_GUEST, FILE_PERMISSION_USER or FILE_PERMISSION_ADMIN. | |||
<b>Returned Value</b> | |||
= | <table class="wikitable"> | ||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_FS_NAME_LEN_RANGE</td> | |||
<td>Filename too long</td> | |||
</tr> | |||
<tr> | |||
<td>UT_FS_FILE_EXIST</td> | |||
<td>The file already exists</td> | |||
</tr> | |||
</table> | |||
<b>Usage Note</b> | |||
File permission types: | |||
# FILE_PERMISSION_GUEST: With GUEST and higher permissions, reading the file is allowed; With USER and higher permissions, writing file is allowed. | |||
# FILE_PERMISSION_USER: With USER and higher permissions, reading and writing file are allowed. | |||
# FILE_PERMISSION_ADMIN: Only ADMIN is allowed to read and write the file. | |||
<b>Sample</b> | |||
== | <source lang="C"> | ||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
char FileName[17]; | |||
ret = UT_FS_CreateFile(utHandle, FileName, 200, FILE_PERMISSION_GUEST); | |||
</source> | |||
== | == UT_FS_DeleteFile == | ||
<b>Prototype</b> | |||
<code>UT_RV UT_API UT_FS_DeleteFile(UT_HANDLE utHandle, char* lpszFileName);</code> | |||
<b>Description</b> | |||
To delete a file. | |||
<b>Parameters</b> | |||
= | <table class="wikitable"> | ||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpszFileName [in]</td> | |||
<td>filename (string, 16 bytes)</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
= | <table class="wikitable"> | ||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_FS_NAME_LEN_RANGE</td> | |||
<td>Filename too long</td> | |||
</tr> | |||
<tr> | |||
<td>UT_FS_NO_FILE</td> | |||
<td>No file found</td> | |||
</tr> | |||
</table> | |||
<b>Usage Note</b> | |||
To call the function, it is required that the current permission be higher than or at the same level with the one of writing the file. | |||
<b>Sample</b> | |||
== | <source lang="C"> | ||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
char FileName[17]; | |||
ret = UT_FS_DeleteFile(utHandle, FileName); | |||
</source> | |||
== | == UT_FS_OpenFile == | ||
<b>Prototype</b> | |||
= | <source lang="C"> | ||
UT_RV UT_API UT_FS_OpenFile( | |||
UT_HANDLE utHandle, | |||
char* lpszFileName, | |||
void* lpReserve | |||
); | |||
</source> | |||
<b>Description</b> | |||
To open a file. | |||
<b>Parameters</b> | |||
= | <table class="wikitable"> | ||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpszFileName [in]</td> | |||
<td>filename (string, 16 bytes)</td> | |||
</tr> | |||
<tr> | |||
<td>lpReserve<td> | |||
<td>reserved for further usage</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
= | <table class="wikitable"> | ||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_FS_NAME_LEN_RANGE</td> | |||
<td>Filename too long</td> | |||
</tr> | |||
<tr> | |||
<td>UT_FS_NO_FILE</td> | |||
<td>No file found</td> | |||
</tr> | |||
</table> | |||
<b>Usage Note</b> | |||
To call the function, it is required that the current permission be higher than or at the same level with the one of writing the file. Files can be read and written only when opened. | |||
<b>Sample</b> | |||
== | <source lang="C"> | ||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
char FileName[17]; | |||
ret = UT_FS_OpenFile(utHandle, FileName, NULL); | |||
</source> | |||
== | == UT_FS_WriteFile == | ||
<b>Prototype</b> | |||
= | <source lang="C"> | ||
UT_RV UT_API UT_FS_WriteFile( | |||
UT_HANDLE utHandle, | |||
unsigned long Offset, | |||
unsigned long Length, | |||
unsigned char* Buffer, | |||
void* lpReserve | |||
); | |||
</source> | |||
<b>Description</b> | |||
To write or modify a file. | |||
<b>Parameters</b> | |||
= | <table class="wikitable"> | ||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>Offset [in]</td> | |||
<td>start position for writing</td> | |||
</tr> | |||
<tr> | |||
<td>Length [in]</td> | |||
<td>length of data</td> | |||
</tr> | |||
<tr> | |||
<td>Buffer [in]</td> | |||
<td>data to write</td> | |||
</tr> | |||
<tr> | |||
<td>lpReserve</td> | |||
<td>reserved for further usage</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
= | <table class="wikitable"> | ||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_FS_OFFSET_INVALID</td> | |||
<td>Invalid start point for specified file</td> | |||
</tr> | |||
<tr> | |||
<td>UT_FS_NO_OPEN</td> | |||
<td>Cannot open file</td> | |||
</tr> | |||
<tr> | |||
<td>UT_FS_NOSPACE</td> | |||
<td>No room in file system</td> | |||
</tr> | |||
<tr> | |||
<td>UT_FS_NO_FILE</td> | |||
<td>No file found</td> | |||
</tr> | |||
</table> | |||
<b>Usage Note</b> | |||
To call the function, it is required that the current permission be higher than or at the same level with the one of writing the file. New function of appending is added. | |||
<b>Sample</b> | |||
== | <source lang="C"> | ||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
unsigned long Offset; | |||
unsigned char Buffer[200]; | |||
ret = UT_FS_WriteFile(utHandle, 0, 200, Buffer, NULL); | |||
</source> | |||
== | == UT_FS_ReadFile == | ||
<b>Prototype</b> | |||
= | <source lang="C"> | ||
UT_RV UT_API UT_FS_ReadFile( | |||
UT_HANDLE utHandle, | |||
unsigned long Offset, | |||
unsigned long Length, | |||
unsigned char* Buffer, | |||
void* lpReserve | |||
); | |||
</source> | |||
<b>Description</b> | |||
To read a file. | |||
<b>Parameters</b> | |||
= | <table class="wikitable"> | ||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>Offset [in]</td> | |||
<td>start position for writing</td> | |||
</tr> | |||
<tr> | |||
<td>Length [in]</td> | |||
<td>length of data</td> | |||
</tr> | |||
<tr> | |||
<td>Buffer [in]</td> | |||
<td>data to write</td> | |||
</tr> | |||
<tr> | |||
<td>lpReserve</td> | |||
<td>reserved for further usage</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
= | <table class="wikitable"> | ||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_ARGUMENTS_BAD</td> | |||
<td>Invalid argument</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_FS_OFFSET_INVALID</td> | |||
<td>Invalid start point for specified file</td> | |||
</tr> | |||
<tr> | |||
<td>UT_FS_NO_OPEN</td> | |||
<td>Cannot open file</td> | |||
</tr> | |||
<tr> | |||
<td>UT_FS_DATA_LEN_RANGE</td> | |||
<td>Out of range of data length<td> | |||
</tr> | |||
<tr> | |||
<td>UT_FS_NO_FILE</td> | |||
<td>No file found</td> | |||
</tr> | |||
</table> | |||
<b>Usage Note</b> | |||
To call the function, it is required that the current permission be higher than or at the same level with the one of writing the file. | |||
<b>Sample</b> | |||
== | <source lang="C"> | ||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
unsigned long Offset; | |||
unsigned char Buffer[200]; | |||
ret = UT_FS_ReadFile(utHandle, 0, 200, Buffer, NULL); | |||
</source> | |||
== | == UT_FS_CloseFile == | ||
<b>Prototype</b> | |||
<code>UT_RV UT_API UT_FS_CloseFile(UT_HANDLE utHandle, void* lpReserve);</code> | |||
<b>Description</b> | |||
To close a file. | |||
<b>Parameters</b> | |||
= | <table class="wikitable"> | ||
<tr> | |||
<th>PARAMETERS</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>utHandle [in]</td> | |||
<td>device handle</td> | |||
</tr> | |||
<tr> | |||
<td>lpReserve</td> | |||
<td>reserved for further usage</td> | |||
</tr> | |||
</table> | |||
<b>Returned Value</b> | |||
= | <table class="wikitable"> | ||
<tr> | |||
<th>RETURNED VALUE</th> | |||
<th>DESCRIPTION</th> | |||
</tr> | |||
<tr> | |||
<td>UT_OK</td> | |||
<td>Successful operation</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NOT_INITIALIZE</td> | |||
<td>Library not initialized</td> | |||
</tr> | |||
<tr> | |||
<td>UT_TOKEN_HANDLE_INVALID</td> | |||
<td>Invalid token handle</td> | |||
</tr> | |||
<tr> | |||
<td>UT_NO_PERMISSION</td> | |||
<td>No permission</td> | |||
</tr> | |||
<tr> | |||
<td>UT_FS_NO_OPEN</td> | |||
<td>Cannot open file</td> | |||
</tr> | |||
</table> | |||
<b>Usage Note</b> | |||
To call the function, it is required that the current permission be higher than or at the same level with the one of writing the file. | |||
<b>Sample</b> | |||
== UT_FS_CloseFile | <source lang="C"> | ||
UT_RV ret; | |||
UT_HANDLE utHandle; | |||
ret = UT_FS_CloseFile(utHandle, NULL); | |||
</source> | |||
Latest revision as of 16:35, 23 August 2016
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. This should be called before any other function, with the exception 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 retrieved from UT_GetTokenList instead manually entered. Therefore, this function cannot be called before UT_GetTokenList
Sample
See 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 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_INVALIDM | Invalid token handle |
Sample
See 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:
- Inserted, when UniToken is inserted into the slot;
- removed, when UniToken is removed from the slot;
- 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 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 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 the PIN.
Parameters
| PARAMETERS | DESCRIPTION |
|---|---|
| utHandle [in] | device handle |
| UserLevel [in] | permission level |
| ChangeMode [in] | mode to change to |
| OldPIN [in] | old PIN |
| NewPin [in] | new PIN |
Notes:
Change Mode can 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:
- 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 - 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_USERIn 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 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 |
| 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
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 the 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 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 number of failed login attempts.
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 bytes) |
| lpOut [out] | random number |
| lpReserve | reserved for future use |
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 keys 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] | plaintext |
| DataLength [in] | length of plaintext in bytes |
| lpEncryptedData [out] | ciphertext |
| lpEncryptedDataLength [out] | length of ciphertext |
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 [in] | ciphertext |
| EncryptedDataLength [in] | length of ciphertext in bytes |
| lpData [out] | plaintext |
| lpDataLength [out] | length of plaintext |
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 keys 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_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;
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 keys 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] | plaintext |
| DataLength [in] | length of plaintext |
| lpEncryptedData [out] | ciphertext |
| lpEncryptedDataLength [out] | length of ciphertext |
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] | ciphertext |
| EncryptedDataLength [in] | length of ciphertext |
| lpData [out] | plaintext |
| lpDataLength [out] | length of plaintext |
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 keys 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 [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_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 keys 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 | DESCRIPTION |
|---|---|
| utHandle [in] | device handle |
| KeyHandle [in] | key handle |
| lpData [in] | plaintext |
| DataLength [in] | length of plaintext |
| lpEncryptedData [out] | ciphertext |
| lpEncryptedDataLength [out] | length of ciphertext |
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(
HANDLE utHandle,
KEY_HANDLE KeyHandle,
unsigned char* lpEncryptedData,
unsigned 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] | ciphertext |
| EncryptedDataLength [in] | length of ciphertext |
| lpData [out] | plaintext |
| lpDataLength [out] | length of plaintext |
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(handle,
KeyHandle,
EncryptedData,
AES_DATA_LEN_16_BYTE,
Data,
&DataLength
);
UT_AESImportKey
Prototype
UT_RV UT_API UT_AESImportKey(
HANDLE 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 |
| 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 keys 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 |
| lpKeyHandle [out] | 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:
- UniToken device can store as many as 16 RSA key pairs
- ModulusBits can be
RSA_MODULUS_LEN_1024_BITorRSA_MODULUS_LEN_2048_BIT - 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 keys 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 |
| KeyHandle [in] | key handle |
| lpData [in] | plaintext |
| lpDataLength [in] | length of plaintext |
| lpEncryptedData [out] | ciphertext |
| EncryptedDataLength [out] | length of ciphertext |
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 retrieved with UT_RSAGetPubKeyByPriKey instead manually entered. 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 |
| KeyHandle [in] | key handle |
| lpEncryptedData [in] | ciphertext |
| EncryptedDataLength [in] | length of ciphertext |
| lpData [out] | plaintext |
| lpDataLength [out] | length of plaintext |
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 retrieved with 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 |
| KeyHandle [in] | key handle |
| lpData [in] | plaintext |
| lpDataLength [in] | length of plaintext |
| lpEncryptedData [out] | ciphertext |
| EncryptedDataLength [out] | length of ciphertext |
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 retrieved with UT_RSAGetPriKeyByPubKey instead manually entered. 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 |
| KeyHandle [in] | key handle |
| lpEncryptedData [in] | ciphertext |
| EncryptedDataLength [in] | length of ciphertext |
| lpData [out] | plaintext |
| lpDataLength [out] | length of plaintext |
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 retrieved with UT_RSAGetPubKeyByPriKey instead manually entered. 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 |
| 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 keys 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. The UniToken device can store up to 16 RSA key pairs; if there arere already 16 key pairs stored, calling this function will return UT_KEY_FULL
Sample
See 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 |
| 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 keys 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 keys 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 is <= 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 keys 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 will 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] | 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] | 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 |
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 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 |
| 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 keys 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 is <=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 keys 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 will 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-SHA1 algorithm.
Parameters
| PARAMETERS | DESCRIPTION |
|---|---|
| utHandle [in] | device handle |
| KeyHandle [in] | key handle |
| lpData [in] | data to be digested |
| DataLength [in] | data length |
| lpDigest [out] | 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] | 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_KEY_HANDLE_INVALID | Invalid key 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_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;
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 keys 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
Prototype
UT_RV UT_API UT_FS_GetSpace(
UT_HANDLE utHandle,
unsigned long* UsedSpace,
unsigned long* FreeSpace
);Description
To get the size of the free memory.
Parameters
| PARAMETERS | DESCRIPTION |
|---|---|
| UsedSize [out] | size of used memory |
| FreeSize [out] | size of free memory |
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 UsedSpace;
unsigned long FreeSpace;
ret = UT_FS_GetSpace(utHandle, &UsedSpace, &FreeSpace);UT_FS_GetFileCount
Prototype
UT_RV UT_API UT_FS_GetFileCount(UT_HANDLE utHandle, unsigned long* lpFileCount);
Description
To get the number of files.
Parameters
| PARAMETERS | DESCRIPTION |
|---|---|
| utHandle [in] | device handle |
| lpFileCount [out] | the number of files |
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_FS_NO_FILE | No file found |
Sample
UT_RV ret;
UT_HANDLE utHandle;
unsigned long FileCount;
ret = UT_FS_GetFileCount(utHandle, &FileCount);UT_FS_GetFirstFileName
Prototype
UT_RV UT_API UT_FS_GetFirstFileName(UT_HANDLE utHandle, char* lpszFileName);
Description
To get the name of the first file.
Parameters
| PARAMETERS | DESCRIPTION |
|---|---|
| utHandle [in] | device handle |
| lpszFileName [out] | filename (string, 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_FS_NO_FILE | No file found |
Sample
See also the sample of UT_GetNextFileName
UT_FS_GetNextFileName
Prototype
UT_RV UT_API UT_FS_GetNextFileName(UT_HANDLE utHandle, char* lpszFileName);
Description To get the name of the next file.
Parameters
| PARAMETERS | DESCRIPTION |
|---|---|
| utHandle [in] | device handle |
| lpszFileName [out] | filename (string, 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_FS_LIST_END | End of fire list |
| UT_OPERATE_INVALID | Invalid operation |
Sample
UT_RV ret;
UT_HANDLE utHandle;
char FileName[17];
ret = UT_FS_GetFirstFileName(utHandle, FileName);
ret = UT_FS_GetNextFileName(utHandle, FileName);UT_FS_GetFileSize
Prototype
UT_RV UT_API UT_FS_GetFileSize(
UT_HANDLE utHandle,
char* lpszFileName,
unsigned long* lpFileSize
);Description
To get the file size.
Parameters
| PARAMETERS | DESCRIPTION |
|---|---|
| utHandle [in] | device handle |
| lpszFileName [in] | filename (string, 16 bytes) |
| lpFileSize [out] | size of file |
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_FS_NAME_LEN_RANGE | Filename too long |
| UT_FS_NO_FILE | No file found |
Sample
UT_RV ret;
UT_HANDLE utHandle;
char FileName[17];
unsigned long FileSize;
ret = UT_FS_GetFileSize(utHandle, FileName, &FileSize);UT_FS_GetFilePermission
Prototype
UT_RV UT_API UT_FS_GetFilePermission(
UT_HANDLE utHandle,
char* lpszFileName,
unsigned char* lpFilePermission
);Description
To get the file permission of the specified file.
Parameters
| PARAMETERS | DESCRIPTION |
|---|---|
| utHandle [in] | device handle |
| lpszFileName [in] | filename (string, 16 bytes) |
| lpFilePermission [out] | file permission |
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_FS_NAME_LEN_RANGE | Filename too long |
| UT_FS_NO_FILE | No file found |
Sample
UT_RV ret;
UT_HANDLE utHandle;
char FileName[17];
unsigned char FilePermission;
ret = UT_FS_GetFilePermission(utHandle, FileName, &FilePermission);UT_FS_CreatFile
Prototype
UT_RV UT_API UT_FS_CreateFile(
UT_HANDLE utHandle,
char* lpszFileName,
unsigned long FileSize,
unsigned char FilePermission
);Description
To create a file.
Parameters
| PARAMETERS | DESCRIPTION |
|---|---|
| utHandle [in] | device handle |
| lpszFileName [in] | filename (string, 16 bytes) |
| FileSize [in] | size of file |
| FilePermission [in] | file permission |
Notes:
- The max. File size is 262112 bytes;
- FilePermission can be FILE_PERMISSION_GUEST, FILE_PERMISSION_USER or FILE_PERMISSION_ADMIN.
Returned Value
| RETURNED VALUE | DESCRIPTION |
|---|---|
| UT_OK | Successful operation |
| UT_NOT_INITIALIZE | Library not initialized |
| UT_ARGUMENTS_BAD | Invalid argument |
| UT_NO_PERMISSION | No permission |
| UT_TOKEN_HANDLE_INVALID | Invalid token handle |
| UT_FS_NAME_LEN_RANGE | Filename too long |
| UT_FS_FILE_EXIST | The file already exists |
Usage Note File permission types:
- FILE_PERMISSION_GUEST: With GUEST and higher permissions, reading the file is allowed; With USER and higher permissions, writing file is allowed.
- FILE_PERMISSION_USER: With USER and higher permissions, reading and writing file are allowed.
- FILE_PERMISSION_ADMIN: Only ADMIN is allowed to read and write the file.
Sample
UT_RV ret;
UT_HANDLE utHandle;
char FileName[17];
ret = UT_FS_CreateFile(utHandle, FileName, 200, FILE_PERMISSION_GUEST);UT_FS_DeleteFile
Prototype
UT_RV UT_API UT_FS_DeleteFile(UT_HANDLE utHandle, char* lpszFileName);
Description
To delete a file.
Parameters
| PARAMETERS | DESCRIPTION |
|---|---|
| utHandle [in] | device handle |
| lpszFileName [in] | filename (string, 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_FS_NAME_LEN_RANGE | Filename too long |
| UT_FS_NO_FILE | No file found |
Usage Note
To call the function, it is required that the current permission be higher than or at the same level with the one of writing the file.
Sample
UT_RV ret;
UT_HANDLE utHandle;
char FileName[17];
ret = UT_FS_DeleteFile(utHandle, FileName);UT_FS_OpenFile
Prototype
UT_RV UT_API UT_FS_OpenFile(
UT_HANDLE utHandle,
char* lpszFileName,
void* lpReserve
);Description
To open a file.
Parameters
| PARAMETERS | DESCRIPTION | |
|---|---|---|
| utHandle [in] | device handle | |
| lpszFileName [in] | filename (string, 16 bytes) | |
| lpReserve | reserved for further 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 |
| UT_NO_PERMISSION | No permission |
| UT_FS_NAME_LEN_RANGE | Filename too long |
| UT_FS_NO_FILE | No file found |
Usage Note
To call the function, it is required that the current permission be higher than or at the same level with the one of writing the file. Files can be read and written only when opened.
Sample
UT_RV ret;
UT_HANDLE utHandle;
char FileName[17];
ret = UT_FS_OpenFile(utHandle, FileName, NULL);UT_FS_WriteFile
Prototype
UT_RV UT_API UT_FS_WriteFile(
UT_HANDLE utHandle,
unsigned long Offset,
unsigned long Length,
unsigned char* Buffer,
void* lpReserve
);Description
To write or modify a file.
Parameters
| PARAMETERS | DESCRIPTION |
|---|---|
| utHandle [in] | device handle |
| Offset [in] | start position for writing |
| Length [in] | length of data |
| Buffer [in] | data to write |
| lpReserve | reserved for further 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 |
| UT_NO_PERMISSION | No permission |
| UT_FS_OFFSET_INVALID | Invalid start point for specified file |
| UT_FS_NO_OPEN | Cannot open file |
| UT_FS_NOSPACE | No room in file system |
| UT_FS_NO_FILE | No file found |
Usage Note
To call the function, it is required that the current permission be higher than or at the same level with the one of writing the file. New function of appending is added.
Sample
UT_RV ret;
UT_HANDLE utHandle;
unsigned long Offset;
unsigned char Buffer[200];
ret = UT_FS_WriteFile(utHandle, 0, 200, Buffer, NULL);UT_FS_ReadFile
Prototype
UT_RV UT_API UT_FS_ReadFile(
UT_HANDLE utHandle,
unsigned long Offset,
unsigned long Length,
unsigned char* Buffer,
void* lpReserve
);Description
To read a file.
Parameters
| PARAMETERS | DESCRIPTION |
|---|---|
| utHandle [in] | device handle |
| Offset [in] | start position for writing |
| Length [in] | length of data |
| Buffer [in] | data to write |
| lpReserve | reserved for further 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 | |
| UT_NO_PERMISSION | No permission | |
| UT_FS_OFFSET_INVALID | Invalid start point for specified file | |
| UT_FS_NO_OPEN | Cannot open file | |
| UT_FS_DATA_LEN_RANGE | Out of range of data length | |
| UT_FS_NO_FILE | No file found |
Usage Note
To call the function, it is required that the current permission be higher than or at the same level with the one of writing the file.
Sample
UT_RV ret;
UT_HANDLE utHandle;
unsigned long Offset;
unsigned char Buffer[200];
ret = UT_FS_ReadFile(utHandle, 0, 200, Buffer, NULL);UT_FS_CloseFile
Prototype
UT_RV UT_API UT_FS_CloseFile(UT_HANDLE utHandle, void* lpReserve);
Description
To close a file.
Parameters
| PARAMETERS | DESCRIPTION |
|---|---|
| utHandle [in] | device handle |
| lpReserve | reserved for further usage |
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_FS_NO_OPEN | Cannot open file |
Usage Note
To call the function, it is required that the current permission be higher than or at the same level with the one of writing the file.
Sample
UT_RV ret;
UT_HANDLE utHandle;
ret = UT_FS_CloseFile(utHandle, NULL);