鲲鹏社区首页
中文
注册
我要评分
文档获取效率
文档正确性
内容完整性
文档易理解
在线提单
论坛求助

非对称算法运算类

非对称算法运算类接口支持如下,接口定义符合GM/T 0018-2012标准,接口参数与返回值可参考标准文档,算法标识描述可参考GM/T 0006-2012。

int SDF_ExternalVerify_ECC(void *hSessionHandle, unsigned int uiAlgID, ECCrefPublicKey *pucPublicKey, unsigned char *pucDataInput, unsigned int uiInputLength, ECCSignature *pucSignature);
int SDF_InternalSign_ECC(void *hSessionHandle, unsigned int uiISKIndex, unsigned char *pucData, unsigned int uiDataLength, ECCSignature *pucSignature);
int SDF_InternalVerify_ECC(void *hSessionHandle, unsigned int uiISKIndex, unsigned char *pucData, unsigned int uiDataLength, ECCSignature *pucSignature);
int SDF_ExternalEncrypt_ECC(void *hSessionHandle, unsigned int uiAlgID, ECCrefPublicKey *pucPublicKey, unsigned char *pucData, unsigned int uiDataLength, ECCCipher *pucEncature);

自定义接口

  • 使用外部ECC公钥对ECC签名值进行验证运算。
    int SDF_ExternalSign_ECC(void *hSessionHandle, unsigned int uiAlgID, ECCrefPrivateKey *pucPrivateKey, unsigned char *pucData, unsigned int uiDataLength, ECCSignature *pucSignature);
    表1 参数说明

    参数

    描述

    hSessionHandle[in]

    与设备建立的会话句柄。

    uiAlgID[in]

    算法标识,指定使用的ECC算法,暂无限制。

    pucPrivateKey[in]

    外部ECC私钥结构,密钥长度不超过256bit。

    pucData[in]

    缓冲区指针,用于存放外部输入的数据。

    uiDataLength[in]

    输入的数据长度,固定32字节。

    pucSignature[out]

    缓冲区指针,用于存放输入的签名值。

    表2 返回值说明

    返回值

    说明

    0

    成功

    非0

    失败,返回错误码。

  • 使用外部ECC私钥对数据进行解密运算。
    int SDF_ExternalDecrypt_ECC(void *hSessionHandle, unsigned int uiAlgID, ECCrefPrivateKey *pucPrivateKey, ECCCipher *pucEncData, unsigned char *pucData, unsigned int *puiDataLength);
    表3 参数说明

    参数

    描述

    hSessionHandle[in]

    与设备建立的会话句柄。

    uiAlgID[in]

    算法标识,指定使用的ECC算法,暂无限制。

    pucPrivateKey[in]

    外部ECC私钥结构,密钥长度不超过256bit。

    pucEncData[in]

    缓冲区指针,用于存放外部输入的数据密文,数据长度不大于20K。

    pucData[out]

    缓冲区指针,用于存放解密结果。

    puiDataLength[out]

    输出的解密结果长度,输入值不大于500K。

    表4 返回值说明

    返回值

    说明

    0

    成功

    非0

    失败,返回错误码。

  • 使用内部ECC公钥对数据进行加密运算。
    int SDF_InternalEncrypt_ECC(void *hSessionHandle, unsigned int uiISKIndex, unsigned char *pucData, unsigned int uiDataLength, ECCCipher *pucEncData);
    表5 参数说明

    参数

    描述

    hSessionHandle[in]

    与设备建立的会话句柄。

    uiISKIndex[in]

    内部密钥索引值,范围0-1000。

    pucData[in]

    缓冲区指针,用于存放输入数据。

    uiDataLength[in]

    输入数据长度,不大于20K。

    pucEncData[out]

    缓冲区指针,用于存放输出的数据密文。

    表6 返回值说明

    返回值

    说明

    0

    成功

    非0

    失败,返回错误码。

  • 使用内部ECC私钥对数据进行解密运算。
    int SDF_InternalDecrypt_ECC(void *hSessionHandle, unsigned int uiISKIndex, unsigned int ECCKeyType, ECCCipher *pucEncData, unsigned char *pucData, unsigned int *puiDataLength);
    表7 参数说明

    参数

    描述

    hSessionHandle[in]

    与设备建立的会话句柄。

    uiISKIndex[in]

    内部密钥索引值,范围0-1000。

    ECCKeyType[in]

    内部密钥类型,SGD_SM2_3指定加密私钥,SGD_SM2_1指定签名私钥。

    pucEncData[in]

    缓冲区指针,用于存放外部输入的数据密文,数据长度不大于20K。

    pucData[out]

    缓冲区指针,用于存放解密结果。

    puiDataLength[out]

    输出的解密结果长度,输入值不大于500K。

    表8 返回值说明

    返回值

    说明

    0

    成功

    非0

    失败,返回错误码。

规格限制

  • 外部输入的ECC公钥长度当前仅支持256bit。
  • 签名验签输入数据为待签数据的杂凑值,长度限制为32字节。
  • 加解密数据长度不大于20K,解密结果长度不大于500K。