gitee.com/lh-her-team/common@v1.5.1/crypto/sdf/base/sdf.h (about)

     1  /*
     2  * File: swsds.h
     3  * Copyright (c) SWXA 2009
     4  *
     5  */
     6  
     7  #ifndef _SW_SDS_H_
     8  #define _SW_SDS_H_ 1
     9  
    10  #ifdef __cplusplus
    11  	extern "C"{
    12  #endif
    13  
    14  /*RSA最大模长定义*/
    15  #define SGD_RSA_MAX_BITS    4096
    16  
    17  /*数据类型定义*/
    18  typedef char				SGD_CHAR;
    19  typedef char				SGD_INT8;
    20  typedef short				SGD_INT16;
    21  typedef int					SGD_INT32;
    22  typedef long long			SGD_INT64;
    23  typedef unsigned char		SGD_UCHAR;
    24  typedef unsigned char		SGD_UINT8;
    25  typedef unsigned short		SGD_UINT16;
    26  typedef unsigned int		SGD_UINT32;
    27  typedef unsigned long long	SGD_UINT64;
    28  typedef unsigned int		SGD_RV;
    29  typedef void*				SGD_OBJ;
    30  typedef int					SGD_BOOL;
    31  typedef void*				SGD_HANDLE;
    32  
    33  /*设备信息*/
    34  typedef struct DeviceInfo_st{
    35  	unsigned char IssuerName[40];
    36  	unsigned char DeviceName[16];
    37  	unsigned char DeviceSerial[16];
    38  	unsigned int  DeviceVersion;
    39  	unsigned int  StandardVersion;
    40  	unsigned int  AsymAlgAbility[2];
    41  	unsigned int  SymAlgAbility;
    42  	unsigned int  HashAlgAbility;
    43  	unsigned int  BufferSize;
    44  }DEVICEINFO;
    45  
    46  
    47  typedef struct st_DeviceRunStatus{
    48  	unsigned int onboot;		//服务是否开机自启动
    49  	unsigned int service;		//当前服务状态,0-未启动,1-已启动,>1状态异常
    50  	unsigned int concurrency;	//当前并发数
    51  	unsigned int memtotal;      //内存大小
    52  	unsigned int memfree;		//内存空闲
    53  	unsigned int cpu;			//CPU占用率,不包含小数点部分
    54  	unsigned int reserve1;
    55  	unsigned int reserve2;
    56  }DEVICE_RUN_STATUS;
    57  
    58  /*RSA密钥*/
    59  #define LiteRSAref_MAX_BITS    2048
    60  #define LiteRSAref_MAX_LEN     ((LiteRSAref_MAX_BITS + 7) / 8)
    61  #define LiteRSAref_MAX_PBITS   ((LiteRSAref_MAX_BITS + 1) / 2)
    62  #define LiteRSAref_MAX_PLEN    ((LiteRSAref_MAX_PBITS + 7)/ 8)
    63  
    64  typedef struct RSArefPublicKeyLite_st
    65  {
    66  	unsigned int  bits;
    67  	unsigned char m[LiteRSAref_MAX_LEN];
    68  	unsigned char e[LiteRSAref_MAX_LEN];
    69  }RSArefPublicKeyLite;
    70  
    71  typedef struct RSArefPrivateKeyLite_st
    72  {
    73  	unsigned int  bits;
    74  	unsigned char m[LiteRSAref_MAX_LEN];
    75  	unsigned char e[LiteRSAref_MAX_LEN];
    76  	unsigned char d[LiteRSAref_MAX_LEN];
    77  	unsigned char prime[2][LiteRSAref_MAX_PLEN];
    78  	unsigned char pexp[2][LiteRSAref_MAX_PLEN];
    79  	unsigned char coef[LiteRSAref_MAX_PLEN];
    80  }RSArefPrivateKeyLite;
    81  
    82  #define ExRSAref_MAX_BITS    4096
    83  #define ExRSAref_MAX_LEN     ((ExRSAref_MAX_BITS + 7) / 8)
    84  #define ExRSAref_MAX_PBITS   ((ExRSAref_MAX_BITS + 1) / 2)
    85  #define ExRSAref_MAX_PLEN    ((ExRSAref_MAX_PBITS + 7)/ 8)
    86  
    87  typedef struct RSArefPublicKeyEx_st
    88  {
    89  	unsigned int  bits;
    90  	unsigned char m[ExRSAref_MAX_LEN];
    91  	unsigned char e[ExRSAref_MAX_LEN];
    92  } RSArefPublicKeyEx;
    93  
    94  typedef struct RSArefPrivateKeyEx_st
    95  {
    96  	unsigned int  bits;
    97  	unsigned char m[ExRSAref_MAX_LEN];
    98  	unsigned char e[ExRSAref_MAX_LEN];
    99  	unsigned char d[ExRSAref_MAX_LEN];
   100  	unsigned char prime[2][ExRSAref_MAX_PLEN];
   101  	unsigned char pexp[2][ExRSAref_MAX_PLEN];
   102  	unsigned char coef[ExRSAref_MAX_PLEN];
   103  } RSArefPrivateKeyEx;
   104  
   105  //#if defined(SGD_RSA_MAX_BITS) && (SGD_RSA_MAX_BITS > LiteRSAref_MAX_BITS)
   106  //#define RSAref_MAX_BITS    ExRSAref_MAX_BITS
   107  //#define RSAref_MAX_LEN     ExRSAref_MAX_LEN
   108  //#define RSAref_MAX_PBITS   ExRSAref_MAX_PBITS
   109  //#define RSAref_MAX_PLEN    ExRSAref_MAX_PLEN
   110  //
   111  //typedef struct RSArefPublicKeyEx_st  RSArefPublicKey;
   112  //typedef struct RSArefPrivateKeyEx_st  RSArefPrivateKey;
   113  //#else
   114  #define RSAref_MAX_BITS    LiteRSAref_MAX_BITS
   115  #define RSAref_MAX_LEN     LiteRSAref_MAX_LEN
   116  #define RSAref_MAX_PBITS   LiteRSAref_MAX_PBITS
   117  #define RSAref_MAX_PLEN    LiteRSAref_MAX_PLEN
   118  
   119  typedef struct RSArefPublicKeyLite_st  RSArefPublicKey;
   120  typedef struct RSArefPrivateKeyLite_st  RSArefPrivateKey;
   121  //#endif
   122  
   123  
   124  #define ECCref_MAX_BITS			512 
   125  #define ECCref_MAX_LEN			((ECCref_MAX_BITS+7) / 8)
   126  #define ECCref_MAX_CIPHER_LEN	136
   127  
   128  typedef struct ECCrefPublicKey_st
   129  {
   130  	unsigned int  bits;
   131  	unsigned char x[ECCref_MAX_LEN]; 
   132  	unsigned char y[ECCref_MAX_LEN]; 
   133  } ECCrefPublicKey;
   134  
   135  typedef struct ECCrefPrivateKey_st
   136  {
   137      unsigned int  bits;
   138      unsigned char K[ECCref_MAX_LEN];
   139  } ECCrefPrivateKey;
   140  
   141  
   142  typedef struct ECCCipher_st
   143  {
   144  	unsigned char x[ECCref_MAX_LEN]; 
   145  	unsigned char y[ECCref_MAX_LEN]; 
   146      unsigned char M[32];
   147  	unsigned int L;
   148  	unsigned char C[ECCref_MAX_CIPHER_LEN];
   149  } ECCCipher;
   150  
   151  
   152  
   153  typedef struct ECCSignature_st
   154  {
   155  	unsigned char r[ECCref_MAX_LEN];	
   156  	unsigned char s[ECCref_MAX_LEN];	
   157  } ECCSignature;
   158  
   159  
   160  
   161  /*常量定义*/
   162  #define SGD_TRUE		0x00000001
   163  #define SGD_FALSE		0x00000000
   164  
   165  /*算法标识*/
   166  #define SGD_SM1_ECB		0x00000101
   167  #define SGD_SM1_CBC		0x00000102
   168  #define SGD_SM1_CFB		0x00000104
   169  #define SGD_SM1_OFB		0x00000108
   170  #define SGD_SM1_MAC		0x00000110
   171  #define SGD_SM1_CTR		0x00000120
   172  
   173  #define SGD_SSF33_ECB	0x00000201
   174  #define SGD_SSF33_CBC	0x00000202
   175  #define SGD_SSF33_CFB	0x00000204
   176  #define SGD_SSF33_OFB	0x00000208
   177  #define SGD_SSF33_MAC	0x00000210
   178  #define SGD_SSF33_CTR	0x00000220
   179  
   180  #define SGD_SMS4_ECB	0x00000401
   181  #define SGD_SMS4_CBC	0x00000402
   182  #define SGD_SMS4_CFB	0x00000404
   183  #define SGD_SMS4_OFB	0x00000408
   184  #define SGD_SMS4_MAC	0x00000410
   185  #define SGD_SMS4_CTR	0x00000420
   186  
   187  #define SGD_3DES_ECB	0x00000801
   188  #define SGD_3DES_CBC	0x00000802
   189  #define SGD_3DES_CFB	0x00000804
   190  #define SGD_3DES_OFB	0x00000808
   191  #define SGD_3DES_MAC	0x00000810
   192  #define SGD_3DES_CTR	0x00000820
   193  
   194  #define SGD_AES_ECB		0x00002001
   195  #define SGD_AES_CBC		0x00002002
   196  #define SGD_AES_CFB		0x00002004
   197  #define SGD_AES_OFB		0x00002008
   198  #define SGD_AES_MAC		0x00002010
   199  #define SGD_AES_CTR		0x00002020
   200  
   201  
   202  #define SGD_RSA			0x00010000
   203  #define SGD_RSA_SIGN	0x00010100
   204  #define SGD_RSA_ENC		0x00010200
   205  
   206  #define SGD_SM2 		0x00020100 
   207  #define SGD_SM2_1		0x00020200
   208  #define SGD_SM2_2		0x00020400
   209  #define SGD_SM2_3		0x00020800
   210  
   211  #define SGD_SM9         0x00100000
   212  #define SGD_SM9_1       0x00100100
   213  #define SGD_SM9_2       0x00100200
   214  #define SGD_SM9_3       0x00100400
   215  #define SGD_SM9_4       0x00100800
   216  
   217  #define SGD_SM3			0x00000001
   218  #define SGD_SHA1		0x00000002
   219  #define SGD_SHA256		0x00000004
   220  #define SGD_SHA512		0x00000008
   221  #define SGD_SHA384		0x00000010
   222  #define SGD_SHA224		0x00000020
   223  #define SGD_MD5			0x00000080
   224  
   225  
   226  
   227  #define SDR_OK				0x0
   228  #define SDR_BASE			0x01000000
   229  #define SDR_UNKNOWERR				(SDR_BASE + 0x00000001)
   230  #define SDR_NOTSUPPORT				(SDR_BASE + 0x00000002)
   231  #define SDR_COMMFAIL				(SDR_BASE + 0x00000003)
   232  #define SDR_HARDFAIL				(SDR_BASE + 0x00000004)
   233  #define SDR_OPENDEVICE				(SDR_BASE + 0x00000005)
   234  #define SDR_OPENSESSION				(SDR_BASE + 0x00000006)
   235  #define SDR_PARDENY					(SDR_BASE + 0x00000007)
   236  #define SDR_KEYNOTEXIST				(SDR_BASE + 0x00000008)
   237  #define SDR_ALGNOTSUPPORT			(SDR_BASE + 0x00000009)
   238  #define SDR_ALGMODNOTSUPPORT 		(SDR_BASE + 0x0000000A)
   239  #define SDR_PKOPERR					(SDR_BASE + 0x0000000B)
   240  #define SDR_SKOPERR					(SDR_BASE + 0x0000000C)
   241  #define SDR_SIGNERR					(SDR_BASE + 0x0000000D)
   242  #define SDR_VERIFYERR				(SDR_BASE + 0x0000000E)
   243  #define SDR_SYMOPERR				(SDR_BASE + 0x0000000F)
   244  #define SDR_STEPERR					(SDR_BASE + 0x00000010)
   245  #define SDR_FILESIZEERR				(SDR_BASE + 0x00000011)
   246  #define SDR_FILENOEXIST				(SDR_BASE + 0x00000012)
   247  #define SDR_FILEOFSERR				(SDR_BASE + 0x00000013)
   248  #define SDR_KEYTYPEERR				(SDR_BASE + 0x00000014)
   249  #define SDR_KEYERR					(SDR_BASE + 0x00000015)
   250  
   251  
   252  #define SWR_BASE				(SDR_BASE + 0x00010000)
   253  #define SWR_INVALID_USER		(SWR_BASE + 0x00000001)
   254  #define SWR_INVALID_AUTHENCODE	(SWR_BASE + 0x00000002)
   255  #define SWR_PROTOCOL_VER_ERR	(SWR_BASE + 0x00000003)
   256  #define SWR_INVALID_COMMAND		(SWR_BASE + 0x00000004)
   257  #define SWR_INVALID_PACKAGE		(SWR_BASE + 0x00000005)
   258  #define SWR_INVALID_PARAMETERS	(SWR_BASE + 0x00000005)
   259  #define SWR_FILE_ALREADY_EXIST	(SWR_BASE + 0x00000006)
   260  #define SWR_SOCKET_ERR_BASE		(SWR_BASE + 0x00000100)
   261  #define SWR_SOCKET_TIMEOUT		(SWR_BASE + 0x00000100)
   262  #define SWR_CONNECT_ERR			(SWR_BASE + 0x00000101)
   263  #define SWR_SET_SOCKOPT_ERR		(SWR_BASE + 0x00000102)
   264  #define SWR_SOCKET_SEND_ERR		(SWR_BASE + 0x00000104)
   265  #define SWR_SOCKET_RECV_ERR		(SWR_BASE + 0x00000105)
   266  #define SWR_SOCKET_RECV_0		(SWR_BASE + 0x00000106)
   267  #define SWR_NO_AVAILABLE_HSM	(SWR_BASE + 0x00000201)
   268  #define SWR_NO_AVAILABLE_CSM	(SWR_BASE + 0x00000202)
   269  #define SWR_CONFIG_ERR			(SWR_BASE + 0x00000301)
   270  #define SWR_CARD_BASE           (SDR_BASE + 0x00020000)
   271  #define SDR_BUFFER_TOO_SMALL	(SWR_CARD_BASE + 0x00000101)
   272  #define SDR_DATA_PAD			(SWR_CARD_BASE + 0x00000102)
   273  #define SDR_DATA_SIZE			(SWR_CARD_BASE + 0x00000103)
   274  #define SDR_CRYPTO_NOT_INIT		(SWR_CARD_BASE + 0x00000104)
   275  #define SWR_MANAGEMENT_DENY		(SWR_CARD_BASE + 0x00001001)
   276  #define SWR_OPERATION_DENY		(SWR_CARD_BASE + 0x00001002)
   277  #define SWR_DEVICE_STATUS_ERR   (SWR_CARD_BASE + 0x00001003)
   278  #define SWR_LOGIN_ERR           1     (SWR_CARD_BASE + 0x00001011)
   279  #define SWR_USERID_ERR          (SWR_CARD_BASE + 0x00001012)
   280  #define SWR_PARAMENT_ERR         (SWR_CARD_BASE + 0x00001013)
   281  #define SWR_KEYTYPEERR			(SWR_CARD_BASE + 0x00000020)
   282  
   283  //设备管理类函数
   284  //1. 打开设备
   285  SGD_RV SDF_OpenDevice(SGD_HANDLE *phDeviceHandle);
   286  //2. 关闭设备
   287  SGD_RV SDF_CloseDevice(SGD_HANDLE hDeviceHandle);
   288  //3. 创建会话
   289  SGD_RV SDF_OpenSession(SGD_HANDLE hDeviceHandle, SGD_HANDLE *phSessionHandle);
   290  //4. 关闭会话
   291  SGD_RV SDF_CloseSession(SGD_HANDLE hSessionHandle);
   292  //5. 获取设备信息
   293  SGD_RV SDF_GetDeviceInfo(SGD_HANDLE hSessionHandle, DEVICEINFO *pstDeviceInfo);
   294  //6. 产生随机数
   295  SGD_RV SDF_GenerateRandom(SGD_HANDLE hSessionHandle, SGD_UINT32  uiLength, SGD_UCHAR *pucRandom);
   296  //7. 获取私钥使用权限
   297  SGD_RV SDF_GetPrivateKeyAccessRight(SGD_HANDLE hSessionHandle, SGD_UINT32 uiKeyIndex,SGD_UCHAR *pucPassword, SGD_UINT32  uiPwdLength);
   298  //8. 释放私钥使用权限
   299  SGD_RV SDF_ReleasePrivateKeyAccessRight(SGD_HANDLE hSessionHandle, SGD_UINT32  uiKeyIndex);
   300  
   301  //密钥管理类函数
   302  //9. 导出RSA签名公钥
   303  SGD_RV SDF_ExportSignPublicKey_RSA(SGD_HANDLE hSessionHandle, SGD_UINT32  uiKeyIndex,RSArefPublicKey *pucPublicKey);
   304  //10. 导出RSA加密公钥
   305  SGD_RV SDF_ExportEncPublicKey_RSA(SGD_HANDLE hSessionHandle, SGD_UINT32  uiKeyIndex,RSArefPublicKey *pucPublicKey);
   306  //11. 产生RSA非对称密钥对并输出
   307  SGD_RV SDF_GenerateKeyPair_RSA(SGD_HANDLE hSessionHandle, SGD_UINT32  uiKeyBits,RSArefPublicKey *pucPublicKey,RSArefPrivateKey *pucPrivateKey); //ok
   308  //12. 生成会话密钥并用内部RSA公钥加密输出
   309  SGD_RV SDF_GenerateKeyWithIPK_RSA(SGD_HANDLE hSessionHandle, SGD_UINT32 uiIPKIndex,SGD_UINT32 uiKeyBits,SGD_UCHAR *pucKey,SGD_UINT32 *puiKeyLength,SGD_HANDLE *phKeyHandle);
   310  //13. 生成会话密钥并用外部RSA公钥加密输出
   311  SGD_RV SDF_GenerateKeyWithEPK_RSA(SGD_HANDLE hSessionHandle, SGD_UINT32 uiKeyBits,RSArefPublicKey *pucPublicKey,SGD_UCHAR *pucKey,SGD_UINT32 *puiKeyLength,SGD_HANDLE *phKeyHandle);
   312  //14. 导入会话密钥并用内部RSA私钥解密
   313  SGD_RV SDF_ImportKeyWithISK_RSA(SGD_HANDLE hSessionHandle, SGD_UINT32 uiISKIndex,SGD_UCHAR *pucKey,SGD_UINT32 uiKeyLength,SGD_HANDLE *phKeyHandle);
   314  //15. 基于RSA算法的数字信封转换
   315  SGD_RV SDF_ExchangeDigitEnvelopeBaseOnRSA(SGD_HANDLE hSessionHandle, SGD_UINT32  uiKeyIndex,RSArefPublicKey *pucPublicKey,SGD_UCHAR *pucDEInput,SGD_UINT32  uiDELength,SGD_UCHAR *pucDEOutput,SGD_UINT32  *puiDELength);
   316  //16. 导出ECC签名公钥
   317  SGD_RV SDF_ExportSignPublicKey_ECC(SGD_HANDLE hSessionHandle, SGD_UINT32  uiKeyIndex,ECCrefPublicKey *pucPublicKey);
   318  //17. 导出ECC加密公钥
   319  SGD_RV SDF_ExportEncPublicKey_ECC(SGD_HANDLE hSessionHandle, SGD_UINT32  uiKeyIndex,ECCrefPublicKey *pucPublicKey);
   320  //18. 产生ECC非对称密钥对并输出
   321  SGD_RV SDF_GenerateKeyPair_ECC(SGD_HANDLE hSessionHandle, SGD_UINT32  uiAlgID,SGD_UINT32  uiKeyBits,ECCrefPublicKey *pucPublicKey,ECCrefPrivateKey *pucPrivateKey);
   322  //19. 生成会话密钥并用内部ECC公钥加密输出
   323  SGD_RV SDF_GenerateKeyWithIPK_ECC (SGD_HANDLE hSessionHandle, SGD_UINT32 uiIPKIndex,SGD_UINT32 uiKeyBits,ECCCipher *pucKey,SGD_HANDLE *phKeyHandle);
   324  //20. 生成会话密钥并用外部ECC公钥加密输出
   325  SGD_RV SDF_GenerateKeyWithEPK_ECC (SGD_HANDLE hSessionHandle, SGD_UINT32 uiKeyBits,SGD_UINT32  uiAlgID,ECCrefPublicKey *pucPublicKey,ECCCipher *pucKey,SGD_HANDLE *phKeyHandle);
   326  //21. 导入会话密钥并用内部ECC私钥解密
   327  SGD_RV SDF_ImportKeyWithISK_ECC (SGD_HANDLE hSessionHandle,SGD_UINT32 uiISKIndex,ECCCipher *pucKey,SGD_HANDLE *phKeyHandle);
   328  //22. 生成密钥协商参数并输出
   329  SGD_RV SDF_GenerateAgreementDataWithECC (SGD_HANDLE hSessionHandle, SGD_UINT32 uiISKIndex,SGD_UINT32 uiKeyBits,SGD_UCHAR *pucSponsorID,SGD_UINT32 uiSponsorIDLength,ECCrefPublicKey  *pucSponsorPublicKey,ECCrefPublicKey  *pucSponsorTmpPublicKey,SGD_HANDLE *phAgreementHandle);
   330  //23. 计算会话密钥
   331  SGD_RV SDF_GenerateKeyWithECC (SGD_HANDLE hSessionHandle, SGD_UCHAR *pucResponseID,SGD_UINT32 uiResponseIDLength,ECCrefPublicKey *pucResponsePublicKey,ECCrefPublicKey *pucResponseTmpPublicKey,SGD_HANDLE hAgreementHandle,SGD_HANDLE *phKeyHandle);
   332  //24. 产生协商数据并计算会话密钥
   333  SGD_RV SDF_GenerateAgreementDataAndKeyWithECC (SGD_HANDLE hSessionHandle, SGD_UINT32 uiISKIndex,SGD_UINT32 uiKeyBits,SGD_UCHAR *pucResponseID,SGD_UINT32 uiResponseIDLength,SGD_UCHAR *pucSponsorID,SGD_UINT32 uiSponsorIDLength,ECCrefPublicKey *pucSponsorPublicKey,ECCrefPublicKey *pucSponsorTmpPublicKey,ECCrefPublicKey  *pucResponsePublicKey,	ECCrefPublicKey  *pucResponseTmpPublicKey,SGD_HANDLE *phKeyHandle);
   334  //25. 基于 ECC算法的数字信封转换
   335  SGD_RV SDF_ExchangeDigitEnvelopeBaseOnECC(SGD_HANDLE hSessionHandle, SGD_UINT32  uiKeyIndex,SGD_UINT32  uiAlgID,ECCrefPublicKey *pucPublicKey,ECCCipher *pucEncDataIn,ECCCipher *pucEncDataOut);
   336  //26. 生成会话密钥并用密钥加密密钥加密输出
   337  SGD_RV SDF_GenerateKeyWithKEK(SGD_HANDLE hSessionHandle, SGD_UINT32 uiKeyBits,SGD_UINT32  uiAlgID,SGD_UINT32 uiKEKIndex, SGD_UCHAR *pucKey, SGD_UINT32 *puiKeyLength, SGD_HANDLE *phKeyHandle);
   338  //27. 导入会话密钥并用密钥加密密钥解密
   339  SGD_RV SDF_ImportKeyWithKEK(SGD_HANDLE hSessionHandle, SGD_UINT32  uiAlgID,SGD_UINT32 uiKEKIndex, SGD_UCHAR *pucKey, SGD_UINT32 uiKeyLength, SGD_HANDLE *phKeyHandle);
   340  //28. 导入明文会话密钥
   341  SGD_RV SDF_ImportKey(SGD_HANDLE hSessionHandle, SGD_UCHAR *pucKey, SGD_UINT32 uiKeyLength,SGD_HANDLE *phKeyHandle);
   342  //29. 销毁会话密钥
   343  SGD_RV SDF_DestroyKey(SGD_HANDLE hSessionHandle, SGD_HANDLE hKeyHandle);
   344  
   345  //非对称算法运算类函数
   346  //30. 外部公钥RSA运算
   347  SGD_RV SDF_ExternalPublicKeyOperation_RSA(SGD_HANDLE hSessionHandle, RSArefPublicKey *pucPublicKey,SGD_UCHAR *pucDataInput,SGD_UINT32  uiInputLength,SGD_UCHAR *pucDataOutput,SGD_UINT32  *puiOutputLength);
   348  //31. 外部私钥RSA运算
   349  SGD_RV SDF_ExternalPrivateKeyOperation_RSA(SGD_HANDLE hSessionHandle, RSArefPrivateKey *pucPrivateKey,SGD_UCHAR *pucDataInput,SGD_UINT32  uiInputLength,SGD_UCHAR *pucDataOutput,SGD_UINT32  *puiOutputLength);
   350  //32. 内部公钥RSA运算
   351  SGD_RV SDF_InternalPublicKeyOperation_RSA(SGD_HANDLE hSessionHandle,SGD_UINT32  uiKeyIndex,SGD_UCHAR *pucDataInput,SGD_UINT32  uiInputLength,SGD_UCHAR *pucDataOutput,SGD_UINT32  *puiOutputLength);
   352  //33. 内部私RSA运算
   353  SGD_RV SDF_InternalPrivateKeyOperation_RSA(SGD_HANDLE hSessionHandle,SGD_UINT32  uiKeyIndex,SGD_UCHAR *pucDataInput,SGD_UINT32  uiInputLength,SGD_UCHAR *pucDataOutput,SGD_UINT32  *puiOutputLength);
   354  //34. 外部密钥ECC签名
   355  SGD_RV SDF_ExternalSign_ECC(SGD_HANDLE hSessionHandle,SGD_UINT32 uiAlgID,ECCrefPrivateKey *pucPrivateKey,SGD_UCHAR *pucData,SGD_UINT32  uiDataLength,ECCSignature *pucSignature);
   356  //35. 外部密钥ECC验证
   357  SGD_RV SDF_ExternalVerify_ECC(SGD_HANDLE hSessionHandle,SGD_UINT32 uiAlgID,ECCrefPublicKey *pucPublicKey,SGD_UCHAR *pucDataInput,SGD_UINT32  uiInputLength,ECCSignature *pucSignature);
   358  //36. 内部密钥ECC签名
   359  SGD_RV SDF_InternalSign_ECC(SGD_HANDLE hSessionHandle,SGD_UINT32  uiISKIndex,SGD_UCHAR *pucData,SGD_UINT32  uiDataLength,ECCSignature *pucSignature);
   360  //37. 内部密钥ECC验证
   361  SGD_RV SDF_InternalVerify_ECC(SGD_HANDLE hSessionHandle,SGD_UINT32  uiISKIndex,SGD_UCHAR *pucData,SGD_UINT32  uiDataLength,ECCSignature *pucSignature);
   362  //38. 外部密钥ECC加密
   363  SGD_RV SDF_ExternalEncrypt_ECC(SGD_HANDLE hSessionHandle,SGD_UINT32 uiAlgID,ECCrefPublicKey *pucPublicKey,SGD_UCHAR *pucData,SGD_UINT32  uiDataLength,ECCCipher *pucEncData);
   364  //39. 外部密钥ECC解密
   365  SGD_RV SDF_ExternalDecrypt_ECC(SGD_HANDLE hSessionHandle,SGD_UINT32 uiAlgID,ECCrefPrivateKey *pucPrivateKey,ECCCipher *pucEncData,SGD_UCHAR *pucData,SGD_UINT32  *puiDataLength);
   366  
   367  //对称算法运算类函数
   368  //40. 对称加密
   369  SGD_RV SDF_Encrypt(SGD_HANDLE hSessionHandle,SGD_HANDLE hKeyHandle,SGD_UINT32 uiAlgID,SGD_UCHAR *pucIV,SGD_UCHAR *pucData,SGD_UINT32 uiDataLength,SGD_UCHAR *pucEncData,SGD_UINT32  *puiEncDataLength);
   370  //41. 对称解密
   371  SGD_RV SDF_Decrypt (SGD_HANDLE hSessionHandle,SGD_HANDLE hKeyHandle,SGD_UINT32 uiAlgID,SGD_UCHAR *pucIV,SGD_UCHAR *pucEncData,SGD_UINT32  uiEncDataLength,SGD_UCHAR *pucData,SGD_UINT32 *puiDataLength);
   372  //42. 计算MAC
   373  SGD_RV SDF_CalculateMAC(SGD_HANDLE hSessionHandle,SGD_HANDLE hKeyHandle,SGD_UINT32 uiAlgID,SGD_UCHAR *pucIV,SGD_UCHAR *pucData,SGD_UINT32 uiDataLength,SGD_UCHAR *pucMAC,SGD_UINT32  *puiMACLength);
   374  
   375  //杂凑运算类函数
   376  //43. 杂凑运算初始化
   377  SGD_RV SDF_HashInit(SGD_HANDLE hSessionHandle,SGD_UINT32 uiAlgID,ECCrefPublicKey *pucPublicKey,SGD_UCHAR *pucID,SGD_UINT32 uiIDLength);
   378  //44. 多包杂凑运算
   379  SGD_RV SDF_HashUpdate(SGD_HANDLE hSessionHandle,SGD_UCHAR *pucData,SGD_UINT32  uiDataLength);
   380  //45. 杂凑运算结束
   381  SGD_RV SDF_HashFinal(SGD_HANDLE hSessionHandle,SGD_UCHAR *pucHash,SGD_UINT32  *puiHashLength);
   382  
   383  //用户文件操作类函数
   384  //46. 创建文件
   385  SGD_RV SDF_CreateFile(SGD_HANDLE hSessionHandle,SGD_UCHAR *pucFileName,SGD_UINT32 uiNameLen,SGD_UINT32 uiFileSize);
   386  //47. 读取文件
   387  SGD_RV SDF_ReadFile(SGD_HANDLE hSessionHandle,SGD_UCHAR *pucFileName,SGD_UINT32 uiNameLen,SGD_UINT32 uiOffset,SGD_UINT32 *puiReadLength,SGD_UCHAR *pucBuffer);
   388  //48. 写文件
   389  SGD_RV SDF_WriteFile(SGD_HANDLE hSessionHandle,SGD_UCHAR *pucFileName,SGD_UINT32 uiNameLen,SGD_UINT32 uiOffset,SGD_UINT32 uiWriteLength,SGD_UCHAR *pucBuffer);
   390  //49. 删除文件
   391  SGD_RV SDF_DeleteFile(SGD_HANDLE hSessionHandle,SGD_UCHAR *pucFileName,SGD_UINT32 uiNameLen);
   392  
   393  #ifdef __cplusplus
   394  }
   395  #endif
   396  
   397  #endif /*#ifndef _SW_SDS_H_*/