UniToken API Usage: Difference between revisions

From SecuTech Wiki
Jump to navigationJump to search
Joseph (talk | contribs)
No edit summary
Bao (talk | contribs)
mNo edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
[[category:UniToken_APIs]]
[[category:UniToken_API]]


<p>UniToken provides a set of UniToken APIs to manage the secure file system for general usage, apart from PKI applications. Please install the UniToken API package or the UniToken full package to enable features.</p>
UniToken provides a set of UniToken APIs to manage the secure file system for general usage, apart from PKI applications. Please install the UniToken API package or the UniToken full package to enable features.
<p>The UniToken API package installs UniToken.dll for general UniToken API implementation and UniTokenAx.dll for ActiveX usage.
The UniToken API package installs UniToken.dll for general UniToken API implementation and UniTokenAx.dll for ActiveX usage.
</p>
 
<h2> API Usage </h2>
==API Usage==
<p>Initialize the library to release resources by calling UT_Initialize and UT_Finalize. UT_Initialize needs to be called before using the library and UT_Finalize needs to be called by end of the operation. Both functions need to be called only once.<br /> Calling UT_GetTokenList and UT_OpenDevice will get device and open it to obtain the device handle. Get all the slots having devices by calling UT_GetTokenList. Open the device of the specified slot to obtain the device handle.<br /> Start operating the device.  
Initialize the library to release resources by calling UT_Initialize and UT_Finalize. UT_Initialize needs to be called before using the library and UT_Finalize needs to be called by end of the operation. Both functions need to be called only once. Calling UT_GetTokenList and UT_OpenDevice will get device and open it to obtain the device handle. Get all the slots having devices by calling UT_GetTokenList. Open the device of the specified slot to obtain the device handle. Start operating the device.
</p>
 
<h2> Prototype Specification </h2>
==Prototype Specification==
<h4> UT_HANDLE </h4>
 
<p>UT_HANDLE is specified by UniToken library and used for detecting devices. It is defined as follows: <br /><br />
===UT_HANDLE===
</p><p>typedef unsigned long UT_HANDLE;  
UT_HANDLE is specified by UniToken library and used for detecting devices. It is defined as follows:
</p>
 
<h4> KEY_HANDLE, KEY_HANDLE_PTR </h4>
<code>typedef unsigned long UT_HANDLE;</code>
<p>KEY_HANDLE is specified by UniToken library and used for detecting keys. It is defined as follows: <br /><br />
 
</p><p>typedef unsigned long KEY_HANDLE; KEY_HANDLE_PTR is the pointer of KEY_HANDLE.  
; KEY_HANDLE, KEY_HANDLE_PTR
</p>
: KEY_HANDLE is specified by UniToken library and used for detecting keys. It is defined as follows:
<h4> UT_RV </h4>
 
<p>UT_RV is specified by UniToken library and used for identifying the return value of library. It is defined as follows: <br /><br />
<code>typedef unsigned long KEY_HANDLE;</code>
</p><p>typedef unsigned long UT_RV;  
 
</p>
KEY_HANDLE_PTR is the pointer of KEY_HANDLE.
<h4> UT_SLOT_ID </h4>
 
<p>UT_SLOT_ID is specified by UniToken library and used for identifying slots. It is defined as follows: <br /><br />
===UT_RV===
</p><p>typedef unsigned long UT_SLOT_ID;  
UT_RV is specified by UniToken library and used for identifying the return value of library. It is defined as follows:
</p>
 
<h4> UT_STATUS </h4>
<code>typedef unsigned long UT_RV;</code>
<p>UT_STATUS is specified by UniToken library and used for identifying the status of slot. It is defined as follows:<br /><br />
 
</p><p>typedef unsigned long UT_STATUS; <br /><br />  
===UT_SLOT_ID===
</p><p>We defined some values for this UniToken library version.<br /><br />
UT_SLOT_ID is specified by UniToken library and used for identifying slots. It is defined as follows:
</p>
 
<ol><li>define TOKEN_NO_EVENT 0 <br />
<code>typedef unsigned long UT_SLOT_ID;</code>
</li><li>define TOKEN_INSERT 1 <br />
 
</li><li>define TOKEN_REMOVE 2 <br />
===UT_STATUS===
</li></ol>
UT_STATUS is specified by UniToken library and used for identifying the status of slot. It is defined as follows:
<h2> About Macro </h2>
 
