Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
1608b869
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看板
提交
1608b869
编写于
6月 29, 2022
作者:
Y
yuanyuhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
yuanyuhang1@huawei.com
Signed-off-by:
N
yuanyuhang
<
yuanyuhang1@huawei.com
>
上级
d68e668d
变更
10
展开全部
隐藏空白更改
内联
并排
Showing
10 changed file
with
2094 addition
and
5 deletion
+2094
-5
security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/securityHuksExportSupportJsunit.test.js
...in/js/test/Cipher/securityHuksExportSupportJsunit.test.js
+461
-0
security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/List.test.js
...er_callback_BasicTest/entry/src/main/js/test/List.test.js
+2
-1
security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksAccessControlJsunit.test.js
...main/js/test/HMAC/SecurityHuksAccessControlJsunit.test.js
+438
-0
security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksImportJsunit.test.js
...ry/src/main/js/test/HMAC/SecurityHuksImportJsunit.test.js
+1183
-0
security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/List.test.js
...ac_callback_BasicTest/entry/src/main/js/test/List.test.js
+2
-0
security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksSM2BasicAbort63KBPromiseJsunit.test.js
...Verify/SecurityHuksSM2BasicAbort63KBPromiseJsunit.test.js
+1
-1
security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksSM2BasicAbort65KBPromiseJsunit.test.js
...Verify/SecurityHuksSM2BasicAbort65KBPromiseJsunit.test.js
+1
-1
security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksSM2BasicFinish63KBPromiseJsunit.test.js
...erify/SecurityHuksSM2BasicFinish63KBPromiseJsunit.test.js
+1
-1
security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksSM2BasicFinish65KBPromiseJsunit.test.js
...erify/SecurityHuksSM2BasicFinish65KBPromiseJsunit.test.js
+1
-1
security/security_huks_basic/utils/param/cipher/publicCipherParam.js
...curity_huks_basic/utils/param/cipher/publicCipherParam.js
+4
-0
未找到文件。
security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/securityHuksExportSupportJsunit.test.js
0 → 100644
浏览文件 @
1608b869
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
{
describe
,
it
,
expect
}
from
'
deccjsunit/index
'
;
import
{
HuksCipherRSA
}
from
'
../../../../../../../utils/param/cipher/publicCipherParam
'
;
import
{
stringToUint8Array
}
from
'
../../../../../../../utils/param/publicFunc
'
;
import
huks
from
'
@ohos.security.huks
'
import
{
HuksKeyAlgX25519
,
HuksAgreeECDH
}
from
'
../../../../../../../utils/param/agree/publicAgreeParam
'
;
import
{
HuksSignVerifySM2
,
HuksSignVerifyED25519
,
HuksSignVerifyRSA
,
HuksSignVerifyDSA
}
from
'
../../../../../../../utils/param/signverify/publicSignverifyParam
'
;
let
gInData64
=
'
RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
'
;
let
gInData64Array
=
stringToUint8Array
(
gInData64
);
async
function
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptions
)
{
await
generateKey
(
srcKeyAlies
,
HuksOptions
)
.
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
(
srcKeyAlies
,
HuksOptions
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
huks
.
generateKey
(
srcKeyAlies
,
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
publicExportKeyFunc
(
srcKeyAlies
,
HuksOptions
)
{
await
exportkey
(
srcKeyAlies
,
HuksOptions
)
.
then
((
data
)
=>
{
console
.
log
(
`test ExportKey data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
data
.
errorCode
==
0
).
assertTrue
();
})
.
catch
((
err
)
=>
{
console
.
log
(
'
test ImportKey err information:
'
+
JSON
.
stringify
(
err
));
expect
(
null
).
assertFail
();
});
}
function
exportkey
(
srcKeyAlies
,
HuksOptions
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
huks
.
exportKey
(
srcKeyAlies
,
HuksOptions
,
function
(
err
,
data
)
{
console
.
log
(
`test exportKey data:
${
JSON
.
stringify
(
data
)}
`
);
if
(
err
.
code
!==
0
)
{
console
.
log
(
'
test exportKey err information:
'
+
JSON
.
stringify
(
err
));
reject
(
err
);
}
else
{
resolve
(
data
);
}
});
});
}
async
function
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptions
)
{
await
deleteKey
(
srcKeyAlies
,
HuksOptions
)
.
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
(
srcKeyAlies
,
HuksOptions
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
huks
.
deleteKey
(
srcKeyAlies
,
HuksOptions
,
function
(
err
,
data
)
{
if
(
err
.
code
!==
0
)
{
console
.
log
(
'
test deleteKey err information:
'
+
JSON
.
stringify
(
err
));
reject
(
err
);
}
else
{
resolve
(
data
);
}
});
});
}
describe
(
'
securityHuksExportSupportJsunit
'
,
function
()
{
// HKS_SUPPORT_SM4_CBC_NOPADDING
it
(
'
HUKS_Basic_Capability_Export_0100
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
HUKS_Basic_Capability_Export_0100
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyRSASize512
,
HuksCipherRSA
.
HuksKeyPurposeDECRYPT
,
HuksCipherRSA
.
HuksKeyRSAPADDINGNONE
,
HuksCipherRSA
.
HuksKeyRSABLOCKMODEECB
,
HuksCipherRSA
.
HuksKeyRSADIGESTSHA256
),
inData
:
gInData64Array
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicExportKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptions
)
done
();
});
it
(
'
HUKS_Basic_Capability_Export_0200
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
HUKS_Basic_Capability_Export_0200
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyRSASize768
,
HuksCipherRSA
.
HuksKeyPurposeDECRYPT
,
HuksCipherRSA
.
HuksKeyRSAPADDINGNONE
,
HuksCipherRSA
.
HuksKeyRSABLOCKMODEECB
,
HuksCipherRSA
.
HuksKeyRSADIGESTSHA256
),
inData
:
gInData64Array
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicExportKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptions
)
done
();
});
it
(
'
HUKS_Basic_Capability_Export_0300
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
HUKS_Basic_Capability_Export_0300
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyRSASize1024
,
HuksCipherRSA
.
HuksKeyPurposeDECRYPT
,
HuksCipherRSA
.
HuksKeyRSAPADDINGNONE
,
HuksCipherRSA
.
HuksKeyRSABLOCKMODEECB
,
HuksCipherRSA
.
HuksKeyRSADIGESTSHA256
),
inData
:
gInData64Array
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicExportKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptions
)
done
();
});
it
(
'
HUKS_Basic_Capability_Export_0400
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
HUKS_Basic_Capability_Export_0400
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyRSASize2048
,
HuksCipherRSA
.
HuksKeyPurposeDECRYPT
,
HuksCipherRSA
.
HuksKeyRSAPADDINGNONE
,
HuksCipherRSA
.
HuksKeyRSABLOCKMODEECB
,
HuksCipherRSA
.
HuksKeyRSADIGESTSHA256
),
inData
:
gInData64Array
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicExportKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptions
)
done
();
});
it
(
'
HUKS_Basic_Capability_Export_0500
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
HUKS_Basic_Capability_Export_0500
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyRSASize3072
,
HuksCipherRSA
.
HuksKeyPurposeDECRYPT
,
HuksCipherRSA
.
HuksKeyRSAPADDINGNONE
,
HuksCipherRSA
.
HuksKeyRSABLOCKMODEECB
,
HuksCipherRSA
.
HuksKeyRSADIGESTSHA256
),
inData
:
gInData64Array
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicExportKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptions
)
done
();
});
it
(
'
HUKS_Basic_Capability_Export_0600
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
HUKS_Basic_Capability_Export_0600
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyRSASize4096
,
HuksCipherRSA
.
HuksKeyPurposeDECRYPT
,
HuksCipherRSA
.
HuksKeyRSAPADDINGNONE
,
HuksCipherRSA
.
HuksKeyRSABLOCKMODEECB
,
HuksCipherRSA
.
HuksKeyRSADIGESTSHA256
),
inData
:
gInData64Array
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicExportKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptions
)
done
();
});
it
(
'
HUKS_Basic_Capability_Export_0700
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
HUKS_Basic_Capability_Export_0700
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksAgreeECDH
.
HuksKeyAlgECC
,
HuksAgreeECDH
.
HuksKeyECCSize224
,
HuksAgreeECDH
.
HuksKeyPurposeECDH
,
HuksAgreeECDH
.
HuksKeyECCDIGEST
),
inData
:
gInData64Array
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicExportKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptions
)
done
();
});
it
(
'
HUKS_Basic_Capability_Export_0800
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
HUKS_Basic_Capability_Export_0800
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksAgreeECDH
.
HuksKeyAlgECC
,
HuksAgreeECDH
.
HuksKeyECCSize256
,
HuksAgreeECDH
.
HuksKeyPurposeECDH
,
//没找到
HuksAgreeECDH
.
HuksKeyECCDIGEST
),
inData
:
gInData64Array
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicExportKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptions
)
done
();
});
it
(
'
HUKS_Basic_Capability_Export_0900
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
HUKS_Basic_Capability_Export_0900
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksAgreeECDH
.
HuksKeyAlgECC
,
HuksAgreeECDH
.
HuksKeyECCSize384
,
HuksAgreeECDH
.
HuksKeyPurposeECDH
,
//没找到
HuksAgreeECDH
.
HuksKeyECCDIGEST
),
inData
:
gInData64Array
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicExportKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptions
)
done
();
});
it
(
'
HUKS_Basic_Capability_Export_1000
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
HUKS_Basic_Capability_Export_1000
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksAgreeECDH
.
HuksKeyAlgECC
,
HuksAgreeECDH
.
HuksKeyECCSize521
,
HuksAgreeECDH
.
HuksKeyPurposeECDH
,
//没找到
HuksAgreeECDH
.
HuksKeyECCDIGEST
),
inData
:
gInData64Array
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicExportKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptions
)
done
();
});
it
(
'
HUKS_Basic_Capability_Export_1100
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
HUKS_Basic_Capability_Export_1100
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksAgreeECDH
.
HuksKeyAlgECC
,
HuksAgreeECDH
.
HuksKeyPurposeECDH
,
HuksAgreeECDH
.
HuksKeyECCSize224
,
HuksAgreeECDH
.
HuksKeyECCDIGEST
,
HuksAgreeECDH
.
HuksKeyECCPADDING
,
HuksAgreeECDH
.
HuksKeyECCBLOCKMODE
,
),
inData
:
gInData64Array
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicExportKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptions
)
done
();
});
it
(
'
HUKS_Basic_Capability_Export_1200
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
HUKS_Basic_Capability_Export_1200
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksAgreeECDH
.
HuksKeyAlgECC
,
HuksAgreeECDH
.
HuksKeyPurposeECDH
,
HuksAgreeECDH
.
HuksKeyECCSize256
,
HuksAgreeECDH
.
HuksKeyECCDIGEST
,
HuksAgreeECDH
.
HuksKeyECCPADDING
,
HuksAgreeECDH
.
HuksKeyECCBLOCKMODE
),
inData
:
gInData64Array
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicExportKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptions
)
done
();
});
it
(
'
HUKS_Basic_Capability_Export_1300
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
HUKS_Basic_Capability_Export_1300
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksAgreeECDH
.
HuksKeyAlgECC
,
HuksAgreeECDH
.
HuksKeyPurposeECDH
,
HuksAgreeECDH
.
HuksKeyECCSize384
,
HuksAgreeECDH
.
HuksKeyECCDIGEST
,
HuksAgreeECDH
.
HuksKeyECCPADDING
,
HuksAgreeECDH
.
HuksKeyECCBLOCKMODE
),
inData
:
gInData64Array
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicExportKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptions
)
done
();
});
it
(
'
HUKS_Basic_Capability_Export_1400
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
HUKS_Basic_Capability_Export_1400
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksAgreeECDH
.
HuksKeyAlgECC
,
HuksAgreeECDH
.
HuksKeyPurposeECDH
,
HuksAgreeECDH
.
HuksKeyECCSize521
,
HuksAgreeECDH
.
HuksKeyECCDIGEST
,
HuksAgreeECDH
.
HuksKeyECCPADDING
,
HuksAgreeECDH
.
HuksKeyECCBLOCKMODE
),
inData
:
gInData64Array
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicExportKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptions
)
done
();
});
it
(
'
HUKS_Basic_Capability_Export_1500
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
HUKS_Basic_Capability_Export_1500
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksSignVerifyED25519
.
HuksKeyAlgED25519
,
HuksSignVerifyED25519
.
HuksKeyRSAPurposeSINGVERIFY
,
HuksSignVerifyED25519
.
HuksKeyED25519Size256
,
HuksSignVerifyED25519
.
HuksTagDigestSHA1
),
inData
:
gInData64Array
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicExportKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptions
)
done
();
});
it
(
'
HUKS_Basic_Capability_Export_1600
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
HUKS_Basic_Capability_Export_1600
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksKeyAlgX25519
.
HuksKeyAlgX25519
,
HuksKeyAlgX25519
.
HuksKeyCURVE25519Size256
,
HuksKeyAlgX25519
.
HuksKeyDIGEST
,
HuksKeyAlgX25519
.
HuksKeyPADDING
,
HuksKeyAlgX25519
.
HuksKeyPurposeAGREE
,
HuksKeyAlgX25519
.
HuksKeyBLOCKMODE
),
inData
:
gInData64Array
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicExportKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptions
)
done
();
});
it
(
'
HUKS_Basic_Capability_Export_1700
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
HUKS_Basic_Capability_Export_1700
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksSignVerifyDSA
.
HuksKeyAlgDSA
,
HuksSignVerifyDSA
.
HuksKeyDSAPurposeSIGN
,
HuksSignVerifyDSA
.
HuksTagDSADigestSHA1
,
HuksSignVerifyDSA
.
HuksKeySIZE1024
),
inData
:
gInData64Array
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicExportKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptions
)
done
();
});
it
(
'
HUKS_Basic_Capability_Export_1800
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlies
=
"
HUKS_Basic_Capability_Export_1800
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksSignVerifySM2
.
HuksKeyAlgSM2
,
HuksSignVerifySM2
.
HuksKeySM2PurposeSIGN
,
HuksSignVerifySM2
.
HuksKeySize256
,
HuksSignVerifySM2
.
HuksTagSM2DigestSM3
,
),
inData
:
gInData64Array
,
};
await
publicGenerateKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicExportKeyFunc
(
srcKeyAlies
,
HuksOptions
);
await
publicDeleteKeyFunc
(
srcKeyAlies
,
HuksOptions
)
done
();
});
it
(
'
HUKS_Basic_Capability_Export_2000
'
,
0
,
async
function
(
done
)
{
const
srcKeyAlies
=
'
****
'
let
HuksOptions
=
{
properties
:
new
Array
(
HuksCipherRSA
.
HuksKeyAlgRSA
,
HuksCipherRSA
.
HuksKeyPurposeENCRYPT
,
HuksCipherRSA
.
HuksKeyRSASize512
,
HuksCipherRSA
.
HuksKeyRSAPADDINGNONE
,
HuksCipherRSA
.
HuksKeyRSABLOCKMODEECB
,
HuksCipherRSA
.
HuksKeyRSADIGESTSHA256
,
),
inData
:
gInData64Array
,
};
await
exportkey
(
srcKeyAlies
,
HuksOptions
)
.
then
((
data
)
=>
{
console
.
log
(
`test ExportKey data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
null
).
assertFail
();
})
.
catch
((
err
)
=>
{
console
.
log
(
'
test ImportKey err information:
'
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
==
-
13
).
assertTrue
();
});
done
();
});
});
security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/List.test.js
浏览文件 @
1608b869
...
...
@@ -13,6 +13,7 @@
* limitations under the License.
*/
require
(
'
./Cipher/securityHuksExportSupportJsunit.test.js
'
);
require
(
'
./Cipher/SecurityHuksAESBasicCallbackJsunit.test.js
'
);
require
(
'
./Cipher/SecurityHuksRSABasicCallbackJsunit.test.js
'
);
require
(
'
./Cipher/SecurityHuksSM4BasicCallbackJsunit.test.js
'
);
\ No newline at end of file
require
(
'
./Cipher/SecurityHuksSM4BasicCallbackJsunit.test.js
'
);
security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksAccessControlJsunit.test.js
0 → 100644
浏览文件 @
1608b869
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
{
describe
,
it
,
expect
}
from
'
deccjsunit/index
'
;
import
huks
from
'
@ohos.security.huks
'
;
import
Data
from
'
../../../../../../../utils/data.json
'
;
import
{
stringToUint8Array
}
from
'
../../../../../../../utils/param/publicFunc
'
;
import
{
HuksSignVerifyDSA
,
HuksSignVerifyRSA
,
HuksSignVerifyECC
}
from
'
../../../../../../../utils/param/signverify/publicSignverifyParam
'
;
import
{
HuksAgreeDH
,
HuksAgreeECDH
}
from
'
../../../../../../../utils/param/agree/publicAgreeParam
'
;
import
{
HuksCipherAES
,
HuksCipherRSA
}
from
'
../../../../../../../utils/param/cipher/publicCipherParam
'
;
import
{
HuksHmac
}
from
'
../../../../../../../utils/param/hmac/publicHmacParam
'
;
let
srcData63
=
Data
.
Data63b
;
let
srcData63Kb
=
stringToUint8Array
(
srcData63
);
function
generateKey
(
srcKeyAlies
,
HuksOptions
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
huks
.
generateKey
(
srcKeyAlies
,
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
);
}
});
});
}
function
exportKey
(
srcKeyAlies
,
HuksOptions
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
huks
.
exportKey
(
srcKeyAlies
,
HuksOptions
,
function
(
err
,
data
)
{
console
.
log
(
`test exportKey data:
${
JSON
.
stringify
(
data
)}
`
);
if
(
err
.
code
!==
0
)
{
console
.
log
(
'
test exportKey err information:
'
+
JSON
.
stringify
(
err
));
reject
(
err
);
}
else
{
resolve
(
data
);
}
});
});
}
function
init
(
srcKeyAlies
,
HuksOptions
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
huks
.
init
(
srcKeyAlies
,
HuksOptions
,
function
(
err
,
data
)
{
if
(
err
.
code
!==
0
)
{
console
.
log
(
'
test init err information:
'
+
JSON
.
stringify
(
err
));
reject
(
err
);
}
else
{
resolve
(
data
);
}
});
});
}
function
deleteKey
(
srcKeyAlies
,
HuksOptions
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
huks
.
deleteKey
(
srcKeyAlies
,
HuksOptions
,
function
(
err
,
data
)
{
if
(
err
.
code
!==
0
)
{
console
.
log
(
'
test deleteKey err information:
'
+
JSON
.
stringify
(
err
));
reject
(
err
);
}
else
{
resolve
(
data
);
}
});
});
}
async
function
generateKeyFunc
(
srcKeyAlies
,
HuksOptions
)
{
await
generateKey
(
srcKeyAlies
,
HuksOptions
)
.
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
deleteKeyFunc
(
srcKeyAlies
,
HuksOptions
)
{
await
deleteKey
(
srcKeyAlies
,
HuksOptions
)
.
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
exportKeyFunc
(
srcKeyAlias
,
HuksOptions
)
{
await
exportKey
(
srcKeyAlias
,
HuksOptions
)
.
then
((
data
)
=>
{
console
.
log
(
'
test exportKey data =
'
+
JSON
.
stringify
(
data
));
expect
(
data
.
errorCode
==
0
).
assertTrue
();
}).
catch
((
err
)
=>
{
console
.
log
(
`test exportKey err: " +
${
JSON
.
stringify
(
err
)}
`
);
expect
(
null
).
assertFail
();
})
}
describe
(
'
SecurityHuksAccessControlJsunit
'
,
function
()
{
it
(
'
HUKS_Basic_Capability_AccessControl_0100
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlias
=
"
HUKS_Basic_Capability_AccessControl_0100
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksSignVerifyDSA
.
HuksKeyAlgDSA
,
HuksSignVerifyDSA
.
HuksKeyRSAPurposeSINGVERIFY
,
HuksSignVerifyDSA
.
HuksKeySIZE1024
,
HuksSignVerifyDSA
.
HuksTagDSADigestSHA1
),
inData
:
srcData63Kb
,
}
await
generateKeyFunc
(
srcKeyAlias
,
HuksOptions
);
await
exportKeyFunc
(
srcKeyAlias
,
HuksOptions
);
HuksOptions
.
properties
.
splice
(
1
,
1
,
HuksAgreeDH
.
HuksKeyPurposeDH
);
HuksOptions
.
properties
.
splice
(
3
,
1
);
await
init
(
srcKeyAlias
,
HuksOptions
).
then
((
data
)
=>
{
console
.
log
(
`test init data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
data
.
errorCode
==
-
112
).
assertTrue
();
}).
catch
((
err
)
=>
{
console
.
log
(
`test init err: " +
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
.
code
==
-
112
).
assertTrue
();
});
await
deleteKeyFunc
(
srcKeyAlias
,
HuksOptions
);
done
();
});
it
(
'
HUKS_Basic_Capability_AccessControl_0200
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlias
=
"
HUKS_Basic_Capability_AccessControl_0200
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksSignVerifyECC
.
HuksKeyAlgECC
,
HuksSignVerifyECC
.
HuksKeyECCPurposeSINGVERIFY
,
HuksSignVerifyECC
.
HuksKeyECCSize224
,
HuksSignVerifyECC
.
HuksTagECCDigestNONE
,
),
inData
:
srcData63Kb
,
}
await
generateKeyFunc
(
srcKeyAlias
,
HuksOptions
);
await
exportKeyFunc
(
srcKeyAlias
,
HuksOptions
);
HuksOptions
.
properties
.
splice
(
0
,
1
,
HuksAgreeECDH
.
HuksKeyAlgECDH
);
HuksOptions
.
properties
.
splice
(
1
,
1
,
HuksAgreeECDH
.
HuksKeyPurposeECDH
);
await
init
(
srcKeyAlias
,
HuksOptions
).
then
((
data
)
=>
{
console
.
log
(
`test init data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
data
.
errorCode
==
-
3
).
assertTrue
();
}).
catch
((
err
)
=>
{
console
.
log
(
`test init err: " +
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
.
code
==
-
3
).
assertTrue
();
});
await
deleteKeyFunc
(
srcKeyAlias
,
HuksOptions
);
done
();
});
it
(
'
HUKS_Basic_Capability_AccessControl_0300
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlias
=
"
HUKS_Basic_Capability_AccessControl_0300
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksSignVerifyDSA
.
HuksKeyAlgDSA
,
HuksSignVerifyDSA
.
HuksKeyRSAPurposeSINGVERIFY
,
HuksSignVerifyDSA
.
HuksKeySIZE1024
,
HuksSignVerifyDSA
.
HuksTagDSADigestSHA1
),
inData
:
srcData63Kb
,
};
await
generateKeyFunc
(
srcKeyAlias
,
HuksOptions
);
await
exportKeyFunc
(
srcKeyAlias
,
HuksOptions
);
HuksOptions
.
properties
.
splice
(
1
,
1
,
HuksCipherAES
.
HuksKeyPurposeENCRYPT
);
await
init
(
srcKeyAlias
,
HuksOptions
).
then
((
data
)
=>
{
console
.
log
(
`test init data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
null
).
assertFail
();
}).
catch
((
err
)
=>
{
console
.
log
(
`test init err: " +
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
.
code
==
-
112
).
assertTrue
();
});
HuksOptions
.
properties
.
splice
(
1
,
1
,
HuksCipherAES
.
HuksKeyPurposeDECRYPT
);
await
init
(
srcKeyAlias
,
HuksOptions
).
then
((
data
)
=>
{
console
.
log
(
`test init data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
null
).
assertFail
();
}).
catch
((
err
)
=>
{
console
.
log
(
`test init err: " +
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
.
code
==
-
112
).
assertTrue
();
});
await
deleteKeyFunc
(
srcKeyAlias
,
HuksOptions
);
done
();
})
it
(
"
HUKS_Basic_Capability_AccessControl_0400
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlias
=
"
HUKS_Basic_Capability_AccessControl_0400
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksSignVerifyRSA
.
HuksKeyAlgRSA
,
HuksSignVerifyRSA
.
HuksKeyRSAPurposeSIGN
,
HuksSignVerifyRSA
.
HuksTagPKCS1DigestMD5
,
HuksSignVerifyRSA
.
HuksKeyRSAPADDINGPKCS1V15
,
HuksSignVerifyRSA
.
HuksKeyRSASize512
),
inData
:
srcData63Kb
,
};
await
generateKeyFunc
(
srcKeyAlias
,
HuksOptions
);
await
exportKeyFunc
(
srcKeyAlias
,
HuksOptions
);
HuksOptions
.
properties
.
splice
(
1
,
1
,
HuksCipherRSA
.
HuksKeyPurposeENCRYPT
);
await
init
(
srcKeyAlias
,
HuksOptions
).
then
((
data
)
=>
{
console
.
log
(
`test init data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
data
.
errorCode
==
-
3
).
assertTrue
();
}).
catch
((
err
)
=>
{
console
.
log
(
`test init err: " +
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
.
code
==
-
3
).
assertTrue
();
});
HuksOptions
.
properties
.
splice
(
1
,
1
,
HuksCipherRSA
.
HuksKeyPurposeDECRYPT
);
await
init
(
srcKeyAlias
,
HuksOptions
).
then
((
data
)
=>
{
console
.
log
(
`test init data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
data
.
errorCode
==
-
3
).
assertTrue
();
}).
catch
((
err
)
=>
{
console
.
log
(
`test init err: " +
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
.
code
==
-
3
).
assertTrue
();
});
HuksOptions
.
properties
.
splice
(
1
,
1
,
HuksHmac
.
HuksKeyPurpose
);
await
init
(
srcKeyAlias
,
HuksOptions
).
then
((
data
)
=>
{
console
.
log
(
`test init data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
data
.
errorCode
==
-
112
).
assertTrue
();
}).
catch
((
err
)
=>
{
console
.
log
(
`test init err: " +
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
.
code
==
-
112
).
assertTrue
();
});
await
deleteKeyFunc
(
srcKeyAlias
,
HuksOptions
);
done
();
});
it
(
"
HUKS_Basic_Capability_AccessControl_0500
"
,
0
,
async
function
(
done
)
{
let
srcKeyAlias
=
"
HUKS_Basic_Capability_AccessControl_0500
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurpose
,
HuksCipherAES
.
HuksKeyAESSize128
,
HuksCipherAES
.
HuksKeyAESBLOCKMODE
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
),
};
await
generateKeyFunc
(
srcKeyAlias
,
HuksOptions
);
HuksOptions
.
properties
.
splice
(
1
,
1
,
HuksHmac
.
HuksKeyPurpose
);
await
init
(
srcKeyAlias
,
HuksOptions
).
then
((
data
)
=>
{
console
.
log
(
`test init data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
data
.
errorCode
==
-
112
).
assertTrue
();
}).
catch
((
err
)
=>
{
console
.
log
(
`test init err: " +
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
.
code
==
-
112
).
assertTrue
();
});
await
deleteKeyFunc
(
srcKeyAlias
,
HuksOptions
);
done
();
});
it
(
'
HUKS_Basic_Capability_AccessControl_0600
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlias
=
"
HUKS_Basic_Capability_AccessControl_0600
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksSignVerifyDSA
.
HuksKeyAlgDSA
,
HuksSignVerifyDSA
.
HuksKeyRSAPurposeSINGVERIFY
,
HuksSignVerifyDSA
.
HuksKeySIZE1024
,
HuksSignVerifyDSA
.
HuksTagDSADigestSHA1
),
inData
:
srcData63Kb
,
};
await
generateKeyFunc
(
srcKeyAlias
,
HuksOptions
);
await
exportKeyFunc
(
srcKeyAlias
,
HuksOptions
);
HuksOptions
.
properties
.
splice
(
1
,
1
,
HuksHmac
.
HuksKeyPurpose
);
await
init
(
srcKeyAlias
,
HuksOptions
).
then
((
data
)
=>
{
console
.
log
(
`test init data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
null
).
assertFail
();
}).
catch
((
err
)
=>
{
console
.
log
(
`test init err: " +
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
.
code
==
-
112
).
assertTrue
();
});
await
deleteKeyFunc
(
srcKeyAlias
,
HuksOptions
);
done
();
});
it
(
'
HUKS_Basic_Capability_AccessControl_0700
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlias
=
"
HUKS_Basic_Capability_AccessControl_0700
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurpose
,
HuksCipherAES
.
HuksKeyAESSize128
,
HuksCipherAES
.
HuksKeyAESBLOCKMODE
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
),
};
await
generateKeyFunc
(
srcKeyAlias
,
HuksOptions
);
HuksOptions
.
properties
.
splice
(
1
,
1
,
HuksSignVerifyRSA
.
HuksKeyRSAPurposeSIGN
);
HuksOptions
.
properties
.
splice
(
5
,
1
,
HuksSignVerifyRSA
.
HuksTagPKCS1DigestNONE
);
await
init
(
srcKeyAlias
,
HuksOptions
).
then
((
data
)
=>
{
console
.
log
(
`test init data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
null
).
assertFail
();
}).
catch
((
err
)
=>
{
console
.
log
(
`test init err: " +
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
.
code
==
-
112
).
assertTrue
();
});
HuksOptions
.
properties
.
splice
(
1
,
1
,
HuksSignVerifyRSA
.
HuksKeyRSAPurposeVERIFY
);
await
init
(
srcKeyAlias
,
HuksOptions
).
then
((
data
)
=>
{
console
.
log
(
`test init data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
null
).
assertFail
();
}).
catch
((
err
)
=>
{
console
.
log
(
`test init err: " +
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
.
code
==
-
112
).
assertTrue
();
});
await
deleteKeyFunc
(
srcKeyAlias
,
HuksOptions
);
done
();
});
it
(
'
HUKS_Basic_Capability_AccessControl_0800
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlias
=
"
HUKS_Basic_Capability_AccessControl_0800
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksAgreeECDH
.
HuksKeyAlgECC
,
HuksAgreeECDH
.
HuksKeyPurposeECDH
,
HuksAgreeECDH
.
HuksKeyECCSize224
,
HuksAgreeECDH
.
HuksKeyECCDIGEST
,
HuksAgreeECDH
.
HuksKeyECCPADDING
,
HuksAgreeECDH
.
HuksKeyECCBLOCKMODE
),
inData
:
srcData63Kb
,
};
await
generateKeyFunc
(
srcKeyAlias
,
HuksOptions
);
await
exportKeyFunc
(
srcKeyAlias
,
HuksOptions
);
HuksOptions
.
properties
.
splice
(
0
,
1
,
HuksSignVerifyECC
.
HuksKeyECCPurposeSIGN
);
HuksOptions
.
properties
.
splice
(
4
,
2
);
await
init
(
srcKeyAlias
,
HuksOptions
).
then
((
data
)
=>
{
console
.
log
(
`test init data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
data
.
errorCode
==
-
3
).
assertTrue
();
}).
catch
((
err
)
=>
{
console
.
log
(
`test init err: " +
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
.
code
==
-
3
).
assertTrue
();
});
HuksOptions
.
properties
.
splice
(
0
,
1
,
HuksSignVerifyECC
.
HuksKeyECCPurposeVERIFY
);
HuksOptions
.
properties
.
splice
(
4
,
2
);
await
init
(
srcKeyAlias
,
HuksOptions
).
then
((
data
)
=>
{
console
.
log
(
`test init data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
data
.
errorCode
==
-
3
).
assertTrue
();
}).
catch
((
err
)
=>
{
console
.
log
(
`test init err: " +
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
.
code
==
-
3
).
assertTrue
();
});
await
deleteKeyFunc
(
srcKeyAlias
,
HuksOptions
);
done
();
});
it
(
'
HUKS_Basic_Capability_AccessControl_0900
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlias
=
"
HUKS_Basic_Capability_AccessControl_0900
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksSignVerifyDSA
.
HuksKeyAlgDSA
,
HuksSignVerifyDSA
.
HuksKeyRSAPurposeSINGVERIFY
,
HuksSignVerifyDSA
.
HuksKeySIZE1024
,
HuksSignVerifyDSA
.
HuksTagDSADigestSHA1
),
inData
:
srcData63Kb
,
}
await
generateKeyFunc
(
srcKeyAlias
,
HuksOptions
);
await
exportKeyFunc
(
srcKeyAlias
,
HuksOptions
);
HuksOptions
.
properties
.
splice
(
1
,
1
,
HuksAgreeDH
.
HuksKeyPurposeDH
);
HuksOptions
.
properties
.
splice
(
3
,
1
);
await
huks
.
init
(
srcKeyAlias
,
HuksOptions
).
then
((
data
)
=>
{
console
.
log
(
`test init data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
data
.
errorCode
==
-
112
).
assertTrue
();
}).
catch
((
err
)
=>
{
console
.
log
(
`test init err: " +
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
.
code
==
-
112
).
assertTrue
();
});
await
deleteKeyFunc
(
srcKeyAlias
,
HuksOptions
);
done
();
});
it
(
'
HUKS_Basic_Capability_AccessControl_1000
'
,
0
,
async
function
(
done
)
{
let
srcKeyAlias
=
"
HUKS_Basic_Capability_AccessControl_1000
"
;
let
HuksOptions
=
{
properties
:
new
Array
(
HuksCipherAES
.
HuksKeyAlgAES
,
HuksCipherAES
.
HuksKeyPurposeENCRYPT
,
HuksCipherAES
.
HuksKeyAESSize128
,
HuksCipherAES
.
HuksKeyAESBLOCKMODE
,
HuksCipherAES
.
HuksKeyAESPADDINGNONE
,
),
};
await
generateKeyFunc
(
srcKeyAlias
,
HuksOptions
);
HuksOptions
.
properties
.
splice
(
1
,
1
,
HuksCipherAES
.
HuksKeyPurposeDECRYPT
);
await
init
(
srcKeyAlias
,
HuksOptions
).
then
((
data
)
=>
{
console
.
log
(
`test init data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
data
.
errorCode
==
-
3
).
assertTrue
();
}).
catch
((
err
)
=>
{
console
.
log
(
`test init err: " +
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
.
code
==
-
3
).
assertTrue
();
});
await
deleteKeyFunc
(
srcKeyAlias
,
HuksOptions
);
done
();
});
});
security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksImportJsunit.test.js
0 → 100644
浏览文件 @
1608b869
此差异已折叠。
点击以展开。
security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/List.test.js
浏览文件 @
1608b869
...
...
@@ -13,4 +13,6 @@
* limitations under the License.
*/
require
(
'
./HMAC/SecurityHuksAccessControlJsunit.test.js
'
);
require
(
'
./HMAC/SecurityHuksImportJsunit.test.js
'
);
require
(
'
./HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js
'
);
security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksSM2BasicAbort63KBPromiseJsunit.test.js
浏览文件 @
1608b869
...
...
@@ -19,7 +19,7 @@ import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'
import
{
publicSignVerifyFunc
}
from
'
../../../../../../../utils/param/signverify/publicSignverifyPromise.js
'
;
let
srcData63
=
Data
.
Data63b
;
let
srcData63Kb
=
stringToUint8Array
(
srcData63
);
describe
(
'
SecurityHuksS
ignVerifySM2
PromiseJsunit
'
,
function
()
{
describe
(
'
SecurityHuksS
M2BasicAbort63KB
PromiseJsunit
'
,
function
()
{
it
(
'
testSignVerifySM2102
'
,
0
,
async
function
(
done
)
{
const
srcKeyAlies
=
'
testSignVerifySM2Size256SIGNSM3KeyAlias102
'
;
let
HuksOptions
=
{
...
...
security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksSM2BasicAbort65KBPromiseJsunit.test.js
浏览文件 @
1608b869
...
...
@@ -19,7 +19,7 @@ import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'
import
{
publicSignVerifyFunc
}
from
'
../../../../../../../utils/param/signverify/publicSignverifyPromise.js
'
;
let
srcData65
=
Data
.
Data65b
;
let
srcData65Kb
=
stringToUint8Array
(
srcData65
);
describe
(
'
SecurityHuksS
ignVerifySM2
PromiseJsunit
'
,
function
()
{
describe
(
'
SecurityHuksS
M2BasicAbort65KB
PromiseJsunit
'
,
function
()
{
it
(
'
testSignVerifySM2104
'
,
0
,
async
function
(
done
)
{
const
srcKeyAlies
=
'
testSignVerifySM2Size256SIGNSM3KeyAlias104
'
;
let
HuksOptions
=
{
...
...
security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksSM2BasicFinish63KBPromiseJsunit.test.js
浏览文件 @
1608b869
...
...
@@ -20,7 +20,7 @@ import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverif
let
srcData63
=
Data
.
Data63b
;
let
srcData63Kb
=
stringToUint8Array
(
srcData63
);
let
finishOutData
;
describe
(
'
SecurityHuksS
ignVerifySM2
PromiseJsunit
'
,
function
()
{
describe
(
'
SecurityHuksS
M2BasicFinish63KB
PromiseJsunit
'
,
function
()
{
it
(
'
testSignVerifySM2101
'
,
0
,
async
function
(
done
)
{
const
srcKeyAlies
=
'
testSignVerifySM2Size256SIGNSM3KeyAlias101
'
;
let
HuksOptions
=
{
...
...
security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksSM2BasicFinish65KBPromiseJsunit.test.js
浏览文件 @
1608b869
...
...
@@ -20,7 +20,7 @@ import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverif
let
srcData65
=
Data
.
Data65b
;
let
srcData65Kb
=
stringToUint8Array
(
srcData65
);
let
finishOutData
;
describe
(
'
SecurityHuksS
ignVerifySM2
PromiseJsunit
'
,
function
()
{
describe
(
'
SecurityHuksS
M2BasicFinish65KB
PromiseJsunit
'
,
function
()
{
it
(
'
testSignVerifySM2103
'
,
0
,
async
function
(
done
)
{
const
srcKeyAlies
=
'
testSignVerifySM2Size256SIGNSM3KeyAlias103
'
;
let
HuksOptions
=
{
...
...
security/security_huks_basic/utils/param/cipher/publicCipherParam.js
浏览文件 @
1608b869
...
...
@@ -44,6 +44,10 @@ let HuksCipherAES = {
tag
:
param
.
HksTag
.
HKS_TAG_KEY_SIZE
,
value
:
param
.
HksKeySize
.
HKS_AES_KEY_SIZE_256
,
},
HuksKeyAESSize512
:
{
tag
:
param
.
HksTag
.
HKS_TAG_KEY_SIZE
,
value
:
param
.
HksKeySize
.
HKS_AES_KEY_SIZE_512
,
},
HuksKeyAESPADDINGNONE
:
{
tag
:
param
.
HksTag
.
HKS_TAG_PADDING
,
value
:
param
.
HksKeyPadding
.
HKS_PADDING_NONE
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录