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

205 lines
6.3 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>S0</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="算法类型">
支持算法3DES、AES、SM1、SM4
取值参考数据字典
</algorithmKey>
<iv :len="ivLen()" :if="useCbc()" 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>
<inputDataLen len="4" :value="inputDataLen()" cn="数据长度">
输入数据长度
</inputDataLen>
<inputData cn="输入数据">
输入数据
</inputData>
</data>
</req>
<res>
<command>
<hex>S1</hex>
</command>
<data>
<error len="2" cn="错误码" format="X" :catch="catchError('%s')">
<options>
<option cn="无错误">
<hex>00</hex>
</option>
</options>
</error>
<infoLen len="4" cn="输出数据长度">
数据长度
</infoLen>
<info :len="getInfoLen()" cn="数据">
数据
</info>
</data>
</res>
<script>
function keyLen() {
return $packet.data.key.length;
}
function ivLen() {
var algorithmKey = $packet.data.algorithmKey
if( 6== algorithmKey || 8== algorithmKey ){
return 8;
}
if( 10== algorithmKey || 2== algorithmKey || 6== algorithmKey ){
return 16;
}
}
function useCbc(){
var algorithmKey = $packet.data.algorithmKey
if( 6== algorithmKey || 8== algorithmKey || 10== algorithmKey || 2== algorithmKey || 4== 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 &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 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 || 5 == algorithmKey || 10 == algorithmKey){
return 16;
}
}
function getInfoLen(){
return Util.a2i( $final.getSection('data').getSection('infoLen') )
}
</script>
</packet>