<h4> Size </h4>
<code>typedef unsigned long UT_STATUS;</code>
<ol><li>define UT_MAX_PIN_LEN 128 <br />
 
</li><li>define UT_MAX_ID_LEN 32 <br />
We defined some values for this UniToken library version.
</li><li>define MAX_SLOT_NUMBER 32 <br />
 
</li><li>define FS_MEMORY (256*1024) <br />
* define TOKEN_NO_EVENT 0
</li></ol>
* define TOKEN_INSERT 1
<p>Parameter Meaning <br /> UT_MAX_PIN_LEN the maximum password length <br /> UT_MAX_ID_LEN the maximum UniToken ID length <br /> MAX_SLOT_NUMBER the maximum volume of slot <br /> FS_MEMORY the maximum capacity of file system<br />
* define TOKEN_REMOVE 2
</p>
 
<h4> Password </h4>
==About Macro==
<ol><li>define UT_DEFAULT_SO "admin" <br />
 
</li><li>define UT_DEFAULT_USER "user" <br />
===Size===
</li></ol>
* define UT_MAX_PIN_LEN 128
<p>Parameter Meaning <br /> UT_DEFAULT_SO the admin default password of UniToken <br /> T_DEFAULT_USER the user default password of UniToken <br />
* define UT_MAX_ID_LEN 32
</p>
* define MAX_SLOT_NUMBER 32
<h4> Slot Status </h4>
* define FS_MEMORY (256*1024)
<ol><li>define TOKEN_NO_EVENT 0 <br />
 
</li><li>define TOKEN_INSERT 1 <br />
; Parameter Meaning
</li><li>define TOKEN_REMOVE 2 <br />
* UT_MAX_PIN_LEN the maximum password length
</li></ol>
* UT_MAX_ID_LEN the maximum UniToken ID length
<p>Parameter Meaning <br /> TOKEN_NO_EVENT No slot status has changed <br /> TOKEN_INSERT A device is inserted in a slot <br /> TOKEN_REMOVE The device in the slot is removed <br />
* MAX_SLOT_NUMBER the maximum volume of slot
</p>
* FS_MEMORY the maximum capacity of file system
<h4> User Level </h4>
 
<ol><li>define UT_USER_LEVEL_GUEST 0x0 <br />
===Password===
</li><li>define UT_USER_LEVEL_USER 0x1 <br />
* define UT_DEFAULT_SO "admin"
</li><li>define UT_USER_LEVEL_ADMIN 0x2 <br />
* define UT_DEFAULT_USER "user"
</li></ol>
 
<p>Parameter Meaning <br /> UT_USER_LEVEL_GUEST GUEST Level <br /> UT_USER_LEVEL_USER USER Level <br /> UT_USER_LEVEL_ADMIN ADMIN ADMIN Level <br />
; Parameter Meaning
</p>
* UT_DEFAULT_SO the admin default password of UniToken
<h4> Modes of Changing Passwords </h4>
* T_DEFAULT_USER the user default password of UniToken
<ol><li>define UT_CHANGE_PIN_MODE_BYSELF 0x1 <br />
 
</li><li>define UT_CHANGE_PIN_MODE_ADMIN_CHANGE_USER 0x2 <br />
===Slot Status===
</li></ol>
* define TOKEN_NO_EVENT 0
<p>Parameter Meaning <br /> UT_CHANGE_PIN_MODE_BYSELF Current user changes his password <br /> UT_CHANGE_PIN_MODE_ADMIN_CHANGE_USER Changing user password requires admin permission<br />
* define TOKEN_INSERT 1
</p>
* define TOKEN_REMOVE 2
<h4> LED On-off </h4>
 
<ol><li>define LED_ON 1 <br />
; Parameter Meaning
</li><li>define LED_OFF 0 <br />
* TOKEN_NO_EVENT No slot status has changed
</li></ol>
* TOKEN_INSERT A device is inserted in a slot
<p>Parameter Meaning <br /> LED_ON turn on LED <br /> LED_OFF turn off LED <br />
* TOKEN_REMOVE The device in the slot is removed
</p>
 
<h4> DES Key Length </h4>
===User Level===
<ol><li>define DES_KEY_LEN_8_BYTE 8 <br />
* define UT_USER_LEVEL_GUEST 0x0
</li><li>define DES3_KEY_LEN_24_BYTE 24 <br />
* define UT_USER_LEVEL_USER 0x1
</li></ol>
* define UT_USER_LEVEL_ADMIN 0x2
<p>Parameter Meaning <br /> DES_KEY_LEN_8_BYTE DES key length <br /> DES3_KEY_LEN_24_BYTE DES3 key length <br />
 
</p>
; Parameter Meaning
<h4> DES Data Length </h4>
* UT_USER_LEVEL_GUEST GUEST Level
<ol><li>define DES_DATA_LEN_8_BYTE 8 <br />
* UT_USER_LEVEL_USER USER Level
</li></ol>
* UT_USER_LEVEL_ADMIN ADMIN ADMIN Level
<p>Parameter Meaning <br /> DES_DATA_LEN_8_BYTE BYTE DES en/decrypt data length <br />
 
</p>
===Modes of Changing Passwords===
<h4> AES Key Length </h4>
* define UT_CHANGE_PIN_MODE_BYSELF 0x1
<ol><li>define AES_KEY_LEN_128_BIT 16 <br />
* define UT_CHANGE_PIN_MODE_ADMIN_CHANGE_USER 0x2
</li><li>define AES_KEY_LEN_192_BIT 24 <br />
 
</li></ol>
; Parameter Meaning
<p>Parameter Meaning <br /> AES_KEY_LEN_128_BIT default key length <br /> AES_KEY_LEN_192_BIT maximum key length <br />
* UT_CHANGE_PIN_MODE_BYSELF Current user changes his password
</p>
* UT_CHANGE_PIN_MODE_ADMIN_CHANGE_USER Changing user password requires admin permission
<h4> AES Data Length </h4>
 
<ol><li>define AES_DATA_LEN_16_BYTE 16 <br />
===LED On-off===
</li></ol>
* define LED_ON 1
<p>Parameter Meaning <br /> AES_DATA_LEN_16_BYTE AES en/decrypt data length<br />
* define LED_OFF 0
</p>
 
<h4> RSA Modulus Length </h4>
; Parameter Meaning
<ol><li>define RSA_MODULUS_LEN_1024_BIT 128 <br />
* LED_ON turn on LED
</li><li>define RSA_MODULUS_LEN_2048_BIT 256 <br />
* LED_OFF turn off LED
</li></ol>
 
<p>Parameter Meaning <br /> RSA_MODULUS_LEN_1024_BIT default modulus length <br /> RSA_MODULUS_LEN_2048_BIT Maximum modulus length <br />
===DES Key Length===
</p>
* define DES_KEY_LEN_8_BYTE 8
<h4> RSA Public Exponent </h4>
* define DES3_KEY_LEN_24_BYTE 24
<ol><li>define RSA_PUBEXP_LEN_65537_BIT 65537 <br />
 
</li></ol>
; Parameter Meaning
<p>Parameter Meaning <br /> RSA_PUBEXP_LEN_65537_BIT RSA public exponent <br />
* DES_KEY_LEN_8_BYTE DES key length
</p>
* DES3_KEY_LEN_24_BYTE DES3 key length
<h4> RSA Data Length </h4>
 
<ol><li>define RSA_DATA_LEN_1024_BIT 128 <br />
===DES Data Length===
</li><li>define RSA_DATA_LEN_2048_BIT 256 <br />
* define DES_DATA_LEN_8_BYTE 8
</li></ol>
 
<p>Parameter Meaning <br /> RSA_DATA_LEN_1024_BIT default data length <br /> RSA_DATA_LEN_2048_BIT maximum data length <br />
; Parameter Meaning
</p>
* DES_DATA_LEN_8_BYTE BYTE DES en/decrypt data length
<h4> RSA Import New Key Pair </h4>
 
<ol><li>define RSA_IMPORT_NEW 0 <br />
===AES Key Length===
</li></ol>
* define AES_KEY_LEN_128_BIT 16
<p>Parameter Meaning <br /> RSA_IMPORT_NEW newly imported key pair <br />
* define AES_KEY_LEN_192_BIT 24
</p>
 
<h4> File Name Length </h4>
; Parameter Meaning
<ol><li>define UT_FILE_NAME_LENGTH 16 <br />
* AES_KEY_LEN_128_BIT default key length
</li></ol>
* AES_KEY_LEN_192_BIT maximum key length
<p>Parameter Meaning <br /> UT_FILE_NAME_LENGTH file name maximum length not including string terminator<br />
 
</p>
===AES Data Length===
<h4> File Permission </h4>
* define AES_DATA_LEN_16_BYTE 16
<ol><li>define FILE_PERMISSION_GUEST 0x0 <br />
 
</li><li>define FILE_PERMISSION_USER 0x1 <br />
; Parameter Meaning
</li><li>define FILE_PERMISSION_ADMIN 0x2 <br />
* AES_DATA_LEN_16_BYTE AES en/decrypt data length
</li></ol>
 
<p>Parameter Meaning <br /> FILE_PERMISSION_GUEST GUEST permission file <br /> FILE_PERMISSION_USER USER permission file <br /> FILE_PERMISSION_ADMIN ADMIN permission file <br />
===RSA Modulus Length===
* define RSA_MODULUS_LEN_1024_BIT 128
* define RSA_MODULUS_LEN_2048_BIT 256
 
; Parameter Meaning
* RSA_MODULUS_LEN_1024_BIT default modulus length
* RSA_MODULUS_LEN_2048_BIT Maximum modulus length
 
===RSA Public Exponent===
* define RSA_PUBEXP_LEN_65537_BIT 65537
 
; Parameter Meaning
* RSA_PUBEXP_LEN_65537_BIT RSA public exponent
 
===RSA Data Length===
* define RSA_DATA_LEN_1024_BIT 128
* define RSA_DATA_LEN_2048_BIT 256
 
; Parameter Meaning
* RSA_DATA_LEN_1024_BIT default data length
* RSA_DATA_LEN_2048_BIT maximum data length
 
===RSA Import New Key Pair===
* define RSA_IMPORT_NEW 0
 
; Parameter Meaning
* RSA_IMPORT_NEW newly imported key pair
 
===File Name Length===
* define UT_FILE_NAME_LENGTH 16
 
; Parameter Meaning
* UT_FILE_NAME_LENGTH file name maximum length not including string terminator
 
===File Permission===
* define FILE_PERMISSION_GUEST 0x0
* define FILE_PERMISSION_USER 0x1
* define FILE_PERMISSION_ADMIN 0x2
 
; Parameter Meaning
* FILE_PERMISSION_GUEST GUEST permission file
* FILE_PERMISSION_USER USER permission file
* FILE_PERMISSION_ADMIN ADMIN permission file

Latest revision as of 16:36, 17 August 2016


UniToken provides a set of UniToken APIs to manage the secure file system for general usage, apart from PKI applications. Please install the UniToken API package or the UniToken full package to enable features. The UniToken API package installs UniToken.dll for general UniToken API implementation and UniTokenAx.dll for ActiveX usage.

API Usage

Initialize the library to release resources by calling UT_Initialize and UT_Finalize. UT_Initialize needs to be called before using the library and UT_Finalize needs to be called by end of the operation. Both functions need to be called only once. Calling UT_GetTokenList and UT_OpenDevice will get device and open it to obtain the device handle. Get all the slots having devices by calling UT_GetTokenList. Open the device of the specified slot to obtain the device handle. Start operating the device.

Prototype Specification

UT_HANDLE

UT_HANDLE is specified by UniToken library and used for detecting devices. It is defined as follows:

typedef unsigned long UT_HANDLE;

KEY_HANDLE, KEY_HANDLE_PTR
KEY_HANDLE is specified by UniToken library and used for detecting keys. It is defined as follows:

typedef unsigned long KEY_HANDLE;

KEY_HANDLE_PTR is the pointer of KEY_HANDLE.

UT_RV

UT_RV is specified by UniToken library and used for identifying the return value of library. It is defined as follows:

typedef unsigned long UT_RV;

UT_SLOT_ID

UT_SLOT_ID is specified by UniToken library and used for identifying slots. It is defined as follows:

typedef unsigned long UT_SLOT_ID;

UT_STATUS

UT_STATUS is specified by UniToken library and used for identifying the status of slot. It is defined as follows:

typedef unsigned long UT_STATUS;

We defined some values for this UniToken library version.

  • define TOKEN_NO_EVENT 0
  • define TOKEN_INSERT 1
  • define TOKEN_REMOVE 2

About Macro

Size

  • define UT_MAX_PIN_LEN 128
  • define UT_MAX_ID_LEN 32
  • define MAX_SLOT_NUMBER 32
  • define FS_MEMORY (256*1024)
