185 lines
6.0 KiB
XML
185 lines
6.0 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
||
<packet extend="base">
|
||
<req>
|
||
|
||
<command>
|
||
<hex>SA</hex>
|
||
</command>
|
||
<data extend="data">
|
||
<keyIndex len="27" cn="密钥索引">
|
||
仅当存储类型为0时有效
|
||
内部密钥索引, 接口层对外限制8位,通讯层限制27位,16位机构号+3位密钥类型+8位密钥索引号。前19位补0。
|
||
注意:后八位密钥索引不允许输入全0
|
||
</keyIndex>
|
||
|
||
<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 为16H
|
||
SM1-ECB、SM1-CBC、SM4-ECB、SM4-CBC、
|
||
AES-ECB、AES-CBC 为32H
|
||
</scatterAlgorithmVector1>
|
||
|
||
<scatterAlgorithmVector2 :len="vectorLen()" :if="hasScatterFactor2()" cn="分散算法的初始向量2">
|
||
仅当分散级数不为0时存在,同上
|
||
</scatterAlgorithmVector2>
|
||
|
||
<scatterAlgorithmVector3 :len="vectorLen()" :if="hasScatterFactor3()" cn="分散算法的初始向量3">
|
||
仅当分散级数不为0时存在,同上
|
||
</scatterAlgorithmVector3>
|
||
|
||
<masterKeyLabelLength :value="getMasterKeyLabel()" len="4" cn="主密钥标签长度">
|
||
主密钥标签长度,最大不超过256字节
|
||
</masterKeyLabelLength>
|
||
|
||
<masterKeyLabel cn="主密钥标签">
|
||
主密钥标签
|
||
</masterKeyLabel>
|
||
|
||
<workKeyLabelLength :value="getWorkKeyLabel()" len="4" cn="工作密钥标签长度">
|
||
工作密钥标签长度,最大不超过256字节
|
||
</workKeyLabelLength>
|
||
|
||
<workKeyLabel cn="工作密钥标签">
|
||
工作密钥标签
|
||
</workKeyLabel>
|
||
|
||
<clientRandomNumLength len="4" :value="getClientRandomNum()" cn="客户端随机数长度">
|
||
客户端随机数长度,最大不超过2048
|
||
</clientRandomNumLength>
|
||
|
||
<clientRandomNum cn="客户端随机数">
|
||
客户端随机数
|
||
</clientRandomNum>
|
||
|
||
<serverRandomNumLength len="4" :value="getServerRandomNum()" cn="服务端随机数长度">
|
||
服务端随机数长度,最大不超过2048
|
||
</serverRandomNumLength>
|
||
|
||
<serverRandomNum cn="服务端随机数">
|
||
服务端随机数
|
||
</serverRandomNum>
|
||
|
||
</data>
|
||
|
||
</req>
|
||
<res>
|
||
|
||
<command>
|
||
<hex>B2</hex>
|
||
</command>
|
||
<data>
|
||
<error len="2" cn="错误代码" format="X" :catch="catchError('%s')">
|
||
<options>
|
||
<option cn="成功">
|
||
<hex>00</hex>
|
||
</option>
|
||
</options>
|
||
</error>
|
||
|
||
<sessionKey len="176" cn="会话密钥">
|
||
输出会话密钥密文
|
||
数序如下:
|
||
masterKey(48字节)
|
||
clientWriteMacKey(32字节)
|
||
serverWriteMacKey(32字节)
|
||
clientWriteKey(16字节)
|
||
serverWriteKey(16字节)
|
||
clientWriteIv(16字节)
|
||
serverWriteIv(16字节)
|
||
</sessionKey>
|
||
</data>
|
||
|
||
</res>
|
||
<script>
|
||
|
||
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 getMasterKeyLabel(){
|
||
return $packet.data.masterKeyLabel.length;
|
||
}
|
||
|
||
function getWorkKeyLabel(){
|
||
return $packet.data.workKeyLabel.length;
|
||
}
|
||
|
||
function getClientRandomNum(){
|
||
return $packet.data.clientRandomNum.length;
|
||
}
|
||
|
||
function getServerRandomNum(){
|
||
return $packet.data.serverRandomNum.length;
|
||
}
|
||
|
||
</script>
|
||
</packet>
|