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
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
<p><br /> 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.<br /><br />
[[category:UniToken_API]]
</p><p>The UniToken API package installs UniToken.dll for general UniToken API implementation and UniTokenAx.dll for ActiveX usage.<br /><br />
 
</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.
<h2> API Usage </h2>
The UniToken API package installs UniToken.dll for general UniToken API implementation and UniTokenAx.dll for ActiveX 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.  
 
</p>
==API Usage==
<h2> Prototype Specification </h2>
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.
<h4> UT_HANDLE </h4>
 
<p>UT_HANDLE is specified by UniToken library and used for detecting devices. It is defined as follows: <br /><br />
==Prototype Specification==
</p><p>typedef unsigned long UT_HANDLE;  
 
</p>
===UT_HANDLE===
<h4> KEY_HANDLE, KEY_HANDLE_PTR </h4>
UT_HANDLE is specified by UniToken library and used for detecting devices. It is defined as follows:
<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.  
<code>typedef unsigned long UT_HANDLE;</code>
</p>
 
<h4> UT_RV </h4>
; KEY_HANDLE, KEY_HANDLE_PTR
<p>UT_RV is specified by UniToken library and used for identifying the return value of library. It is defined as follows: <br /><br />
: KEY_HANDLE is specified by UniToken library and used for detecting keys. It is defined as follows:
</p><p>typedef unsigned long UT_RV;  
 
</p>
<code>typedef unsigned long KEY_HANDLE;</code>
<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 />
KEY_HANDLE_PTR is the pointer of KEY_HANDLE.
</p><p>typedef unsigned long UT_SLOT_ID;  
 
</p>
===UT_RV===
<h4> UT_STATUS </h4>
UT_RV is specified by UniToken library and used for identifying the return value of library. It is defined as follows:
<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 />  
<code>typedef unsigned long UT_RV;</code>
</p><p>We defined some values for this UniToken library version.<br /><br />
 
</p>
===UT_SLOT_ID===
<ol><li>define TOKEN_NO_EVENT 0 <br />
UT_SLOT_ID is specified by UniToken library and used for identifying slots. It is defined as follows:
</li><li>define TOKEN_INSERT 1 <br />
 
</li><li>define TOKEN_REMOVE 2 <br />
<code>typedef unsigned long UT_SLOT_ID;</code>
</li></ol>
 
<h2> About Macro </h2>
===UT_STATUS===
<h4> Size </h4>
UT_STATUS is specified by UniToken library and used for identifying the status of slot. It is defined as follows:
<ol><li>define UT_MAX_PIN_LEN 128 <br />
 
</li><li>define UT_MAX_ID_LEN 32 <br />
<code>typedef unsigned long UT_STATUS;</code>
</li><li>define MAX_SLOT_NUMBER 32 <br />
 
</li><li>define FS_MEMORY (256*1024) <br />
We defined some values for this UniToken library version.
</li></ol>
 
<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_NO_EVENT 0
</p>
* define TOKEN_INSERT 1
<h4> Password </h4>
* define TOKEN_REMOVE 2
<ol><li>define UT_DEFAULT_SO "admin" <br />
 
</li><li>define UT_DEFAULT_USER "user" <br />
==About Macro==
</li></ol>
 
<p>Parameter Meaning <br /> UT_DEFAULT_SO the admin default password of UniToken <br /> T_DEFAULT_USER the user default password of UniToken <br />
===Size===
</p>
* define UT_MAX_PIN_LEN 128
<h4> Slot Status </h4>
* define UT_MAX_ID_LEN 32
<ol><li>define TOKEN_NO_EVENT 0 <br />
* define MAX_SLOT_NUMBER 32
</li><li>define TOKEN_INSERT 1 <br />
* define FS_MEMORY (256*1024)
</li><li>define TOKEN_REMOVE 2 <br />
 
</li></ol>
; Parameter Meaning
<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 />
* UT_MAX_PIN_LEN the maximum password length
</p>
* UT_MAX_ID_LEN the maximum UniToken ID length
<h4> User Level </h4>
* MAX_SLOT_NUMBER the maximum volume of slot
<ol><li>define UT_USER_LEVEL_GUEST 0x0 <br />
* FS_MEMORY the maximum capacity of file system
</li><li>define UT_USER_LEVEL_USER 0x1 <br />
 
</li><li>define UT_USER_LEVEL_ADMIN 0x2 <br />
===Password===
</li></ol>
* define UT_DEFAULT_SO "admin"
<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 />
* define UT_DEFAULT_USER "user"
</p>
 
<h4> Modes of Changing Passwords </h4>
; Parameter Meaning
<ol><li>define UT_CHANGE_PIN_MODE_BYSELF 0x1 <br />
* UT_DEFAULT_SO the admin default password of UniToken
</li><li>define UT_CHANGE_PIN_MODE_ADMIN_CHANGE_USER 0x2 <br />
* T_DEFAULT_USER the user default password of UniToken
</li></ol>
 
<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 />
===Slot Status===
</p>
* define TOKEN_NO_EVENT 0
<h4> LED On-off </h4>
* define TOKEN_INSERT 1
<ol><li>define LED_ON 1 <br />
* define TOKEN_REMOVE 2
</li><li>define LED_OFF 0 <br />
 
