UniToken API Usage: Difference between revisions

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


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>
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.
UniToken API package installs UniToken.dll for general UniToken API  
implementation and UniTokenAx.dll for ActiveX usage.<br><br>


== API 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.


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>
==Prototype Specification==
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>
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:


==== UT_HANDLE ====
<code>typedef unsigned long UT_HANDLE;</code>


UT_HANDLE is specified by UniToken library and used for detecting devices. It  
; KEY_HANDLE, KEY_HANDLE_PTR
is defined as follows: <br><br>
: KEY_HANDLE is specified by UniToken library and used for detecting keys. It is defined as follows:
typedef unsigned long UT_HANDLE;


==== KEY_HANDLE, KEY_HANDLE_PTR ====
<code>typedef unsigned long KEY_HANDLE;</code>


KEY_HANDLE is specified by UniToken library and used for detecting keys. It is defined as follows: <br><br>
typedef unsigned long KEY_HANDLE;
KEY_HANDLE_PTR is the pointer of KEY_HANDLE.
KEY_HANDLE_PTR is the pointer of KEY_HANDLE.


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


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 UT_RV;</code>
typedef unsigned long UT_RV;


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


UT_SLOT_ID is specified by UniToken library and used for identifying slots. It is defined as follows: <br><br> 
<code>typedef unsigned long UT_SLOT_ID;</code>
typedef unsigned long UT_SLOT_ID;


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


UT_STATUS is specified by UniToken library and used for identifying the status of slot. It is defined as follows:<br><br>  
<code>typedef unsigned long UT_STATUS;</code>
typedef unsigned long UT_STATUS; <br><br>
We defined some values for this UniToken library version.<br><br>   
#define TOKEN_NO_EVENT  0 <br>
#define TOKEN_INSERT    1 <br>
#define TOKEN_REMOVE    2 <br>


== About Macro ==
We defined some values for this UniToken library version.


==== Size ====
* define TOKEN_NO_EVENT 0
* define TOKEN_INSERT 1
* define TOKEN_REMOVE 2


#define UT_MAX_PIN_LEN    128 <br>
==About Macro==
#define UT_MAX_ID_LEN    32 <br>
#define MAX_SLOT_NUMBER  32 <br>
#define FS_MEMORY  (256*1024) <br>


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


==== Password ====
; 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


#define UT_DEFAULT_SO "admin" <br>
===Password===
#define UT_DEFAULT_USER "user" <br>
* define UT_DEFAULT_SO "admin"
* define UT_DEFAULT_USER "user"


Parameter Meaning <br>
; Parameter Meaning
UT_DEFAULT_SO the admin default password of UniToken <br>
* UT_DEFAULT_SO the admin default password of UniToken
T_DEFAULT_USER the user default password of UniToken <br>
* T_DEFAULT_USER the user default password of UniToken


==== Slot status ====
===Slot Status===
* define TOKEN_NO_EVENT 0
* define TOKEN_INSERT 1
* define TOKEN_REMOVE 2


#define TOKEN_NO_EVENT  0 <br>
; Parameter Meaning
#define TOKEN_INSERT  1 <br>
* TOKEN_NO_EVENT No slot status has changed
#define TOKEN_REMOVE  2 <br>
* TOKEN_INSERT A device is inserted in a slot
* TOKEN_REMOVE The device in the slot is removed
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>


==== User level ====
===User Level===
* define UT_USER_LEVEL_GUEST 0x0
* define UT_USER_LEVEL_USER 0x1
* define UT_USER_LEVEL_ADMIN 0x2


#define UT_USER_LEVEL_GUEST  0x0 <br>
; Parameter Meaning
#define UT_USER_LEVEL_USER  0x1 <br>
* UT_USER_LEVEL_GUEST GUEST Level
#define UT_USER_LEVEL_ADMIN  0x2 <br>
* UT_USER_LEVEL_USER USER Level
* UT_USER_LEVEL_ADMIN ADMIN ADMIN Level
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>


==== Modes of changing passwords ====
===Modes of Changing Passwords===
* define UT_CHANGE_PIN_MODE_BYSELF 0x1
* define UT_CHANGE_PIN_MODE_ADMIN_CHANGE_USER 0x2


#define UT_CHANGE_PIN_MODE_BYSELF  0x1 <br>
; Parameter Meaning
#define UT_CHANGE_PIN_MODE_ADMIN_CHANGE_USER  0x2 <br>
* UT_CHANGE_PIN_MODE_BYSELF Current user changes his password
* UT_CHANGE_PIN_MODE_ADMIN_CHANGE_USER Changing user password requires admin permission
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>


==== LED on-off ====
===LED On-off===
* define LED_ON 1
* define LED_OFF 0


#define LED_ON  1 <br>
; Parameter Meaning
#define LED_OFF  0 <br>
* LED_ON turn on LED
* LED_OFF turn off LED
Parameter Meaning <br>
LED_ON turn on LED <br>
LED_OFF turn off LED <br>