Parameter Meaning
  • UT_MAX_PIN_LEN the maximum password length
  • UT_MAX_ID_LEN the maximum UniToken ID length
  • MAX_SLOT_NUMBER the maximum volume of slot
  • FS_MEMORY the maximum capacity of file system

Password

  • define UT_DEFAULT_SO "admin"
  • define UT_DEFAULT_USER "user"
Parameter Meaning
  • UT_DEFAULT_SO the admin default password of UniToken
  • T_DEFAULT_USER the user default password of UniToken

Slot Status

  • define TOKEN_NO_EVENT 0
  • define TOKEN_INSERT 1
  • define TOKEN_REMOVE 2
Parameter Meaning
  • TOKEN_NO_EVENT No slot status has changed
  • TOKEN_INSERT A device is inserted in a slot
  • TOKEN_REMOVE The device in the slot is removed

User Level

  • define UT_USER_LEVEL_GUEST 0x0
  • define UT_USER_LEVEL_USER 0x1
  • define UT_USER_LEVEL_ADMIN 0x2
Parameter Meaning
  • UT_USER_LEVEL_GUEST GUEST Level
  • UT_USER_LEVEL_USER USER Level
  • UT_USER_LEVEL_ADMIN ADMIN ADMIN Level

Modes of Changing Passwords

  • define UT_CHANGE_PIN_MODE_BYSELF 0x1
  • define UT_CHANGE_PIN_MODE_ADMIN_CHANGE_USER 0x2
Parameter Meaning
  • UT_CHANGE_PIN_MODE_BYSELF Current user changes his password
  • UT_CHANGE_PIN_MODE_ADMIN_CHANGE_USER Changing user password requires admin permission

LED On-off

  • define LED_ON 1
  • define LED_OFF 0
Parameter Meaning
  • LED_ON turn on LED
  • LED_OFF turn off LED

DES Key Length

  • define DES_KEY_LEN_8_BYTE 8
  • define DES3_KEY_LEN_24_BYTE 24
Parameter Meaning
  • DES_KEY_LEN_8_BYTE DES key length
  • DES3_KEY_LEN_24_BYTE DES3 key length

DES Data Length

  • define DES_DATA_LEN_8_BYTE 8
Parameter Meaning
  • DES_DATA_LEN_8_BYTE BYTE DES en/decrypt data length

AES Key Length

  • define AES_KEY_LEN_128_BIT 16
  • define AES_KEY_LEN_192_BIT 24
Parameter Meaning
  • AES_KEY_LEN_128_BIT default key length
  • AES_KEY_LEN_192_BIT maximum key length

AES Data Length

  • define AES_DATA_LEN_16_BYTE 16
Parameter Meaning
  • AES_DATA_LEN_16_BYTE AES en/decrypt data length

RSA Modulus Length

  • define RSA_MODULUS_LEN_1024_BIT 128
  • define RSA_MODULUS_LEN_2048_BIT 256
Parameter Meaning
  • RSA_MODULUS_LEN_1024_BIT default modulus length
  • RSA_MODULUS_LEN_2048_BIT Maximum modulus length

RSA Public Exponent

  • define RSA_PUBEXP_LEN_65537_BIT 65537
Parameter Meaning
  • RSA_PUBEXP_LEN_65537_BIT RSA public exponent

RSA Data Length

  • define RSA_DATA_LEN_1024_BIT 128
  • define RSA_DATA_LEN_2048_BIT 256
Parameter Meaning
  • RSA_DATA_LEN_1024_BIT default data length
  • RSA_DATA_LEN_2048_BIT maximum data length

RSA Import New Key Pair

  • define RSA_IMPORT_NEW 0
Parameter Meaning
  • RSA_IMPORT_NEW newly imported key pair

File Name Length

  • define UT_FILE_NAME_LENGTH 16
Parameter Meaning
  • UT_FILE_NAME_LENGTH file name maximum length not including string terminator

File Permission

  • define FILE_PERMISSION_GUEST 0x0
  • define FILE_PERMISSION_USER 0x1
  • define FILE_PERMISSION_ADMIN 0x2
Parameter Meaning
  • FILE_PERMISSION_GUEST GUEST permission file
  • FILE_PERMISSION_USER USER permission file
  • FILE_PERMISSION_ADMIN ADMIN permission file