⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stm_api.h

📁 RSA C++源代码DEMO,附加DESMD5等众多算法
💻 H
📖 第 1 页 / 共 5 页
字号:
#define STM_RECORD_NEXT      0x3000
#define STM_RECORD_PREVIOUS  0x4000
#define STM_RECORD_APPEND    0x7000

//operation modes for STM_UpdateRecord()
#define STM_OVERWRITE   0
#define STM_APPEND      1

//selection of data to be read with STM_GetCardData()
#define STM_SERIAL_NO     0     
#define STM_OS_VERSION    1   
#define STM_CHIP_CONFIG   2   

//authentication modes
#define STM_INTERNAL    0
#define STM_EXTERNAL    1
#define STM_MUTUAL      2

//authentication partners
#define STM_HOST_ICC    0

//key info flags
#define STM_SESSION_KEY   1
#define STM_MASTER_KEY    2

//key level
#define STM_CURRENT   0
#define STM_GLOBAL    1

//key type
#define STM_DES_KEY   0        
#define STM_DES3_KEY  1        
#define STM_RSA_KEY   2        
#define STM_DSA_KEY   3       

//private use tags for asymmetric RSA authentication keys
#define STM_TAG_RSA      0xE0
#define STM_TAG_RSA_N    0x80
#define STM_TAG_RSA_E    0x81
#define STM_TAG_RSA_D    0x82

//private use tags for asymmetric DSA authentication keys
#define STM_TAG_DSA      0xE1
#define STM_TAG_DSA_P    0x80
#define STM_TAG_DSA_Q    0x81
#define STM_TAG_DSA_G    0x82
#define STM_TAG_DSA_Y    0x83
#define STM_TAG_DSA_X    0x84

//(DES) crypt modes
#define STM_ENCRYPT 0
#define STM_DECRYPT 1
#define STM_MAC     2

//DES chaining modes
#define STM_CBC 0
#define STM_ECB 1

//DES and DES-Hash padding modes
#define STM_PAD_ISO_1   0
#define STM_PAD_ISO_2   1

//algorithms for DES cryptographic processes
#define STM_SINGLE_DES   0
#define STM_TRIPLE_DES   1

// Hash algorithms
#define STM_HASH_SHA1        0
#define STM_HASH_MD5         1
#define STM_HASH_DES_SINGLE  2
#define STM_HASH_DES_DOUBLE  3
#define STM_HASH_RIPE        4
#define STM_HASH_RIPE128     5
#define STM_HASH_RIPE160     6

//modes for STM_SecureMessaging()
#define STM_SECM_OFF             0
#define STM_SECM_AUTHENTIC_ON    1
#define STM_SECM_CRYPT_ON        2
#define STM_SECM_COMBINED_ON     3

//operation modes for STM_Journal()
#define STM_JOU_ON    0
#define STM_JOU_OFF   1
#define STM_JOU_CLR   2
#define STM_JOU_SAVE  3

//save modes for STM_JournalSave()
#define STM_JOU_OVERWRITE  0
#define STM_JOU_APPEND     1

//linefeed modes for STM_JournalSave()
#define STM_JOU_NO_LF  0
#define STM_JOU_LF     1

//operation modes for the global journal-callback-function
#define STM_CBK_COMMAND    0x0001
#define STM_CBK_RESPONSE   0x0002
#define STM_CBK_SECM       0x0010
#define STM_CBK_STM        0x0100
#define STM_CBK_PCCTI      0x0200
#define STM_CBK_ERR        0x8000
//host ID for the global journal-callback-function
#define STM_HOST           0x0100
#define STM_REMOTE         0x1000
//port ID for the global journal-callback-function
/*      STM_COMx  x = 1 - 32       */
/*      STM_OPEN_x    (rfu)        */
//client ID for the global journal-callback-function
/*      STM_CT                     */
/*      STM_ICCx  x = 1 - 14       */

//templates for STM_SetSecurityEnvironment()
#define STM_DIG_SIG    0
#define STM_AUTH       1
#define STM_CIPHER     2

//padding modes for DSA/RSA signature generation and verification
#define STM_RSA_PAD_RND         0  
#define STM_RSA_PAD_80          1 
#define STM_RSA_PAD_NONE        2 //not supported by cards 
#define STM_RSA_PAD_9796        3 //method 1 or 2_RND padding
#define STM_RSA_PAD_9796_1      4 //ISO 9796 method 1 
#define STM_RSA_PAD_9796_2      5 //ISO 9796 method 2 
#define STM_RSA_PAD_9796_2_RND  6 //ISO 9796 method 2 + 8 random bytes
#define STM_RSA_PAD_PKCS1_01    7 //PKCS#1 block type 01
#define STM_RSA_PAD_AR          8 //according to algorithm reference
#define STM_RSA_PAD_AR_11       6 //ISO 9796 method 2 + 8 random bytes/SHA-1
#define STM_RSA_PAD_AR_12       9 //PKCS#1 block type 01/SHA-1/OIW
#define STM_RSA_PAD_AR_21       6 //ISO 9796 method 2 + 8 random bytes/RIPEMD-160
#define STM_RSA_PAD_AR_22      10 //PKCS#1 block type 01/RIPEMD-160/TeleTrust
#define STM_RSA_PAD_AR_32      11 //PKCS#1 block type 01/MD-5/RSADSI
#define STM_DSA_PAD_NONE     0x80 //DSA does not feature padding

//PTS modes for STM_ICCSetPTS()
#define STM_PTS_AUTO_OFF   0
#define STM_PTS_AUTO_ON    1    
#define STM_PTS_MANUAL     2

//ICC states
#define STM_ICC_OK        0
#define STM_NO_ICC        1    
#define STM_ICC_NO_VCC    2
#define STM_ICC_UNKNOWN   3

//language option for GetMsg()
#define STM_LANG_E        0

//random generator types
#define STM_CRAND         0 //provided by C-Compiler => 8 bytes of seed
#define STM_DESRAND       1 //DES based              => 16 bytes of seed
#define STM_DES3RAND      2 //Triple-DES based       => 24 bytes of seed

//key generation algorithms for RSA
#define STM_RSA_TESTDIV       1 //test division by the first 1001 primes
                                //only usefull for small test keys!!
#define STM_RSA_RABMIL05      2 //5 rounds of Rabin-Miller-Test
#define STM_RSA_RABMIL10      3 //10 rounds of Rabin-Miller-Test
#define STM_RSA_STRONG        4 //pseudo primes p such that p-1 and p+1 are non-smooth
#define STM_RSA_GORDON        5 //pseudo primes fulfilling all of Gordon's criteria
#define STM_RSA_MAURER        6 //true primes genrated using a variant of 
                                //Maurer's algorithm

//format option for STM_GenerateAndWriteRSAKey()
#define STM_ENTRY_N_D                0
#define STM_ENTRY_P_Q_D              1
#define STM_ENTRY_P_Q_DP_DQ          2
#define STM_ENTRY_P_Q_DP_DQ_QINV     3
#define STM_ENTRY_P_Q_DP_DQ_PINV     4

//key generation algorithms for DSA
#define STM_DSA_RABMIL05      1 //5 rounds of Rabin-Miller-Test
#define STM_DSA_RABMIL10      2 //10 rounds of Rabin-Miller-Test
#define STM_DSA_ANSIX930      3 //Implementation of the generation method given in 
                                //ANSI X9.30 - Part 1

//access control for STM_CardAccessControl()
#define STM_AC_UNLOCK       0 //release temporary exclusive access to a terminal
#define STM_AC_LOCK         1 //request temporary exclusive access to a terminal

//list mode for STM_GetTermList()
#define STM_LIST_ALL           0 //list all terminals
#define STM_LIST_PCSC          1 //list PCSC terminals only
#define STM_LIST_CTAPI         2 //list CTAPI terminals only

//config mode for STM_PCCTIConfig()
#define STM_PCCTI_CONFIG_MSG_BOX    0x0002 //control generation of PC/CTI message
                                           // boxes
#define STM_PCCTI_CONFIG_INI_FILE   0x0004 //(re)set CT-API INI-file(path &) name

//config mode for STM_TermConfig()
#define STM_TERM_CONFIG_GET_TIMING  0x0010 //get waiting times of T=1 Host
#define STM_TERM_CONFIG_SET_TIMING  0x0020 //set waiting times of T=1 Host

//purse declarations for SRF1.3 (Air 1.0)
#define STM_PURSE_CREDIT    0x00
#define STM_PURSE_DEBIT     0x01
#define STM_PURSE_SECURE    0x00
#define STM_PURSE_FREE      0x02
#define STM_PURSE_ONLINE    0x00
#define STM_PURSE_OFFLINE   0x04
#define STM_PURSE_LOCK      0x08
#define STM_PURSE_DSC       0x10

/** **** END EXTRACTION **** **/

/** ****************************************************************** **/
/** External Function Set - all STM_Functions()                        **/
/** ****************************************************************** **/

