添加6A、6B关于P7的数字信封

This commit is contained in:
zb
2022-04-12 20:54:20 +08:00
parent b20bb8f2b0
commit b4bdf191de
9 changed files with 458 additions and 68 deletions
+17 -5
View File
@@ -17,6 +17,9 @@
<option cn="SM2_SM4_ECB 机构码|02|密钥">
<hex>2</hex>
</option>
<option cn="PKCS7_SM2_SM4_ECB">
<hex>3</hex>
</option>
</options>
</alg>
@@ -49,6 +52,14 @@
可选项,只针对“证书模式”为 1时有。
</certificateDn>
<orgDataLen len="4" :value="dataLen()" :if="3 == $packet.data.alg$option" cn="数据长度">
只针对算法标识为3时传入
</orgDataLen>
<orgData :if="3 == $packet.data.alg$option" cn="数据长度">
只针对算法标识为3时传入
</orgData>
<keyType len="1" cn="加密密钥方案">
LMK 下加密密钥的方案。
</keyType>
@@ -72,11 +83,10 @@
</tail>
</data>
</req>
<res>
<res>
<command>
<hex>6B</hex>
</command>
@@ -162,12 +172,10 @@
}
}
function getKeyLen() {
return Util.a2i( $final.getSection('data').getSection('keyLen') )
}
function lmkLen() {
if( Arrays.equals("L".getBytes(),
$final.getSection('data').getSection('lmkHead').getValue()
@@ -178,6 +186,10 @@
}
}
function dataLen() {
return $packet.data.orgData.length()
}
<![CDATA[
function hasOrgCode() {
if(2 == $packet.data.alg$option && 'P' == $packet.data.pFlag) {
+16 -2
View File
@@ -7,6 +7,10 @@
</command>
<data extend="data">
<pFlag len="1" required="false" cn="P标志">
可选,如果输入P代表使用PKCS7_SM2_SM4_ECB模式解密数字信封
</pFlag>
<certificateModel len="1" cn="证书模式">
<options>
<option cn="证书序号">
@@ -55,8 +59,6 @@
</tail>
</data>
</req>
<res>
@@ -104,6 +106,14 @@
</options>
</error>
<oDataLen len="4" cn="明文数据长度">
明文原始数据长度(只针对P存在时,无P时为0)
</oDataLen>
<oData :len="oDataLen()" cn="明文数据">
原始数据(只针对P存在时,无P时不存在)
</oData>
<!--<keyLen len="4" cn="密钥密文长度">-->
<!--公钥加密的密钥密文长度-->
<!--</keyLen>-->
@@ -173,5 +183,9 @@
function orgCodeLen() {
return Util.a2i( $final.getSection('data').getSection('orgCodeLen') )
}
function oDataLen() {
return Util.a2i( $final.getSection('data').getSection('oDataLen') )
}
</script>
</packet>
+191
View File
@@ -0,0 +1,191 @@
<?xml version="1.0" encoding="UTF-8" ?>
<packet extend="base">
<req>
<command>
<hex>6B</hex>
</command>
<data extend="data">
<pFlag len="1" required="false" cn="P标志">
可选,如果输入P代表使用PKCS7_SM2_SM4_ECB模式解密数字信封
</pFlag>
<certificateModel len="1" cn="证书模式">
<options>
<option cn="证书序号">
<hex>0</hex>
</option>
<option cn="证书 DN">
<hex>1</hex>
</option>
</options>
</certificateModel>
<certificateLen len="4" :value="certificateLen()" cn="证书内容长度">
根据证书模式,需要输入内容项的长度 n
</certificateLen>
<certificateSn :len="strlen()" :if="0 == $packet.data.certificateModel$option" cn="X509 证书序号">
可选项,只针对“证书模式”为 0时有。
</certificateSn>
<certificateDn :if="1 == $packet.data.certificateModel$option" cn="X509 证书的 subject">
可选项,只针对“证书模式”为 1时有。
</certificateDn>
<keyLen len="4" :value="keyLen()" cn="密钥密文长度">
公钥加密的密钥密文长度
</keyLen>
<key :len="getKeyLen()" cn="密钥密文">
公钥加密的密钥密文的 BASE64 编码
</key>
<keyType len="1" cn="加密密钥方案">
LMK 下加密密钥的方案。
</keyType>
<tailSep len="1" :if=" null != $packet.data.tail " cn="尾分隔">
可选项。如果显示消息尾域,则该域必须显示。值为
“X’19”。
<hex>19</hex>
</tailSep>
<tail maxLen="32" required="false" cn="尾部">
可选项。最大长度为 32个字符。
</tail>
</data>
</req>
<res>
<command>
<hex>6C</hex>
</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="输入的数据格式错误">
<hex>21</hex>
</option>
<option cn="DSP 错误">
DSP 错误;报告给管理员。
<hex>47</hex>
</option>
<option cn="密钥块长度错误">
<hex>76</hex>
</option>
<option cn="输入数据长度错误">
<hex>80</hex>
</option>
</options>
</error>
<oDataLen len="4" cn="明文数据长度">
明文原始数据长度(只针对P存在时,无P时为0)
</oDataLen>
<oData :len="oDataLen()" cn="明文数据">
原始数据(只针对P存在时,无P时不存在)
</oData>
<!--<keyLen len="4" cn="密钥密文长度">-->
<!--公钥加密的密钥密文长度-->
<!--</keyLen>-->
<lmkHead len="1" cn="lmk 头">
如果是 'L' ,lmk 32 个字节长,否则 lmk 64 个字节长。
</lmkHead>
<lmk :len="lmkLen()" cn="对称密钥的密文">
对称密钥的密文,由 LMK30-31 保护。
</lmk>
<keyCheck len="16" cn="密钥校验值">
密钥校验值
</keyCheck>
<orgCodeLen len="4" cn="机构码长度">
公钥加密的密钥格式3所需机构码长度,仅当格式3以及'P'存在时存在
</orgCodeLen>
<orgCode :len="orgCodeLen()" cn="机构码长度">
公钥加密的密钥格式3所需机构码长度,仅当格式3以及'P'存在时存在
</orgCode>
<tailSep len="1" required="false" cn="尾分隔">
可选项。如果显示消息尾域,则该域必须显示。值为 “X’19”。
<hex>19</hex>
</tailSep>
<tail maxLen="32" required="false" cn="尾部">
可选项。最大长度为 32个字符。
</tail>
</data>
</res>
<script>
function certificateLen(){
var data = $packet.data;
if( 0 == data.certificateModel$option ){
return data.certificateSn.length
}
if( 1 == data.certificateModel$option ){
return data.certificateDn.length
}
}
function keyLen() {
return $packet.data.key.length()
}
function getKeyLen() {
return Util.a2i( $final.getSection('data').getSection('keyLen') )
}
function lmkLen() {
if( Arrays.equals("L".getBytes(),
$final.getSection('data').getSection('lmkHead').getValue()
) ){
return 64
}else{
return 32
}
}
function orgCodeLen() {
return Util.a2i( $final.getSection('data').getSection('orgCodeLen') )
}
function oDataLen() {
return Util.a2i( $final.getSection('data').getSection('oDataLen') )
}
</script>
</packet>