| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- #ifdef RVCCRYPT_EXPORTS
- #define RVCCRYPT_API __declspec(dllexport)
- #else
- #define RVCCRYPT_API __declspec(dllimport)
- #endif
- #ifndef WINAPI
- #define WINAPI __stdcall
- #endif
- #define PUKFILENAME_RSA "RVCPubKey.ini"
- #define PUKFILENAME_SM2 "RVCSM2PubKey.ini"
- #define PFKEYFILENAME_DES "CMBRVCKeys.dat"
- #define PFKEYFILENAME_SM4 "CMBRVCSm4Keys.dat"
- typedef enum {
- cKEK = 0,
- cTMK = 1,
- cTPK = 2,
- cEDK = 4,
- csKEK = 5,
- csTMK = 6,
- csTPK = 7,
- csEDK = 9
- } TWKKeyType;
- #define TMK_LEN 32
- #define EDK_LEN 32
- #define TPK_LEN 32
- #define TMK_CHK_LEN 8
- #define EDK_CHK_LEN 8
- #define TPK_CHK_LEN 8
- typedef enum {
- TMK, TMKCHK, TPK, TPKCHK, EDK, EDKCHK, FIELDS
- } KeyType;
- typedef enum {
- DES, SM4, DES_SM4, NO_ALG
- } ALGType;
- typedef struct _EncKeys EncKeys;
- #ifdef __cplusplus
- extern "C"{
- #endif
- RVCCRYPT_API int WINAPI Init(const char* szKeyFileDirBuf,int nKeyFileDirBufLen, int algFlag);
- RVCCRYPT_API int WINAPI Release();
- RVCCRYPT_API int WINAPI CreateInitTMKReq(char* pOutBuf,int* pOutBufLen);
- RVCCRYPT_API int WINAPI CreateInitSMTMKReq(char* pOutBuf,int* pOutBufLen);
- RVCCRYPT_API int WINAPI ParseTMKRes(char * pTMKRes,int nTMKResLen);
- RVCCRYPT_API int WINAPI ParseSMTMKRes(char * pTMKRes,int nTMKResLen);
- RVCCRYPT_API int WINAPI CreateUpdateReq(char* pOutBuf,int* pOutBufLen, int algFlag);
- RVCCRYPT_API int WINAPI ParseUpdateRes(char* pUpdateRes,int nUpdateResLen, int algFlag);
- RVCCRYPT_API int WINAPI GetKey(char* pOutKeyBuf, int *pOutKeyBufLen, char *pOutChkBuf, int *pOutChkBufLen, TWKKeyType tKeyType);
- RVCCRYPT_API int WINAPI GetLastErrorMsg(char * pOutMsgBuf, int* pOutMsgBufLen);
- ///*
- // return value: 0 success
- // Input: szRSAKeyBuf RSA public key string
- // nRSAKeyBufLen RSA public key string length
- // szSM2KeyBuf RSA public key string
- // nSM2KeyBufLen RSA public key string length
- // logDir log dir
- // algFlag des/sm4/des_sm4
- // */
- //RVCCRYPT_API int WINAPI Init(const char* szRSAKeyBuf, int nRSAKeyBufLen, const char* szSM2KeyBuf, int nSM2KeyBufLen, char* logDir, int algFlag);
- //
- ///*
- // return Value: 0 success
- // input: algFlag des/sm4
- // output: pTMKRequest tmk init request
- // pTMKRequestLen buffer length
- //*/
- //RVCCRYPT_API int WINAPI CreateInitTMKReq(int algFlag, char* pTMKRequest, int* pTMKRequestLen);
- //
- ///*
- // return value: 0 success
- // input: pTMKRes tmk response
- // nTMKResLen buffer length
- // algFlag des/sm4
- // output: pKeys tmk & other keys
- // pTmk tmk value
- // pTmkLen tmk len
- //*/
- //RVCCRYPT_API int WINAPI ParseTMKRes(char *pTMKRes, int nTMKResLen, int algFlag, char* pTmk, int* pTmkLen, EncKeys **pKeys);
- //
- ///*
- //return Value: 0 success
- //input: pKeyChk tmk check value
- // algFlag des/sm4
- //output: pUpdateRequest update request
- // pUpdateRequestLen buffer length
- //*/
- //RVCCRYPT_API int WINAPI CreateUpdateReq(char *pKeyChk, int algFlag, char* pUpdateRequest, int* pUpdateRequestLen);
- //
- ///*
- // Return Value: 0 success
- // input: pUpdateRes update response
- // nUpdateResLen buffer length
- // algFlag des/sm4
- // output: pKeys work keys
- //*/
- //RVCCRYPT_API int WINAPI ParseUpdateRes(char* pUpdateRes, int nUpdateResLen, int algFlag, EncKeys **pKeys);
- //
- ///*
- // Return Value: addr of keybuf
- // input: pKeys struct EncKeys
- // type tmk/tmkchk...
- // output: keybuf key value or check value
- //*/
- //RVCCRYPT_API char* WINAPI GetKey(EncKeys *pKeys, KeyType type, char* keybuf);
- ///*
- // Return Value: 0 success
- // input: pKeys struct EncKeys
- //*/
- //RVCCRYPT_API int Close(EncKeys *pKeys);
- //
- //RVCCRYPT_API int WINAPI GetLastErrorMsg(char* pOutMsgBuf, int* pOutMsgBufLen);
- //RVCCRYPT_API int WINAPI Release();
- /*
- return value: 0 success
- Input: szRSAKeyBuf RSA public key string
- nRSAKeyBufLen RSA public key string length
- szSM2KeyBuf RSA public key string
- nSM2KeyBufLen RSA public key string length
- logDir log dir
- algFlag des/sm4/des_sm4
- */
- RVCCRYPT_API int WINAPI RvcInit(const char* szRSAKeyBuf, int nRSAKeyBufLen, const char* szSM2KeyBuf, int nSM2KeyBufLen, char* logDir, int algFlag);
-
- /*
- return Value: 0 success
- input: algFlag des/sm4
- output: pTMKRequest tmk init request
- pTMKRequestLen buffer length
- */
- RVCCRYPT_API int WINAPI RvcCreateInitTMKReq(int algFlag, char* pTMKRequest, int* pTMKRequestLen);
-
- /*
- return value: 0 success
- input: pTMKRes tmk response
- nTMKResLen buffer length
- algFlag des/sm4
- output: pKeys tmk & other keys
- pTmk tmk value
- pTmkLen tmk len
- */
- RVCCRYPT_API int WINAPI RvcParseTMKRes(char *pTMKRes, int nTMKResLen, int algFlag, char* pTmk, int* pTmkLen, EncKeys **pKeys);
-
- /*
- return Value: 0 success
- input: pKeyChk tmk check value
- algFlag des/sm4
- output: pUpdateRequest update request
- pUpdateRequestLen buffer length
- */
- RVCCRYPT_API int WINAPI RvcCreateUpdateReq(char *pKeyChk, int algFlag, char* pUpdateRequest, int* pUpdateRequestLen);
-
- /*
- Return Value: 0 success
- input: pUpdateRes update response
- nUpdateResLen buffer length
- algFlag des/sm4
- output: pKeys work keys
- */
- RVCCRYPT_API int WINAPI RvcParseUpdateRes(char* pUpdateRes, int nUpdateResLen, int algFlag, EncKeys **pKeys);
-
- /*
- Return Value: addr of keybuf
- input: pKeys struct EncKeys
- type tmk/tmkchk...
- output: keybuf key value or check value
- */
- RVCCRYPT_API char* WINAPI RvcGetKey(EncKeys *pKeys, KeyType type, char* keybuf);
- /*
- Return Value: 0 success
- input: pKeys struct EncKeys
- */
- RVCCRYPT_API int RvcClose(EncKeys *pKeys);
-
- RVCCRYPT_API int WINAPI RvcGetLastErrorMsg(char* pOutMsgBuf, int* pOutMsgBufLen);
- RVCCRYPT_API int WINAPI RvcRelease();
- #ifdef __cplusplus
- }
- #endif
|