📄 sense4.h
字号:
#define S4_CRYPTO_KEY_NOT_FOUND 0x00009403 /** the specified pin or key cann't be found*/
#define S4_APPLICATION_TEMP_BLOCK 0x00006985 /** the directory has been temporarily locked*/
#define S4_APPLICATION_PERM_BLOCK 0x00009303 /** the directory has been locked*/
#define S4_DATA_BUFFER_LENGTH_ERROR 0x00006700 /** invalid data length*/
#define S4_CODE_RANGE 0x00010000 /** the PC register of the virtual machine is out of range*/
#define S4_CODE_RESERVED_INST 0x00020000 /** invalid instruction*/
#define S4_CODE_RAM_RANGE 0x00040000 /** internal ram address is out of range*/
#define S4_CODE_BIT_RANGE 0x00080000 /** bit address is out of range*/
#define S4_CODE_SFR_RANGE 0x00100000 /** SFR address is out of range*/
#define S4_CODE_XRAM_RANGE 0x00200000 /** external ram address is out of range*/
#define S4_ERROR_UNKNOWN 0xffffffff /** unknown error*/
//@}
#define MAX_ATR_LEN 56 /** max ATR length */
#define MAX_ID_LEN 8 /** max device ID length */
#define S4_RSA_MODULUS_LEN 128 /** RSA key modules length,in bytes */
#define S4_RSA_PRIME_LEN 64 /** RSA key prime length,in bytes*/
//@{
/**
structure definition
*/
/* file information definition*/
typedef struct{
WORD EfID; /* file ID*/
BYTE EfType; /* file type*/
WORD EfSize; /* file size*/
}EFINFO,*PEFINFO;
/* device production date structure definition*/
typedef struct {
WORD wYear; /* year*/
BYTE byMonth; /* month*/
BYTE byDay; /* the day of the month */
}S4_MANUFACTURE_DATE;
/* current time structure definition*/
#ifndef _TM_DEFINED
typedef struct {
int tm_sec; /* seconds after the minute - [0,59] */
int tm_min; /* minutes after the hour - [0,59] */
int tm_hour; /* hours since midnight - [0,23] */
int tm_mday; /* day of the month - [1,31] */
int tm_mon; /* months since January - [0,11] */
int tm_year; /* years since 1900 */
int tm_wday; /* days since Sunday - [0,6] */
int tm_yday; /* days since January 1 - [0,365] */
int tm_isdst; /* daylight savings time flag */
} TM;
#define _TM_DEFINED
#endif
/**
device version definition
*/
typedef enum{
SENSE4_CARD_TYPE_V2_00 = 0x00020000, /** version 2.00*/
SENSE4_CARD_TYPE_V2_01 = 0x00020001, /** version 2.10*/
SENSE4_CARD_TYPE_V2_02 = 0x00020002, /** version 2.20*/
SENSE4_CARD_TYPE_V2_30 = 0x00020300 /** version 2.30*/
}CARD_VERSION;
/**
device information structure definition
*/
typedef struct {
DWORD dwIndex; /** device index; index begins at zero*/
DWORD dwVersion; /** device version*/
S4HANDLE hLock; /** device handle*/
BYTE reserve[12]; /** reserved*/
BYTE bAtr[MAX_ATR_LEN]; /** ATR*/
BYTE bID[MAX_ID_LEN]; /** device ID*/
DWORD dwAtrLen; /** ATR length*/
}SENSE4_CONTEXT,*PSENSE4_CONTEXT;
/** RSA public key structure*/
typedef struct {
unsigned char modulus[S4_RSA_MODULUS_LEN]; /* modulus*/
unsigned char exponent[S4_RSA_MODULUS_LEN]; /* public exponent*/
} S4_RSA_PUBLIC_KEY;
/** RSA private key structure*/
typedef struct {
unsigned char modulus[S4_RSA_MODULUS_LEN]; /* modulus*/
unsigned char publicExponent[S4_RSA_MODULUS_LEN]; /* public exponent*/
unsigned char exponent[S4_RSA_MODULUS_LEN]; /* private exponent*/
unsigned char prime[2][S4_RSA_PRIME_LEN]; /* prime factors*/
unsigned char primeExponent[2][S4_RSA_PRIME_LEN]; /* exponents for CRT*/
unsigned char coefficient[S4_RSA_PRIME_LEN]; /* CRT coefficient*/
} S4_RSA_PRIVATE_KEY;
/** S4CREATEDIRINFO structure definition*/
typedef struct _S4CREATEDIRINFO {
DWORD dwS4CreateDirInfoSize; /* size of the structure*/
BYTE szAtr[8]; /* ATR information */
} S4CREATEDIRINFO;
/** S4OPENINFO structure definition*/
typedef struct _S4OPENINFO {
DWORD dwS4OpenInfoSize; /* size of the structure*/
DWORD dwShareMode; /* share mode*/
} S4OPENINFO;
//@}
//@{
/**
@function interface
*/
/*
reserved
*/
unsigned long WINAPI S4Startup(
VOID
);
/*
reserved
*/
unsigned long WINAPI S4Cleanup(
VOID
);
/**
enumerate all EliteIV devices plugged in the computer.
if pS4CtxList is NULL, the pdwCtxListSize will return the required buffer size
@paramter pS4CtxList [out] return the device list
@paramter pdwCtxListSize [in][out] return the amount of storage of device list, in bytes.
@return value
if the function succeeds,the return vlaue is S4_SUCCESS, otherwise return other defined return value.
*/
DWORD WINAPI S4Enum(
OUT SENSE4_CONTEXT *pS4CtxList,
IN OUT DWORD *pdwCtxListSize
);
/**
open the EliteIV device with sharable mode
@paramter pS4Ctx [in][out] the context pointer of the device
@return value
if the function succeeds,the return vlaue is S4_SUCCESS, otherwise return other defined return value.
*/
DWORD WINAPI S4Open(
IN OUT SENSE4_CONTEXT *pS4Ctx
);
/**
close the EliteIV device
@parameter pS4Ctx [in] the context pointer of the device
@return value
if the function succeeds,the return vlaue is S4_SUCCESS, otherwise return other defined return value.
*/
DWORD WINAPI S4Close(
IN SENSE4_CONTEXT *pS4Ctx
);
/**
Send control command to device
@parameter pS4Ctx [in] the context pointer of the device, the device must has been opened
@parameter dwCtlCode [in] control code
@parameter pInBuffer [in] input buffer
@parameter dwInBufferLen [in] the length of input data,in bytes
@parameter pOutBuffer [out] return output data
@parameter dwOutBufferLen [in] output buffer size, in bytes
@parameter pdwBytesReturned [out] the length of output data, cannot be NULL
@return value
if the function succeeds,the return vlaue is S4_SUCCESS, otherwise return other defined return value.
*/
DWORD WINAPI S4Control(
IN SENSE4_CONTEXT *pS4Ctx,
IN DWORD dwCtlCode,
IN VOID *pInBuffer,
IN DWORD dwInBufferLen,
OUT VOID *pOutBuffer,
IN DWORD dwOutBufferLen,
OUT DWORD *pdwBytesReturned
);
/**
create a new child directory for the current directory, and set current directory to the new directory
@parameter pS4Ctx [in] the context pointer of the device, the device must has been opened
@parameter lpszDirID [in] ID of the new directory
@parameter dwDirSize [in] size of the new directory
@parameter dwFlags [in] flag
@return value
if the function succeeds,the return vlaue is S4_SUCCESS, otherwise return other defined return value.
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -