sydapi/DProto/S9.xml
2021-08-12 10:47:32 +08:00

179 lines
5.8 KiB
XML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8" ?>
<packet extend="base">
<req>
<command>
<hex>S9</hex>
</command>
<data extend="data">
<protectedKeyIndex len="27" cn="保护密钥的索引">
内部密钥索引, 接口层对外限制8位通讯层限制27位16位机构号+3位密钥类型+8位密钥索引号。前19位补0
</protectedKeyIndex>
<algorithmKey len="2" cn="保护密钥算法">
支持算法3DES、AES、SM1、SM4
</algorithmKey>
<iv len="8" :if="useCbc()" :len="ivLen()" cn="IV 数据域">
仅当算法为非ECB模式下有此域
当算法标识为3DES-CBC、DES-CBC 时该域为8B。
当算法标识为AES-CBC、SM1-CBC、SM4-CBC 时该域为16B。
</iv>
<keyScatterLevel len="1" cn="保护密钥分散级数">
密钥分散级数03
</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>
<exportKeyNum len="2" cn="导出的密钥索引个数">
被导出的密钥索引个数,最大不超过50
</exportKeyNum>
<exportKey cn="导出的密钥结构体">
分散密钥结构体STC_KEYDIV
结构体格式参考数据字典
</exportKey>
</data>
</req>
<res>
<command>
<hex>SA</hex>
</command>
<data>
<error len="2" cn="错误代码" format="X" :catch="catchError('%s')">
<options>
<option cn="成功">
<hex>00</hex>
</option>
</options>
</error>
<linkKeyOut :len="linkKeyOutLen()" cn="依次连接所有密钥密文输出">
依次连接所有密钥密文输出
</linkKeyOut>
<linkKeyCheckOut :len="linkKeyCheckOutLen()" cn="依次连接所有密钥校验值输出">
依次连接所有密钥校验值输出
</linkKeyCheckOut>
</data>
</res>
<script>
function useCbc(){
var algorithmKey = $packet.data.algorithmKey
if( 6==algorithmKey || 8==algorithmKey || 2==algorithmKey || 4==algorithmKey || 10==algorithmKey ){
return true;
}else{
return false;
}
}
function ivLen() {
var algorithmKey = $packet.data.algorithmKey
if(6==algorithmKey || 8==algorithmKey){
return 8;
}
if( 2==algorithmKey || 4==algorithmKey || 10==algorithmKey ){
return 16;
}
}
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 hasScatterFactor1(){
var keyScatterLevel = $packet.data.keyScatterLevel
if( 1 &lt;= keyScatterLevel ){
return true;
}else{
return false;
}
}
function hasScatterFactor2(){
var keyScatterLevel = $packet.data.keyScatterLevel
if( 2 &lt;= keyScatterLevel ){
return true;
}else{
return false;
}
}
function hasScatterFactor3(){
var keyScatterLevel = $packet.data.keyScatterLevel
if( 3 == keyScatterLevel){
return true;
}else{
return false;
}
}
function linkKeyOutLen(){
var exportKeyNum = $packet.data.exportKeyNum
return exportKeyNum * 16
}
function linkKeyCheckOutLen(){
var exportKeyNum = $packet.data.exportKeyNum
return exportKeyNum * 8
}
</script>
</packet>