增加大数据裸签功能,完善RSA签名功能接口(修改counthash使用)

This commit is contained in:
yihzhou
2022-12-15 17:26:22 +08:00
parent 85ef86ee49
commit 54e636dd4f
8 changed files with 393 additions and 283 deletions
+103 -99
View File
@@ -1,120 +1,124 @@
<?xml version="1.0" encoding="UTF-8" ?>
<packet extend="base">
<req>
<req>
<command>
<bin>8003</bin>
</command>
<data extend="data">
<rFlag len="1" required="false" cn="RSA标志">
可选,存在,则固定值为‘P’
</rFlag>
<signatureDataType len="1" cn="获取公私钥标记位">
<options>
<option cn="索引方式">
<bin>00</bin>
</option>
<option cn="DN 方式">
<bin>01</bin>
</option>
</options>
</signatureDataType>
<command>
<bin>8003</bin>
</command>
<data extend="data">
<signatureDataType len="1" cn="获取公私钥标记位">
<options>
<option cn="索引方式">
<bin>00</bin>
</option>
<option cn="DN 方式">
<bin>01</bin>
</option>
</options>
</signatureDataType>
<DN cn="DN 或 DN索引">
若上面的标志为1,则此域为证书DN,若为0,则此域为两个字节的证书索引;
</DN>
<DN cn="DN 或 DN索引">
若上面的标志为1,则此域为证书DN,若为0,则此域为两个字节的证书索引;
</DN>
<dataLength len="2" :value="dataLen()" cn="待签名数据长度">
待签名数据长度
</dataLength>
<hashFlag len="1" :if="null != $packet.data.hash" cn="外部 hash 标记">
<text>P</text>
</hashFlag>
<signData cn="待签名数据">
待签名数据
</signData>
<hash len="32" :if="null != $packet.data.hash" cn="外部 hash">
</hash>
</data>
<dataLength len="2" :value="dataLen()" :if="null == $packet.data.hash" cn="待签名数据长度">
待签名数据长度
</dataLength>
<signData cn="待签名数据" :if="null == $packet.data.hash">
待签名数据
</signData>
</data>
</req>
<res>
</req>
<res>
<command>
<bin>8004</bin>
</command>
<data>
<error len="2" cn="错误码" format="X" :catch="catchError('%s')">
<options>
<option cn="无错误">
<hex>00</hex>
</option>
<option cn="无效的私钥类型">
<hex>03</hex>
</option>
<option cn="无效私钥标记">
<hex>04</hex>
</option>
<option cn="无效的哈希标识">
<hex>05</hex>
</option>
<option cn="无效的签名标识">
<hex>06</hex>
</option>
<option cn="无效的附加标识">
<hex>07</hex>
</option>
<option cn="LMK 错误">
LMK 错误;报告给管理员。
<hex>13</hex>
</option>
<option cn="输入数据错">
<hex>15</hex>
</option>
<option cn="DSP 错误">
DSP 错误;报告给管理员。
<hex>47</hex>
</option>
<option cn="私钥错误">
私钥错误;报告给管理员。
<hex>49</hex>
</option>
<option cn="无效摘要信息语法(仅仅无哈希模式)">
<hex>74</hex>
</option>
<option cn="公钥长度错误">
<hex>76</hex>
</option>
<option cn="私钥长度错误">
<hex>78</hex>
</option>
<option cn="输入数据长度错误">
<hex>80</hex>
</option>
</options>
</error>
<command>
<bin>8004</bin>
</command>
<data>
<error len="2" cn="错误码" format="X" :catch="catchError('%s')">
<options>
<option cn="无错误">
<hex>00</hex>
</option>
<option cn="无效的私钥类型">
<hex>03</hex>
</option>
<option cn="无效私钥标记">
<hex>04</hex>
</option>
<option cn="无效的哈希标识">
<hex>05</hex>
</option>
<option cn="无效的签名标识">
<hex>06</hex>
</option>
<option cn="无效的附加标识">
<hex>07</hex>
</option>
<option cn="LMK 错误">
LMK 错误;报告给管理员。
<hex>13</hex>
</option>
<option cn="输入数据错">
<hex>15</hex>
</option>
<option cn="DSP 错误">
DSP 错误;报告给管理员。
<hex>47</hex>
</option>
<option cn="私钥错误">
私钥错误;报告给管理员。
<hex>49</hex>
</option>
<option cn="无效摘要信息语法(仅仅无哈希模式)">
<hex>74</hex>
</option>
<option cn="公钥长度错误">
<hex>76</hex>
</option>
<option cn="私钥长度错误">
<hex>78</hex>
</option>
<option cn="输入数据长度错误">
<hex>80</hex>
</option>
</options>
</error>
<signatureLen len="2" cn="签名的字节长度">
签名的字节长度
</signatureLen>
<signatureLen len="2" cn="签名的字节长度">
签名的字节长度
</signatureLen>
<signature :len="signatureLen()" cn="签名的 DER 编码">
签名的 DER 编码
</signature>
<signature :len="signatureLen()" cn="签名的 DER 编码">
签名的 DER 编码
</signature>
<tailSep len="1" required="false" cn="尾分隔">
可选项。如果显示消息尾域,则该域必须显示。值为 “X’19”。
<hex>19</hex>
</tailSep>
<tailSep len="1" required="false" cn="尾分隔">
可选项。如果显示消息尾域,则该域必须显示。值为 “X’19”。
<hex>19</hex>
</tailSep>
<tail maxLen="32" required="false" cn="尾部">
可选项。最大长度为 32个字符。
</tail>
</data>
<tail maxLen="32" required="false" cn="尾部">
可选项。最大长度为 32个字符。
</tail>
</data>
</res>
<script type="javascript"><![CDATA[
</res>
<script type="javascript"><![CDATA[
function dataLen(){
def len = $packet.data.signData.length
def ret = new byte[2]
+112 -109
View File
@@ -1,134 +1,137 @@
<?xml version="1.0" encoding="UTF-8" ?>
<packet extend="base">
<req>
<req>
<command>
<bin>8004</bin>
</command>
<data extend="data">
<rFlag len="1" required="false" cn="RSA标志">
可选,存在,则固定值为‘P’
</rFlag>
<signatureDataType len="1" cn="获取公私钥标记位">
<options>
<option cn="索引方式">
<bin>00</bin>
</option>
<option cn="DN 方式">
<bin>01</bin>
</option>
<option cn="通过机构号获取">
<bin>02</bin>
</option>
</options>
</signatureDataType>
<command>
<bin>8004</bin>
</command>
<data extend="data">
<signatureDataType len="1" cn="获取公私钥标记位">
<options>
<option cn="索引方式">
<bin>00</bin>
</option>
<option cn="DN 方式">
<bin>01</bin>
</option>
<option cn="通过机构号获取">
<bin>02</bin>
</option>
</options>
</signatureDataType>
<DN :if="useDN()" cn="DN 或 DN索引">
若上面的标志为1,则此域为证书DN,若为0,则此域为两个字节的证书索引;若为2,该域不存在
</DN>
<DN :if="useDN()" cn="DN 或 DN索引">
若上面的标志为1,则此域为证书DN,若为0,则此域为两个字节的证书索引;若为2,该域不存在
</DN>
<organizationNumLen len="2" :if="useOrganization()" :value="bNumberLength()" cn="机构号长度">
标志为2 时存在
</organizationNumLen>
<organizationNumLen len="2" :if="useOrganization()" :value="bNumberLength()" cn="机构号长度">
标志为2 时存在
</organizationNumLen>
<organizationNum :if="useOrganization()" cn="机构号内容">
标志为2 时存在
</organizationNum>
<organizationNum :if="useOrganization()" cn="机构号内容">
标志为2 时存在
</organizationNum>
<hashFlag len="1" :if="null != $packet.data.hash" cn="外部 hash 标记">
<text>P</text>
</hashFlag>
<dataLength len="2" :value="dataLen()" cn="待签名数据长度">
待签名数据长度
</dataLength>
<hash len="32" :if="null != $packet.data.hash" cn="外部 hash">
</hash>
<odata cn="待签名数据">
待签名数据
</odata>
<dataLength len="2" :if="null == $packet.data.hash" :value="dataLen()" cn="待签名数据长度">
待签名数据长度
</dataLength>
<signatureLen len="2" :value="signLen()" cn="签名的字节长度">
签名的字节长度
</signatureLen>
<odata cn="待签名数据" :if="null == $packet.data.hash">
待签名数据
</odata>
<signature :len="signatureLen()" cn="已签名数据">
待验签的已签名数据,若为RSA签名则为相应长度的签名数据,若为SM2签名,则前半部分为R.后面半部分为S;
</signature>
<signatureLen len="2" :value="signLen()" cn="签名的字节长度">
签名的字节长度
</signatureLen>
<returnSign len="2" cn="返回证书信息标志">
<options>
<option cn="不返回">
<bin>0000</bin>
</option>
<option cn="返回">
<bin>0001</bin>
</option>
</options>
</returnSign>
</data>
<signature :len="signatureLen()" cn="已签名数据">
待验签的已签名数据,若为RSA签名则为相应长度的签名数据,若为SM2签名,则前半部分为R.后面半部分为S;
</signature>
<returnSign len="2" cn="返回证书信息标志">
<options>
<option cn="不返回">
<bin>0000</bin>
</option>
<option cn="返回">
<bin>0001</bin>
</option>
</options>
</returnSign>
</data>
</req>
<res>
</req>
<res>
<command>
<bin>8005</bin>
</command>
<data>
<error len="2" cn="错误码" format="X" :catch="catchError('%s')">
<options>
<option cn="无错误">
<hex>00</hex>
</option>
<option cn="公钥不符合编码规则">
<hex>04</hex>
</option>
<option cn="无效的加密标识">
<hex>06</hex>
</option>
<option cn="无效的附加模式标识">
<hex>07</hex>
</option>
<option cn="密钥奇偶校验错误">
<hex>10</hex>
</option>
<option cn="LMK 错误">
LMK 错误;报告给管理员。
<hex>13</hex>
</option>
<option cn="输入数据错">
<hex>15</hex>
</option>
<option cn="DSP 错误">
DSP 错误;报告给管理员。
<hex>47</hex>
</option>
<option cn="私钥错误">
私钥错误;报告给管理员。
<hex>49</hex>
</option>
<option cn="密钥块长度错误">
<hex>76</hex>
</option>
<option cn="输入数据长度错误">
<hex>80</hex>
</option>
</options>
</error>
<command>
<bin>8005</bin>
</command>
<data>
<error len="2" cn="错误码" format="X" :catch="catchError('%s')">
<options>
<option cn="无错误">
<hex>00</hex>
</option>
<option cn="公钥不符合编码规则">
<hex>04</hex>
</option>
<option cn="无效的加密标识">
<hex>06</hex>
</option>
<option cn="无效的附加模式标识">
<hex>07</hex>
</option>
<option cn="密钥奇偶校验错误">
<hex>10</hex>
</option>
<option cn="LMK 错误">
LMK 错误;报告给管理员。
<hex>13</hex>
</option>
<option cn="输入数据错">
<hex>15</hex>
</option>
<option cn="DSP 错误">
DSP 错误;报告给管理员。
<hex>47</hex>
</option>
<option cn="私钥错误">
私钥错误;报告给管理员。
<hex>49</hex>
</option>
<option cn="密钥块长度错误">
<hex>76</hex>
</option>
<option cn="输入数据长度错误">
<hex>80</hex>
</option>
</options>
</error>
<infoLen len="2" cn="信息长度" :if="0 != $packet.data.returnSign$option">
信息长度
</infoLen>
<infoLen len="2" cn="信息长度" :if="0 != $packet.data.returnSign$option">
信息长度
</infoLen>
<info :len="getInfoLen()" cn="信息" :if="0 != $packet.data.returnSign$option">
若发送报文返回证书信息标志位为0,则返回一段垃圾数据,可以不用管
若发送报文返回证书信息标志位为1,则返回 CERT_INFO 结构的证书数据
</info>
<info :len="getInfoLen()" cn="信息" :if="0 != $packet.data.returnSign$option">
若发送报文返回证书信息标志位为0,则返回一段垃圾数据,可以不用管
若发送报文返回证书信息标志位为1,则返回 CERT_INFO 结构的证书数据
</info>
</data>
</data>
</res>
<script><![CDATA[
</res>
<script><![CDATA[
function dataLen(){
def len = $packet.data.odata.length
def ret = new byte[2]