==== DES key length ====
===DES Key Length===
* define DES_KEY_LEN_8_BYTE 8
* define DES3_KEY_LEN_24_BYTE 24


#define DES_KEY_LEN_8_BYTE    8 <br>
; Parameter Meaning
#define DES3_KEY_LEN_24_BYTE  24 <br>
* DES_KEY_LEN_8_BYTE DES key length
* DES3_KEY_LEN_24_BYTE DES3 key length
Parameter Meaning <br>
DES_KEY_LEN_8_BYTE DES key length <br>
DES3_KEY_LEN_24_BYTE DES3 key length <br>


==== DES data length ====
===DES Data Length===
* define DES_DATA_LEN_8_BYTE 8


#define DES_DATA_LEN_8_BYTE     8 <br>
; Parameter Meaning
* DES_DATA_LEN_8_BYTE BYTE DES en/decrypt data length


Parameter  Meaning <br>
===AES Key Length===
DES_DATA_LEN_8_BYTE  BYTE    DES en/decrypt data length <br>
* define AES_KEY_LEN_128_BIT 16
* define AES_KEY_LEN_192_BIT 24


==== AES key length ====
; Parameter Meaning
* AES_KEY_LEN_128_BIT default key length
* AES_KEY_LEN_192_BIT maximum key length


#define AES_KEY_LEN_128_BIT  16 <br>
===AES Data Length===
#define AES_KEY_LEN_192_BIT  24 <br>
* define AES_DATA_LEN_16_BYTE 16
Parameter  Meaning <br>
AES_KEY_LEN_128_BIT  default key length <br>
AES_KEY_LEN_192_BIT  maximum key length <br>


==== AES data length ====
; Parameter Meaning
* AES_DATA_LEN_16_BYTE AES en/decrypt data length


#define AES_DATA_LEN_16_BYTE    16 <br>
===RSA Modulus Length===
* define RSA_MODULUS_LEN_1024_BIT 128
Parameter  Meaning <br>
* define RSA_MODULUS_LEN_2048_BIT 256
AES_DATA_LEN_16_BYTE  AES en/decrypt data length<br>


==== RSA modulus length ====
; Parameter Meaning
* RSA_MODULUS_LEN_1024_BIT default modulus length
* RSA_MODULUS_LEN_2048_BIT Maximum modulus length


#define RSA_MODULUS_LEN_1024_BIT  128 <br>
===RSA Public Exponent===
#define RSA_MODULUS_LEN_2048_BIT  256 <br>
* define RSA_PUBEXP_LEN_65537_BIT 65537
Parameter  Meaning <br>
RSA_MODULUS_LEN_1024_BIT  default modulus length <br>
RSA_MODULUS_LEN_2048_BIT  Maximum    modulus length <br>


==== RSA PUBLIC EXPONENT ====
; Parameter Meaning
* RSA_PUBEXP_LEN_65537_BIT RSA public exponent


#define RSA_PUBEXP_LEN_65537_BIT  65537 <br>
===RSA Data Length===
* define RSA_DATA_LEN_1024_BIT 128
Parameter  Meaning <br>
* define RSA_DATA_LEN_2048_BIT 256
RSA_PUBEXP_LEN_65537_BIT  RSA public exponent <br>


==== RSA data length ====
; Parameter Meaning
* RSA_DATA_LEN_1024_BIT default data length
* RSA_DATA_LEN_2048_BIT maximum data length


#define RSA_DATA_LEN_1024_BIT  128 <br>
===RSA Import New Key Pair===
#define RSA_DATA_LEN_2048_BIT  256 <br>
* define RSA_IMPORT_NEW 0
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 ====
; Parameter Meaning
* RSA_IMPORT_NEW newly imported key pair


#define RSA_IMPORT_NEW      0 <br>
===File Name Length===
* define UT_FILE_NAME_LENGTH 16
Parameter  Meaning <br>
RSA_IMPORT_NEW  newly imported key pair <br>


==== File name length ====
; Parameter Meaning
* UT_FILE_NAME_LENGTH file name maximum length not including string terminator


#define UT_FILE_NAME_LENGTH  16 <br>
===File Permission===
* define FILE_PERMISSION_GUEST 0x0
Parameter  Meaning <br>
* define FILE_PERMISSION_USER 0x1
UT_FILE_NAME_LENGTH    file name maximum length not including string terminator<br>
* define FILE_PERMISSION_ADMIN 0x2


==== File permission ====
; Parameter Meaning
 
* FILE_PERMISSION_GUEST GUEST permission file
#define FILE_PERMISSION_GUEST  0x0 <br>
* FILE_PERMISSION_USER USER permission file
#define FILE_PERMISSION_USER  0x1 <br>
* FILE_PERMISSION_ADMIN ADMIN permission file
#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>

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