Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
85692db0
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看板
提交
85692db0
编写于
3月 30, 2023
作者:
伞
伞木希美
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
huks:add testcase,appoint configure while using
Signed-off-by:
N
伞木希美
<
zhanghanlin9@huawei.com
>
上级
cf3830df
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
2333 addition
and
122 deletion
+2333
-122
security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSASignExtendJsunit.test.js
...s/test/SignVerify/SecurityHuksRSASignExtendJsunit.test.js
+2333
-122
未找到文件。
security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSASignExtendJsunit.test.js
浏览文件 @
85692db0
...
@@ -13,10 +13,33 @@
...
@@ -13,10 +13,33 @@
* limitations under the License.
* limitations under the License.
*/
*/
import
huks
from
"
@ohos.security.huks
"
;
import
huks
from
"
@ohos.security.huks
"
;
import
{
describe
,
it
,
expect
,
beforeAll
}
from
"
@ohos/hypium
"
;
import
{
describe
,
it
,
expect
}
from
"
@ohos/hypium
"
;
import
Data
from
'
../../../../../../utils/data.json
'
;
import
Data
from
'
../../../../../../utils/data.json
'
;
import
{
stringToUint8Array
,
checkSoftware
}
from
'
../../../../../../utils/param/publicFunc
'
;
import
{
import
{
HuksSignVerifyRSA
}
from
'
../../../../../../utils/param/signverify/publicSignverifyParam
'
;
stringToUint8Array
,
arrayEqual
,
checkSoftware
}
from
'
../../../../../../utils/param/publicFunc
'
;
import
{
HuksSignVerifyRSA
,
HuksSignVerifyDSA
,
HuksSignVerifyECC
,
HuksSignVerifyED25519
,
HuksSignVerifySM2
}
from
'
../../../../../../utils/param/signverify/publicSignverifyParam
'
;
import
{
HuksAgreeECDH
}
from
'
../../../../../../utils/param/agree/publicAgreeParam
'
;
import
{
HuksCipherAES
,
HuksCipherRSA
,
HuksCipherSM4
}
from
'
../../../../../../utils/param/cipher/publicCipherParam
'
;
import
{
HuksDeriveHKDF
,
HuksDerivePBKDF2
}
from
'
../../../../../../utils/param/derive/publicDeriveParam
'
;
import
{
HuksHmac
}
from
'
../../../../../../utils/param/hmac/publicHmacParam
'
;
let
inDataString
=
"
Hks_RSA_Sign_Verify_Test_0000000000000000000000000000000000000000000000000000000
"
+
let
inDataString
=
"
Hks_RSA_Sign_Verify_Test_0000000000000000000000000000000000000000000000000000000
"
+
"
00000000000000000000000000000000000000000000000000000000000000000000000000000000
"
+
"
00000000000000000000000000000000000000000000000000000000000000000000000000000000
"
+
...
@@ -29,10 +52,16 @@ let srcData64 = Data.Data64b;
...
@@ -29,10 +52,16 @@ let srcData64 = Data.Data64b;
let
srcData64Kb
=
stringToUint8Array
(
srcData64
);
let
srcData64Kb
=
stringToUint8Array
(
srcData64
);
let
signedResult
;
let
signedResult
;
let
handle
;
let
handle
;
let
IV
=
'
0000000000000000
'
;
let
IVErr
=
'
00000000000000000000000000000000000000000000000000000000000000000000
'
;
let
AAD
=
'
0000000000000000
'
;
let
NONCE
=
'
00000000000
'
;
let
AEAD
=
'
0000000000000000
'
;
let
useSoftware
=
true
;
let
useSoftware
=
true
;
async
function
publicGenerateKeyFunc
(
srcKeyAlias
,
genHuksOptionsNONECBC
)
{
async
function
publicGenerateKeyFunc
(
srcKeyAlias
,
genHuksOptionsNONECBC
)
{
console
.
error
(
`
enter promise generateKeyItem
`
);
console
.
error
(
`
promise: generateKeyItem options, data =
${
JSON
.
stringify
(
genHuksOptionsNONECBC
)}
`
);
try
{
try
{
await
huks
.
generateKeyItem
(
srcKeyAlias
,
genHuksOptionsNONECBC
)
await
huks
.
generateKeyItem
(
srcKeyAlias
,
genHuksOptionsNONECBC
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
...
@@ -83,6 +112,23 @@ async function publicInitSessionError(srcKeyAlias, HuksOptions, errCode) {
...
@@ -83,6 +112,23 @@ async function publicInitSessionError(srcKeyAlias, HuksOptions, errCode) {
}
}
}
}
async
function
publicDeleteKeyFunc
(
srcKeyAlias
,
genHuksOptionsNONECBC
)
{
console
.
error
(
`enter promise deleteKeyItem`
);
try
{
await
huks
.
deleteKeyItem
(
srcKeyAlias
,
genHuksOptionsNONECBC
)
.
then
((
data
)
=>
{
console
.
error
(
`promise: deleteKeyItem key success, data =
${
JSON
.
stringify
(
data
)}
`
);
})
.
catch
(
error
=>
{
console
.
error
(
`promise: deleteKeyItem failed, code:
${
error
.
code
}
, msg:
${
error
.
message
}
`
);
expect
(
null
).
assertFail
();
});
}
catch
(
error
)
{
console
.
error
(
`promise: deleteKeyItem input arg invalid, code:
${
error
.
code
}
, msg:
${
error
.
message
}
`
);
expect
(
null
).
assertFail
();
}
}
async
function
publicUpdateSessionFunction
(
HuksOptions
)
{
async
function
publicUpdateSessionFunction
(
HuksOptions
)
{
const
maxUpdateSize
=
64
;
const
maxUpdateSize
=
64
;
const
inData
=
HuksOptions
.
inData
;
const
inData
=
HuksOptions
.
inData
;
...
@@ -121,29 +167,33 @@ async function publicUpdateSessionFunction(HuksOptions) {
...
@@ -121,29 +167,33 @@ async function publicUpdateSessionFunction(HuksOptions) {
console
.
log
(
`update size invalid isFinished =
${
isFinished
}
`
);
console
.
log
(
`update size invalid isFinished =
${
isFinished
}
`
);
console
.
log
(
`inDataSegPosition =
${
inDataSegPosition
}
`
);
console
.
log
(
`inDataSegPosition =
${
inDataSegPosition
}
`
);
console
.
log
(
`lastInDataPosition =
${
lastInDataPosition
}
`
);
console
.
log
(
`lastInDataPosition =
${
lastInDataPosition
}
`
);
outData
=
[];
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
return
;
return
outData
;
}
}
inDataSegPosition
+=
maxUpdateSize
;
inDataSegPosition
+=
maxUpdateSize
;
}
}
return
outData
;
}
}
async
function
publicUpdate
Error
(
HuksOptions
,
errCode
)
{
async
function
publicUpdate
Once
(
HuksOptions
)
{
console
.
error
(
`enter promise doUpdate`
);
console
.
error
(
`enter promise doUpdate`
);
let
outData
;
try
{
try
{
await
huks
.
updateSession
(
handle
,
HuksOptions
)
await
huks
.
updateSession
(
handle
,
HuksOptions
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
console
.
error
(
`promise: doUpdate success, data =
${
JSON
.
stringify
(
data
)}
`
);
console
.
error
(
`promise: doUpdate success, data =
${
JSON
.
stringify
(
data
)}
`
);
expect
(
null
).
assertFail
()
;
outData
=
data
.
outData
;
})
})
.
catch
(
error
=>
{
.
catch
(
error
=>
{
console
.
error
(
`promise: doUpdate failed, code:
${
error
.
code
}
, msg:
${
error
.
message
}
`
);
console
.
error
(
`promise: doUpdate failed, code:
${
error
.
code
}
, msg:
${
error
.
message
}
`
);
expect
(
err
.
code
==
errCode
).
assertTrue
();
expect
(
null
).
assertFail
();
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
`promise: doUpdate input arg invalid, code:
${
error
.
code
}
, msg:
${
error
.
message
}
`
);
console
.
error
(
`promise: doUpdate input arg invalid, code:
${
error
.
code
}
, msg:
${
error
.
message
}
`
);
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
return
outData
;
}
}
async
function
publicFinishSessionFunc
(
HuksOptions
)
{
async
function
publicFinishSessionFunc
(
HuksOptions
)
{
...
@@ -166,29 +216,33 @@ async function publicFinishSessionFunc(HuksOptions) {
...
@@ -166,29 +216,33 @@ async function publicFinishSessionFunc(HuksOptions) {
}
}
}
}
async
function
publicDeleteKeyFunc
(
srcKeyAlias
,
genHuksOptionsNONECBC
)
{
async
function
publicExportFunc
(
srcKeyAlies
,
HuksOptions
)
{
console
.
error
(
`enter promise deleteKeyItem`
);
console
.
info
(
`enter promise export`
);
let
exportKey
;
try
{
try
{
await
huks
.
deleteKeyItem
(
srcKeyAlias
,
genHuksOptionsNONECBC
)
await
huks
.
exportKeyItem
(
srcKeyAlies
,
HuksOptions
)
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
console
.
error
(
`promise: deleteKeyItem key success, data =
${
JSON
.
stringify
(
data
)}
`
);
console
.
info
(
`promise: exportKeyItem success, data =
${
JSON
.
stringify
(
data
)}
`
);
exportKey
=
data
.
outData
;
})
})
.
catch
(
error
=>
{
.
catch
(
error
=>
{
console
.
error
(
`promise:
delete
KeyItem failed, code:
${
error
.
code
}
, msg:
${
error
.
message
}
`
);
console
.
error
(
`promise:
export
KeyItem failed, code:
${
error
.
code
}
, msg:
${
error
.
message
}
`
);
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
`promise:
delete
KeyItem input arg invalid, code:
${
error
.
code
}
, msg:
${
error
.
message
}
`
);
console
.
error
(
`promise:
export
KeyItem input arg invalid, code:
${
error
.
code
}
, msg:
${
error
.
message
}
`
);
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
return
exportKey
;
}
}
export
default
function
SecurityHuksRSASignExtendJsunit
()
{
export
default
function
SecurityHuksRSASignExtendJsunit
()
{
describe
(
'
SecurityHuksRSASignExtendJsunit
'
,
function
()
{
describe
(
'
SecurityHuksRSASignExtendJsunit
'
,
function
()
{
beforeAll
(
async
function
(
done
)
{
beforeAll
(
async
function
(
done
)
{
useSoftware
=
await
checkSoftware
();
useSoftware
=
checkSoftware
();
done
();
done
();
})
})
/**
/**
* @tc.number Security_HUKS_RSA_SignExtend_0100
* @tc.number Security_HUKS_RSA_SignExtend_0100
* @tc.name No Padding and Sign Verify with RSA.
* @tc.name No Padding and Sign Verify with RSA.
...
@@ -196,50 +250,48 @@ export default function SecurityHuksRSASignExtendJsunit() {
...
@@ -196,50 +250,48 @@ export default function SecurityHuksRSASignExtendJsunit() {
*/
*/
it
(
"
Security_HUKS_RSA_SignExtend_0100
"
,
0
,
async
function
(
done
)
{
it
(
"
Security_HUKS_RSA_SignExtend_0100
"
,
0
,
async
function
(
done
)
{
let
srcKeyAliesGen
=
"
Security_HUKS_RSA_SignExtend_0100_Gen
"
;
let
srcKeyAliesGen
=
"
Security_HUKS_RSA_SignExtend_0100_Gen
"
;
if
(
useSoftware
)
{
let
HuksOptionsGen
=
{
let
HuksOptionsGen
=
{
properties
:
new
Array
(
properties
:
new
Array
(
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyRSAPurposeSINGVERIFY
,
HuksSignVerifyRSA
.
HuksKeyRSAPurposeSINGVERIFY
,
HuksSignVerifyRSA
.
HuksTagPKCS1DigestSHA256
,
HuksSignVerifyRSA
.
HuksTagPKCS1DigestSHA256
,
HuksSignVerifyRSA
.
HuksKeyRSASize4096
HuksSignVerifyRSA
.
HuksKeyRSASize4096
),
),
inData
:
srcData64Kb
,
inData
:
srcData64Kb
,
};
};
let
HuksOptionsSign
=
{
let
HuksOptionsSign
=
{
properties
:
new
Array
(
properties
:
new
Array
(
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyRSAPurposeSIGN
,
HuksSignVerifyRSA
.
HuksKeyRSAPurposeSIGN
,
HuksSignVerifyRSA
.
HuksTagPKCS1DigestSHA256
,
HuksSignVerifyRSA
.
HuksTagPKCS1DigestSHA256
,
HuksSignVerifyRSA
.
HuksKeyRSAPADDINGPKCS1V15
,
HuksSignVerifyRSA
.
HuksKeyRSAPADDINGPKCS1V15
,
HuksSignVerifyRSA
.
HuksKeyRSASize4096
HuksSignVerifyRSA
.
HuksKeyRSASize4096
),
),
inData
:
srcData64Kb
,
inData
:
srcData64Kb
,
}
}
await
publicGenerateKeyFunc
(
srcKeyAliesGen
,
HuksOptionsGen
);
await
publicGenerateKeyFunc
(
srcKeyAliesGen
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAliesGen
,
HuksOptionsSign
);
await
publicInitFunc
(
srcKeyAliesGen
,
HuksOptionsSign
);
HuksOptionsSign
.
inData
=
srcData64Kb
;
HuksOptionsSign
.
inData
=
srcData64Kb
;
await
publicUpdateSessionFunction
(
HuksOptionsSign
);
await
publicUpdateSessionFunction
(
HuksOptionsSign
);
HuksOptionsSign
.
inData
=
new
Uint8Array
(
new
Array
());
HuksOptionsSign
.
inData
=
new
Uint8Array
(
new
Array
());
await
publicFinishSessionFunc
(
HuksOptionsSign
);
await
publicFinishSessionFunc
(
HuksOptionsSign
);
let
HuksOptionsVerify
=
{
let
HuksOptionsVerify
=
{
properties
:
new
Array
(
properties
:
new
Array
(
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyRSAPurposeVERIFY
,
HuksSignVerifyRSA
.
HuksKeyRSAPurposeVERIFY
,
HuksSignVerifyRSA
.
HuksTagPKCS1DigestSHA256
,
HuksSignVerifyRSA
.
HuksTagPKCS1DigestSHA256
,
HuksSignVerifyRSA
.
HuksKeyRSAPADDINGPKCS1V15
,
HuksSignVerifyRSA
.
HuksKeyRSAPADDINGPKCS1V15
,
HuksSignVerifyRSA
.
HuksKeyRSASize4096
HuksSignVerifyRSA
.
HuksKeyRSASize4096
),
),
inData
:
srcData64Kb
,
inData
:
srcData64Kb
,
}
await
publicInitFunc
(
srcKeyAliesGen
,
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
srcData64Kb
;
await
publicUpdateSessionFunction
(
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
signedResult
;
await
publicFinishSessionFunc
(
HuksOptionsVerify
);
await
publicDeleteKeyFunc
(
srcKeyAliesGen
,
HuksOptionsGen
);
}
}
await
publicInitFunc
(
srcKeyAliesGen
,
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
srcData64Kb
;
await
publicUpdateSessionFunction
(
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
signedResult
;
await
publicFinishSessionFunc
(
HuksOptionsVerify
);
await
publicDeleteKeyFunc
(
srcKeyAliesGen
,
HuksOptionsGen
);
done
();
done
();
})
})
...
@@ -250,50 +302,48 @@ export default function SecurityHuksRSASignExtendJsunit() {
...
@@ -250,50 +302,48 @@ export default function SecurityHuksRSASignExtendJsunit() {
*/
*/
it
(
"
Security_HUKS_RSA_SignExtend_0200
"
,
0
,
async
function
(
done
)
{
it
(
"
Security_HUKS_RSA_SignExtend_0200
"
,
0
,
async
function
(
done
)
{
let
srcKeyAliesGen
=
"
Security_HUKS_RSA_SignExtend_0200
"
;
let
srcKeyAliesGen
=
"
Security_HUKS_RSA_SignExtend_0200
"
;
if
(
useSoftware
)
{
let
HuksOptionsGen
=
{
let
HuksOptionsGen
=
{
properties
:
new
Array
(
properties
:
new
Array
(
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyRSAPurposeSINGVERIFY
,
HuksSignVerifyRSA
.
HuksKeyRSAPurposeSINGVERIFY
,
HuksSignVerifyRSA
.
HuksKeyRSAPADDINGPKCS1V15
,
HuksSignVerifyRSA
.
HuksKeyRSAPADDINGPKCS1V15
,
HuksSignVerifyRSA
.
HuksKeyRSASize4096
HuksSignVerifyRSA
.
HuksKeyRSASize4096
),
),
inData
:
srcData64Kb
,
inData
:
srcData64Kb
,
};
};
let
HuksOptionsSign
=
{
let
HuksOptionsSign
=
{
properties
:
new
Array
(
properties
:
new
Array
(
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyRSAPurposeSIGN
,
HuksSignVerifyRSA
.
HuksKeyRSAPurposeSIGN
,
HuksSignVerifyRSA
.
HuksTagPKCS1DigestSHA256
,
HuksSignVerifyRSA
.
HuksTagPKCS1DigestSHA256
,
HuksSignVerifyRSA
.
HuksKeyRSAPADDINGPKCS1V15
,
HuksSignVerifyRSA
.
HuksKeyRSAPADDINGPKCS1V15
,
HuksSignVerifyRSA
.
HuksKeyRSASize4096
HuksSignVerifyRSA
.
HuksKeyRSASize4096
),
),
inData
:
srcData64Kb
,
inData
:
srcData64Kb
,
}
}
await
publicGenerateKeyFunc
(
srcKeyAliesGen
,
HuksOptionsGen
);
await
publicGenerateKeyFunc
(
srcKeyAliesGen
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAliesGen
,
HuksOptionsSign
);
await
publicInitFunc
(
srcKeyAliesGen
,
HuksOptionsSign
);
HuksOptionsSign
.
inData
=
srcData64Kb
;
HuksOptionsSign
.
inData
=
srcData64Kb
;
await
publicUpdateSessionFunction
(
HuksOptionsSign
);
await
publicUpdateSessionFunction
(
HuksOptionsSign
);
HuksOptionsSign
.
inData
=
new
Uint8Array
(
new
Array
());
HuksOptionsSign
.
inData
=
new
Uint8Array
(
new
Array
());
await
publicFinishSessionFunc
(
HuksOptionsSign
);
await
publicFinishSessionFunc
(
HuksOptionsSign
);
let
HuksOptionsVerify
=
{
let
HuksOptionsVerify
=
{
properties
:
new
Array
(
properties
:
new
Array
(
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyRSAPurposeVERIFY
,
HuksSignVerifyRSA
.
HuksKeyRSAPurposeVERIFY
,
HuksSignVerifyRSA
.
HuksTagPKCS1DigestSHA256
,
HuksSignVerifyRSA
.
HuksTagPKCS1DigestSHA256
,
HuksSignVerifyRSA
.
HuksKeyRSAPADDINGPKCS1V15
,
HuksSignVerifyRSA
.
HuksKeyRSAPADDINGPKCS1V15
,
HuksSignVerifyRSA
.
HuksKeyRSASize4096
HuksSignVerifyRSA
.
HuksKeyRSASize4096
),
),
inData
:
srcData64Kb
,
inData
:
srcData64Kb
,
}
await
publicInitFunc
(
srcKeyAliesGen
,
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
srcData64Kb
;
await
publicUpdateSessionFunction
(
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
signedResult
;
await
publicFinishSessionFunc
(
HuksOptionsVerify
);
await
publicDeleteKeyFunc
(
srcKeyAliesGen
,
HuksOptionsGen
);
}
}
await
publicInitFunc
(
srcKeyAliesGen
,
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
srcData64Kb
;
await
publicUpdateSessionFunction
(
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
signedResult
;
await
publicFinishSessionFunc
(
HuksOptionsVerify
);
await
publicDeleteKeyFunc
(
srcKeyAliesGen
,
HuksOptionsGen
);
done
();
done
();
})
})
...
@@ -322,31 +372,29 @@ export default function SecurityHuksRSASignExtendJsunit() {
...
@@ -322,31 +372,29 @@ export default function SecurityHuksRSASignExtendJsunit() {
),
),
inData
:
srcData64Kb
,
inData
:
srcData64Kb
,
}
}
if
(
useSoftware
)
{
await
publicGenerateKeyFunc
(
srcKeyAliesGen
,
HuksOptionsGen
);
await
publicGenerateKeyFunc
(
srcKeyAliesGen
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAliesGen
,
HuksOptionsSign
);
await
publicInitFunc
(
srcKeyAliesGen
,
HuksOptionsSign
);
HuksOptionsSign
.
inData
=
srcData64Kb
;
HuksOptionsSign
.
inData
=
srcData64Kb
;
await
publicUpdateSessionFunction
(
HuksOptionsSign
);
await
publicUpdateSessionFunction
(
HuksOptionsSign
);
HuksOptionsSign
.
inData
=
new
Uint8Array
(
new
Array
());
HuksOptionsSign
.
inData
=
new
Uint8Array
(
new
Array
());
await
publicFinishSessionFunc
(
HuksOptionsSign
);
await
publicFinishSessionFunc
(
HuksOptionsSign
);
let
HuksOptionsVerify
=
{
let
HuksOptionsVerify
=
{
properties
:
new
Array
(
properties
:
new
Array
(
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyRSAPurposeVERIFY
,
HuksSignVerifyRSA
.
HuksKeyRSAPurposeVERIFY
,
HuksSignVerifyRSA
.
HuksTagPKCS1DigestSHA256
,
HuksSignVerifyRSA
.
HuksTagPKCS1DigestSHA256
,
HuksSignVerifyRSA
.
HuksKeyRSAPADDINGPKCS1V15
,
HuksSignVerifyRSA
.
HuksKeyRSAPADDINGPKCS1V15
,
HuksSignVerifyRSA
.
HuksKeyRSASize4096
HuksSignVerifyRSA
.
HuksKeyRSASize4096
),
),
inData
:
srcData64Kb
,
inData
:
srcData64Kb
,
}
await
publicInitFunc
(
srcKeyAliesGen
,
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
srcData64Kb
;
await
publicUpdateSessionFunction
(
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
signedResult
;
await
publicFinishSessionFunc
(
HuksOptionsVerify
);
await
publicDeleteKeyFunc
(
srcKeyAliesGen
,
HuksOptionsGen
);
}
}
await
publicInitFunc
(
srcKeyAliesGen
,
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
srcData64Kb
;
await
publicUpdateSessionFunction
(
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
signedResult
;
await
publicFinishSessionFunc
(
HuksOptionsVerify
);
await
publicDeleteKeyFunc
(
srcKeyAliesGen
,
HuksOptionsGen
);
done
();
done
();
})
})
...
@@ -530,5 +578,2168 @@ export default function SecurityHuksRSASignExtendJsunit() {
...
@@ -530,5 +578,2168 @@ export default function SecurityHuksRSASignExtendJsunit() {
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
done
();
})
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_0900
* @tc.name AES not GCM,no BlockMode while generate.
* @tc.desc AES not GCM,no BlockMode while generate.
*/
it
(
"
Security_HUKS_RSA_SignExtend_0900
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_0900
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurpose
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
srcData64Kb
,
};
let
HuksOptionsEncrypt
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurposeENCRYPT
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODE
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsEncrypt
);
let
encryptedData
=
await
publicUpdateSessionFunction
(
HuksOptionsEncrypt
);
let
HuksOptionsDecrypt
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurposeDECRYPT
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODE
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
encryptedData
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsDecrypt
);
let
outData
=
await
publicUpdateSessionFunction
(
HuksOptionsDecrypt
);
expect
(
arrayEqual
(
Array
.
from
(
outData
),
Array
.
from
(
srcData64Kb
))).
assertTrue
();
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_1000
* @tc.name AES not GCM,no digest while generate.
* @tc.desc AES not GCM,no digest while generate.
*/
it
(
"
Security_HUKS_RSA_SignExtend_1000
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_1000
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurpose
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
srcData64Kb
,
};
let
HuksOptionsEncrypt
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurposeENCRYPT
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODE
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsEncrypt
);
let
encryptedData
=
await
publicUpdateSessionFunction
(
HuksOptionsEncrypt
);
let
HuksOptionsDecrypt
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurposeDECRYPT
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODE
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
encryptedData
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsDecrypt
);
let
outData
=
await
publicUpdateSessionFunction
(
HuksOptionsDecrypt
);
expect
(
arrayEqual
(
Array
.
from
(
outData
),
Array
.
from
(
srcData64Kb
))).
assertTrue
();
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_1100
* @tc.name AES not GCM,no padding while generate.
* @tc.desc AES not GCM,no padding while generate.
*/
it
(
"
Security_HUKS_RSA_SignExtend_1100
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_1100
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurpose
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESBLOCKMODE
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
srcData64Kb
,
};
let
HuksOptionsEncrypt
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurposeENCRYPT
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODE
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsEncrypt
);
let
encryptedData
=
await
publicUpdateSessionFunction
(
HuksOptionsEncrypt
);
let
HuksOptionsDecrypt
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurposeDECRYPT
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODE
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
encryptedData
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsDecrypt
);
let
outData
=
await
publicUpdateSessionFunction
(
HuksOptionsDecrypt
);
expect
(
arrayEqual
(
Array
.
from
(
outData
),
Array
.
from
(
srcData64Kb
))).
assertTrue
();
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_1200
* @tc.name AES not GCM,no IV while generate.
* @tc.desc AES not GCM,no IV while generate.
*/
it
(
"
Security_HUKS_RSA_SignExtend_1200
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_1200
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurpose
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODE
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
),
inData
:
srcData64Kb
,
};
let
HuksOptionsEncrypt
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurposeENCRYPT
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODE
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsEncrypt
);
let
encryptedData
=
await
publicUpdateSessionFunction
(
HuksOptionsEncrypt
);
let
HuksOptionsDecrypt
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurposeDECRYPT
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODE
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
encryptedData
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsDecrypt
);
let
outData
=
await
publicUpdateSessionFunction
(
HuksOptionsDecrypt
);
expect
(
arrayEqual
(
Array
.
from
(
outData
),
Array
.
from
(
srcData64Kb
))).
assertTrue
();
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_1300
* @tc.name AES not GCM,no blockmode,digest,padding,IV while generate.
* @tc.desc AES not GCM,no blockmode,digest,padding,IV while generate.
*/
it
(
"
Security_HUKS_RSA_SignExtend_1300
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_1300
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurpose
,
HuksCipherAES
.
HuksKeyAESSize256
,
),
inData
:
srcData64Kb
,
};
let
HuksOptionsEncrypt
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurposeENCRYPT
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODE
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsEncrypt
);
let
encryptedData
=
await
publicUpdateSessionFunction
(
HuksOptionsEncrypt
);
let
HuksOptionsDecrypt
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurposeDECRYPT
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODE
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
encryptedData
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsDecrypt
);
let
outData
=
await
publicUpdateSessionFunction
(
HuksOptionsDecrypt
);
expect
(
arrayEqual
(
Array
.
from
(
outData
),
Array
.
from
(
srcData64Kb
))).
assertTrue
();
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_1400
* @tc.name AES GCM,no blockmode while generate.
* @tc.desc AES GCM,no blockmode while generate.
*/
it
(
"
Security_HUKS_RSA_SignExtend_1400
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_1400
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurpose
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ASSOCIATED_DATA
,
value
:
stringToUint8Array
(
AAD
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_NONCE
,
value
:
stringToUint8Array
(
NONCE
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_AE_TAG
,
value
:
stringToUint8Array
(
AEAD
)
},
),
inData
:
srcData64Kb
,
};
let
HuksOptionsEncrypt
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurposeENCRYPT
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODEGCM
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ASSOCIATED_DATA
,
value
:
stringToUint8Array
(
AAD
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_NONCE
,
value
:
stringToUint8Array
(
NONCE
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_AE_TAG
,
value
:
stringToUint8Array
(
AEAD
)
},
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsEncrypt
);
let
encryptedData
=
await
publicUpdateSessionFunction
(
HuksOptionsEncrypt
);
let
HuksOptionsDecrypt
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurposeDECRYPT
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODEGCM
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ASSOCIATED_DATA
,
value
:
stringToUint8Array
(
AAD
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_NONCE
,
value
:
stringToUint8Array
(
NONCE
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_AE_TAG
,
value
:
stringToUint8Array
(
AEAD
)
},
),
inData
:
encryptedData
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsDecrypt
);
let
outData
=
await
publicUpdateSessionFunction
(
HuksOptionsDecrypt
);
expect
(
arrayEqual
(
Array
.
from
(
outData
),
Array
.
from
(
srcData64Kb
))).
assertTrue
();
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_1500
* @tc.name AES GCM,no digest while generate.
* @tc.desc AES GCM,no digest while generate.
*/
it
(
"
Security_HUKS_RSA_SignExtend_1500
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_1500
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurpose
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODEGCM
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ASSOCIATED_DATA
,
value
:
stringToUint8Array
(
AAD
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_NONCE
,
value
:
stringToUint8Array
(
NONCE
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_AE_TAG
,
value
:
stringToUint8Array
(
AEAD
)
},
),
inData
:
srcData64Kb
,
};
let
HuksOptionsEncrypt
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurposeENCRYPT
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODEGCM
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ASSOCIATED_DATA
,
value
:
stringToUint8Array
(
AAD
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_NONCE
,
value
:
stringToUint8Array
(
NONCE
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_AE_TAG
,
value
:
stringToUint8Array
(
AEAD
)
},
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsEncrypt
);
let
encryptedData
=
await
publicUpdateSessionFunction
(
HuksOptionsEncrypt
);
let
HuksOptionsDecrypt
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurposeDECRYPT
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODEGCM
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ASSOCIATED_DATA
,
value
:
stringToUint8Array
(
AAD
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_NONCE
,
value
:
stringToUint8Array
(
NONCE
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_AE_TAG
,
value
:
stringToUint8Array
(
AEAD
)
},
),
inData
:
encryptedData
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsDecrypt
);
let
outData
=
await
publicUpdateSessionFunction
(
HuksOptionsDecrypt
);
expect
(
arrayEqual
(
Array
.
from
(
outData
),
Array
.
from
(
srcData64Kb
))).
assertTrue
();
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_1600
* @tc.name AES GCM,no padding while generate.
* @tc.desc AES GCM,no padding while generate.
*/
it
(
"
Security_HUKS_RSA_SignExtend_1600
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_1600
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurpose
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESBLOCKMODEGCM
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ASSOCIATED_DATA
,
value
:
stringToUint8Array
(
AAD
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_NONCE
,
value
:
stringToUint8Array
(
NONCE
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_AE_TAG
,
value
:
stringToUint8Array
(
AEAD
)
},
),
inData
:
srcData64Kb
,
};
let
HuksOptionsEncrypt
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurposeENCRYPT
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODEGCM
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ASSOCIATED_DATA
,
value
:
stringToUint8Array
(
AAD
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_NONCE
,
value
:
stringToUint8Array
(
NONCE
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_AE_TAG
,
value
:
stringToUint8Array
(
AEAD
)
},
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsEncrypt
);
let
encryptedData
=
await
publicUpdateSessionFunction
(
HuksOptionsEncrypt
);
let
HuksOptionsDecrypt
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurposeDECRYPT
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODEGCM
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ASSOCIATED_DATA
,
value
:
stringToUint8Array
(
AAD
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_NONCE
,
value
:
stringToUint8Array
(
NONCE
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_AE_TAG
,
value
:
stringToUint8Array
(
AEAD
)
},
),
inData
:
encryptedData
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsDecrypt
);
let
outData
=
await
publicUpdateSessionFunction
(
HuksOptionsDecrypt
);
expect
(
arrayEqual
(
Array
.
from
(
outData
),
Array
.
from
(
srcData64Kb
))).
assertTrue
();
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_1700
* @tc.name AES GCM,no blockmode,digest,padding while generate.
* @tc.desc AES GCM,no blockmode,digest,padding while generate.
*/
it
(
"
Security_HUKS_RSA_SignExtend_1700
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_1700
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurpose
,
HuksCipherAES
.
HuksKeyAESSize256
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ASSOCIATED_DATA
,
value
:
stringToUint8Array
(
AAD
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_NONCE
,
value
:
stringToUint8Array
(
NONCE
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_AE_TAG
,
value
:
stringToUint8Array
(
AEAD
)
},
),
inData
:
srcData64Kb
,
};
let
HuksOptionsEncrypt
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurposeENCRYPT
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODEGCM
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ASSOCIATED_DATA
,
value
:
stringToUint8Array
(
AAD
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_NONCE
,
value
:
stringToUint8Array
(
NONCE
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_AE_TAG
,
value
:
stringToUint8Array
(
AEAD
)
},
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsEncrypt
);
let
encryptedData
=
await
publicUpdateSessionFunction
(
HuksOptionsEncrypt
);
let
HuksOptionsDecrypt
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurposeDECRYPT
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODEGCM
,
HuksCipherAES
.
HuksKeyAESDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ASSOCIATED_DATA
,
value
:
stringToUint8Array
(
AAD
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_NONCE
,
value
:
stringToUint8Array
(
NONCE
)
},
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_AE_TAG
,
value
:
stringToUint8Array
(
AEAD
)
},
),
inData
:
encryptedData
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsDecrypt
);
let
outData
=
await
publicUpdateSessionFunction
(
HuksOptionsDecrypt
);
expect
(
arrayEqual
(
Array
.
from
(
outData
),
Array
.
from
(
srcData64Kb
))).
assertTrue
();
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_1800
* @tc.name AES GCM,no digest while generate,use wrong digest (SHA256)
* @tc.desc AES GCM,no digest while generate,use wrong digest (SHA256)
*/
it
(
"
Security_HUKS_RSA_SignExtend_1800
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_1800
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurpose
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
srcData64Kb
,
};
let
HuksOptionsEncrypt
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurposeENCRYPT
,
HuksCipherAES
.
HuksKeyAESSize256
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
HuksCipherAES
.
HuksKeyAESBLOCKMODE
,
HuksCipherRSA
.
HuksKeyRSADIGESTSHA256
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsEncrypt
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_1900
* @tc.name RSA Cipher,no blockMode while generate.
* @tc.desc RSA Cipher,no blockMode while generate.
*/
it
(
"
Security_HUKS_RSA_SignExtend_1900
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_1900
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksCipherRSA
.
HuksKeyAlgRSA
,
HuksCipherRSA
.
HuksKeyPurpose
,
HuksCipherRSA
.
HuksKeyRSASize4096
,
HuksCipherRSA
.
HuksKeyRSAPADDINGOAEP
,
HuksCipherRSA
.
HuksKeyRSADIGESTSHA256
),
inData
:
srcData64Kb
,
};
let
HuksOptionsEncrypt
=
{
properties
:
new
Array
(
HuksCipherRSA
.
HuksKeyAlgRSA
,
HuksCipherRSA
.
HuksKeyPurposeENCRYPT
,
HuksCipherRSA
.
HuksKeyRSASize4096
,
HuksCipherRSA
.
HuksKeyRSAPADDINGOAEP
,
HuksCipherRSA
.
HuksKeyRSABLOCKMODEECB
,
HuksCipherRSA
.
HuksKeyRSADIGESTSHA256
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsEncrypt
);
await
publicUpdateSessionFunction
(
HuksOptionsEncrypt
);
await
publicFinishSessionFunc
(
HuksOptionsEncrypt
);
let
HuksOptionsDecrypt
=
{
properties
:
new
Array
(
HuksCipherRSA
.
HuksKeyAlgRSA
,
HuksCipherRSA
.
HuksKeyPurposeDECRYPT
,
HuksCipherRSA
.
HuksKeyRSASize4096
,
HuksCipherRSA
.
HuksKeyRSAPADDINGOAEP
,
HuksCipherRSA
.
HuksKeyRSABLOCKMODEECB
,
HuksCipherRSA
.
HuksKeyRSADIGESTSHA256
),
inData
:
signedResult
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsDecrypt
);
await
publicUpdateSessionFunction
(
HuksOptionsDecrypt
);
await
publicFinishSessionFunc
(
signedResult
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_2000
* @tc.name RSA Cipher,no digest while generate.
* @tc.desc RSA Cipher,no digest while generate.
*/
it
(
"
Security_HUKS_RSA_SignExtend_2000
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_2000
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksCipherRSA
.
HuksKeyAlgRSA
,
HuksCipherRSA
.
HuksKeyPurpose
,
HuksCipherRSA
.
HuksKeyRSASize4096
,
HuksCipherRSA
.
HuksKeyRSAPADDINGOAEP
,
HuksCipherRSA
.
HuksKeyRSABLOCKMODEECB
),
inData
:
srcData64Kb
,
};
let
HuksOptionsEncrypt
=
{
properties
:
new
Array
(
HuksCipherRSA
.
HuksKeyAlgRSA
,
HuksCipherRSA
.
HuksKeyPurposeENCRYPT
,
HuksCipherRSA
.
HuksKeyRSASize4096
,
HuksCipherRSA
.
HuksKeyRSAPADDINGOAEP
,
HuksCipherRSA
.
HuksKeyRSABLOCKMODEECB
,
HuksCipherRSA
.
HuksKeyRSADIGESTSHA256
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsEncrypt
);
await
publicUpdateSessionFunction
(
HuksOptionsEncrypt
);
await
publicFinishSessionFunc
(
HuksOptionsEncrypt
);
let
HuksOptionsDecrypt
=
{
properties
:
new
Array
(
HuksCipherRSA
.
HuksKeyAlgRSA
,
HuksCipherRSA
.
HuksKeyPurposeDECRYPT
,
HuksCipherRSA
.
HuksKeyRSASize4096
,
HuksCipherRSA
.
HuksKeyRSAPADDINGOAEP
,
HuksCipherRSA
.
HuksKeyRSABLOCKMODEECB
,
HuksCipherRSA
.
HuksKeyRSADIGESTSHA256
),
inData
:
signedResult
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsDecrypt
);
await
publicUpdateSessionFunction
(
HuksOptionsDecrypt
);
await
publicFinishSessionFunc
(
signedResult
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_2100
* @tc.name RSA Cipher,no padding while generate.
* @tc.desc RSA Cipher,no padding while generate.
*/
it
(
"
Security_HUKS_RSA_SignExtend_2100
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_2100
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksCipherRSA
.
HuksKeyAlgRSA
,
HuksCipherRSA
.
HuksKeyPurpose
,
HuksCipherRSA
.
HuksKeyRSASize4096
,
HuksCipherRSA
.
HuksKeyRSABLOCKMODEECB
,
HuksCipherRSA
.
HuksKeyRSADIGESTSHA256
),
inData
:
srcData64Kb
,
};
let
HuksOptionsEncrypt
=
{
properties
:
new
Array
(
HuksCipherRSA
.
HuksKeyAlgRSA
,
HuksCipherRSA
.
HuksKeyPurposeENCRYPT
,
HuksCipherRSA
.
HuksKeyRSASize4096
,
HuksCipherRSA
.
HuksKeyRSAPADDINGOAEP
,
HuksCipherRSA
.
HuksKeyRSABLOCKMODEECB
,
HuksCipherRSA
.
HuksKeyRSADIGESTSHA256
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsEncrypt
);
await
publicUpdateSessionFunction
(
HuksOptionsEncrypt
);
await
publicFinishSessionFunc
(
HuksOptionsEncrypt
);
let
HuksOptionsDecrypt
=
{
properties
:
new
Array
(
HuksCipherRSA
.
HuksKeyAlgRSA
,
HuksCipherRSA
.
HuksKeyPurposeDECRYPT
,
HuksCipherRSA
.
HuksKeyRSASize4096
,
HuksCipherRSA
.
HuksKeyRSAPADDINGOAEP
,
HuksCipherRSA
.
HuksKeyRSABLOCKMODEECB
,
HuksCipherRSA
.
HuksKeyRSADIGESTSHA256
),
inData
:
signedResult
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsDecrypt
);
await
publicUpdateSessionFunction
(
HuksOptionsDecrypt
);
await
publicFinishSessionFunc
(
signedResult
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_2200
* @tc.name RSA Cipher,no blockmode,digest,padding while generate.
* @tc.desc RSA Cipher,no blockmode,digest,padding while generate.
*/
it
(
"
Security_HUKS_RSA_SignExtend_2200
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_2200
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksCipherRSA
.
HuksKeyAlgRSA
,
HuksCipherRSA
.
HuksKeyPurpose
,
HuksCipherRSA
.
HuksKeyRSASize4096
,
),
inData
:
srcData64Kb
,
};
let
HuksOptionsEncrypt
=
{
properties
:
new
Array
(
HuksCipherRSA
.
HuksKeyAlgRSA
,
HuksCipherRSA
.
HuksKeyPurposeENCRYPT
,
HuksCipherRSA
.
HuksKeyRSASize4096
,
HuksCipherRSA
.
HuksKeyRSAPADDINGOAEP
,
HuksCipherRSA
.
HuksKeyRSABLOCKMODEECB
,
HuksCipherRSA
.
HuksKeyRSADIGESTSHA256
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsEncrypt
);
await
publicUpdateSessionFunction
(
HuksOptionsEncrypt
);
await
publicFinishSessionFunc
(
HuksOptionsEncrypt
);
let
HuksOptionsDecrypt
=
{
properties
:
new
Array
(
HuksCipherRSA
.
HuksKeyAlgRSA
,
HuksCipherRSA
.
HuksKeyPurposeDECRYPT
,
HuksCipherRSA
.
HuksKeyRSASize4096
,
HuksCipherRSA
.
HuksKeyRSAPADDINGOAEP
,
HuksCipherRSA
.
HuksKeyRSABLOCKMODEECB
,
HuksCipherRSA
.
HuksKeyRSADIGESTSHA256
),
inData
:
signedResult
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsDecrypt
);
await
publicUpdateSessionFunction
(
HuksOptionsDecrypt
);
await
publicFinishSessionFunc
(
signedResult
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_2300
* @tc.name RSA Cipher,wrong blockmode
* @tc.desc RSA Cipher,wrong blockmode
*/
it
(
"
Security_HUKS_RSA_SignExtend_2300
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_2300
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksCipherRSA
.
HuksKeyAlgRSA
,
HuksCipherRSA
.
HuksKeyPurpose
,
HuksCipherRSA
.
HuksKeyRSASize4096
,
HuksCipherRSA
.
HuksKeyRSAPADDINGOAEP
,
HuksCipherRSA
.
HuksKeyRSADIGESTSHA256
),
inData
:
srcData64Kb
,
};
let
HuksOptionsEncrypt
=
{
properties
:
new
Array
(
HuksCipherRSA
.
HuksKeyAlgRSA
,
HuksCipherRSA
.
HuksKeyPurposeENCRYPT
,
HuksCipherRSA
.
HuksKeyRSASize4096
,
HuksCipherRSA
.
HuksKeyRSAPADDINGOAEP
,
HuksCipherAES
.
HuksKeyAESBLOCKMODEGCM
,
HuksCipherRSA
.
HuksKeyRSADIGESTSHA256
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsEncrypt
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_2400
* @tc.name SM4 Cipher,no blockmode while generate
* @tc.desc SM4 Cipher,no blockmode while generate
*/
it
(
"
Security_HUKS_RSA_SignExtend_2400
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_2400
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksCipherSM4
.
HuksKeyAlgSM4
,
HuksCipherSM4
.
HuksKeyPurpose
,
HuksCipherSM4
.
HuksKeySM4Size128
,
HuksCipherSM4
.
HuksKeySM4PADDINGNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
srcData64Kb
,
};
let
HuksOptionsEncrypt
=
{
properties
:
new
Array
(
HuksCipherSM4
.
HuksKeyAlgSM4
,
HuksCipherSM4
.
HuksKeyPurposeENCRYPT
,
HuksCipherSM4
.
HuksKeySM4Size128
,
HuksCipherSM4
.
HuksKeySM4PADDINGNONE
,
HuksCipherSM4
.
HuksKeySM4BLOCKMODECBC
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsEncrypt
);
let
encryptedData
=
await
publicUpdateSessionFunction
(
HuksOptionsEncrypt
);
let
HuksOptionsDecrypt
=
{
properties
:
new
Array
(
HuksCipherSM4
.
HuksKeyAlgSM4
,
HuksCipherSM4
.
HuksKeyPurposeDECRYPT
,
HuksCipherSM4
.
HuksKeySM4Size128
,
HuksCipherSM4
.
HuksKeySM4PADDINGNONE
,
HuksCipherSM4
.
HuksKeySM4BLOCKMODECBC
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
encryptedData
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsDecrypt
);
let
outData
=
await
publicUpdateSessionFunction
(
HuksOptionsDecrypt
);
expect
(
arrayEqual
(
Array
.
from
(
outData
),
Array
.
from
(
srcData64Kb
))).
assertTrue
();
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_2600
* @tc.name SM4 Cipher,no padding while generate
* @tc.desc SM4 Cipher,no padding while generate
*/
it
(
"
Security_HUKS_RSA_SignExtend_2600
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_2600
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksCipherSM4
.
HuksKeyAlgSM4
,
HuksCipherSM4
.
HuksKeyPurpose
,
HuksCipherSM4
.
HuksKeySM4Size128
,
HuksCipherSM4
.
HuksKeySM4BLOCKMODECBC
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
srcData64Kb
,
};
let
HuksOptionsEncrypt
=
{
properties
:
new
Array
(
HuksCipherSM4
.
HuksKeyAlgSM4
,
HuksCipherSM4
.
HuksKeyPurposeENCRYPT
,
HuksCipherSM4
.
HuksKeySM4Size128
,
HuksCipherSM4
.
HuksKeySM4PADDINGNONE
,
HuksCipherSM4
.
HuksKeySM4BLOCKMODECBC
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsEncrypt
);
let
encryptedData
=
await
publicUpdateSessionFunction
(
HuksOptionsEncrypt
);
let
HuksOptionsDecrypt
=
{
properties
:
new
Array
(
HuksCipherSM4
.
HuksKeyAlgSM4
,
HuksCipherSM4
.
HuksKeyPurposeDECRYPT
,
HuksCipherSM4
.
HuksKeySM4Size128
,
HuksCipherSM4
.
HuksKeySM4PADDINGNONE
,
HuksCipherSM4
.
HuksKeySM4BLOCKMODECBC
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
encryptedData
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsDecrypt
);
let
outData
=
await
publicUpdateSessionFunction
(
HuksOptionsDecrypt
);
expect
(
arrayEqual
(
Array
.
from
(
outData
),
Array
.
from
(
srcData64Kb
))).
assertTrue
();
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_2700
* @tc.name SM4 Cipher,no IV while generate
* @tc.desc SM4 Cipher,no IV while generate
*/
it
(
"
Security_HUKS_RSA_SignExtend_2700
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_2700
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksCipherSM4
.
HuksKeyAlgSM4
,
HuksCipherSM4
.
HuksKeyPurpose
,
HuksCipherSM4
.
HuksKeySM4Size128
,
HuksCipherSM4
.
HuksKeySM4PADDINGNONE
,
HuksCipherSM4
.
HuksKeySM4BLOCKMODECBC
,
),
inData
:
srcData64Kb
,
};
let
HuksOptionsEncrypt
=
{
properties
:
new
Array
(
HuksCipherSM4
.
HuksKeyAlgSM4
,
HuksCipherSM4
.
HuksKeyPurposeENCRYPT
,
HuksCipherSM4
.
HuksKeySM4Size128
,
HuksCipherSM4
.
HuksKeySM4PADDINGNONE
,
HuksCipherSM4
.
HuksKeySM4BLOCKMODECBC
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsEncrypt
);
let
encryptedData
=
await
publicUpdateSessionFunction
(
HuksOptionsEncrypt
);
let
HuksOptionsDecrypt
=
{
properties
:
new
Array
(
HuksCipherSM4
.
HuksKeyAlgSM4
,
HuksCipherSM4
.
HuksKeyPurposeDECRYPT
,
HuksCipherSM4
.
HuksKeySM4Size128
,
HuksCipherSM4
.
HuksKeySM4PADDINGNONE
,
HuksCipherSM4
.
HuksKeySM4BLOCKMODECBC
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
encryptedData
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsDecrypt
);
let
outData
=
await
publicUpdateSessionFunction
(
HuksOptionsDecrypt
);
expect
(
arrayEqual
(
Array
.
from
(
outData
),
Array
.
from
(
srcData64Kb
))).
assertTrue
();
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_2800
* @tc.name SM4 Cipher,no blockMode,padding,IV while generate
* @tc.desc SM4 Cipher,no blockMode,padding,IV while generate
*/
it
(
"
Security_HUKS_RSA_SignExtend_2800
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_2800
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksCipherSM4
.
HuksKeyAlgSM4
,
HuksCipherSM4
.
HuksKeyPurpose
,
HuksCipherSM4
.
HuksKeySM4Size128
,
),
inData
:
srcData64Kb
,
};
let
HuksOptionsEncrypt
=
{
properties
:
new
Array
(
HuksCipherSM4
.
HuksKeyAlgSM4
,
HuksCipherSM4
.
HuksKeyPurposeENCRYPT
,
HuksCipherSM4
.
HuksKeySM4Size128
,
HuksCipherSM4
.
HuksKeySM4PADDINGNONE
,
HuksCipherSM4
.
HuksKeySM4BLOCKMODECBC
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsEncrypt
);
let
encryptedData
=
await
publicUpdateSessionFunction
(
HuksOptionsEncrypt
);
let
HuksOptionsDecrypt
=
{
properties
:
new
Array
(
HuksCipherSM4
.
HuksKeyAlgSM4
,
HuksCipherSM4
.
HuksKeyPurposeDECRYPT
,
HuksCipherSM4
.
HuksKeySM4Size128
,
HuksCipherSM4
.
HuksKeySM4PADDINGNONE
,
HuksCipherSM4
.
HuksKeySM4BLOCKMODECBC
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
encryptedData
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsDecrypt
);
let
outData
=
await
publicUpdateSessionFunction
(
HuksOptionsDecrypt
);
expect
(
arrayEqual
(
Array
.
from
(
outData
),
Array
.
from
(
srcData64Kb
))).
assertTrue
();
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_2900
* @tc.name SM4 Cipher,wrong padding while generate
* @tc.desc SM4 Cipher,wrong padding while generate
*/
it
(
"
Security_HUKS_RSA_SignExtend_2900
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_2900
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksCipherSM4
.
HuksKeyAlgSM4
,
HuksCipherSM4
.
HuksKeyPurpose
,
HuksCipherSM4
.
HuksKeySM4Size128
,
HuksCipherSM4
.
HuksKeySM4PADDINGNONE
,
HuksCipherSM4
.
HuksKeySM4BLOCKMODECBC
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
srcData64Kb
,
};
let
HuksOptionsEncrypt
=
{
properties
:
new
Array
(
HuksCipherSM4
.
HuksKeyAlgSM4
,
HuksCipherSM4
.
HuksKeyPurposeENCRYPT
,
HuksCipherSM4
.
HuksKeySM4Size128
,
HuksSignVerifyRSA
.
HuksKeyRSAPADDINGPKCS1V15
,
HuksCipherSM4
.
HuksKeySM4BLOCKMODECBC
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitSessionError
(
srcKeyAlies
,
HuksOptionsEncrypt
,
401
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_3000
* @tc.name RSA SignVreify,hash mode doesn't suite for the hashed data
* @tc.desc RSA SignVreify,hash mode doesn't suite for the hashed data
*/
it
(
"
Security_HUKS_RSA_SignExtend_3000
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_3000
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyRSAPurposeSINGVERIFY
,
HuksSignVerifyRSA
.
HuksTagPKCS1DigestNONE
,
HuksSignVerifyRSA
.
HuksKeyRSAPADDINGPKCS1V15
,
HuksSignVerifyRSA
.
HuksKeyRSASize4096
),
inData
:
inDataAfterSha512
,
}
let
HuksOptionsSign
=
{
properties
:
new
Array
(
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyRSAPurposeSIGN
,
HuksSignVerifyRSA
.
HuksTagPKCS1DigestNONE
,
HuksSignVerifyRSA
.
HuksKeyRSAPADDINGPKCS1V15
,
HuksSignVerifyRSA
.
HuksKeyRSASize4096
),
inData
:
inDataAfterSha512
,
}
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsSign
);
HuksOptionsSign
.
inData
=
inDataAfterSha512
;
await
publicUpdateSessionFunction
(
HuksOptionsSign
);
HuksOptionsSign
.
inData
=
new
Uint8Array
(
new
Array
());
await
publicFinishSessionFunc
(
HuksOptionsSign
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_3100
* @tc.name DSA SignVerify,no digest while generate(TEE Not support)
* @tc.desc DSA SignVerify,no digest while generate(TEE Not support)
*/
it
(
"
Security_HUKS_RSA_SignExtend_3100
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_3100
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksSignVerifyDSA
.
HuksKeyAlgDSA
,
HuksSignVerifyDSA
.
HuksKeyRSAPurposeSINGVERIFY
,
HuksSignVerifyDSA
.
HuksKeySIZE1024
),
inData
:
srcData64Kb
,
};
let
HuksOptionsSign
=
{
properties
:
new
Array
(
HuksSignVerifyDSA
.
HuksKeyAlgDSA
,
HuksSignVerifyDSA
.
HuksKeyDSAPurposeSIGN
,
HuksSignVerifyDSA
.
HuksTagDSADigestSHA1
,
HuksSignVerifyDSA
.
HuksKeySIZE1024
),
inData
:
srcData64Kb
,
};
if
(
useSoftware
)
{
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsSign
);
HuksOptionsSign
.
inData
=
srcData64Kb
;
await
publicUpdateSessionFunction
(
HuksOptionsSign
);
HuksOptionsSign
.
inData
=
new
Uint8Array
(
new
Array
());
await
publicFinishSessionFunc
(
HuksOptionsSign
);
let
HuksOptionsVerify
=
{
properties
:
new
Array
(
HuksSignVerifyDSA
.
HuksKeyAlgDSA
,
HuksSignVerifyDSA
.
HuksKeyDSAPurposeVERIFY
,
HuksSignVerifyDSA
.
HuksTagDSADigestSHA1
,
HuksSignVerifyDSA
.
HuksKeySIZE1024
),
inData
:
srcData64Kb
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
srcData64Kb
;
await
publicUpdateSessionFunction
(
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
signedResult
;
await
publicFinishSessionFunc
(
HuksOptionsVerify
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
}
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_3200
* @tc.name ECC SignVerify,no Hash Support
* @tc.desc ECC SignVerify,no Hash Support
*/
it
(
"
Security_HUKS_RSA_SignExtend_3200
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_3200
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksSignVerifyECC
.
HuksKeyAlgECC
,
HuksSignVerifyECC
.
HuksKeyECCPurposeSINGVERIFY
,
HuksSignVerifyECC
.
HuksTagECCDigestNONE
,
HuksSignVerifyECC
.
HuksKeyECCSize384
),
inData
:
inDataAfterSha512
,
};
let
HuksOptionsSign
=
{
properties
:
new
Array
(
HuksSignVerifyECC
.
HuksKeyAlgECC
,
HuksSignVerifyECC
.
HuksKeyECCPurposeSIGN
,
HuksSignVerifyECC
.
HuksTagECCDigestNONE
,
HuksSignVerifyECC
.
HuksKeyECCSize384
),
inData
:
inDataAfterSha512
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsSign
);
HuksOptionsSign
.
inData
=
inDataAfterSha512
;
await
publicUpdateSessionFunction
(
HuksOptionsSign
);
HuksOptionsSign
.
inData
=
new
Uint8Array
(
new
Array
());
await
publicFinishSessionFunc
(
HuksOptionsSign
);
let
HuksOptionsVerify
=
{
properties
:
new
Array
(
HuksSignVerifyECC
.
HuksKeyAlgECC
,
HuksSignVerifyECC
.
HuksKeyECCPurposeVERIFY
,
HuksSignVerifyECC
.
HuksTagECCDigestNONE
,
HuksSignVerifyECC
.
HuksKeyECCSize384
),
inData
:
inDataAfterSha512
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
inDataAfterSha512
;
await
publicUpdateSessionFunction
(
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
signedResult
;
await
publicFinishSessionFunc
(
HuksOptionsVerify
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_3300
* @tc.name ECC SignVerify,hash mode doesn't suite for the hashed data
* @tc.desc ECC SignVerify,hash mode doesn't suite for the hashed data
*/
it
(
"
Security_HUKS_RSA_SignExtend_3300
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_3300
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksSignVerifyECC
.
HuksKeyAlgECC
,
HuksSignVerifyECC
.
HuksKeyECCPurposeSINGVERIFY
,
HuksSignVerifyECC
.
HuksTagECCDigestNONE
,
HuksSignVerifyECC
.
HuksKeyECCSize384
),
inData
:
inDataAfterSha512
,
};
let
HuksOptionsSign
=
{
properties
:
new
Array
(
HuksSignVerifyECC
.
HuksKeyAlgECC
,
HuksSignVerifyECC
.
HuksKeyECCPurposeSIGN
,
HuksSignVerifyECC
.
HuksTagECCDigestSHA384
,
HuksSignVerifyECC
.
HuksKeyECCSize384
),
inData
:
inDataAfterSha512
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitSessionError
(
srcKeyAlies
,
HuksOptionsSign
,
401
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_3400
* @tc.name ECC SignVerify,no digest while generate
* @tc.desc ECC SignVerify,no digest while generate
*/
it
(
"
Security_HUKS_RSA_SignExtend_3400
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_3400
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksSignVerifyECC
.
HuksKeyAlgECC
,
HuksSignVerifyECC
.
HuksKeyECCPurposeSINGVERIFY
,
HuksSignVerifyECC
.
HuksKeyECCSize384
),
inData
:
srcData64Kb
,
};
let
HuksOptionsSign
=
{
properties
:
new
Array
(
HuksSignVerifyECC
.
HuksKeyAlgECC
,
HuksSignVerifyECC
.
HuksKeyECCPurposeSIGN
,
HuksSignVerifyECC
.
HuksTagECCDigestSHA256
,
HuksSignVerifyECC
.
HuksKeyECCSize384
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsSign
);
HuksOptionsSign
.
inData
=
srcData64Kb
;
await
publicUpdateSessionFunction
(
HuksOptionsSign
);
HuksOptionsSign
.
inData
=
new
Uint8Array
(
new
Array
());
await
publicFinishSessionFunc
(
HuksOptionsSign
);
let
HuksOptionsVerify
=
{
properties
:
new
Array
(
HuksSignVerifyECC
.
HuksKeyAlgECC
,
HuksSignVerifyECC
.
HuksKeyECCPurposeVERIFY
,
HuksSignVerifyECC
.
HuksTagECCDigestSHA256
,
HuksSignVerifyECC
.
HuksKeyECCSize384
),
inData
:
srcData64Kb
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
srcData64Kb
;
await
publicUpdateSessionFunction
(
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
signedResult
;
await
publicFinishSessionFunc
(
HuksOptionsVerify
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_3500
* @tc.name ED25519 SignVerify,no digest while generate
* @tc.desc ED25519 SignVerify,no digest while generate
*/
it
(
"
Security_HUKS_RSA_SignExtend_3500
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_3500
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksSignVerifyED25519
.
HuksKeyAlgED25519
,
HuksSignVerifyED25519
.
HuksKeyRSAPurposeSINGVERIFY
,
HuksSignVerifyED25519
.
HuksKeyED25519Size256
,
),
inData
:
srcData64Kb
,
};
let
HuksOptionsSign
=
{
properties
:
new
Array
(
HuksSignVerifyED25519
.
HuksKeyAlgED25519
,
HuksSignVerifyED25519
.
HuksKeyED25519PurposeSIGN
,
HuksSignVerifyED25519
.
HuksKeyED25519Size256
,
HuksSignVerifyED25519
.
HuksTagDigestSHA1
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsSign
);
HuksOptionsSign
.
inData
=
srcData64Kb
;
await
publicUpdateSessionFunction
(
HuksOptionsSign
);
HuksOptionsSign
.
inData
=
new
Uint8Array
(
new
Array
());
await
publicFinishSessionFunc
(
HuksOptionsSign
);
let
HuksOptionsVerify
=
{
properties
:
new
Array
(
HuksSignVerifyED25519
.
HuksKeyAlgED25519
,
HuksSignVerifyED25519
.
HuksKeyED25519PurposeVERIFY
,
HuksSignVerifyED25519
.
HuksKeyED25519Size256
,
HuksSignVerifyED25519
.
HuksTagDigestSHA1
),
inData
:
srcData64Kb
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
srcData64Kb
;
await
publicUpdateSessionFunction
(
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
signedResult
;
await
publicFinishSessionFunc
(
HuksOptionsVerify
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_3600
* @tc.name SM2 SignVerify,no hash support
* @tc.desc SM2 SignVerify,no hash support
*/
it
(
"
Security_HUKS_RSA_SignExtend_3600
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_3600
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksSignVerifySM2
.
HuksKeyAlgSM2
,
HuksSignVerifySM2
.
HuksKeySM2PurposeSINGVERIFY
,
HuksSignVerifyECC
.
HuksTagECCDigestNONE
,
HuksSignVerifySM2
.
HuksKeySize256
),
inData
:
inDataAfterSha512
,
};
let
HuksOptionsSign
=
{
properties
:
new
Array
(
HuksSignVerifySM2
.
HuksKeyAlgSM2
,
HuksSignVerifySM2
.
HuksKeySM2PurposeSIGN
,
HuksSignVerifyECC
.
HuksTagECCDigestNONE
,
HuksSignVerifySM2
.
HuksKeySize256
),
inData
:
inDataAfterSha512
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsSign
);
HuksOptionsSign
.
inData
=
inDataAfterSha512
;
await
publicUpdateSessionFunction
(
HuksOptionsSign
);
HuksOptionsSign
.
inData
=
new
Uint8Array
(
new
Array
());
await
publicFinishSessionFunc
(
HuksOptionsSign
);
let
HuksOptionsVerify
=
{
properties
:
new
Array
(
HuksSignVerifySM2
.
HuksKeyAlgSM2
,
HuksSignVerifySM2
.
HuksKeySM2PurposeVERIFY
,
HuksSignVerifyECC
.
HuksTagECCDigestNONE
,
HuksSignVerifySM2
.
HuksKeySize256
),
inData
:
inDataAfterSha512
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
inDataAfterSha512
;
await
publicUpdateSessionFunction
(
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
signedResult
;
await
publicFinishSessionFunc
(
HuksOptionsVerify
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_3700
* @tc.name SM2 SignVerify,hash mode doesn't suite for the hashed data
* @tc.desc SM2 SignVerify,hash mode doesn't suite for the hashed data
*/
it
(
"
Security_HUKS_RSA_SignExtend_3700
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_3700
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksSignVerifySM2
.
HuksKeyAlgSM2
,
HuksSignVerifySM2
.
HuksKeySM2PurposeSINGVERIFY
,
HuksSignVerifyECC
.
HuksTagECCDigestNONE
,
HuksSignVerifySM2
.
HuksKeySize256
),
inData
:
inDataAfterSha512
,
};
let
HuksOptionsSign
=
{
properties
:
new
Array
(
HuksSignVerifySM2
.
HuksKeyAlgSM2
,
HuksSignVerifySM2
.
HuksKeySM2PurposeSIGN
,
HuksSignVerifyECC
.
HuksTagECCDigestSHA384
,
HuksSignVerifySM2
.
HuksKeySize256
),
inData
:
inDataAfterSha512
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitSessionError
(
srcKeyAlies
,
HuksOptionsSign
,
401
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_3800
* @tc.name SM2 SignVerify,no digest while generate
* @tc.desc SM2 SignVerify,no digest while generate
*/
it
(
"
Security_HUKS_RSA_SignExtend_3800
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_3800
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksSignVerifySM2
.
HuksKeyAlgSM2
,
HuksSignVerifySM2
.
HuksKeySM2PurposeSINGVERIFY
,
HuksSignVerifySM2
.
HuksTagSM2DigestSM3
,
HuksSignVerifySM2
.
HuksKeySize256
),
inData
:
srcData64Kb
,
};
let
HuksOptionsSign
=
{
properties
:
new
Array
(
HuksSignVerifySM2
.
HuksKeyAlgSM2
,
HuksSignVerifySM2
.
HuksKeySM2PurposeSIGN
,
HuksSignVerifySM2
.
HuksTagSM2DigestSM3
,
HuksSignVerifySM2
.
HuksKeySize256
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsSign
);
HuksOptionsSign
.
inData
=
srcData64Kb
;
await
publicUpdateSessionFunction
(
HuksOptionsSign
);
HuksOptionsSign
.
inData
=
new
Uint8Array
(
new
Array
());
await
publicFinishSessionFunc
(
HuksOptionsSign
);
let
HuksOptionsVerify
=
{
properties
:
new
Array
(
HuksSignVerifySM2
.
HuksKeyAlgSM2
,
HuksSignVerifySM2
.
HuksKeySM2PurposeVERIFY
,
HuksSignVerifySM2
.
HuksTagSM2DigestSM3
,
HuksSignVerifySM2
.
HuksKeySize256
),
inData
:
srcData64Kb
,
};
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
srcData64Kb
;
await
publicUpdateSessionFunction
(
HuksOptionsVerify
);
HuksOptionsVerify
.
inData
=
signedResult
;
await
publicFinishSessionFunc
(
HuksOptionsVerify
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_3900
* @tc.name ECDH Agree,no blockMode while generate
* @tc.desc ECDH Agree,no blockMode while generate
*/
it
(
"
Security_HUKS_RSA_SignExtend_3900
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_3900
"
;
let
srcKeyAliesSecond
=
"
Security_HUKS_RSA_SignExtend_3900_02
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksAgreeECDH
.
HuksKeyAlgECC
,
HuksAgreeECDH
.
HuksKeyPurposeECDH
,
HuksAgreeECDH
.
HuksKeyECCSize256
,
HuksAgreeECDH
.
HuksKeyECCDIGEST
,
HuksAgreeECDH
.
HuksKeyECCPADDING
),
inData
:
srcData64Kb
,
};
let
HuksOptionsAgree
=
{
properties
:
new
Array
(
HuksAgreeECDH
.
HuksKeyAlgECDH
,
HuksAgreeECDH
.
HuksKeyPurposeECDH
,
HuksAgreeECDH
.
HuksKeyECCSize256
,
HuksAgreeECDH
.
HuksKeyECCDIGEST
,
HuksAgreeECDH
.
HuksKeyECCPADDING
,
HuksAgreeECDH
.
HuksKeyECCBLOCKMODE
),
inData
:
srcData64Kb
,
};
let
huksOptionsFinish
=
{
properties
:
new
Array
(
HuksAgreeECDH
.
HuksKeySTORAGE
,
HuksAgreeECDH
.
HuksKeyISKEYALIAS
,
HuksAgreeECDH
.
HuksKeyALGORITHMAES
,
HuksAgreeECDH
.
HuksKeySIZE256
,
HuksAgreeECDH
.
HuksKeyPurposeENCRYPTDECRYPT
,
HuksAgreeECDH
.
HuksKeyDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_KEY_ALIAS
,
value
:
stringToUint8Array
(
srcKeyAlies
),
},
HuksAgreeECDH
.
HuksKeyPADDINGNONE
,
HuksAgreeECDH
.
HuksKeyBLOCKMODEECB
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicGenerateKeyFunc
(
srcKeyAliesSecond
,
HuksOptionsGen
);
let
exportKeyFrist
=
await
publicExportFunc
(
srcKeyAlies
,
HuksOptionsGen
);
let
exportKeySecond
=
await
publicExportFunc
(
srcKeyAliesSecond
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsAgree
);
HuksOptionsAgree
.
inData
=
exportKeySecond
;
await
publicUpdateOnce
(
HuksOptionsAgree
);
await
publicFinishSessionFunc
(
huksOptionsFinish
);
let
huksOptionsFinishSecond
=
huksOptionsFinish
;
huksOptionsFinishSecond
.
properties
.
splice
(
6
,
1
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_KEY_ALIAS
,
value
:
stringToUint8Array
(
srcKeyAliesSecond
+
'
final
'
),
});
await
publicInitFunc
(
srcKeyAliesSecond
,
HuksOptionsAgree
);
HuksOptionsAgree
.
inData
=
exportKeyFrist
;
await
publicUpdateOnce
(
HuksOptionsAgree
);
await
publicFinishSessionFunc
(
huksOptionsFinishSecond
);
await
publicDeleteKeyFunc
(
srcKeyAliesSecond
+
'
final
'
,
HuksOptionsAgree
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicDeleteKeyFunc
(
srcKeyAliesSecond
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_4000
* @tc.name ECDH Agree,no digest while generate
* @tc.desc ECDH Agree,no digest while generate
*/
it
(
"
Security_HUKS_RSA_SignExtend_4000
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_4000
"
;
let
srcKeyAliesSecond
=
"
Security_HUKS_RSA_SignExtend_4000_02
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksAgreeECDH
.
HuksKeyAlgECC
,
HuksAgreeECDH
.
HuksKeyPurposeECDH
,
HuksAgreeECDH
.
HuksKeyECCSize256
,
HuksAgreeECDH
.
HuksKeyECCPADDING
,
HuksAgreeECDH
.
HuksKeyECCBLOCKMODE
),
inData
:
srcData64Kb
,
};
let
HuksOptionsAgree
=
{
properties
:
new
Array
(
HuksAgreeECDH
.
HuksKeyAlgECDH
,
HuksAgreeECDH
.
HuksKeyPurposeECDH
,
HuksAgreeECDH
.
HuksKeyECCSize256
,
HuksAgreeECDH
.
HuksKeyECCDIGEST
,
HuksAgreeECDH
.
HuksKeyECCPADDING
,
HuksAgreeECDH
.
HuksKeyECCBLOCKMODE
),
inData
:
srcData64Kb
,
};
let
huksOptionsFinish
=
{
properties
:
new
Array
(
HuksAgreeECDH
.
HuksKeySTORAGE
,
HuksAgreeECDH
.
HuksKeyISKEYALIAS
,
HuksAgreeECDH
.
HuksKeyALGORITHMAES
,
HuksAgreeECDH
.
HuksKeySIZE256
,
HuksAgreeECDH
.
HuksKeyPurposeENCRYPTDECRYPT
,
HuksAgreeECDH
.
HuksKeyDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_KEY_ALIAS
,
value
:
stringToUint8Array
(
srcKeyAlies
),
},
HuksAgreeECDH
.
HuksKeyPADDINGNONE
,
HuksAgreeECDH
.
HuksKeyBLOCKMODEECB
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicGenerateKeyFunc
(
srcKeyAliesSecond
,
HuksOptionsGen
);
let
exportKeyFrist
=
await
publicExportFunc
(
srcKeyAlies
,
HuksOptionsGen
);
let
exportKeySecond
=
await
publicExportFunc
(
srcKeyAliesSecond
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsAgree
);
HuksOptionsAgree
.
inData
=
exportKeySecond
;
await
publicUpdateOnce
(
HuksOptionsAgree
);
await
publicFinishSessionFunc
(
huksOptionsFinish
);
let
huksOptionsFinishSecond
=
huksOptionsFinish
;
huksOptionsFinishSecond
.
properties
.
splice
(
6
,
1
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_KEY_ALIAS
,
value
:
stringToUint8Array
(
srcKeyAliesSecond
+
'
final
'
),
});
await
publicInitFunc
(
srcKeyAliesSecond
,
HuksOptionsAgree
);
HuksOptionsAgree
.
inData
=
exportKeyFrist
;
await
publicUpdateOnce
(
HuksOptionsAgree
);
await
publicFinishSessionFunc
(
huksOptionsFinishSecond
);
await
publicDeleteKeyFunc
(
srcKeyAliesSecond
+
'
final
'
,
HuksOptionsAgree
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicDeleteKeyFunc
(
srcKeyAliesSecond
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_4100
* @tc.name ECDH Agree,no padding while generate
* @tc.desc ECDH Agree,no padding while generate
*/
it
(
"
Security_HUKS_RSA_SignExtend_4100
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_4100
"
;
let
srcKeyAliesSecond
=
"
Security_HUKS_RSA_SignExtend_4100_02
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksAgreeECDH
.
HuksKeyAlgECC
,
HuksAgreeECDH
.
HuksKeyPurposeECDH
,
HuksAgreeECDH
.
HuksKeyECCSize256
,
HuksAgreeECDH
.
HuksKeyECCDIGEST
,
HuksAgreeECDH
.
HuksKeyECCBLOCKMODE
),
inData
:
srcData64Kb
,
};
let
HuksOptionsAgree
=
{
properties
:
new
Array
(
HuksAgreeECDH
.
HuksKeyAlgECDH
,
HuksAgreeECDH
.
HuksKeyPurposeECDH
,
HuksAgreeECDH
.
HuksKeyECCSize256
,
HuksAgreeECDH
.
HuksKeyECCDIGEST
,
HuksAgreeECDH
.
HuksKeyECCPADDING
,
HuksAgreeECDH
.
HuksKeyECCBLOCKMODE
),
inData
:
srcData64Kb
,
};
let
huksOptionsFinish
=
{
properties
:
new
Array
(
HuksAgreeECDH
.
HuksKeySTORAGE
,
HuksAgreeECDH
.
HuksKeyISKEYALIAS
,
HuksAgreeECDH
.
HuksKeyALGORITHMAES
,
HuksAgreeECDH
.
HuksKeySIZE256
,
HuksAgreeECDH
.
HuksKeyPurposeENCRYPTDECRYPT
,
HuksAgreeECDH
.
HuksKeyDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_KEY_ALIAS
,
value
:
stringToUint8Array
(
srcKeyAlies
),
},
HuksAgreeECDH
.
HuksKeyPADDINGNONE
,
HuksAgreeECDH
.
HuksKeyBLOCKMODEECB
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicGenerateKeyFunc
(
srcKeyAliesSecond
,
HuksOptionsGen
);
let
exportKeyFrist
=
await
publicExportFunc
(
srcKeyAlies
,
HuksOptionsGen
);
let
exportKeySecond
=
await
publicExportFunc
(
srcKeyAliesSecond
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsAgree
);
HuksOptionsAgree
.
inData
=
exportKeySecond
;
await
publicUpdateOnce
(
HuksOptionsAgree
);
await
publicFinishSessionFunc
(
huksOptionsFinish
);
let
huksOptionsFinishSecond
=
huksOptionsFinish
;
huksOptionsFinishSecond
.
properties
.
splice
(
6
,
1
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_KEY_ALIAS
,
value
:
stringToUint8Array
(
srcKeyAliesSecond
+
'
final
'
),
});
await
publicInitFunc
(
srcKeyAliesSecond
,
HuksOptionsAgree
);
HuksOptionsAgree
.
inData
=
exportKeyFrist
;
await
publicUpdateOnce
(
HuksOptionsAgree
);
await
publicFinishSessionFunc
(
huksOptionsFinishSecond
);
await
publicDeleteKeyFunc
(
srcKeyAliesSecond
+
'
final
'
,
HuksOptionsAgree
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicDeleteKeyFunc
(
srcKeyAliesSecond
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_4200
* @tc.name ECDH Agree,no padding,blockmode,digest while generate
* @tc.desc ECDH Agree,no padding,blockmode,digest while generate
*/
it
(
"
Security_HUKS_RSA_SignExtend_4200
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_4200
"
;
let
srcKeyAliesSecond
=
"
Security_HUKS_RSA_SignExtend_4200_02
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksAgreeECDH
.
HuksKeyAlgECC
,
HuksAgreeECDH
.
HuksKeyPurposeECDH
,
HuksAgreeECDH
.
HuksKeyECCSize256
),
inData
:
srcData64Kb
,
};
let
HuksOptionsAgree
=
{
properties
:
new
Array
(
HuksAgreeECDH
.
HuksKeyAlgECDH
,
HuksAgreeECDH
.
HuksKeyPurposeECDH
,
HuksAgreeECDH
.
HuksKeyECCSize256
,
HuksAgreeECDH
.
HuksKeyECCDIGEST
,
HuksAgreeECDH
.
HuksKeyECCPADDING
,
HuksAgreeECDH
.
HuksKeyECCBLOCKMODE
),
inData
:
srcData64Kb
,
};
let
huksOptionsFinish
=
{
properties
:
new
Array
(
HuksAgreeECDH
.
HuksKeySTORAGE
,
HuksAgreeECDH
.
HuksKeyISKEYALIAS
,
HuksAgreeECDH
.
HuksKeyALGORITHMAES
,
HuksAgreeECDH
.
HuksKeySIZE256
,
HuksAgreeECDH
.
HuksKeyPurposeENCRYPTDECRYPT
,
HuksAgreeECDH
.
HuksKeyDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_KEY_ALIAS
,
value
:
stringToUint8Array
(
srcKeyAlies
),
},
HuksAgreeECDH
.
HuksKeyPADDINGNONE
,
HuksAgreeECDH
.
HuksKeyBLOCKMODEECB
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicGenerateKeyFunc
(
srcKeyAliesSecond
,
HuksOptionsGen
);
let
exportKeyFrist
=
await
publicExportFunc
(
srcKeyAlies
,
HuksOptionsGen
);
let
exportKeySecond
=
await
publicExportFunc
(
srcKeyAliesSecond
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsAgree
);
HuksOptionsAgree
.
inData
=
exportKeySecond
;
await
publicUpdateOnce
(
HuksOptionsAgree
);
await
publicFinishSessionFunc
(
huksOptionsFinish
);
let
huksOptionsFinishSecond
=
huksOptionsFinish
;
huksOptionsFinishSecond
.
properties
.
splice
(
6
,
1
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_KEY_ALIAS
,
value
:
stringToUint8Array
(
srcKeyAliesSecond
+
'
final
'
),
});
await
publicInitFunc
(
srcKeyAliesSecond
,
HuksOptionsAgree
);
HuksOptionsAgree
.
inData
=
exportKeyFrist
;
await
publicUpdateOnce
(
HuksOptionsAgree
);
await
publicFinishSessionFunc
(
huksOptionsFinishSecond
);
await
publicDeleteKeyFunc
(
srcKeyAliesSecond
+
'
final
'
,
HuksOptionsAgree
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicDeleteKeyFunc
(
srcKeyAliesSecond
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_4300
* @tc.name HKDF Derive,no digest while generate
* @tc.desc HKDF Derive,no digest while generate
*/
it
(
"
Security_HUKS_RSA_SignExtend_4300
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_4300
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksDeriveHKDF
.
HuksKeyAlgAES
,
HuksDeriveHKDF
.
HuksKeyPurposeHKDF
,
HuksDeriveHKDF
.
HuksKeyHKDFSize192
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
srcData64Kb
,
};
let
HuksOptionsDerive
=
{
properties
:
new
Array
(
HuksDeriveHKDF
.
HuksKeyAlgHKDF
,
HuksDeriveHKDF
.
HuksKeyPurposeHKDF
,
HuksDeriveHKDF
.
HuksTagHKDFDigestSHA256
,
HuksDeriveHKDF
.
HuksKeyDERIVEKEYSIZE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
srcData64Kb
,
};
let
huksOptionsFinish
=
{
properties
:
new
Array
(
HuksDeriveHKDF
.
HuksKeySTORAGE
,
HuksDeriveHKDF
.
HuksKeyISKEYALIAS
,
HuksDeriveHKDF
.
HuksKeyALGORITHMAES
,
HuksDeriveHKDF
.
HuksKeySIZE256
,
HuksDeriveHKDF
.
HuksKeyPurposeENCRYPTDECRYPT
,
HuksDeriveHKDF
.
HuksKeyDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_KEY_ALIAS
,
value
:
stringToUint8Array
(
srcKeyAlies
),
},
HuksDeriveHKDF
.
HuksKeyPADDINGNONE
,
HuksDeriveHKDF
.
HuksKeyBLOCKMODEGCM
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsDerive
);
await
publicUpdateOnce
(
HuksOptionsDerive
);
await
publicFinishSessionFunc
(
huksOptionsFinish
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_4400
* @tc.name HKDF Derive,no IV while generate
* @tc.desc HKDF Derive,no IV while generate
*/
it
(
"
Security_HUKS_RSA_SignExtend_4400
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_4400
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksDeriveHKDF
.
HuksKeyAlgAES
,
HuksDeriveHKDF
.
HuksKeyPurposeHKDF
,
HuksDeriveHKDF
.
HuksTagHKDFDigestSHA256
,
HuksDeriveHKDF
.
HuksKeyHKDFSize192
,
),
inData
:
srcData64Kb
,
};
let
HuksOptionsDerive
=
{
properties
:
new
Array
(
HuksDeriveHKDF
.
HuksKeyAlgHKDF
,
HuksDeriveHKDF
.
HuksKeyPurposeHKDF
,
HuksDeriveHKDF
.
HuksTagHKDFDigestSHA256
,
HuksDeriveHKDF
.
HuksKeyDERIVEKEYSIZE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
srcData64Kb
,
};
let
huksOptionsFinish
=
{
properties
:
new
Array
(
HuksDeriveHKDF
.
HuksKeySTORAGE
,
HuksDeriveHKDF
.
HuksKeyISKEYALIAS
,
HuksDeriveHKDF
.
HuksKeyALGORITHMAES
,
HuksDeriveHKDF
.
HuksKeySIZE256
,
HuksDeriveHKDF
.
HuksKeyPurposeENCRYPTDECRYPT
,
HuksDeriveHKDF
.
HuksKeyDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_KEY_ALIAS
,
value
:
stringToUint8Array
(
srcKeyAlies
),
},
HuksDeriveHKDF
.
HuksKeyPADDINGNONE
,
HuksDeriveHKDF
.
HuksKeyBLOCKMODEGCM
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsDerive
);
await
publicUpdateOnce
(
HuksOptionsDerive
);
await
publicFinishSessionFunc
(
huksOptionsFinish
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_4500
* @tc.name HKDF Derive,no digest,IV while generate
* @tc.desc HKDF Derive,no digest,IV while generate
*/
it
(
"
Security_HUKS_RSA_SignExtend_4500
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_4500
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksDeriveHKDF
.
HuksKeyAlgAES
,
HuksDeriveHKDF
.
HuksKeyPurposeHKDF
,
HuksDeriveHKDF
.
HuksKeyHKDFSize192
,
),
inData
:
srcData64Kb
,
};
let
HuksOptionsDerive
=
{
properties
:
new
Array
(
HuksDeriveHKDF
.
HuksKeyAlgHKDF
,
HuksDeriveHKDF
.
HuksKeyPurposeHKDF
,
HuksDeriveHKDF
.
HuksTagHKDFDigestSHA256
,
HuksDeriveHKDF
.
HuksKeyDERIVEKEYSIZE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IV
)
}
),
inData
:
srcData64Kb
,
};
let
huksOptionsFinish
=
{
properties
:
new
Array
(
HuksDeriveHKDF
.
HuksKeySTORAGE
,
HuksDeriveHKDF
.
HuksKeyISKEYALIAS
,
HuksDeriveHKDF
.
HuksKeyALGORITHMAES
,
HuksDeriveHKDF
.
HuksKeySIZE256
,
HuksDeriveHKDF
.
HuksKeyPurposeENCRYPTDECRYPT
,
HuksDeriveHKDF
.
HuksKeyDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_KEY_ALIAS
,
value
:
stringToUint8Array
(
srcKeyAlies
),
},
HuksDeriveHKDF
.
HuksKeyPADDINGNONE
,
HuksDeriveHKDF
.
HuksKeyBLOCKMODEGCM
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsDerive
);
await
publicUpdateOnce
(
HuksOptionsDerive
);
await
publicFinishSessionFunc
(
huksOptionsFinish
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_4600
* @tc.name HKDF Derive,IV length err
* @tc.desc HKDF Derive,IV length err
*/
it
(
"
Security_HUKS_RSA_SignExtend_4600
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_4600
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksDeriveHKDF
.
HuksKeyAlgAES
,
HuksDeriveHKDF
.
HuksKeyPurposeHKDF
,
HuksDeriveHKDF
.
HuksTagHKDFDigestSHA256
,
HuksDeriveHKDF
.
HuksKeyHKDFSize192
,
),
inData
:
srcData64Kb
,
};
let
HuksOptionsDerive
=
{
properties
:
new
Array
(
HuksDeriveHKDF
.
HuksKeyAlgHKDF
,
HuksDeriveHKDF
.
HuksKeyPurposeHKDF
,
HuksDeriveHKDF
.
HuksTagHKDFDigestSHA256
,
HuksDeriveHKDF
.
HuksKeyDERIVEKEYSIZE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
stringToUint8Array
(
IVErr
)
}
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsDerive
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_4700
* @tc.name HKDF Derive,IV format err
* @tc.desc HKDF Derive,IV format err
*/
it
(
"
Security_HUKS_RSA_SignExtend_4700
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_4700
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksDeriveHKDF
.
HuksKeyAlgAES
,
HuksDeriveHKDF
.
HuksKeyPurposeHKDF
,
HuksDeriveHKDF
.
HuksTagHKDFDigestSHA256
,
HuksDeriveHKDF
.
HuksKeyHKDFSize192
,
),
inData
:
srcData64Kb
,
};
let
HuksOptionsDerive
=
{
properties
:
new
Array
(
HuksDeriveHKDF
.
HuksKeyAlgHKDF
,
HuksDeriveHKDF
.
HuksKeyPurposeHKDF
,
HuksDeriveHKDF
.
HuksTagHKDFDigestSHA256
,
HuksDeriveHKDF
.
HuksKeyDERIVEKEYSIZE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_IV
,
value
:
IV
}
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
try
{
await
huks
.
initSession
(
srcKeyAlies
,
HuksOptionsDerive
).
then
(
data
=>
{
console
.
error
(
`promise: doInit success, data =
${
JSON
.
stringify
(
data
)}
`
);
expect
(
null
).
assertFail
();
}).
catch
(
err
=>
{
console
.
error
(
`promise: doInit key failed, code:
${
err
.
code
}
, msg:
${
err
.
message
}
`
);
expect
(
err
.
code
==
401
).
assertTrue
();
})
}
catch
(
err
)
{
console
.
error
(
`promise: doInit input arg invalid, code:
${
err
.
code
}
, msg:
${
err
.
message
}
`
);
expect
(
err
.
code
==
401
).
assertTrue
();
}
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_4800
* @tc.name PBKDF Derive,no digest while generate
* @tc.desc PBKDF Derive,no digest while generate
*/
it
(
"
Security_HUKS_RSA_SignExtend_4800
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_4800
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksDerivePBKDF2
.
HuksKeyAlgAES
,
HuksDerivePBKDF2
.
HuksKeyPurposePBKDF2
,
HuksDerivePBKDF2
.
HuksKeyPBKDF2Size192
,
HuksDerivePBKDF2
.
HuksKeyPBKDF2Iteration
,
HuksDerivePBKDF2
.
HuksKeyPBKDF2Salt
),
inData
:
srcData64Kb
,
};
let
HuksOptionsDerive
=
{
properties
:
new
Array
(
HuksDerivePBKDF2
.
HuksKeyAlgPBKDF2
,
HuksDerivePBKDF2
.
HuksKeyPurposePBKDF2
,
HuksDerivePBKDF2
.
HuksTagPBKDF2DigestSHA256
,
HuksDerivePBKDF2
.
HuksKeyDERIVEKEYSIZE
,
HuksDerivePBKDF2
.
HuksKeyPBKDF2Iteration
,
HuksDerivePBKDF2
.
HuksKeyPBKDF2Salt
),
inData
:
srcData64Kb
,
};
let
huksOptionsFinish
=
{
properties
:
new
Array
(
HuksDerivePBKDF2
.
HuksKeySTORAGE
,
HuksDerivePBKDF2
.
HuksKeyISKEYALIAS
,
HuksDerivePBKDF2
.
HuksKeyALGORITHMAES
,
HuksDerivePBKDF2
.
HuksKeySIZE256
,
HuksDerivePBKDF2
.
HuksKeyPurposeENCRYPTDECRYPT
,
HuksDerivePBKDF2
.
HuksKeyDIGESTNONE
,
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_KEY_ALIAS
,
value
:
stringToUint8Array
(
srcKeyAlies
),
},
HuksDerivePBKDF2
.
HuksKeyPADDINGNONE
,
HuksDerivePBKDF2
.
HuksKeyBLOCKMODEGCM
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsDerive
);
await
publicUpdateOnce
(
HuksOptionsDerive
);
await
publicFinishSessionFunc
(
huksOptionsFinish
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_4900
* @tc.name HMAC ,no digest while ...
* @tc.desc HMAC ,no digest while ...
*/
it
(
"
Security_HUKS_RSA_SignExtend_4900
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
Security_HUKS_RSA_SignExtend_4900
"
;
let
HuksOptionsGen
=
{
properties
:
new
Array
(
HuksHmac
.
HuksKeyAlg
,
HuksHmac
.
HuksKeyPurpose
,
HuksHmac
.
HuksKeySIZE
,
),
inData
:
srcData64Kb
,
};
let
HuksOptionsUse
=
{
properties
:
new
Array
(
HuksHmac
.
HuksKeyAlg
,
HuksHmac
.
HuksKeyPurpose
,
HuksHmac
.
HuksKeySIZE
,
HuksHmac
.
HuksTagDigestSHA512
),
inData
:
srcData64Kb
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
await
publicInitFunc
(
srcKeyAlies
,
HuksOptionsUse
);
await
publicUpdateSessionFunction
(
HuksOptionsUse
);
await
publicFinishSessionFunc
(
HuksOptionsUse
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptionsGen
);
done
();
})
})
})
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录