</li></ol>
; Parameter Meaning
<p>Parameter Meaning <br /> LED_ON turn on LED <br /> LED_OFF turn off LED <br />
* TOKEN_NO_EVENT No slot status has changed
</p>
* TOKEN_INSERT A device is inserted in a slot
<h4> DES Key Length </h4>
* TOKEN_REMOVE The device in the slot is removed
<ol><li>define DES_KEY_LEN_8_BYTE 8 <br />
 
</li><li>define DES3_KEY_LEN_24_BYTE 24 <br />
===User Level===
</li></ol>
* define UT_USER_LEVEL_GUEST 0x0
<p>Parameter Meaning <br /> DES_KEY_LEN_8_BYTE DES key length <br /> DES3_KEY_LEN_24_BYTE DES3 key length <br />
* define UT_USER_LEVEL_USER 0x1
</p>
* define UT_USER_LEVEL_ADMIN 0x2
<h4> DES Data Length </h4>
 
<ol><li>define DES_DATA_LEN_8_BYTE 8 <br />
; Parameter Meaning
</li></ol>
* UT_USER_LEVEL_GUEST GUEST Level
<p>Parameter Meaning <br /> DES_DATA_LEN_8_BYTE BYTE DES en/decrypt data length <br />
* UT_USER_LEVEL_USER USER Level
</p>
* UT_USER_LEVEL_ADMIN ADMIN ADMIN Level
<h4> AES Key Length </h4>
 
<ol><li>define AES_KEY_LEN_128_BIT 16 <br />
===Modes of Changing Passwords===
</li><li>define AES_KEY_LEN_192_BIT 24 <br />
* define UT_CHANGE_PIN_MODE_BYSELF 0x1
</li></ol>
* define UT_CHANGE_PIN_MODE_ADMIN_CHANGE_USER 0x2
<p>Parameter Meaning <br /> AES_KEY_LEN_128_BIT default key length <br /> AES_KEY_LEN_192_BIT maximum key length <br />
 
</p>
; Parameter Meaning
<h4> AES Data Length </h4>
* UT_CHANGE_PIN_MODE_BYSELF Current user changes his password
<ol><li>define AES_DATA_LEN_16_BYTE 16 <br />
* UT_CHANGE_PIN_MODE_ADMIN_CHANGE_USER Changing user password requires admin permission
</li></ol>
 
<p>Parameter Meaning <br /> AES_DATA_LEN_16_BYTE AES en/decrypt data length<br />
===LED On-off===
</p>
* define LED_ON 1
<h4> RSA Modulus Length </h4>
* define LED_OFF 0
<ol><li>define RSA_MODULUS_LEN_1024_BIT 128 <br />
 
</li><li>define RSA_MODULUS_LEN_2048_BIT 256 <br />
; Parameter Meaning
</li></ol>
* LED_ON turn on LED
<p>Parameter Meaning <br /> RSA_MODULUS_LEN_1024_BIT default modulus length <br /> RSA_MODULUS_LEN_2048_BIT Maximum modulus length <br />
* LED_OFF turn off LED
</p>
 
<h4> RSA Public Exponent </h4>
===DES Key Length===
<ol><li>define RSA_PUBEXP_LEN_65537_BIT 65537 <br />
* define DES_KEY_LEN_8_BYTE 8
</li></ol>
* define DES3_KEY_LEN_24_BYTE 24
<p>Parameter Meaning <br /> RSA_PUBEXP_LEN_65537_BIT RSA public exponent <br />
 
</p>
; Parameter Meaning
<h4> RSA Data Length </h4>
* DES_KEY_LEN_8_BYTE DES key length
<ol><li>define RSA_DATA_LEN_1024_BIT 128 <br />
* DES3_KEY_LEN_24_BYTE DES3 key length
</li><li>define RSA_DATA_LEN_2048_BIT 256 <br />
 
</li></ol>
===DES Data Length===
<p>Parameter Meaning <br /> RSA_DATA_LEN_1024_BIT default data length <br /> RSA_DATA_LEN_2048_BIT maximum data length <br />
* define DES_DATA_LEN_8_BYTE 8
</p>
 
<h4> RSA Import New Key Pair </h4>
; Parameter Meaning
<ol><li>define RSA_IMPORT_NEW 0 <br />
* DES_DATA_LEN_8_BYTE BYTE DES en/decrypt data length
</li></ol>
 
<p>Parameter Meaning <br /> RSA_IMPORT_NEW newly imported key pair <br />
===AES Key Length===
</p>
* define AES_KEY_LEN_128_BIT 16
<h4> File Name Length </h4>
* define AES_KEY_LEN_192_BIT 24
<ol><li>define UT_FILE_NAME_LENGTH 16 <br />
 
</li></ol>
; Parameter Meaning
<p>Parameter Meaning <br /> UT_FILE_NAME_LENGTH file name maximum length not including string terminator<br />
* AES_KEY_LEN_128_BIT default key length
</p>
* AES_KEY_LEN_192_BIT maximum key length
<h4> File Permission </h4>
 
<ol><li>define FILE_PERMISSION_GUEST 0x0 <br />
===AES Data Length===
</li><li>define FILE_PERMISSION_USER 0x1 <br />
* define AES_DATA_LEN_16_BYTE 16
</li><li>define FILE_PERMISSION_ADMIN 0x2 <br />
 
</li></ol>
; Parameter Meaning
<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 />
* AES_DATA_LEN_16_BYTE AES en/decrypt data length
</p><a _fcknotitle="true" href="Category:UniToken_APIs">UniToken_APIs</a>
 
===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