#if defined(__cplusplus) /* extern "C" declaration of C-functions for C++ */
extern "C" {
#endif /* __cplusplus */

STM_API1 int STM_API2 STM_AuthAsym(stmHandle hCard, unsigned int uiAuthMode,
  const unsigned char *ucpAuthKey, const unsigned char *ucpCryptKey,
  unsigned char *ucpRFU, int *bpResult);
  
STM_API1 int STM_API2 STM_Authentication(stmHandle hCard, unsigned int uiAuthMode,
  unsigned int uiDevice, unsigned int uiKeyNo, unsigned int uiKeyLevel, unsigned int uiKeyInfo,
  unsigned int uiKeyType, const unsigned char *ucpKey, int *bpResult);

STM_API1 int STM_API2 STM_CardDecipher(stmHandle hCard, unsigned int uiLenData,
  const unsigned char *ucpData, unsigned int uiRFU, unsigned int uiResBufLen,
  unsigned int *uipActResLen, unsigned char *ucpResBuf);

STM_API1 int STM_API2 STM_CardAccessControl(stmHandle hCard, unsigned int uiAccessControl);

STM_API1 int STM_API2 STM_CardEncipher(stmHandle hCard, unsigned int uiLenData,
  const unsigned char *ucpData, unsigned int uiRFU, unsigned int uiResBufLen,
  unsigned int *uipActResLen, unsigned char *ucpResBuf);

STM_API1 int STM_API2 STM_CardGenerateRSAKey(stmHandle hCard, unsigned int uiKeyNo,
  unsigned int uiKeyLevel, unsigned int uiBitLenKey, unsigned char *ucpModulus);

STM_API1 int STM_API2 STM_ChangePIN(stmHandle hCard, unsigned int uiKeyNo, 
  unsigned int uiKeyLevel, unsigned int uiLenOldPIN, const unsigned char *ucpOldPIN,
  unsigned int uiLenNewPIN, const unsigned char *ucpNewPIN, int *bpResult); 

STM_API1 int STM_API2 STM_CheckISOATR(stmHandle hCard, int *bpIsISO);

STM_API1 int STM_API2 STM_Close(stmHandle hCard);

STM_API1 int STM_API2 STM_CloseAll(unsigned int uiMode, unsigned int uiPort, unsigned int uiDest);

STM_API1 int STM_API2 STM_Commands(unsigned int uiLineNo, unsigned int uiMaxlenTxt,
  char *szTxt);

STM_API1 int STM_API2 STM_ComputeHash(stmHandle hCard, unsigned int uiLenInput,
  const unsigned char *ucpInput, unsigned int uiLenResBuf, unsigned int *uipActResLen,
  unsigned char *ucpResBuf);

STM_API1 int STM_API2 STM_ComputeHashData(stmHandle hCard, unsigned int uiLenInput,
  const unsigned char *ucpInput);

STM_API1 int STM_API2 STM_ComputeHashFinish(stmHandle hCard, unsigned int uiLenResBuf,
  unsigned int *uipActResLen, unsigned char *ucpResBuf);

STM_API1 int STM_API2 STM_ComputeHashInit(stmHandle hCard);

STM_API1 int STM_API2 STM_ComputeSignature(stmHandle hCard, unsigned int uiPadMode,
  unsigned int uiResBufLen, unsigned int *uipActResLen, unsigned char *ucpResBuf);

STM_API1 int STM_API2 STM_Create(stmHandle hCard, unsigned int uiCreateMode, 
  unsigned int uiLenData, const unsigned char *ucpData);

STM_API1 int STM_API2 STM_Crypt(stmHandle hCard, unsigned int uiKeyNo, 
  unsigned int uiKeyLevel, unsigned int uiCryptMode, unsigned int uiLenData, 
  const unsigned char *ucpData, unsigned int uiResBufLen, unsigned int *uipActResLen,
  unsigned char *ucpResBuf);

STM_API1 int STM_API2 STM_Decrease(stmHandle hCard, unsigned int uiShortId,
  unsigned int uiLen, const unsigned char *ucpValue, unsigned int uiLenExtraData,
  const unsigned char *ucpExtraData, unsigned char *ucpCounter);

STM_API1 int STM_API2 STM_DeinitializeLibrary();

STM_API1 int STM_API2 STM_DeleteFile(stmHandle hCard, unsigned int uiFID);

STM_API1 int STM_API2 STM_DeleteMF(stmHandle hCard);

STM_API1 int STM_API2 STM_DeriveKey(stmHandle hCard, unsigned int uiKeyType, 
  const unsigned char *ucpMasterKey, unsigned char *ucpDerivedKey);
                                                        
STM_API1 int STM_API2 STM_DESData(stmHandle hDESProcess, unsigned int uiLenInput, 
  const unsigned char *ucpInput, unsigned int *uipActLenOutput, unsigned char *ucpOutput);

STM_API1 int STM_API2 STM_DESFinish(stmHandle hDESProcess, unsigned int *uipActLenOutput, 
  unsigned char *ucpOutput);

STM_API1 int STM_API2 STM_DESInit(stmHandle *hpDESProcess,  unsigned int uiAlgo, 
  unsigned int uiCryptMode, unsigned int uiChainMode, unsigned int uiPadMode, 
  const unsigned char *ucpKey, const unsigned char *ucpIV);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -