Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
4f9c46b1
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
4f9c46b1
编写于
6月 25, 2022
作者:
O
openharmony_ci
提交者:
Gitee
6月 25, 2022
浏览文件
操作
浏览文件
下载
差异文件
!3787 huks_国密算法失败用例修改
Merge pull request !3787 from yuanyuhang/yyh_0625_01_01
上级
9a595625
7243e7dc
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
386 addition
and
19 deletion
+386
-19
security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksSM4BasicCallbackJsunit.test.js
...js/test/Cipher/SecurityHuksSM4BasicCallbackJsunit.test.js
+227
-13
security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherSM4BasicPromiseJsunit.test.js
...st/Cipher/SecurityHuksCipherSM4BasicPromiseJsunit.test.js
+141
-3
security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksSM2BasicFinish63KBCallbackJsunit.test.js
...rify/SecurityHuksSM2BasicFinish63KBCallbackJsunit.test.js
+0
-1
security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksSM2BasicFinish65KBCallbackJsunit.test.js
...rify/SecurityHuksSM2BasicFinish65KBCallbackJsunit.test.js
+0
-1
security/security_huks_basic/utils/param/publicFunc.js
security/security_huks_basic/utils/param/publicFunc.js
+18
-1
未找到文件。
security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksSM4BasicCallbackJsunit.test.js
浏览文件 @
4f9c46b1
...
...
@@ -13,11 +13,16 @@
* limitations under the License.
*/
import
{
describe
,
it
}
from
'
deccjsunit/index
'
;
import
{
describe
,
it
,
expect
}
from
'
deccjsunit/index
'
;
import
{
HuksCipherSM4
}
from
'
../../../../../../../utils/param/cipher/publicCipherParam
'
;
import
{
HksTag
}
from
'
../../../../../../../utils/param/publicParam
'
;
import
{
stringToUint8Array
}
from
'
../../../../../../../utils/param/publicFunc
'
;
import
{
publicCipherFunc
,
IV
,
updateResult
}
from
'
./SecurityHuksAESBasicCallbackJsunit.test
'
;
import
{
stringToUint8Array
,
arrayEqual
}
from
'
../../../../../../../utils/param/publicFunc
'
;
import
huks
from
'
@ohos.security.huks
'
;
let
IV
=
'
0000000000000000
'
;
let
plainData
;
let
encryptedResult
;
var
handle
;
const
plainString48Bytes
=
'
Hks_SM4_Cipher_Test_000000000000000000000_string
'
;
const
plainData48Bytes
=
stringToUint8Array
(
plainString48Bytes
);
...
...
@@ -36,6 +41,215 @@ let genHuksOptions = {
inData
:
new
Uint8Array
(
new
Array
()),
};
async
function
publicGenerateKeyFunc
(
srcKeyAlias
,
genHuksOptionsNONECBC
)
{
await
generateKey
(
srcKeyAlias
,
genHuksOptionsNONECBC
)
.
then
((
data
)
=>
{
console
.
log
(
`test generateKey data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
data
.
errorCode
==
0
).
assertTrue
();
})
.
catch
((
err
)
=>
{
console
.
log
(
'
test generateKey err information:
'
+
JSON
.
stringify
(
err
));
expect
(
null
).
assertFail
();
});
}
function
generateKey
(
srcKeyAlias
,
HuksOptions
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
huks
.
generateKey
(
srcKeyAlias
,
HuksOptions
,
function
(
err
,
data
)
{
console
.
log
(
`test generateKey data:
${
JSON
.
stringify
(
data
)}
`
);
if
(
err
.
code
!==
0
)
{
console
.
log
(
'
test generateKey err information:
'
+
JSON
.
stringify
(
err
));
reject
(
err
);
}
else
{
resolve
(
data
);
}
});
});
}
async
function
publicInitFunc
(
srcKeyAlias
,
HuksOptions
)
{
await
init
(
srcKeyAlias
,
HuksOptions
)
.
then
((
data
)
=>
{
console
.
log
(
`test init data:
${
JSON
.
stringify
(
data
)}
`
);
handle
=
data
.
handle
;
expect
(
data
.
errorCode
==
0
).
assertTrue
();
})
.
catch
((
err
)
=>
{
console
.
log
(
'
test init err information:
'
+
JSON
.
stringify
(
err
));
expect
(
null
).
assertFail
();
});
}
function
init
(
srcKeyAlias
,
HuksOptions
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
huks
.
init
(
srcKeyAlias
,
HuksOptions
,
function
(
err
,
data
)
{
if
(
err
.
code
!==
0
)
{
console
.
log
(
'
test init err information:
'
+
JSON
.
stringify
(
err
));
reject
(
err
);
}
else
{
resolve
(
data
);
}
});
});
}
async
function
publicUpdateFunc
(
HuksOptions
,
thirdInderfaceName
,
isEncrypt
)
{
const
maxUpdateSize
=
64
;
const
inData
=
HuksOptions
.
inData
;
const
lastInDataPosition
=
inData
.
length
-
1
;
let
inDataSegSize
=
maxUpdateSize
;
let
inDataSegPosition
=
0
;
let
isFinished
=
false
;
let
outData
=
[];
while
(
inDataSegPosition
<=
lastInDataPosition
)
{
if
(
inDataSegPosition
+
maxUpdateSize
>
lastInDataPosition
)
{
isFinished
=
true
;
inDataSegSize
=
lastInDataPosition
-
inDataSegPosition
+
1
;
break
;
}
HuksOptions
.
inData
=
new
Uint8Array
(
Array
.
from
(
inData
).
slice
(
inDataSegPosition
,
inDataSegPosition
+
inDataSegSize
)
);
await
updateCallback
(
handle
,
HuksOptions
)
.
then
((
data
)
=>
{
console
.
log
(
`test update data
${
JSON
.
stringify
(
data
)}
`
);
outData
=
outData
.
concat
(
Array
.
from
(
data
.
outData
));
expect
(
data
.
errorCode
===
0
).
assertTrue
();
})
.
catch
((
err
)
=>
{
console
.
log
(
'
test update err information:
'
+
err
);
expect
(
null
).
assertFail
();
});
if
((
!
isFinished
)
&&
(
inDataSegPosition
+
maxUpdateSize
>
lastInDataPosition
))
{
console
.
log
(
`update size invalid isFinished =
${
isFinished
}
`
);
console
.
log
(
`inDataSegPosition =
${
inDataSegPosition
}
`
);
console
.
log
(
`lastInDataPosition =
${
lastInDataPosition
}
`
);
expect
(
null
).
assertFail
();
return
;
}
inDataSegPosition
+=
maxUpdateSize
;
}
if
(
thirdInderfaceName
==
'
finish
'
)
{
HuksOptions
.
inData
=
new
Uint8Array
(
Array
.
from
(
inData
).
slice
(
inDataSegPosition
,
inDataSegPosition
+
inDataSegSize
)
);
await
finishCallback
(
handle
,
HuksOptions
)
.
then
((
data
)
=>
{
console
.
log
(
`test finish data:
${
JSON
.
stringify
(
data
)}
`
);
outData
=
outData
.
concat
(
Array
.
from
(
data
.
outData
));
expect
(
data
.
errorCode
===
0
).
assertTrue
();
if
(
isEncrypt
)
{
encryptedResult
=
outData
;
console
.
log
(
`encrypted data:
${
encryptedResult
}
`
);
}
else
{
console
.
log
(
`decrypted data:
${
outData
}
`
);
expect
(
arrayEqual
(
outData
,
plainData
)).
assertTrue
();
}
})
.
catch
((
err
)
=>
{
console
.
log
(
'
test finish err information:
'
+
JSON
.
stringify
(
err
));
expect
(
null
).
assertFail
();
});
}
else
if
(
thirdInderfaceName
==
'
abort
'
)
{
await
abortCallback
(
handle
,
HuksOptions
)
.
then
((
data
)
=>
{
console
.
log
(
`test abort data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
data
.
errorCode
===
0
).
assertTrue
();
})
.
catch
((
err
)
=>
{
console
.
log
(
'
test abort err information:
'
+
JSON
.
stringify
(
err
));
expect
(
null
).
assertFail
();
});
}
}
function
updateCallback
(
handle
,
HuksOptions
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
huks
.
update
(
handle
,
HuksOptions
,
function
(
err
,
data
)
{
if
(
err
.
code
!==
0
)
{
console
.
log
(
'
test update err information:
'
+
JSON
.
stringify
(
err
));
reject
(
err
);
}
else
{
resolve
(
data
);
}
});
});
}
function
finishCallback
(
handle
,
huksOptionsFinish
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
huks
.
finish
(
handle
,
huksOptionsFinish
,
function
(
err
,
data
)
{
if
(
err
.
code
!==
0
)
{
console
.
log
(
'
test generateKey err information:
'
+
JSON
.
stringify
(
err
));
reject
(
err
);
}
else
{
resolve
(
data
);
}
});
});
}
function
abortCallback
(
handle
,
huksOptionsAbort
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
huks
.
abort
(
handle
,
huksOptionsAbort
,
function
(
err
,
data
)
{
if
(
err
.
code
!==
0
)
{
console
.
log
(
'
test abort err information:
'
+
JSON
.
stringify
(
err
));
reject
(
err
);
}
else
{
resolve
(
data
);
}
});
});
}
async
function
publicDeleteKeyFunc
(
srcKeyAlias
,
genHuksOptionsNONECBC
)
{
await
deleteKey
(
srcKeyAlias
,
genHuksOptionsNONECBC
)
.
then
((
data
)
=>
{
console
.
log
(
`test deleteKey data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
data
.
errorCode
==
0
).
assertTrue
();
})
.
catch
((
err
)
=>
{
console
.
log
(
'
test deleteKey err information:
'
+
JSON
.
stringify
(
err
));
expect
(
null
).
assertFail
();
});
}
function
deleteKey
(
srcKeyAlias
,
HuksOptions
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
huks
.
deleteKey
(
srcKeyAlias
,
HuksOptions
,
function
(
err
,
data
)
{
if
(
err
.
code
!==
0
)
{
console
.
log
(
'
test deleteKey err information:
'
+
JSON
.
stringify
(
err
));
reject
(
err
);
}
else
{
resolve
(
data
);
}
});
});
}
async
function
publicCipherFunc
(
srcKeyAlias
,
genHuksOptions
,
HuksOptions
,
thirdInderfaceName
,
isEncrypt
)
{
try
{
if
(
isEncrypt
)
{
plainData
=
HuksOptions
.
inData
;
await
publicGenerateKeyFunc
(
srcKeyAlias
,
genHuksOptions
);
}
await
publicInitFunc
(
srcKeyAlias
,
HuksOptions
);
await
publicUpdateFunc
(
HuksOptions
,
thirdInderfaceName
,
isEncrypt
);
if
(
!
isEncrypt
||
(
isEncrypt
&&
thirdInderfaceName
==
'
abort
'
))
{
await
publicDeleteKeyFunc
(
srcKeyAlias
,
genHuksOptions
);
}
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
}
describe
(
'
SecurityHuksCipherSM4CallbackJsunit
'
,
function
()
{
// HKS_SUPPORT_SM4_CBC_NOPADDING
it
(
'
testCipherSM4001_48
'
,
0
,
async
function
(
done
)
{
...
...
@@ -70,7 +284,7 @@ describe('SecurityHuksCipherSM4CallbackJsunit', function () {
HuksCipherSM4
.
HuksKeySM4BLOCKMODECBC
,
{
tag
:
HksTag
.
HKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
new
Uint8Array
(
update
Result
),
inData
:
new
Uint8Array
(
encrypted
Result
),
};
await
publicCipherFunc
(
srcKeyAlias
,
...
...
@@ -114,7 +328,7 @@ describe('SecurityHuksCipherSM4CallbackJsunit', function () {
HuksCipherSM4
.
HuksKeySM4BLOCKMODECBC
,
{
tag
:
HksTag
.
HKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
new
Uint8Array
(
update
Result
),
inData
:
new
Uint8Array
(
encrypted
Result
),
};
await
publicCipherFunc
(
srcKeyAlias
,
...
...
@@ -211,7 +425,7 @@ describe('SecurityHuksCipherSM4CallbackJsunit', function () {
HuksCipherSM4
.
HuksKeySM4BLOCKMODECBC
,
{
tag
:
HksTag
.
HKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
new
Uint8Array
(
update
Result
),
inData
:
new
Uint8Array
(
encrypted
Result
),
};
await
publicCipherFunc
(
srcKeyAlias
,
...
...
@@ -255,7 +469,7 @@ describe('SecurityHuksCipherSM4CallbackJsunit', function () {
HuksCipherSM4
.
HuksKeySM4BLOCKMODECBC
,
{
tag
:
HksTag
.
HKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
new
Uint8Array
(
update
Result
),
inData
:
new
Uint8Array
(
encrypted
Result
),
};
await
publicCipherFunc
(
srcKeyAlias
,
...
...
@@ -352,7 +566,7 @@ describe('SecurityHuksCipherSM4CallbackJsunit', function () {
HuksCipherSM4
.
HuksKeySM4BLOCKMODECTR
,
{
tag
:
HksTag
.
HKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
new
Uint8Array
(
update
Result
),
inData
:
new
Uint8Array
(
encrypted
Result
),
};
await
publicCipherFunc
(
srcKeyAlias
,
...
...
@@ -396,7 +610,7 @@ describe('SecurityHuksCipherSM4CallbackJsunit', function () {
HuksCipherSM4
.
HuksKeySM4BLOCKMODECTR
,
{
tag
:
HksTag
.
HKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
new
Uint8Array
(
update
Result
),
inData
:
new
Uint8Array
(
encrypted
Result
),
};
await
publicCipherFunc
(
srcKeyAlias
,
...
...
@@ -493,7 +707,7 @@ describe('SecurityHuksCipherSM4CallbackJsunit', function () {
HuksCipherSM4
.
HuksKeySM4BLOCKMODEECB
,
{
tag
:
HksTag
.
HKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
new
Uint8Array
(
update
Result
),
inData
:
new
Uint8Array
(
encrypted
Result
),
};
await
publicCipherFunc
(
srcKeyAlias
,
...
...
@@ -537,7 +751,7 @@ describe('SecurityHuksCipherSM4CallbackJsunit', function () {
HuksCipherSM4
.
HuksKeySM4BLOCKMODEECB
,
{
tag
:
HksTag
.
HKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
new
Uint8Array
(
update
Result
),
inData
:
new
Uint8Array
(
encrypted
Result
),
};
await
publicCipherFunc
(
srcKeyAlias
,
...
...
@@ -634,7 +848,7 @@ describe('SecurityHuksCipherSM4CallbackJsunit', function () {
HuksCipherSM4
.
HuksKeySM4BLOCKMODEECB
,
{
tag
:
HksTag
.
HKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
new
Uint8Array
(
update
Result
),
inData
:
new
Uint8Array
(
encrypted
Result
),
};
await
publicCipherFunc
(
srcKeyAlias
,
...
...
@@ -678,7 +892,7 @@ describe('SecurityHuksCipherSM4CallbackJsunit', function () {
HuksCipherSM4
.
HuksKeySM4BLOCKMODEECB
,
{
tag
:
HksTag
.
HKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
new
Uint8Array
(
update
Result
),
inData
:
new
Uint8Array
(
encrypted
Result
),
};
await
publicCipherFunc
(
srcKeyAlias
,
...
...
security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherSM4BasicPromiseJsunit.test.js
浏览文件 @
4f9c46b1
...
...
@@ -13,11 +13,16 @@
* limitations under the License.
*/
import
{
describe
,
it
}
from
'
deccjsunit/index
'
;
import
{
describe
,
it
,
expect
}
from
'
deccjsunit/index
'
;
import
{
HuksCipherSM4
}
from
'
../../../../../../../utils/param/cipher/publicCipherParam
'
;
import
{
HksTag
}
from
'
../../../../../../../utils/param/publicParam
'
;
import
{
stringToUint8Array
}
from
'
../../../../../../../utils/param/publicFunc
'
;
import
{
publicCipherFunc
,
IV
,
encryptedResult
}
from
'
./SecurityHuksCipherAESBasicPromiseJsunit.test
'
;
import
{
stringToUint8Array
,
arrayEqual
}
from
'
../../../../../../../utils/param/publicFunc
'
;
import
huks
from
'
@ohos.security.huks
'
;
let
IV
=
'
0000000000000000
'
;
let
plainData
;
let
encryptedResult
;
var
handle
;
const
plainString48Bytes
=
'
Hks_SM4_Cipher_Test_000000000000000000000_string
'
;
const
plainData48Bytes
=
stringToUint8Array
(
plainString48Bytes
);
...
...
@@ -36,6 +41,139 @@ let genHuksOptions = {
inData
:
new
Uint8Array
(
new
Array
()),
};
async
function
publicGenerateKeyFunc
(
srcKeyAlias
,
genHuksOptionsNONECBC
)
{
await
huks
.
generateKey
(
srcKeyAlias
,
genHuksOptionsNONECBC
)
.
then
((
data
)
=>
{
console
.
log
(
`test generateKey data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
data
.
errorCode
==
0
).
assertTrue
();
})
.
catch
((
err
)
=>
{
console
.
log
(
'
test generateKey err information:
'
+
JSON
.
stringify
(
err
));
expect
(
null
).
assertFail
();
});
}
async
function
publicInitFunc
(
srcKeyAlias
,
HuksOptions
)
{
await
huks
.
init
(
srcKeyAlias
,
HuksOptions
)
.
then
((
data
)
=>
{
console
.
log
(
`test init data:
${
JSON
.
stringify
(
data
)}
`
);
handle
=
data
.
handle
;
expect
(
data
.
errorCode
==
0
).
assertTrue
();
})
.
catch
((
err
)
=>
{
console
.
log
(
'
test init err information:
'
+
JSON
.
stringify
(
err
));
expect
(
null
).
assertFail
();
});
}
async
function
publicUpdateFunc
(
HuksOptions
,
thirdInderfaceName
,
isEncrypt
)
{
const
maxUpdateSize
=
64
;
const
inData
=
HuksOptions
.
inData
;
const
lastInDataPosition
=
inData
.
length
-
1
;
let
inDataSegSize
=
maxUpdateSize
;
let
inDataSegPosition
=
0
;
let
isFinished
=
false
;
let
outData
=
[];
while
(
inDataSegPosition
<=
lastInDataPosition
)
{
if
(
inDataSegPosition
+
maxUpdateSize
>
lastInDataPosition
)
{
isFinished
=
true
;
inDataSegSize
=
lastInDataPosition
-
inDataSegPosition
+
1
;
break
;
}
HuksOptions
.
inData
=
new
Uint8Array
(
Array
.
from
(
inData
).
slice
(
inDataSegPosition
,
inDataSegPosition
+
inDataSegSize
)
);
await
huks
.
update
(
handle
,
HuksOptions
)
.
then
((
data
)
=>
{
console
.
log
(
`test update data
${
JSON
.
stringify
(
data
)}
`
);
outData
=
outData
.
concat
(
Array
.
from
(
data
.
outData
));
expect
(
data
.
errorCode
===
0
).
assertTrue
();
})
.
catch
((
err
)
=>
{
console
.
log
(
'
test update err information:
'
+
err
);
expect
(
null
).
assertFail
();
});
if
((
!
isFinished
)
&&
(
inDataSegPosition
+
maxUpdateSize
>
lastInDataPosition
))
{
console
.
log
(
`update size invalid isFinished =
${
isFinished
}
`
);
console
.
log
(
`inDataSegPosition =
${
inDataSegPosition
}
`
);
console
.
log
(
`lastInDataPosition =
${
lastInDataPosition
}
`
);
expect
(
null
).
assertFail
();
return
;
}
inDataSegPosition
+=
maxUpdateSize
;
}
if
(
thirdInderfaceName
==
'
finish
'
)
{
HuksOptions
.
inData
=
new
Uint8Array
(
Array
.
from
(
inData
).
slice
(
inDataSegPosition
,
inDataSegPosition
+
inDataSegSize
)
);
await
huks
.
finish
(
handle
,
HuksOptions
)
.
then
((
data
)
=>
{
console
.
log
(
`test finish data:
${
JSON
.
stringify
(
data
)}
`
);
outData
=
outData
.
concat
(
Array
.
from
(
data
.
outData
));
expect
(
data
.
errorCode
===
0
).
assertTrue
();
if
(
isEncrypt
)
{
encryptedResult
=
outData
;
console
.
log
(
`encrypted data:
${
encryptedResult
}
`
);
}
else
{
console
.
log
(
`decrypted data:
${
outData
}
`
);
expect
(
arrayEqual
(
outData
,
plainData
)).
assertTrue
();
}
})
.
catch
((
err
)
=>
{
console
.
log
(
'
test finish err information:
'
+
JSON
.
stringify
(
err
));
expect
(
null
).
assertFail
();
});
}
else
if
(
thirdInderfaceName
==
'
abort
'
)
{
await
huks
.
abort
(
handle
,
HuksOptions
)
.
then
((
data
)
=>
{
console
.
log
(
`test abort data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
data
.
errorCode
===
0
).
assertTrue
();
})
.
catch
((
err
)
=>
{
console
.
log
(
'
test abort err information:
'
+
JSON
.
stringify
(
err
));
expect
(
null
).
assertFail
();
});
}
}
async
function
publicDeleteKeyFunc
(
srcKeyAlias
,
genHuksOptionsNONECBC
)
{
await
huks
.
deleteKey
(
srcKeyAlias
,
genHuksOptionsNONECBC
)
.
then
((
data
)
=>
{
console
.
log
(
`test deleteKey data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
data
.
errorCode
==
0
).
assertTrue
();
})
.
catch
((
err
)
=>
{
console
.
log
(
'
test deleteKey err information:
'
+
JSON
.
stringify
(
err
));
expect
(
null
).
assertFail
();
});
}
async
function
publicCipherFunc
(
srcKeyAlias
,
genHuksOptions
,
HuksOptions
,
thirdInderfaceName
,
isEncrypt
)
{
try
{
if
(
isEncrypt
)
{
plainData
=
HuksOptions
.
inData
;
await
publicGenerateKeyFunc
(
srcKeyAlias
,
genHuksOptions
);
}
await
publicInitFunc
(
srcKeyAlias
,
HuksOptions
);
await
publicUpdateFunc
(
HuksOptions
,
thirdInderfaceName
,
isEncrypt
);
if
(
!
isEncrypt
||
(
isEncrypt
&&
thirdInderfaceName
==
'
abort
'
))
{
await
publicDeleteKeyFunc
(
srcKeyAlias
,
genHuksOptions
);
}
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
}
describe
(
'
SecurityHuksCipherSM4PromiseJsunit
'
,
function
()
{
// HKS_SUPPORT_SM4_CBC_NOPADDING
it
(
'
testCipherSM4101_48
'
,
0
,
async
function
(
done
)
{
...
...
security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksSM2BasicFinish63KBCallbackJsunit.test.js
浏览文件 @
4f9c46b1
...
...
@@ -34,7 +34,6 @@ describe('SecurityHuksSignVerifySM2CallbackJsunit', function () {
};
finishOutData
=
await
publicSignVerifyFunc
(
srcKeyAlies
,
srcKeyAlies
+
'
New
'
,
HuksOptions
,
'
finish
'
,
true
,
...
...
security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksSM2BasicFinish65KBCallbackJsunit.test.js
浏览文件 @
4f9c46b1
...
...
@@ -34,7 +34,6 @@ describe('SecurityHuksSignVerifySM2CallbackJsunit', function () {
};
finishOutData
=
await
publicSignVerifyFunc
(
srcKeyAlies
,
srcKeyAlies
+
'
New
'
,
HuksOptions
,
'
finish
'
,
true
,
...
...
security/security_huks_basic/utils/param/publicFunc.js
浏览文件 @
4f9c46b1
...
...
@@ -35,5 +35,22 @@ function stringToUint8Array(str) {
var
tmpUint8Array
=
new
Uint8Array
(
arr
);
return
tmpUint8Array
;
}
function
arrayEqual
(
a
,
b
)
{
if
((
!
a
instanceof
Array
)
||
(
!
b
instanceof
Array
))
{
return
false
;
}
if
(
a
.
length
!==
b
.
length
)
{
return
false
;
}
for
(
let
i
=
0
;
i
<
a
.
length
;
++
i
)
{
if
((
!
a
instanceof
Number
)
||
(
!
b
instanceof
Number
))
{
return
false
;
}
if
(
a
[
i
]
!==
b
[
i
])
{
return
false
;
}
}
return
true
;
}
export
{
stringToArray
,
uint8ArrayToString
,
stringToUint8Array
};
export
{
stringToArray
,
uint8ArrayToString
,
stringToUint8Array
,
arrayEqual
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录