添加中移指令接口
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@
|
||||
</command>
|
||||
<data extend="data">
|
||||
|
||||
<num len="4" cn="授权响应码">
|
||||
<num len="4" cn="授权响应码" required="false">
|
||||
授权响应码
|
||||
</num>
|
||||
|
||||
|
||||
+204
@@ -0,0 +1,204 @@
|
||||
<?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="密钥分散级数">
|
||||
密钥分散级数,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>
|
||||
|
||||
</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 <= 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 || 5 == algorithmKey || 10 == algorithmKey){
|
||||
return 16;
|
||||
}
|
||||
}
|
||||
|
||||
function getInfoLen(){
|
||||
return Util.a2i( $final.getSection('data').getSection('infoLen') )
|
||||
}
|
||||
|
||||
</script>
|
||||
</packet>
|
||||
+204
@@ -0,0 +1,204 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<packet extend="base">
|
||||
<req>
|
||||
|
||||
<command>
|
||||
<hex>S1</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="密钥分散级数">
|
||||
密钥分散级数,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>
|
||||
|
||||
</data>
|
||||
|
||||
</req>
|
||||
<res>
|
||||
|
||||
<command>
|
||||
<hex>S2</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 || 4==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 <= 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 getInfoLen(){
|
||||
return Util.a2i( $final.getSection('data').getSection('infoLen') )
|
||||
}
|
||||
|
||||
</script>
|
||||
</packet>
|
||||
+190
@@ -0,0 +1,190 @@
|
||||
<?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>
|
||||
+157
@@ -0,0 +1,157 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<packet extend="base">
|
||||
<req>
|
||||
|
||||
<command>
|
||||
<hex>S3</hex>
|
||||
</command>
|
||||
<data extend="data">
|
||||
<keyIndex len="27" cn="密钥索引">
|
||||
内部密钥索引, 接口层对外限制8位,通讯层限制27位,16位机构号+3位密钥类型+8位密钥索引号。前19位补0
|
||||
注意:后八位密钥索引不允许输入全0
|
||||
</keyIndex>
|
||||
|
||||
<algorithmKey len="2" cn="算法类型">
|
||||
仅支持3DES-CBC
|
||||
</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>
|
||||
</data>
|
||||
|
||||
</req>
|
||||
<res>
|
||||
|
||||
<command>
|
||||
<hex>S4</hex>
|
||||
</command>
|
||||
<data>
|
||||
<error len="2" cn="错误码" format="X" :catch="catchError('%s')">
|
||||
<options>
|
||||
<option cn="无错误">
|
||||
<hex>00</hex>
|
||||
</option>
|
||||
</options>
|
||||
</error>
|
||||
|
||||
<macAndNextIv len="16" cn="MacAndNextIv数据">
|
||||
输出的MacAndNextIv数据
|
||||
16字节
|
||||
前8字节为MAC
|
||||
后8字节为下一次IV
|
||||
</macAndNextIv>
|
||||
</data>
|
||||
|
||||
</res>
|
||||
<script>
|
||||
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;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</packet>
|
||||
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<packet extend="base">
|
||||
<req>
|
||||
|
||||
<command>
|
||||
<hex>S4</hex>
|
||||
</command>
|
||||
<data extend="data">
|
||||
<storageType len="1" cn="存储类型">
|
||||
<options>
|
||||
<option cn="存储在内部">
|
||||
<hex>0</hex>
|
||||
</option>
|
||||
<option cn="存储在外部">
|
||||
<hex>1</hex>
|
||||
</option>
|
||||
</options>
|
||||
</storageType>
|
||||
|
||||
<algorithmKey len="2" cn="算法类型">
|
||||
仅支持RSA、SM2
|
||||
</algorithmKey>
|
||||
|
||||
<keyLen len="4" cn="密钥长度">
|
||||
RSA密钥长度:1024、2048
|
||||
SM2密钥长度:256
|
||||
</keyLen>
|
||||
|
||||
<keyIndex len="27" :if="0 == $packet.data.storageType$option" cn="密钥索引">
|
||||
内部密钥索引, 接口层对外限制8位,通讯层限制27位,16位机构号+3位密钥类型+8位密钥索引号。前19位补0.
|
||||
</keyIndex>
|
||||
|
||||
</data>
|
||||
|
||||
</req>
|
||||
<res>
|
||||
|
||||
<command>
|
||||
<hex>S5</hex>
|
||||
</command>
|
||||
<data>
|
||||
<error len="2" cn="错误码" format="X" :catch="catchError('%s')">
|
||||
<options>
|
||||
<option cn="无错误">
|
||||
<hex>00</hex>
|
||||
</option>
|
||||
</options>
|
||||
</error>
|
||||
|
||||
<publicKeyLength len="4" cn="公钥长度">
|
||||
公钥长度
|
||||
</publicKeyLength>
|
||||
|
||||
<publicKey :len="getPubKeyLen()" cn="公钥">
|
||||
公钥
|
||||
</publicKey>
|
||||
|
||||
<privateKeyLength len="4" cn="私钥长度">
|
||||
私钥长度
|
||||
</privateKeyLength>
|
||||
|
||||
<privateKey :len="getPriKeyLen()" cn="私钥">
|
||||
私钥
|
||||
</privateKey>
|
||||
</data>
|
||||
|
||||
</res>
|
||||
<script>
|
||||
function getPubKeyLen() {
|
||||
return Util.a2i( $final.getSection('data').getSection('publicKeyLength') )
|
||||
}
|
||||
|
||||
function getPriKeyLen() {
|
||||
return Util.a2i( $final.getSection('data').getSection('privateKeyLength') )
|
||||
}
|
||||
|
||||
</script>
|
||||
</packet>
|
||||
@@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<packet extend="base">
|
||||
<req>
|
||||
|
||||
<command>
|
||||
<hex>S5</hex>
|
||||
</command>
|
||||
<data extend="data">
|
||||
<storageType len="1" cn="存储类型">
|
||||
<options>
|
||||
<option cn="使用内部密钥">
|
||||
<hex>0</hex>
|
||||
</option>
|
||||
<option cn="使用外部密钥">
|
||||
<hex>1</hex>
|
||||
</option>
|
||||
</options>
|
||||
</storageType>
|
||||
|
||||
<algorithmKey len="2" cn="算法类型">
|
||||
仅支持RSA、SM2
|
||||
</algorithmKey>
|
||||
|
||||
<privateKeyLen len="4" :value="getPrivateKeyLen()" :if="1 == $packet.data.storageType$option" cn="签名私钥长度">
|
||||
仅当存储类型为1时有效
|
||||
签名私钥长度
|
||||
</privateKeyLen>
|
||||
|
||||
<privateKey :if="1 == $packet.data.storageType$option" cn="签名私钥">
|
||||
仅当存储类型为1时有效
|
||||
签名私钥
|
||||
</privateKey>
|
||||
|
||||
<keyIndex len="27" :if="0 == $packet.data.storageType$option" cn="密钥索引">
|
||||
内部密钥索引, 接口层对外限制8位,通讯层限制27位,16位机构号+3位密钥类型+8位密钥索引号。前19位补0
|
||||
注意:后八位密钥索引不允许输入全0
|
||||
</keyIndex>
|
||||
|
||||
<inputDataLen len="4" :value="inputDataLen()" cn="数据长度">
|
||||
输入数据长度
|
||||
</inputDataLen>
|
||||
|
||||
<inputData cn="输入数据">
|
||||
输入数据
|
||||
</inputData>
|
||||
</data>
|
||||
|
||||
</req>
|
||||
<res>
|
||||
|
||||
<command>
|
||||
<hex>S6</hex>
|
||||
</command>
|
||||
<data>
|
||||
<error len="2" cn="错误码" format="X" :catch="catchError('%s')">
|
||||
<options>
|
||||
<option cn="无错误">
|
||||
<hex>00</hex>
|
||||
</option>
|
||||
</options>
|
||||
</error>
|
||||
|
||||
<signDataLen len="4" cn="签名数据长度">
|
||||
签名数据长度
|
||||
</signDataLen>
|
||||
|
||||
<signData :len="getSignDataLen()" cn="签名数据">
|
||||
签名数据
|
||||
</signData>
|
||||
</data>
|
||||
|
||||
</res>
|
||||
<script>
|
||||
function getPrivateKeyLen() {
|
||||
return $packet.data.privateKey.length;
|
||||
}
|
||||
|
||||
function inputDataLen(){
|
||||
var data = $packet.data;
|
||||
return data.inputData.length;
|
||||
}
|
||||
|
||||
function getSignDataLen() {
|
||||
return Util.a2i( $final.getSection('data').getSection('signDataLen') )
|
||||
}
|
||||
</script>
|
||||
</packet>
|
||||
@@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<packet extend="base">
|
||||
<req>
|
||||
|
||||
<command>
|
||||
<hex>S6</hex>
|
||||
</command>
|
||||
<data extend="data">
|
||||
<storageType len="1" cn="存储类型">
|
||||
<options>
|
||||
<option cn="使用内部密钥">
|
||||
<hex>0</hex>
|
||||
</option>
|
||||
<option cn="使用外部密钥">
|
||||
<hex>1</hex>
|
||||
</option>
|
||||
</options>
|
||||
</storageType>
|
||||
|
||||
<algorithmKey len="2" cn="算法类型">
|
||||
仅支持RSA、SM2
|
||||
</algorithmKey>
|
||||
|
||||
<publicKeyLen len="4" :value="getPublicKeyLen()" :if="1 == $packet.data.storageType$option" cn="验签公钥长度">
|
||||
仅当存储类型为1时有效
|
||||
验签公钥长度
|
||||
</publicKeyLen>
|
||||
|
||||
<publicKey :if="1 == $packet.data.storageType$option" cn="验签公钥">
|
||||
仅当存储类型为1时有效
|
||||
验签公钥
|
||||
</publicKey>
|
||||
|
||||
<keyIndex len="27" :if="0 == $packet.data.storageType$option" cn="密钥索引">
|
||||
内部密钥索引, 接口层对外限制8位,通讯层限制27位,16位机构号+3位密钥类型+8位密钥索引号。前19位补0
|
||||
注意:后八位密钥索引不允许输入全0
|
||||
</keyIndex>
|
||||
|
||||
<orgDataLen len="4" :value="getOrgDataLen()" cn="原数据长度">
|
||||
原数据长度
|
||||
</orgDataLen>
|
||||
|
||||
<orgData cn="原数据">
|
||||
原数据
|
||||
</orgData>
|
||||
|
||||
<inputDataLen len="4" :value="inputDataLen()" cn="签名数据长度">
|
||||
签名数据长度
|
||||
</inputDataLen>
|
||||
|
||||
<inputData cn="签名数据">
|
||||
签名数据
|
||||
</inputData>
|
||||
</data>
|
||||
|
||||
</req>
|
||||
<res>
|
||||
|
||||
<command>
|
||||
<hex>S7</hex>
|
||||
</command>
|
||||
<data>
|
||||
<error len="2" cn="错误码" format="X" :catch="catchError('%s')">
|
||||
<options>
|
||||
<option cn="无错误">
|
||||
<hex>00</hex>
|
||||
</option>
|
||||
</options>
|
||||
</error>
|
||||
</data>
|
||||
|
||||
</res>
|
||||
<script>
|
||||
function getPublicKeyLen() {
|
||||
return $packet.data.publicKey.length;
|
||||
}
|
||||
|
||||
function getOrgDataLen(){
|
||||
return $packet.data.orgData.length;
|
||||
}
|
||||
|
||||
function inputDataLen(){
|
||||
var data = $packet.data;
|
||||
return data.inputData.length;
|
||||
}
|
||||
</script>
|
||||
</packet>
|
||||
@@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<packet extend="base">
|
||||
<req>
|
||||
|
||||
<command>
|
||||
<hex>S7</hex>
|
||||
</command>
|
||||
<data extend="data">
|
||||
<storageType len="1" cn="存储类型">
|
||||
<options>
|
||||
<option cn="使用内部密钥">
|
||||
<hex>0</hex>
|
||||
</option>
|
||||
<option cn="使用外部密钥">
|
||||
<hex>1</hex>
|
||||
</option>
|
||||
</options>
|
||||
</storageType>
|
||||
|
||||
<algorithmKey len="2" cn="算法类型">
|
||||
仅支持RSA、SM2
|
||||
</algorithmKey>
|
||||
|
||||
<publicKeyLen len="4" :value="getPublicKeyLen()" :if="1 == $packet.data.storageType$option" cn="公钥长度">
|
||||
仅当存储类型为1时有效
|
||||
公钥长度
|
||||
</publicKeyLen>
|
||||
|
||||
<publicKey :if="1 == $packet.data.storageType$option" cn="公钥">
|
||||
仅当存储类型为1时有效
|
||||
公钥
|
||||
</publicKey>
|
||||
|
||||
<keyIndex len="27" :if="0 == $packet.data.storageType$option" cn="密钥索引">
|
||||
内部密钥索引, 接口层对外限制8位,通讯层限制27位,16位机构号+3位密钥类型+8位密钥索引号。前19位补0
|
||||
注意:后八位密钥索引不允许输入全0
|
||||
</keyIndex>
|
||||
|
||||
<inputDataLen len="4" :value="inputDataLen()" cn="数据长度">
|
||||
数据长度
|
||||
</inputDataLen>
|
||||
|
||||
<inputData cn="数据">
|
||||
数据
|
||||
</inputData>
|
||||
</data>
|
||||
|
||||
</req>
|
||||
<res>
|
||||
|
||||
<command>
|
||||
<hex>S8</hex>
|
||||
</command>
|
||||
<data>
|
||||
<error len="2" cn="错误码" format="X" :catch="catchError('%s')">
|
||||
<options>
|
||||
<option cn="无错误">
|
||||
<hex>00</hex>
|
||||
</option>
|
||||
</options>
|
||||
</error>
|
||||
|
||||
<cipherLen len="4" cn="密文长度">
|
||||
密文长度
|
||||
</cipherLen>
|
||||
|
||||
<cipher :len="getCipherLen()" cn="密文">
|
||||
密文
|
||||
</cipher>
|
||||
|
||||
</data>
|
||||
|
||||
</res>
|
||||
<script>
|
||||
function getPublicKeyLen() {
|
||||
return $packet.data.publicKey.length;
|
||||
}
|
||||
|
||||
function inputDataLen(){
|
||||
var data = $packet.data;
|
||||
return data.inputData.length;
|
||||
}
|
||||
|
||||
function getCipherLen(){
|
||||
return Util.a2i( $final.getSection('data').getSection('cipherLen') )
|
||||
}
|
||||
</script>
|
||||
</packet>
|
||||
@@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<packet extend="base">
|
||||
<req>
|
||||
|
||||
<command>
|
||||
<hex>S8</hex>
|
||||
</command>
|
||||
<data extend="data">
|
||||
<storageType len="1" cn="存储类型">
|
||||
<options>
|
||||
<option cn="使用内部密钥">
|
||||
<hex>0</hex>
|
||||
</option>
|
||||
<option cn="使用外部密钥">
|
||||
<hex>1</hex>
|
||||
</option>
|
||||
</options>
|
||||
</storageType>
|
||||
|
||||
<algorithmKey len="2" cn="算法类型">
|
||||
仅支持RSA、SM2
|
||||
</algorithmKey>
|
||||
|
||||
<privateKeyLen len="4" :value="getPrivateKeyLen()" :if="1 == $packet.data.storageType$option" cn="私钥长度">
|
||||
仅当存储类型为1时有效
|
||||
私钥长度
|
||||
</privateKeyLen>
|
||||
|
||||
<privateKey :if="1 == $packet.data.storageType$option" cn="私钥">
|
||||
仅当存储类型为1时有效
|
||||
私钥
|
||||
</privateKey>
|
||||
|
||||
<keyIndex len="27" :if="0 == $packet.data.storageType$option" cn="密钥索引">
|
||||
内部密钥索引, 接口层对外限制8位,通讯层限制27位,16位机构号+3位密钥类型+8位密钥索引号。前19位补0
|
||||
注意:后八位密钥索引不允许输入全0
|
||||
</keyIndex>
|
||||
|
||||
<inputDataLen len="4" :value="inputDataLen()" cn="密文长度">
|
||||
密文长度
|
||||
</inputDataLen>
|
||||
|
||||
<inputData cn="密文">
|
||||
密文
|
||||
</inputData>
|
||||
</data>
|
||||
|
||||
</req>
|
||||
<res>
|
||||
|
||||
<command>
|
||||
<hex>S9</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 getPrivateKeyLen() {
|
||||
return $packet.data.privateKey.length;
|
||||
}
|
||||
|
||||
function inputDataLen(){
|
||||
var data = $packet.data;
|
||||
return data.inputData.length;
|
||||
}
|
||||
|
||||
function getInfoLen(){
|
||||
return Util.a2i( $final.getSection('data').getSection('infoLen') )
|
||||
}
|
||||
</script>
|
||||
</packet>
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
<?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="保护密钥分散级数">
|
||||
密钥分散级数,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>
|
||||
|
||||
<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 <= 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 linkKeyOutLen(){
|
||||
var exportKeyNum = $packet.data.exportKeyNum
|
||||
return exportKeyNum * 16
|
||||
}
|
||||
|
||||
function linkKeyCheckOutLen(){
|
||||
var exportKeyNum = $packet.data.exportKeyNum
|
||||
return exportKeyNum * 8
|
||||
}
|
||||
|
||||
</script>
|
||||
</packet>
|
||||
+184
@@ -0,0 +1,184 @@
|
||||
<?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>
|
||||
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<packet extend="base">
|
||||
<req>
|
||||
|
||||
<command>
|
||||
<hex>SB</hex>
|
||||
</command>
|
||||
<data extend="data">
|
||||
<keyLength len="4" :value="keyLen()" cn="外部密钥长度">
|
||||
外部密钥密文长度
|
||||
</keyLength>
|
||||
|
||||
<key cn="外部密钥">
|
||||
外部密钥密文
|
||||
</key>
|
||||
|
||||
<seedLen len="4" :value="getSeedLen()" cn="种子长度">
|
||||
种子长度
|
||||
</seedLen>
|
||||
|
||||
<seed cn="种子">
|
||||
种子
|
||||
</seed>
|
||||
|
||||
<outLen len="4" cn="输出数据长度">
|
||||
输出数据长度
|
||||
</outLen>
|
||||
|
||||
</data>
|
||||
|
||||
</req>
|
||||
<res>
|
||||
|
||||
<command>
|
||||
<hex>SC</hex>
|
||||
</command>
|
||||
<data>
|
||||
<error len="2" cn="错误码" format="X" :catch="catchError('%s')">
|
||||
<options>
|
||||
<option cn="无错误">
|
||||
<hex>00</hex>
|
||||
</option>
|
||||
</options>
|
||||
</error>
|
||||
|
||||
<pHashLen len="4" cn="输出数据长度">
|
||||
输出数据长度
|
||||
</pHashLen>
|
||||
|
||||
<pHash :len="getPHashLen()" cn="pHash">
|
||||
输出的指定长度的数据
|
||||
若指定长度小于块长的整数倍,则取满足返回长度最小整数倍的前指定长度个字节
|
||||
</pHash>
|
||||
</data>
|
||||
|
||||
</res>
|
||||
<script>
|
||||
function keyLen() {
|
||||
return $packet.data.key.length;
|
||||
}
|
||||
|
||||
function getSeedLen(){
|
||||
return $packet.data.seed.length;
|
||||
}
|
||||
|
||||
function getPHashLen(){
|
||||
return Util.a2i( $final.getSection('data').getSection('pHashLen') )
|
||||
}
|
||||
</script>
|
||||
</packet>
|
||||
+290
@@ -0,0 +1,290 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<packet extend="base">
|
||||
<req>
|
||||
|
||||
<command>
|
||||
<hex>SC</hex>
|
||||
</command>
|
||||
<data extend="data">
|
||||
<deKeyIndex len="27" cn="解密密钥索引">
|
||||
仅当存储类型为0时有效
|
||||
内部密钥索引, 接口层对外限制8位,通讯层限制27位,16位机构号+3位密钥类型+8位密钥索引号。前19位补0。
|
||||
注意:后八位密钥索引不允许输入全0
|
||||
</deKeyIndex>
|
||||
|
||||
<algorithmKey len="2" cn="解密算法类型">
|
||||
解密的算法
|
||||
支持算法:3DES、AES、SM1、SM4
|
||||
</algorithmKey>
|
||||
|
||||
<scatterAlgorithmVector :len="vectorLength()" :if="hasVector()" cn="解密初始向量">
|
||||
仅当算法为非ECB模式下有此域
|
||||
当算法标识为3DES-CBC、DES-CBC 时,该域为8B。
|
||||
当算法标识为AES-CBC、SM1-CBC、SM4-CBC 时,该域为16B。
|
||||
取值参考数据字典
|
||||
</scatterAlgorithmVector>
|
||||
|
||||
<deKeyScatterLevel len="1" cn="解密密钥分散级数">
|
||||
密钥分散级数,0~3
|
||||
</deKeyScatterLevel>
|
||||
|
||||
<deScatterFactor1 len="16" :if="hasDeScatterFactor1()" cn="解密分散因子1">
|
||||
仅当保护密钥分散级数不为0时存在
|
||||
</deScatterFactor1>
|
||||
|
||||
<deScatterFactor2 len="16" :if="hasDeScatterFactor2()" cn="解密分散因子2">
|
||||
仅当保护密钥分散级数不为0时存在
|
||||
</deScatterFactor2>
|
||||
|
||||
<deScatterFactor3 len="16" :if="hasDeScatterFactor3()" cn="解密分散因子3">
|
||||
仅当保护密钥分散级数不为0时存在
|
||||
</deScatterFactor3>
|
||||
|
||||
<deScatterAlgorithmKey1 len="2" :if="hasDeScatterFactor1()" cn="解密分散算法标识1">
|
||||
仅当保护密钥分散级数不为0时存在
|
||||
分散算法标识,定义每一次分散的分散算法,数量与密钥分散级数一致
|
||||
如果保护密钥算法类型为3DES、AES,则支持算法:3DES、AES;
|
||||
如果保护密钥算法类型为SM1、SM4,则支持算法:SM1、SM4;
|
||||
取值参考数据字典
|
||||
</deScatterAlgorithmKey1>
|
||||
|
||||
<deScatterAlgorithmKey2 len="2" :if="hasDeScatterFactor2()" cn="解密分散算法标识2">
|
||||
仅当分散级数不为0时存在,同上
|
||||
</deScatterAlgorithmKey2>
|
||||
|
||||
<deScatterAlgorithmKey3 len="2" :if="hasDeScatterFactor3()" cn="解密分散算法标识3">
|
||||
仅当分散级数不为0时存在,同上
|
||||
</deScatterAlgorithmKey3>
|
||||
|
||||
<deScatterAlgorithmVector1 :len="vectorLen()" :if="hasDeScatterFactor1()" 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
|
||||
</deScatterAlgorithmVector1>
|
||||
|
||||
<deScatterAlgorithmVector2 :len="vectorLen()" :if="hasDeScatterFactor2()" cn="解密分散算法的初始向量2">
|
||||
仅当分散级数不为0时存在,同上
|
||||
</deScatterAlgorithmVector2>
|
||||
|
||||
<deScatterAlgorithmVector3 :len="vectorLen()" :if="hasDeScatterFactor3()" cn="解密分散算法的初始向量3">
|
||||
仅当分散级数不为0时存在,同上
|
||||
</deScatterAlgorithmVector3>
|
||||
|
||||
<enKeyIndex len="27" cn="加密密钥索引">
|
||||
仅当存储类型为0时有效
|
||||
内部密钥索引, 接口层对外限制8位,通讯层限制27位,16位机构号+3位密钥类型+8位密钥索引号。前19位补0。
|
||||
注意:后八位密钥索引不允许输入全0
|
||||
</enKeyIndex>
|
||||
|
||||
<encryptAlgFlag len="2" cn="加密密钥算法">
|
||||
加密密钥算法,支持3DES、AES、SM1、SM4
|
||||
取值参考数据字典
|
||||
</encryptAlgFlag>
|
||||
|
||||
<encryptIv :len="enVectorLength()" :if="hasEnVector()" cn="加密密钥IV">
|
||||
仅当加密密钥算法为CBC模式时存在
|
||||
加密密钥的初始向量
|
||||
</encryptIv>
|
||||
|
||||
<enKeyScatterLevel len="1" cn="加密密钥分散级数">
|
||||
密钥分散级数,0~3
|
||||
</enKeyScatterLevel>
|
||||
|
||||
<enScatterFactor1 len="16" :if="hasEnScatterFactor1()" cn="加密分散因子1">
|
||||
仅当保护密钥分散级数不为0时存在
|
||||
</enScatterFactor1>
|
||||
|
||||
<enScatterFactor2 len="16" :if="hasEnScatterFactor2()" cn="加密分散因子2">
|
||||
仅当保护密钥分散级数不为0时存在
|
||||
</enScatterFactor2>
|
||||
|
||||
<enScatterFactor3 len="16" :if="hasEnScatterFactor3()" cn="加密分散因子3">
|
||||
仅当保护密钥分散级数不为0时存在
|
||||
</enScatterFactor3>
|
||||
|
||||
<enScatterAlgorithmKey1 len="2" :if="hasEnScatterFactor1()" cn="加密分散算法标识1">
|
||||
仅当保护密钥分散级数不为0时存在
|
||||
分散算法标识,定义每一次分散的分散算法,数量与密钥分散级数一致
|
||||
如果保护密钥算法类型为3DES、AES,则支持算法:3DES、AES;
|
||||
如果保护密钥算法类型为SM1、SM4,则支持算法:SM1、SM4;
|
||||
取值参考数据字典
|
||||
</enScatterAlgorithmKey1>
|
||||
|
||||
<enScatterAlgorithmKey2 len="2" :if="hasEnScatterFactor2()" cn="加密分散算法标识2">
|
||||
仅当分散级数不为0时存在,同上
|
||||
</enScatterAlgorithmKey2>
|
||||
|
||||
<enScatterAlgorithmKey3 len="2" :if="hasEnScatterFactor3()" cn="加密分散算法标识3">
|
||||
仅当分散级数不为0时存在,同上
|
||||
</enScatterAlgorithmKey3>
|
||||
|
||||
<enScatterAlgorithmVector1 :len="vectorLen()" :if="hasEnScatterFactor1()" 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
|
||||
</enScatterAlgorithmVector1>
|
||||
|
||||
<enScatterAlgorithmVector2 :len="vectorLen()" :if="hasEnScatterFactor2()" cn="加密分散算法的初始向量2">
|
||||
仅当分散级数不为0时存在,同上
|
||||
</enScatterAlgorithmVector2>
|
||||
|
||||
<enScatterAlgorithmVector3 :len="vectorLen()" :if="hasEnScatterFactor3()" cn="加密分散算法的初始向量3">
|
||||
仅当分散级数不为0时存在,同上
|
||||
</enScatterAlgorithmVector3>
|
||||
|
||||
<inputDataLen len="4" :value="inputDataLen()" cn="输入数据长度">
|
||||
待解密的数据长度
|
||||
</inputDataLen>
|
||||
|
||||
<inputData cn="输入数据">
|
||||
待解密的数据
|
||||
</inputData>
|
||||
</data>
|
||||
|
||||
</req>
|
||||
<res>
|
||||
|
||||
<command>
|
||||
<hex>SD</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 vectorLength(){
|
||||
var algorithmKey = $packet.data.algorithmKey
|
||||
if(6==algorithmKey || 8==algorithmKey ){
|
||||
return 8;
|
||||
}
|
||||
if( 2==algorithmKey || 4==algorithmKey || 10==algorithmKey ){
|
||||
return 16;
|
||||
}
|
||||
}
|
||||
|
||||
function hasVector(){
|
||||
var algorithmKey = $packet.data.algorithmKey
|
||||
if(2==algorithmKey || 4==algorithmKey || 10==algorithmKey || 6==algorithmKey || 8==algorithmKey){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function enVectorLength(){
|
||||
var encryptAlgFlag = $packet.data.encryptAlgFlag
|
||||
if(6==encryptAlgFlag || 8==encryptAlgFlag ){
|
||||
return 8;
|
||||
}
|
||||
if( 2==encryptAlgFlag || 4==encryptAlgFlag || 10==encryptAlgFlag ){
|
||||
return 16;
|
||||
}
|
||||
}
|
||||
|
||||
function hasEnVector(){
|
||||
var encryptAlgFlag =$packet.data.encryptAlgFlag
|
||||
if( 2==encryptAlgFlag || 4==encryptAlgFlag || 10==encryptAlgFlag || 6==encryptAlgFlag || 8==encryptAlgFlag){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function hasDeScatterFactor1(){
|
||||
var deKeyScatterLevel = $packet.data.deKeyScatterLevel
|
||||
if( 1 <= deKeyScatterLevel ){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function hasDeScatterFactor2(){
|
||||
var deKeyScatterLevel = $packet.data.deKeyScatterLevel
|
||||
if( 2 <= deKeyScatterLevel ){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function hasDeScatterFactor3(){
|
||||
var deKeyScatterLevel = $packet.data.deKeyScatterLevel
|
||||
if( 3 == deKeyScatterLevel){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function hasEnScatterFactor1(){
|
||||
var enKeyScatterLevel = $packet.data.enKeyScatterLevel
|
||||
if( 1 <= enKeyScatterLevel ){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function hasEnScatterFactor2(){
|
||||
var enKeyScatterLevel = $packet.data.enKeyScatterLevel
|
||||
if( 2 <= enKeyScatterLevel ){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function hasEnScatterFactor3(){
|
||||
var enKeyScatterLevel = $packet.data.enKeyScatterLevel
|
||||
if( 3 == enKeyScatterLevel){
|
||||
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 inputDataLen(){
|
||||
var data = $packet.data;
|
||||
return data.inputData.length;
|
||||
}
|
||||
|
||||
function getInfoLen(){
|
||||
return Util.a2i( $final.getSection('data').getSection('infoLen') )
|
||||
}
|
||||
</script>
|
||||
</packet>
|
||||
@@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<packet extend="base">
|
||||
<req>
|
||||
|
||||
<command>
|
||||
<hex>SD</hex>
|
||||
</command>
|
||||
<data extend="data">
|
||||
<storageType len="1" cn="存储类型">
|
||||
<options>
|
||||
<option cn="使用内部密钥">
|
||||
<hex>0</hex>
|
||||
</option>
|
||||
<option cn="使用外部密钥">
|
||||
<hex>1</hex>
|
||||
</option>
|
||||
</options>
|
||||
</storageType>
|
||||
|
||||
<keyIndex len="27" :if="0 == $packet.data.storageType$option" cn="解密密钥索引">
|
||||
内部密钥索引, 接口层对外限制8位,通讯层限制27位,16位机构号+3位密钥类型+8位密钥索引号。前19位补0
|
||||
</keyIndex>
|
||||
|
||||
<algorithmKey len="2" cn="解密算法类型">
|
||||
解密算法
|
||||
支持算法:RSA、SM2
|
||||
取值参考数据字典
|
||||
</algorithmKey>
|
||||
|
||||
<privateKeyLen len="4" :value="getPrivateKeyLen()" :if="1 == $packet.data.storageType$option" cn="解密私钥长度">
|
||||
仅当密钥索引全0时,存在此域
|
||||
解密密钥长度
|
||||
</privateKeyLen>
|
||||
|
||||
<privateKey :if="1 == $packet.data.storageType$option" cn="解密私钥">
|
||||
仅当密钥索引全0时,存在此域
|
||||
解密的非对称密钥私钥密文
|
||||
</privateKey>
|
||||
|
||||
<inputDataLen len="4" :value="getInputDataLen()" cn="数据长度">
|
||||
待转加密的数据长度
|
||||
</inputDataLen>
|
||||
|
||||
<inputData cn="数据">
|
||||
待转加密的数据
|
||||
</inputData>
|
||||
</data>
|
||||
|
||||
</req>
|
||||
<res>
|
||||
|
||||
<command>
|
||||
<hex>SE</hex>
|
||||
</command>
|
||||
<data>
|
||||
<error len="2" cn="错误码" format="X" :catch="catchError('%s')">
|
||||
<options>
|
||||
<option cn="无错误">
|
||||
<hex>00</hex>
|
||||
</option>
|
||||
</options>
|
||||
</error>
|
||||
|
||||
<keyCiphertextLen len="4" cn="密钥密文长度">
|
||||
使用加密机主密钥加密的对称密钥长度
|
||||
</keyCiphertextLen>
|
||||
|
||||
<keyCiphertext :len="getKeyCiphertextLen()" cn="密钥密文">
|
||||
使用加密机主密钥加密的对称密钥
|
||||
</keyCiphertext>
|
||||
</data>
|
||||
|
||||
</res>
|
||||
<script>
|
||||
function getPrivateKeyLen(){
|
||||
return $packet.data.privateKey.length;
|
||||
}
|
||||
|
||||
function getInputDataLen(){
|
||||
return $packet.data.inputData.length;
|
||||
}
|
||||
|
||||
function getKeyCiphertextLen(){
|
||||
return Util.a2i( $final.getSection('data').getSection('keyCiphertextLen') )
|
||||
}
|
||||
</script>
|
||||
</packet>
|
||||
@@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<packet extend="base">
|
||||
<req>
|
||||
|
||||
<command>
|
||||
<hex>SE</hex>
|
||||
</command>
|
||||
<data extend="data">
|
||||
|
||||
<keyLength len="4" :value="keyLen()" cn="解密密钥长度">
|
||||
仅当存储类型为1时有效
|
||||
解密密钥密文长度
|
||||
</keyLength>
|
||||
|
||||
<key cn="解密密钥">
|
||||
仅当存储类型为1时有效
|
||||
解密密钥密文
|
||||
</key>
|
||||
|
||||
<algorithmKey len="2" cn="解密算法类型">
|
||||
解密算法
|
||||
支持算法:SM4、3DES和AES
|
||||
取值参考数据字典
|
||||
</algorithmKey>
|
||||
|
||||
<iv :len="ivLen()" :if="useCbc()" cn="IV 数据域">
|
||||
仅当算法为非ECB模式下有此域
|
||||
当算法标识为3DES-CBC 时,该域为8B。
|
||||
当算法标识为AES-CBC、 SM4-CBC 时,该域为16B。
|
||||
取值参考数据字典
|
||||
</iv>
|
||||
|
||||
<inputDataLen len="4" :value="getInputDataLen()" cn="数据长度">
|
||||
待转加密的数据长度
|
||||
</inputDataLen>
|
||||
|
||||
<inputData cn="数据">
|
||||
待转加密的数据
|
||||
</inputData>
|
||||
</data>
|
||||
|
||||
</req>
|
||||
<res>
|
||||
|
||||
<command>
|
||||
<hex>SF</hex>
|
||||
</command>
|
||||
<data>
|
||||
<error len="2" cn="错误码" format="X" :catch="catchError('%s')">
|
||||
<options>
|
||||
<option cn="无错误">
|
||||
<hex>00</hex>
|
||||
</option>
|
||||
</options>
|
||||
</error>
|
||||
|
||||
<keyCiphertextLen len="4" cn="密钥密文长度">
|
||||
使用加密机主密钥加密的对称密钥长度
|
||||
</keyCiphertextLen>
|
||||
|
||||
<keyCiphertext :len="getKeyCiphertextLen()" cn="密钥密文">
|
||||
使用加密机主密钥加密的对称密钥
|
||||
</keyCiphertext>
|
||||
</data>
|
||||
|
||||
</res>
|
||||
<script>
|
||||
function keyLen() {
|
||||
return $packet.data.key.length;
|
||||
}
|
||||
|
||||
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(8==algorithmKey ){
|
||||
return 8;
|
||||
}
|
||||
if( 4==algorithmKey || 10==algorithmKey ){
|
||||
return 16;
|
||||
}
|
||||
}
|
||||
|
||||
function getInputDataLen(){
|
||||
return $packet.data.inputData.length;
|
||||
}
|
||||
|
||||
function getKeyCiphertextLen(){
|
||||
return Util.a2i( $final.getSection('data').getSection('keyCiphertextLen') )
|
||||
}
|
||||
</script>
|
||||
</packet>
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<packet extend="base">
|
||||
<req>
|
||||
|
||||
<command>
|
||||
<hex>SF</hex>
|
||||
</command>
|
||||
<data extend="data">
|
||||
<enKeyIndex len="27" cn="加密密钥索引">
|
||||
仅当存储类型为0时有效
|
||||
内部密钥索引, 接口层对外限制8位,通讯层限制27位,16位机构号+3位密钥类型+8位密钥索引号。前19位补0。
|
||||
注意:后八位密钥索引不允许输入全0
|
||||
</enKeyIndex>
|
||||
|
||||
<algorithmKey len="2" cn="加密算法类型">
|
||||
加密算法类型
|
||||
支持算法:3DES、AES、SM1、SM4
|
||||
</algorithmKey>
|
||||
|
||||
<iv :len="ivLen()" :if="useCbc()" cn="加密算法IV">
|
||||
仅当算法为非ECB模式下有此域
|
||||
当算法标识为3DES-CBC 时,该域为8B。
|
||||
当算法标识为AES-CBC、SM1-CBC、SM4-CBC 时,该域为16B。
|
||||
取值参考数据字典
|
||||
</iv>
|
||||
|
||||
|
||||
<enKeyScatterLevel len="1" cn="加密密钥分散级数">
|
||||
密钥分散级数,0~3
|
||||
</enKeyScatterLevel>
|
||||
|
||||
<enScatterFactor1 len="16" :if="hasEnScatterFactor1()" cn="加密分散因子1">
|
||||
仅当保护密钥分散级数不为0时存在
|
||||
</enScatterFactor1>
|
||||
|
||||
<enScatterFactor2 len="16" :if="hasEnScatterFactor2()" cn="加密分散因子2">
|
||||
仅当保护密钥分散级数不为0时存在
|
||||
</enScatterFactor2>
|
||||
|
||||
<enScatterFactor3 len="16" :if="hasEnScatterFactor3()" cn="加密分散因子3">
|
||||
仅当保护密钥分散级数不为0时存在
|
||||
</enScatterFactor3>
|
||||
|
||||
<enScatterAlgorithmKey1 len="2" :if="hasEnScatterFactor1()" cn="加密分散算法标识1">
|
||||
仅当保护密钥分散级数不为0时存在
|
||||
分散算法标识,定义每一次分散的分散算法,数量与密钥分散级数一致
|
||||
如果保护密钥算法类型为3DES、AES,则支持算法:3DES、AES;
|
||||
如果保护密钥算法类型为SM1、SM4,则支持算法:SM1、SM4;
|
||||
取值参考数据字典
|
||||
</enScatterAlgorithmKey1>
|
||||
|
||||
<enScatterAlgorithmKey2 len="2" :if="hasEnScatterFactor2()" cn="加密分散算法标识2">
|
||||
仅当分散级数不为0时存在,同上
|
||||
</enScatterAlgorithmKey2>
|
||||
|
||||
<enScatterAlgorithmKey3 len="2" :if="hasEnScatterFactor3()" cn="加密分散算法标识3">
|
||||
仅当分散级数不为0时存在,同上
|
||||
</enScatterAlgorithmKey3>
|
||||
|
||||
<enScatterAlgorithmVector1 :len="vectorLen()" :if="hasEnScatterFactor1()" 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
|
||||
</enScatterAlgorithmVector1>
|
||||
|
||||
<enScatterAlgorithmVector2 :len="vectorLen()" :if="hasEnScatterFactor2()" cn="加密分散算法的初始向量2">
|
||||
仅当分散级数不为0时存在,同上
|
||||
</enScatterAlgorithmVector2>
|
||||
|
||||
<enScatterAlgorithmVector3 :len="vectorLen()" :if="hasEnScatterFactor3()" cn="加密分散算法的初始向量3">
|
||||
仅当分散级数不为0时存在,同上
|
||||
</enScatterAlgorithmVector3>
|
||||
|
||||
<inputDataLen len="4" :value="inputDataLen()" cn="输入数据长度">
|
||||
待加密机主密钥解密的数据长度
|
||||
</inputDataLen>
|
||||
|
||||
<inputData cn="输入数据">
|
||||
待加密机主密钥解密的数据
|
||||
</inputData>
|
||||
</data>
|
||||
|
||||
</req>
|
||||
<res>
|
||||
|
||||
<command>
|
||||
<hex>SH</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 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(8==algorithmKey ){
|
||||
return 8;
|
||||
}
|
||||
if( 2==algorithmKey || 4==algorithmKey || 10==algorithmKey){
|
||||
return 16;
|
||||
}
|
||||
}
|
||||
|
||||
function hasEnScatterFactor1(){
|
||||
var enKeyScatterLevel = $packet.data.enKeyScatterLevel
|
||||
if( 1 <= enKeyScatterLevel ){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function hasEnScatterFactor2(){
|
||||
var enKeyScatterLevel = $packet.data.enKeyScatterLevel
|
||||
if( 2 <= enKeyScatterLevel ){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function hasEnScatterFactor3(){
|
||||
var enKeyScatterLevel = $packet.data.enKeyScatterLevel
|
||||
if( 3 == enKeyScatterLevel){
|
||||
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 inputDataLen(){
|
||||
var data = $packet.data;
|
||||
return data.inputData.length;
|
||||
}
|
||||
|
||||
function getInfoLen(){
|
||||
return Util.a2i( $final.getSection('data').getSection('infoLen') )
|
||||
}
|
||||
</script>
|
||||
</packet>
|
||||
Reference in New Issue
Block a user