191 lines
5.9 KiB
XML
191 lines
5.9 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
||
<packet extend="base">
|
||
<req>
|
||
|
||
<command>
|
||
<hex>S2</hex>
|
||
</command>
|
||
<data extend="data">
|
||
<storageType len="1" cn="存储类型">
|
||
<options>
|
||
<option cn="使用内部密钥">
|
||
<hex>0</hex>
|
||
</option>
|
||
<option cn="使用外部密钥">
|
||
<hex>1</hex>
|
||
</option>
|
||
</options>
|
||
</storageType>
|
||
|
||
<keyLength len="4" :value="keyLen()" :if="1 == $packet.data.storageType$option" cn="外部密钥长度">
|
||
仅当存储类型为1时有效
|
||
密钥长度
|
||
</keyLength>
|
||
|
||
<key :if="1 == $packet.data.storageType$option" cn="外部密钥">
|
||
仅当存储类型为1时有效
|
||
密钥密文
|
||
</key>
|
||
|
||
<keyIndex len="27" :if="0 == $packet.data.storageType$option" cn="密钥索引">
|
||
仅当存储类型为0时有效
|
||
内部密钥索引, 接口层对外限制8位,通讯层限制27位,16位机构号+3位密钥类型+8位密钥索引号。前19位补0。
|
||
注意:后八位密钥索引不允许输入全0
|
||
</keyIndex>
|
||
|
||
<algorithmKey len="2" cn="算法类型">
|
||
当存储类型为0时:仅支持3DES-ECB(07)、3DES-CBC(08)
|
||
当存储类型为1时:仅支持3DES-ECB、3DES-CBC、HMAC-SHA256(14)
|
||
取值参考数据字典
|
||
</algorithmKey>
|
||
|
||
<iv len="8" :if="useCbc()" cn="IV 数据域">
|
||
仅当算法为3DES-CBC模式下有此域
|
||
</iv>
|
||
|
||
<keyScatterLevel len="1" cn="密钥分散级数">
|
||
密钥分散级数,0~3
|
||
</keyScatterLevel>
|
||
|
||
<scatterFactor1 len="16" :if="hasScatterFactor1()" cn="分散因子1">
|
||
仅当分散级数不为0时存在
|
||
</scatterFactor1>
|
||
|
||
<scatterFactor2 len="16" :if="hasScatterFactor2()" cn="分散因子2">
|
||
仅当分散级数不为0时存在
|
||
</scatterFactor2>
|
||
|
||
<scatterFactor3 len="16" :if="hasScatterFactor3()" cn="分散因子3">
|
||
仅当分散级数不为0时存在
|
||
</scatterFactor3>
|
||
|
||
<scatterAlgorithmKey1 len="2" :if="hasScatterFactor1()" cn="分散算法标识1">
|
||
仅当分散级数不为0时存在
|
||
分散算法标识,定义每一次分散的分散算法,数量与密钥分散级数一致
|
||
如果算法类型为3DES、AES,则支持算法:3DES、AES;
|
||
如果算法类型为SM1、SM4,则支持算法:SM1、SM4;
|
||
取值参考数据字典
|
||
</scatterAlgorithmKey1>
|
||
|
||
<scatterAlgorithmKey2 len="2" :if="hasScatterFactor2()" cn="分散算法标识2">
|
||
仅当分散级数不为0时存在,同上
|
||
</scatterAlgorithmKey2>
|
||
|
||
<scatterAlgorithmKey3 len="2" :if="hasScatterFactor3()" cn="分散算法标识3">
|
||
仅当分散级数不为0时存在,同上 向量
|
||
</scatterAlgorithmKey3>
|
||
|
||
<scatterAlgorithmVector1 :len="vectorLen()" :if="hasScatterFactor1()" cn="分散算法的初始向量1">
|
||
仅当分散级数不为0时存在
|
||
分散算法的初始向量,定义每一次分散的分散算法的初始向量,数量与分散级数一致
|
||
即使对应分散算法模式为ECB,也需要填充0x00,
|
||
填充数量和CBC模式保持一致,
|
||
3DES-ECB、3DES-CBC、DES-ECB、DES-CBC 为8B
|
||
SM1-ECB、SM1-CBC、SM4-ECB、SM4-CBC、
|
||
AES-ECB、AES-CBC 为16B
|
||
</scatterAlgorithmVector1>
|
||
|
||
<scatterAlgorithmVector2 :len="vectorLen()" :if="hasScatterFactor2()" cn="分散算法的初始向量2">
|
||
仅当分散级数不为0时存在,同上
|
||
</scatterAlgorithmVector2>
|
||
|
||
<scatterAlgorithmVector3 :len="vectorLen()" :if="hasScatterFactor3()" cn="分散算法的初始向量3">
|
||
仅当分散级数不为0时存在,同上
|
||
</scatterAlgorithmVector3>
|
||
|
||
<inputDataLen len="4" :value="inputDataLen()" cn="数据长度">
|
||
输入数据长度
|
||
</inputDataLen>
|
||
|
||
<inputData cn="输入数据">
|
||
输入数据
|
||
</inputData>
|
||
|
||
<macLen len="2" cn="需要的MAC长度">
|
||
需要的MAC数据长度
|
||
</macLen>
|
||
</data>
|
||
|
||
</req>
|
||
<res>
|
||
|
||
<command>
|
||
<hex>S3</hex>
|
||
</command>
|
||
<data>
|
||
<error len="2" cn="错误码" format="X" :catch="catchError('%s')">
|
||
<options>
|
||
<option cn="无错误">
|
||
<hex>00</hex>
|
||
</option>
|
||
</options>
|
||
</error>
|
||
|
||
<mac :len="getMacLen()" cn="MAC数据">
|
||
输出的MAC数据
|
||
</mac>
|
||
</data>
|
||
|
||
</res>
|
||
<script>
|
||
function keyLen() {
|
||
return $packet.data.key.length;
|
||
}
|
||
|
||
function useCbc(){
|
||
var algorithmKey = $packet.data.algorithmKey
|
||
if( 8==algorithmKey){
|
||
return true;
|
||
}else{
|
||
return false;
|
||
}
|
||
}
|
||
|
||
function inputDataLen(){
|
||
var data = $packet.data;
|
||
return data.inputData.length;
|
||
}
|
||
|
||
function hasScatterFactor1(){
|
||
var keyScatterLevel = $packet.data.keyScatterLevel
|
||
if( 1 <= keyScatterLevel ){
|
||
return true;
|
||
}else{
|
||
return false;
|
||
}
|
||
}
|
||
|
||
function hasScatterFactor2(){
|
||
var keyScatterLevel = $packet.data.keyScatterLevel
|
||
if( 2 <= keyScatterLevel ){
|
||
return true;
|
||
}else{
|
||
return false;
|
||
}
|
||
}
|
||
|
||
function hasScatterFactor3(){
|
||
var keyScatterLevel = $packet.data.keyScatterLevel
|
||
if( 3 == keyScatterLevel){
|
||
return true;
|
||
}else{
|
||
return false;
|
||
}
|
||
}
|
||
|
||
function vectorLen(){
|
||
var algorithmKey = $packet.data.algorithmKey
|
||
if( 5==algorithmKey || 6==algorithmKey || 7==algorithmKey || 8==algorithmKey ){
|
||
return 8;
|
||
}
|
||
if( 1==algorithmKey || 2==algorithmKey || 3==algorithmKey || 4==algorithmKey || 9==algorithmKey || 10==algorithmKey ){
|
||
return 16;
|
||
}
|
||
}
|
||
|
||
function getMacLen(){
|
||
return $packet.data.macLen
|
||
}
|
||
</script>
|
||
</packet>
|