UniToken API Usage: Difference between revisions

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

Revision as of 11:46, 1 May 2012


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.

  1. define TOKEN_NO_EVENT 0
  2. define TOKEN_INSERT 1
  3. define TOKEN_REMOVE 2

About Macro

Size

  1. define UT_MAX_PIN_LEN 128
  2. define UT_MAX_ID_LEN 32
  3. define MAX_SLOT_NUMBER 32
  4. 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

  1. define UT_DEFAULT_SO "admin"
  2. 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

  1. define TOKEN_NO_EVENT 0
  2. define TOKEN_INSERT 1
  3. 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

  1. define UT_USER_LEVEL_GUEST 0x0
  2. define UT_USER_LEVEL_USER 0x1
  3. 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

  1. define UT_CHANGE_PIN_MODE_BYSELF 0x1
  2. 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

  1. define LED_ON 1
  2. define LED_OFF 0

Parameter Meaning
LED_ON turn on LED
LED_OFF turn off LED

DES Key Length

  1. define DES_KEY_LEN_8_BYTE 8
  2. 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

  1. define DES_DATA_LEN_8_BYTE 8

Parameter Meaning
DES_DATA_LEN_8_BYTE BYTE DES en/decrypt data length

AES Key Length

  1. define AES_KEY_LEN_128_BIT 16
  2. 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

  1. define AES_DATA_LEN_16_BYTE 16

Parameter Meaning
AES_DATA_LEN_16_BYTE AES en/decrypt data length

RSA Modulus Length

  1. define RSA_MODULUS_LEN_1024_BIT 128
  2. 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

  1. define RSA_PUBEXP_LEN_65537_BIT 65537

Parameter Meaning
RSA_PUBEXP_LEN_65537_BIT RSA public exponent

RSA Data Length

  1. define RSA_DATA_LEN_1024_BIT 128
  2. 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

  1. define RSA_IMPORT_NEW 0

Parameter Meaning
RSA_IMPORT_NEW newly imported key pair

File Name Length

  1. define UT_FILE_NAME_LENGTH 16

Parameter Meaning
UT_FILE_NAME_LENGTH file name maximum length not including string terminator

File Permission

  1. define FILE_PERMISSION_GUEST 0x0
  2. define FILE_PERMISSION_USER 0x1
  3. 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

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