diff --git a/security/BUILD.gn b/security/BUILD.gn index 08ac2f8e7d90e07f1e8a2d974773ae65f0577735..e83d5664cb300b7288458d1db68f792c8282d1be 100644 --- a/security/BUILD.gn +++ b/security/BUILD.gn @@ -19,7 +19,6 @@ group("security") { deps = [ "access_token/AccessTokenTest_Normal_js:ActsAccessTokenApiJSNormalTest", "cipher/datacipher:datacipher", - "huks_standard", "security_huks_basic", ] } diff --git a/security/huks_standard/BUILD.gn b/security/huks_standard/BUILD.gn deleted file mode 100644 index c927d5fc4d75777533a334a65ece54d420070393..0000000000000000000000000000000000000000 --- a/security/huks_standard/BUILD.gn +++ /dev/null @@ -1,24 +0,0 @@ -# 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("//build/ohos_var.gni") - -group("huks_standard") { - testonly = true - if (is_standard_system) { - deps = [ - "HuksAbnormalTest:ActsHuksAbnormalTest", - "HuksAlgCompletionTest:ActsHuksAlgCompletionTest", - ] - } -} diff --git a/security/huks_standard/HuksAbnormalTest/BUILD.gn b/security/huks_standard/HuksAbnormalTest/BUILD.gn deleted file mode 100644 index cd892d4bb6f263a4d6ef9df4a5d77d9800f2ba80..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/BUILD.gn +++ /dev/null @@ -1,31 +0,0 @@ -# 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("//test/xts/tools/build/suite.gni") - -ohos_js_hap_suite("ActsHuksAbnormalTest") { - hap_profile = "./entry/src/main/config.json" - deps = [ - ":hjs_demo_js_assets", - ":hjs_demo_resources", - ] - certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsHuksAbnormalTest" -} -ohos_js_assets("hjs_demo_js_assets") { - source_dir = "./entry/src/main/js/default" -} -ohos_resources("hjs_demo_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" -} diff --git a/security/huks_standard/HuksAbnormalTest/Test.json b/security/huks_standard/HuksAbnormalTest/Test.json deleted file mode 100644 index 17d3d436657eef0843252424eb836dddb2976984..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for algorithm completion test", - "driver": { - "type": "JSUnitTest", - "test-timeout": "7200000", - "package": "com.example.err", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHuksAbnormalTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/config.json b/security/huks_standard/HuksAbnormalTest/entry/src/main/config.json deleted file mode 100644 index c6c264850053362a15c82c400491a1930101bffb..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/config.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "app": { - "bundleName": "com.example.err", - "vendor": "example", - "version": { - "code": 1, - "name": "1.0.0" - }, - "apiVersion": { - "compatible": 4, - "target": 5, - "releaseType": "Beta1" - } - }, - "deviceConfig": {}, - "module": { - "package": "com.example.err", - "name": ".MyApplication", - "mainAbility": "com.example.err.MainAbility", - "deviceType": [ - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry", - "installationFree": true - }, - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "name": "com.example.err.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:entry_MainAbility", - "type": "page", - "launchType": "singleton", - "visible": true, - "isVisible": "true" - } - ], - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": true - } - } - ] - } -} \ No newline at end of file diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/default/app.js b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/default/app.js deleted file mode 100644 index 14ca792625c50b934e7bda87ac333d3414dc12bd..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/default/app.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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. - */ - -export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } -}; diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/default/i18n/en-US.json b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/default/i18n/en-US.json deleted file mode 100644 index e63c70d978a3a53be988388c87182f81785e170c..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/default/i18n/en-US.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - } -} \ No newline at end of file diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/default/i18n/zh-CN.json b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/default/i18n/zh-CN.json deleted file mode 100644 index de6ee5748322f44942c1b003319d8e66c837675f..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/default/i18n/zh-CN.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - } -} \ No newline at end of file diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/default/pages/index/index.css b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/default/pages/index/index.css deleted file mode 100644 index cea86d90eac6e55509e20fee0b234ac060af020c..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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. - */ - -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 40px; - color: #000000; - opacity: 0.9; -} - -@media screen and (device-type: tablet) and (orientation: landscape) { - .title { - font-size: 100px; - } -} - -@media screen and (device-type: wearable) { - .title { - font-size: 28px; - color: #FFFFFF; - } -} - -@media screen and (device-type: tv) { - .container { - background-image: url("../../common/images/Wallpaper.png"); - background-size: cover; - background-repeat: no-repeat; - background-position: center; - } - - .title { - font-size: 100px; - color: #FFFFFF; - } -} - -@media screen and (device-type: phone) and (orientation: landscape) { - .title { - font-size: 60px; - } -} diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/default/pages/index/index.hml b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/default/pages/index/index.hml deleted file mode 100644 index 546cd8296b727c1639d551d2301a0bca055c1457..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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. - */ - -
- - {{ $t('strings.hello') }} {{ title }} - -
diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/default/pages/index/index.js b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/default/pages/index/index.js deleted file mode 100644 index 1e7b197f6005568827b5fd4d3af3039c0359235c..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/default/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 file from '@system.file'; -import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index'; - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - const core = Core.getInstance(); - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }); - const reportExtend = new ReportExtend(file); - core.addService('expect', expectExtend); - core.addService('report', reportExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1000000; - configService.setConfig(this); - require('../../../test/hks_abnormal_testList.test.js'); - core.execute(); - } -} diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/resources/base/element/string.json b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/resources/base/element/string.json deleted file mode 100644 index c0dd3a09e5dcefc69f22b5e00e92296f1c3f55a5..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "entry_MainAbility" - }, - { - "name": "mainability_description", - "value": "JS_Empty Ability" - } - ] -} \ No newline at end of file diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/resources/base/media/icon.png b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/resources/base/media/icon.png and /dev/null differ diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_callback.test.js b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_callback.test.js deleted file mode 100644 index a9d0fe980bcc43734e1b5c2fb7feddd409dc796f..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_callback.test.js +++ /dev/null @@ -1,1526 +0,0 @@ -/* - * 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 hks from '@ohos.security.huks' -import {describe, it, expect} from 'deccjsunit/index' -import { - alias, - aliasEmpty, - aliasTooLong, - aliasCritical, - aliasNotExist, - emptyOption, - invalidValue, - generateAesCBCKeyOption, - generateAesGCMKeyOption, - generateRSAKeyOption, - generateECCKeyOption, - generateMACKeyOption, - plainTextSize8, - plainTextSize16, - plainTextSize64, - makeAgreeOption, - makeEncryptAndDecryptOption, - makeMacOption, - makeSignVerifyAndImportOption -} from './hks_abnormal_common.test.js' - -describe('Hks_XtsTest_Abnormal_Callback', function () { - - async function generateAesKey(mode) { - var option = {}; - if (mode == 'CBC') { - option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - } else { - option = JSON.parse(JSON.stringify(generateAesGCMKeyOption)); - } - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_SUCCESS); - }; - - function deleteKeyCallback(alias, done) { - hks.deleteKey(alias, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_SUCCESS); - done(); - }); - }; - - async function generateRsaKey() { - var option = generateRSAKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_SUCCESS); - }; - - async function generateEccKey() { - var option = generateECCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_SUCCESS); - }; - - async function generateMacKey() { - var option = generateMACKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_SUCCESS); - }; - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_00100 - * @tc.name HUKS_ABNORMAL_CALLBACK_00100 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_00100', 0, async function (done) { - hks.generateKey(aliasEmpty, generateAesCBCKeyOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_00200 - * @tc.name HUKS_ABNORMAL_CALLBACK_00200 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_00200', 0, async function (done) { - hks.generateKey(aliasCritical, generateAesCBCKeyOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_SUCCESS); - deleteKeyCallback(aliasCritical, done); - }) - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_00300 - * @tc.name HUKS_ABNORMAL_CALLBACK_00300 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_00300', 0, async function (done) { - hks.generateKey(aliasTooLong, generateAesCBCKeyOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_00400 - * @tc.name HUKS_ABNORMAL_CALLBACK_00400 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_00400', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties.splice(0, 1); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_ALG_FAIL); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_00500 - * @tc.name HUKS_ABNORMAL_CALLBACK_00500 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_00500', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties.splice(1, 1); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_00600 - * @tc.name HUKS_ABNORMAL_CALLBACK_00600 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_00600', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties.splice(2, 1); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_PURPOSE_FAIL); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_00700 - * @tc.name HUKS_ABNORMAL_CALLBACK_00700 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_00700', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties.splice(3, 1); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_PADDING_FAIL); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_00800 - * @tc.name HUKS_ABNORMAL_CALLBACK_00800 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_00800', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties.splice(4, 1); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_MODE_FAIL); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_00900 - * @tc.name HUKS_ABNORMAL_CALLBACK_00900 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_00900', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties[0].value = invalidValue; - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_01000 - * @tc.name HUKS_ABNORMAL_CALLBACK_01000 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_01000', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties[1].value = invalidValue; - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_01100 - * @tc.name HUKS_ABNORMAL_CALLBACK_01100 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_01100', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties[2].value = invalidValue; - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_01200 - * @tc.name HUKS_ABNORMAL_CALLBACK_01200 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_01200', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties[3].value = invalidValue; - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_01300 - * @tc.name HUKS_ABNORMAL_CALLBACK_01300 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_01300', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties[4].value = invalidValue; - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_MODE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_01400 - * @tc.name HUKS_ABNORMAL_CALLBACK_01400 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_01400', 0, async function (done) { - hks.deleteKey(aliasNotExist, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_NOT_EXIST); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_01500 - * @tc.name HUKS_ABNORMAL_CALLBACK_01500 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_01500', 0, async function (done) { - hks.deleteKey(aliasEmpty, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_01600 - * @tc.name HUKS_ABNORMAL_CALLBACK_01600 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_01600', 0, async function (done) { - hks.deleteKey(aliasTooLong, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_01700 - * @tc.name HUKS_ABNORMAL_CALLBACK_01700 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_01700', 0, async function (done) { - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - hks.encrypt(aliasEmpty, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_01800 - * @tc.name HUKS_ABNORMAL_CALLBACK_01800 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_01800', 0, async function (done) { - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - hks.encrypt(aliasNotExist, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_NOT_EXIST); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_01900 - * @tc.name HUKS_ABNORMAL_CALLBACK_01900 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_01900', 0, async function (done) { - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - hks.encrypt(aliasTooLong, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_02000 - * @tc.name HUKS_ABNORMAL_CALLBACK_02000 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_02000', 0, async function (done) { - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - hks.encrypt(aliasTooLong, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_02100 - * @tc.name HUKS_ABNORMAL_CALLBACK_02100 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_02100', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties.splice(0, 1); - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_ALG_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_02200 - * @tc.name HUKS_ABNORMAL_CALLBACK_02200 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_02200', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties.splice(1, 1); - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_PURPOSE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_02300 - * @tc.name HUKS_ABNORMAL_CALLBACK_02300 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_02300', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties.splice(2, 1); - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_MODE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_02400 - * @tc.name HUKS_ABNORMAL_CALLBACK_02400 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_02400', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties.splice(3, 1); - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_PADDING_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_02500 - * @tc.name HUKS_ABNORMAL_CALLBACK_02500 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_02500', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties.splice(4, 1); - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_IV_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_02600 - * @tc.name HUKS_ABNORMAL_CALLBACK_02600 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_02600', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_GCM); - option.properties.splice(4, 1); - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_NONCE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_02700 - * @tc.name HUKS_ABNORMAL_CALLBACK_02700 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_02700', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_GCM); - option.properties.splice(5, 1); - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_AAD_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_02800 - * @tc.name HUKS_ABNORMAL_CALLBACK_02800 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_02800', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties[0].value = invalidValue; - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ALGORITHM); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_02900 - * @tc.name HUKS_ABNORMAL_CALLBACK_02900 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_02900', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties[1].value = invalidValue; - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_03000 - * @tc.name HUKS_ABNORMAL_CALLBACK_03000 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_03000', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties[2].value = invalidValue; - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_MODE); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_03100 - * @tc.name HUKS_ABNORMAL_CALLBACK_03100 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_03100', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties[3].value = invalidValue; - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_PADDING); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_03200 - * @tc.name HUKS_ABNORMAL_CALLBACK_03200 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_03200', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_GCM); - option.inData = new Uint8Array(0); - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_03300 - * @tc.name HUKS_ABNORMAL_CALLBACK_03300 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_03300', 0, async function (done) { - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - hks.decrypt(aliasEmpty, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_03400 - * @tc.name HUKS_ABNORMAL_CALLBACK_03400 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_03400', 0, async function (done) { - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - hks.decrypt(aliasNotExist, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_NOT_EXIST); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_03500 - * @tc.name HUKS_ABNORMAL_CALLBACK_03500 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_03500', 0, async function (done) { - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - hks.decrypt(aliasTooLong, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_03600 - * @tc.name HUKS_ABNORMAL_CALLBACK_03600 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_03600', 0, async function (done) { - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - hks.decrypt(aliasTooLong, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_03700 - * @tc.name HUKS_ABNORMAL_CALLBACK_03700 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_03700', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties.splice(0, 1); - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_ALG_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_03800 - * @tc.name HUKS_ABNORMAL_CALLBACK_03800 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_03800', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties.splice(1, 1); - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_PURPOSE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_03900 - * @tc.name HUKS_ABNORMAL_CALLBACK_03900 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_03900', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties.splice(2, 1); - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_MODE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_04000 - * @tc.name HUKS_ABNORMAL_CALLBACK_04000 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_04000', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties.splice(3, 1); - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_PADDING_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_04100 - * @tc.name HUKS_ABNORMAL_CALLBACK_04100 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_04100', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties.splice(4, 1); - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_IV_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_04200 - * @tc.name HUKS_ABNORMAL_CALLBACK_04200 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_04200', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_GCM); - option.properties.splice(4, 1); - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_NONCE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_04300 - * @tc.name HUKS_ABNORMAL_CALLBACK_04300 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_04300', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_GCM); - option.properties.splice(5, 1); - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_AAD_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_04400 - * @tc.name HUKS_ABNORMAL_CALLBACK_04400 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_04400', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties[0].value = invalidValue; - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ALGORITHM); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_04500 - * @tc.name HUKS_ABNORMAL_CALLBACK_04500 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_04500', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties[1].value = invalidValue; - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_04600 - * @tc.name HUKS_ABNORMAL_CALLBACK_04600 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_04600', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties[2].value = invalidValue; - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_MODE); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_04700 - * @tc.name HUKS_ABNORMAL_CALLBACK_04700 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_04700', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties[3].value = invalidValue; - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_PADDING); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_04800 - * @tc.name HUKS_ABNORMAL_CALLBACK_04800 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_04800', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_GCM); - option.inData = new Uint8Array(0); - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_04900 - * @tc.name HUKS_ABNORMAL_CALLBACK_04900 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_04900', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - hks.importKey(aliasEmpty, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_05000 - * @tc.name HUKS_ABNORMAL_CALLBACK_05000 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_05000', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - hks.importKey(aliasCritical, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_05100 - * @tc.name HUKS_ABNORMAL_CALLBACK_05100 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_05100', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - hks.importKey(aliasTooLong, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_05200 - * @tc.name HUKS_ABNORMAL_CALLBACK_05200 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_05200', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(0, 1); - hks.importKey(aliasNotExist, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_ALG_FAIL); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_05300 - * @tc.name HUKS_ABNORMAL_CALLBACK_05300 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_05300', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(1, 1); - hks.importKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_05400 - * @tc.name HUKS_ABNORMAL_CALLBACK_05400 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_05400', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(2, 1); - hks.importKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_05500 - * @tc.name HUKS_ABNORMAL_CALLBACK_05500 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_05500', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(3, 1); - hks.importKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_05600 - * @tc.name HUKS_ABNORMAL_CALLBACK_05600 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_05600', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[0].value = invalidValue; - hks.importKey(aliasNotExist, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ALGORITHM); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_05700 - * @tc.name HUKS_ABNORMAL_CALLBACK_05700 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_05700', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[1].value = invalidValue; - hks.importKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_05800 - * @tc.name HUKS_ABNORMAL_CALLBACK_05800 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_05800', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[2].value = invalidValue; - hks.importKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_05900 - * @tc.name HUKS_ABNORMAL_CALLBACK_05900 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_05900', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[3].value = invalidValue; - hks.importKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_06000 - * @tc.name HUKS_ABNORMAL_CALLBACK_06000 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_06000', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.inData = new Uint8Array(0); - hks.importKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_06100 - * @tc.name HUKS_ABNORMAL_CALLBACK_06100 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_06100', 0, async function (done) { - hks.exportKey(aliasNotExist, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_NOT_EXIST); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_06200 - * @tc.name HUKS_ABNORMAL_CALLBACK_06200 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_06200', 0, async function (done) { - hks.exportKey(aliasTooLong, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_06300 - * @tc.name HUKS_ABNORMAL_CALLBACK_06300 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_06300', 0, async function (done) { - hks.exportKey(aliasEmpty, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_06400 - * @tc.name HUKS_ABNORMAL_CALLBACK_06400 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_06400', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - hks.sign(aliasNotExist, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_NOT_EXIST); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_06500 - * @tc.name HUKS_ABNORMAL_CALLBACK_06500 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_06500', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - hks.sign(aliasTooLong, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_06600 - * @tc.name HUKS_ABNORMAL_CALLBACK_06600 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_06600', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - hks.sign(aliasEmpty, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_06700 - * @tc.name HUKS_ABNORMAL_CALLBACK_06700 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_06700', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[0].value = invalidValue; - hks.sign(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ALGORITHM); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_06800 - * @tc.name HUKS_ABNORMAL_CALLBACK_06800 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_06800', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[1].value = invalidValue; - hks.sign(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_06900 - * @tc.name HUKS_ABNORMAL_CALLBACK_06900 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_06900', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties[2].value = invalidValue; - hks.sign(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_07000 - * @tc.name HUKS_ABNORMAL_CALLBACK_07000 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_07000', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties[3].value = invalidValue; - hks.sign(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_07100 - * @tc.name HUKS_ABNORMAL_CALLBACK_07100 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_07100', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.inData = new Uint8Array(0); - hks.sign(aliasEmpty, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_07200 - * @tc.name HUKS_ABNORMAL_CALLBACK_07200 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_07200', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(0, 1); - hks.sign(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_ALG_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_07300 - * @tc.name HUKS_ABNORMAL_CALLBACK_07300 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_07300', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(1, 1); - hks.sign(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_07400 - * @tc.name HUKS_ABNORMAL_CALLBACK_07400 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_07400', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties.splice(2, 1); - hks.sign(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_07500 - * @tc.name HUKS_ABNORMAL_CALLBACK_07500 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_07500', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties.splice(3, 1); - hks.sign(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_07600 - * @tc.name HUKS_ABNORMAL_CALLBACK_07600 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_07600', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - hks.verify(aliasNotExist, option, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_NOT_EXIST); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_07700 - * @tc.name HUKS_ABNORMAL_CALLBACK_07700 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_07700', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - hks.verify(aliasTooLong, option, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_07800 - * @tc.name HUKS_ABNORMAL_CALLBACK_07800 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_07800', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - hks.verify(aliasEmpty, option, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_07900 - * @tc.name HUKS_ABNORMAL_CALLBACK_07900 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_07900', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[0].value = invalidValue; - hks.verify(alias, option, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ALGORITHM); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_08000 - * @tc.name HUKS_ABNORMAL_CALLBACK_08000 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_08000', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties[1].value = invalidValue; - hks.verify(alias, option, plainTextSize8, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_08100 - * @tc.name HUKS_ABNORMAL_CALLBACK_08100 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_08100', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties[2].value = invalidValue; - hks.verify(alias, option, plainTextSize8, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_08200 - * @tc.name HUKS_ABNORMAL_CALLBACK_08200 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_08200', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties[3].value = invalidValue; - hks.verify(alias, option, plainTextSize8, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_08300 - * @tc.name HUKS_ABNORMAL_CALLBACK_08300 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_08300', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize16); - option.inData = new Uint8Array(0); - hks.verify(alias, option, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_08400 - * @tc.name HUKS_ABNORMAL_CALLBACK_08400 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_08400', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(0, 1); - hks.verify(alias, option, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_ALG_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_08500 - * @tc.name HUKS_ABNORMAL_CALLBACK_08500 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_08500', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(1, 1); - hks.verify(aliasNotExist, option, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_NOT_EXIST); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_08600 - * @tc.name HUKS_ABNORMAL_CALLBACK_08600 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_08600', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties.splice(2, 1); - hks.verify(alias, option, plainTextSize8, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_08700 - * @tc.name HUKS_ABNORMAL_CALLBACK_08700 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_08700', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(3, 1); - hks.verify(alias, option, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_08800 - * @tc.name HUKS_ABNORMAL_CALLBACK_08800 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_08800', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[0].value = invalidValue; - hks.verify(alias, option, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ALGORITHM); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_08900 - * @tc.name HUKS_ABNORMAL_CALLBACK_08900 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_08900', 0, async function (done) { - var option = makeAgreeOption(); - hks.agreeKey(aliasEmpty, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_09000 - * @tc.name HUKS_ABNORMAL_CALLBACK_09000 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_09000', 0, async function (done) { - await generateEccKey(); - var option = makeAgreeOption(); - option.properties[0].value = invalidValue; - hks.agreeKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ALGORITHM); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_09100 - * @tc.name HUKS_ABNORMAL_CALLBACK_09100 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_09100', 0, async function (done) { - await generateEccKey(); - var option = makeAgreeOption(); - option.properties[1].value = invalidValue; - hks.agreeKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_09200 - * @tc.name HUKS_ABNORMAL_CALLBACK_09200 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_09200', 0, async function (done) { - await generateEccKey(); - var option = makeAgreeOption(); - option.inData = new Uint8Array(0); - hks.agreeKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_09300 - * @tc.name HUKS_ABNORMAL_CALLBACK_09300 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_09300', 0, async function (done) { - await generateEccKey(); - var option = makeAgreeOption(); - option.properties.splice(0, 1); - hks.agreeKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_ALG_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_09400 - * @tc.name HUKS_ABNORMAL_CALLBACK_09400 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_09400', 0, async function (done) { - await generateEccKey(); - var option = makeAgreeOption(); - option.properties[1].value = invalidValue; - hks.agreeKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_09500 - * @tc.name HUKS_ABNORMAL_CALLBACK_09500 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_09500', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - hks.mac(aliasNotExist, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_NOT_EXIST); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_09600 - * @tc.name HUKS_ABNORMAL_CALLBACK_09600 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_09600', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - hks.mac(aliasTooLong, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_09700 - * @tc.name HUKS_ABNORMAL_CALLBACK_09700 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_09700', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - hks.mac(aliasEmpty, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_09800 - * @tc.name HUKS_ABNORMAL_CALLBACK_09800 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_09800', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - option.properties[0].value = invalidValue; - hks.mac(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_PURPOSE); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_09900 - * @tc.name HUKS_ABNORMAL_CALLBACK_09900 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_09900', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - option.properties[1].value = invalidValue; - hks.mac(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_DIGEST); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_10000 - * @tc.name HUKS_ABNORMAL_CALLBACK_10000 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_10000', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - option.inData = new Uint8Array(0); - hks.mac(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_10100 - * @tc.name HUKS_ABNORMAL_CALLBACK_10100 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_10100', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - option.properties.splice(0, 1); - hks.mac(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_PURPOSE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_10200 - * @tc.name HUKS_ABNORMAL_CALLBACK_10200 - * @tc.desc Abnormal with callback. - */ - it('HUKS_ABNORMAL_CALLBACK_10200', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - option.properties.splice(1, 1); - hks.mac(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_DIGEST_FAIL); - deleteKeyCallback(alias, done); - }); - }); -}); \ No newline at end of file diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_callback_part1.test.js b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_callback_part1.test.js deleted file mode 100644 index a1583c8a43f49fed81f48cd06edc6e92895c6878..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_callback_part1.test.js +++ /dev/null @@ -1,1632 +0,0 @@ -/* - * 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 hks from '@ohos.security.huks' -import { describe, it, expect } from 'deccjsunit/index' -import { - alias, - aliasEmpty, - aliasTooLong, - aliasCritical, - aliasNotExist, - emptyOption, - invalidValue, - generateAesCBCKeyOption, - generateAesGCMKeyOption, - generateRSAKeyOption, - generateECCKeyOption, - generateMACKeyOption, - plainTextSize8, - plainTextSize16, - plainTextSize64, - makeAgreeOption, - makeEncryptAndDecryptOptionForAbnormal, - makeMacOption, - makeSignVerifyAndImportOption, - inDataTooLong, - aliasStrange, - invalidValueUint8Array -} from './hks_abnormal_common.test.js' - -describe('Hks_Abnormal_Callback_Part1', function () { - - async function generateAesKey(mode) { - var option = {}; - if (mode == 'CBC') { - option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - } else { - option = JSON.parse(JSON.stringify(generateAesGCMKeyOption)); - } - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - }; - - function deleteKeyCallback(alias, done) { - hks.deleteKey(alias, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }; - - async function generateRsaKey() { - var option = generateRSAKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - }; - - async function generateEccKey() { - var option = generateECCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - }; - - async function generateMacKey() { - var option = generateMACKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - }; - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_00100 - * @tc.name GenerateKeyCallbackEmptyAlias - * @tc.desc Generate key callback with empty alias. - */ - it('HUKS_ABNORMAL_CALLBACK_00100', 0, async function (done) { - hks.generateKey(aliasEmpty, generateAesCBCKeyOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_00200 - * @tc.name GenerateKeyCallbackCriticalAlias - * @tc.desc Generate key callback with critical length alias. - */ - it('HUKS_ABNORMAL_CALLBACK_00200', 0, async function (done) { - hks.generateKey(aliasCritical, generateAesCBCKeyOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - deleteKeyCallback(aliasCritical, done); - }) - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_00300 - * @tc.name GenerateKeyCallbackLongAlias - * @tc.desc Generate key callback with too long alias. - */ - it('HUKS_ABNORMAL_CALLBACK_00300', 0, async function (done) { - hks.generateKey(aliasTooLong, generateAesCBCKeyOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_00400 - * @tc.name GenerateKeyCallbackLackAlgTag - * @tc.desc Generate key callback lack of alg tag. - */ - it('HUKS_ABNORMAL_CALLBACK_00400', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties.splice(0, 1); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_ALG_FAIL); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_00500 - * @tc.name GenerateKeyCallbackLackSizeTag - * @tc.desc Generate key callback lack of size tag. - */ - it('HUKS_ABNORMAL_CALLBACK_00500', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties.splice(1, 1); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_00600 - * @tc.name GenerateKeyCallbackLackPurposeTag - * @tc.desc Generate key callback lack of purpose tag. - */ - it('HUKS_ABNORMAL_CALLBACK_00600', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties.splice(2, 1); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_PURPOSE_FAIL); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_00700 - * @tc.name GenerateKeyCallbackLackPaddingTag - * @tc.desc Generate key callback lack of padding tag. - */ - it('HUKS_ABNORMAL_CALLBACK_00700', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties.splice(3, 1); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_PADDING_FAIL); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_00800 - * @tc.name GenerateKeyCallbackLackModeTag - * @tc.desc Generate key callback lack of mode tag. - */ - it('HUKS_ABNORMAL_CALLBACK_00800', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties.splice(4, 1); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_MODE_FAIL); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_00900 - * @tc.name InvalidAlgTagForGeneratingKeyCallback - * @tc.desc Invalid value of alg tag for generating key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_00900', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties[0].value = invalidValue; - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_01000 - * @tc.name InvalidSizeTagForGeneratingKeyCallback - * @tc.desc Invalid value of size tag for generating key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_01000', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties[1].value = invalidValue; - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_01100 - * @tc.name InvalidPurposeTagForGeneratingKeyCallback - * @tc.desc Invalid value of purpose tag for generating key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_01100', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties[2].value = invalidValue; - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_01200 - * @tc.name InvalidPaddingTagForGeneratingKeyCallback - * @tc.desc Invalid value of padding tag for generating key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_01200', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties[3].value = invalidValue; - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_01300 - * @tc.name InvalidModeTagForGeneratingKeyCallback - * @tc.desc Invalid value of mode tag for generating key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_01300', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties[4].value = invalidValue; - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_MODE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_01400 - * @tc.name DeletekeyCallbackNotExistAlias - * @tc.desc Delete key callback with not exist alias. - */ - it('HUKS_ABNORMAL_CALLBACK_01400', 0, async function (done) { - hks.deleteKey(aliasNotExist, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_NOT_EXIST); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_01500 - * @tc.name DeletekeyCallbackEmptyAlias - * @tc.desc Delete key callback with empty alias. - */ - it('HUKS_ABNORMAL_CALLBACK_01500', 0, async function (done) { - hks.deleteKey(aliasEmpty, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_01600 - * @tc.name DeletekeyCallbackLongAlias - * @tc.desc Delete key callback with too long alias. - */ - it('HUKS_ABNORMAL_CALLBACK_01600', 0, async function (done) { - hks.deleteKey(aliasTooLong, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_01700 - * @tc.name EncryptCallbackEmptyAlias - * @tc.desc Encrypt callback with empty alias. - */ - it('HUKS_ABNORMAL_CALLBACK_01700', 0, async function (done) { - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - hks.encrypt(aliasEmpty, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_01800 - * @tc.name EncryptCallbackNotExistAlias - * @tc.desc Encrypt callback with not exist alias. - */ - it('HUKS_ABNORMAL_CALLBACK_01800', 0, async function (done) { - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - hks.encrypt(aliasNotExist, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_NOT_EXIST); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_01900 - * @tc.name EncryptCallbackCriticalAlias - * @tc.desc Encrypt callback with critical length alias. - */ - it('HUKS_ABNORMAL_CALLBACK_01900', 0, async function (done) { - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - hks.encrypt(aliasCritical, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_NOT_EXIST); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_02000 - * @tc.name EncryptCallbackLongAlias - * @tc.desc Encrypt callback with too long alias. - */ - it('HUKS_ABNORMAL_CALLBACK_02000', 0, async function (done) { - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - hks.encrypt(aliasTooLong, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_02100 - * @tc.name EncryptCallbackLackAlgTag - * @tc.desc Encrypt callback lack of alg tag. - */ - it('HUKS_ABNORMAL_CALLBACK_02100', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties.splice(0, 1); - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_ALG_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_02200 - * @tc.name EncryptCallbackLackPurposeTag - * @tc.desc Encrypt callback lack of purpose tag. - */ - it('HUKS_ABNORMAL_CALLBACK_02200', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties.splice(1, 1); - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_PURPOSE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_02300 - * @tc.name EncryptCallbackLackModeTag - * @tc.desc Encrypt callback lack of mode tag. - */ - it('HUKS_ABNORMAL_CALLBACK_02300', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties.splice(2, 1); - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_MODE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_02400 - * @tc.name EncryptCallbackLackPaddingTag - * @tc.desc Encrypt callback lack of padding tag. - */ - it('HUKS_ABNORMAL_CALLBACK_02400', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties.splice(3, 1); - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_PADDING_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_02500 - * @tc.name EncryptCallbackLackIvTag - * @tc.desc Encrypt callback lack of iv tag. - */ - it('HUKS_ABNORMAL_CALLBACK_02500', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties.splice(4, 1); - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_IV_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_02600 - * @tc.name EncryptCallbackLackNonceTag - * @tc.desc Encrypt callback lack of nonce tag. - */ - it('HUKS_ABNORMAL_CALLBACK_02600', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_GCM); - option.properties.splice(4, 1); - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_NONCE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_02700 - * @tc.name EncryptCallbackLackAssociatedDataTag - * @tc.desc Encrypt callback lack of associated data tag. - */ - it('HUKS_ABNORMAL_CALLBACK_02700', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_GCM); - option.properties.splice(5, 1); - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_AAD_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_02800 - * @tc.name InvalidAlgTagForEncryptCallback - * @tc.desc Invalid value of alg tag for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_02800', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties[0].value = invalidValue; - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_02900 - * @tc.name InvalidPurposeTagForEncryptCallback - * @tc.desc Invalid value of purpose tag for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_02900', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties[1].value = invalidValue; - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_03000 - * @tc.name InvalidModeTagForEncryptCallback - * @tc.desc Invalid value of mode tag for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_03000', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties[2].value = invalidValue; - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_MODE); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_03100 - * @tc.name InvalidPaddingTagForEncryptCallback - * @tc.desc Invalid value of padding tag for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_03100', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties[3].value = invalidValue; - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_03200 - * @tc.name InvalidIndataOfOptionForEncryptCallback - * @tc.desc Invalid indata of option for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_03200', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_GCM); - option.inData = new Uint8Array(0); - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_03300 - * @tc.name DecryptCallbackEmptyAlias - * @tc.desc Decrypt callback with empty alias. - */ - it('HUKS_ABNORMAL_CALLBACK_03300', 0, async function (done) { - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - hks.decrypt(aliasEmpty, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_03400 - * @tc.name DecryptCallbackNotExistAlias - * @tc.desc Decrypt callback with not exist alias. - */ - it('HUKS_ABNORMAL_CALLBACK_03400', 0, async function (done) { - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - hks.decrypt(aliasNotExist, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_NOT_EXIST); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_03500 - * @tc.name DecryptCallbackCriticalAlias - * @tc.desc Decrypt callback with critical length alias. - */ - it('HUKS_ABNORMAL_CALLBACK_03500', 0, async function (done) { - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - hks.decrypt(aliasCritical, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_NOT_EXIST); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_03600 - * @tc.name DecryptCallbackLongAlias - * @tc.desc Decrypt callback with too long alias. - */ - it('HUKS_ABNORMAL_CALLBACK_03600', 0, async function (done) { - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - hks.decrypt(aliasTooLong, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_03700 - * @tc.name DecryptCallbackLackAlgTag - * @tc.desc Decrypt callback lack of alg tag. - */ - it('HUKS_ABNORMAL_CALLBACK_03700', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties.splice(0, 1); - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_ALG_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_03800 - * @tc.name DecryptCallbackLackPurposeTag - * @tc.desc Decrypt callback lack of purpose tag. - */ - it('HUKS_ABNORMAL_CALLBACK_03800', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties.splice(1, 1); - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_PURPOSE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_03900 - * @tc.name DecryptCallbackLackModeTag - * @tc.desc Decrypt callback lack of mode tag. - */ - it('HUKS_ABNORMAL_CALLBACK_03900', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties.splice(2, 1); - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_MODE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_04000 - * @tc.name DecryptCallbackLackPaddingTag - * @tc.desc Decrypt callback lack of padding tag. - */ - it('HUKS_ABNORMAL_CALLBACK_04000', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties.splice(3, 1); - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_PADDING_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_04100 - * @tc.name DecryptCallbackLackIvTag - * @tc.desc Decrypt callback lack of iv tag. - */ - it('HUKS_ABNORMAL_CALLBACK_04100', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties.splice(4, 1); - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_IV_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_04200 - * @tc.name DecryptCallbackLackNonceTag - * @tc.desc Decrypt callback lack of nonce tag. - */ - it('HUKS_ABNORMAL_CALLBACK_04200', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_GCM); - option.properties.splice(4, 1); - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_NONCE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_04300 - * @tc.name DecryptCallbackLackAssociatedDataTag - * @tc.desc Decrypt callback lack of associated data tag. - */ - it('HUKS_ABNORMAL_CALLBACK_04300', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_GCM); - option.properties.splice(5, 1); - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_AAD_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_04400 - * @tc.name InvalidAlgTagForDecryptCallback - * @tc.desc Invalid value of alg tag for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_04400', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties[0].value = invalidValue; - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_04500 - * @tc.name InvalidPurposeTagForDecryptCallback - * @tc.desc Invalid value of purpose tag for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_04500', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties[1].value = invalidValue; - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_04600 - * @tc.name InvalidModeTagForDecryptCallback - * @tc.desc Invalid value of mode tag for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_04600', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties[2].value = invalidValue; - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_MODE); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_04700 - * @tc.name InvalidPaddingTagForDecryptCallback - * @tc.desc Invalid value of padding tag for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_04700', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties[3].value = invalidValue; - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_04800 - * @tc.name InvalidIndataOfOptionForDecryptCallback - * @tc.desc Invalid indata of option for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_04800', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_GCM); - option.inData = new Uint8Array(0); - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_04900 - * @tc.name ImportKeyCallbackEmptyAlias - * @tc.desc Import key callback with empty alias. - */ - it('HUKS_ABNORMAL_CALLBACK_04900', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - hks.importKey(aliasEmpty, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_05000 - * @tc.name ImportKeyCallbackCriticalAlias - * @tc.desc Import key callback with critical length alias. - */ - it('HUKS_ABNORMAL_CALLBACK_05000', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - hks.importKey(aliasCritical, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_05100 - * @tc.name ImportKeyCallbackLongAlias - * @tc.desc Import key callback with too long alias. - */ - it('HUKS_ABNORMAL_CALLBACK_05100', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - hks.importKey(aliasTooLong, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_05200 - * @tc.name ImportKeyCallbackLackAlgTag - * @tc.desc Import key callback lack of alg tag. - */ - it('HUKS_ABNORMAL_CALLBACK_05200', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(0, 1); - hks.importKey(aliasNotExist, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_ALG_FAIL); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_05300 - * @tc.name ImportKeyCallbackLackPurposeTag - * @tc.desc Import key callback lack of purpose tag. - */ - it('HUKS_ABNORMAL_CALLBACK_05300', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(1, 1); - hks.importKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_05400 - * @tc.name ImportKeyCallbackLackPaddingTag - * @tc.desc Import key callback lack of padding tag. - */ - it('HUKS_ABNORMAL_CALLBACK_05400', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(2, 1); - hks.importKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_05500 - * @tc.name ImportKeyCallbackLackDigestTag - * @tc.desc Import key callback lack of digest tag. - */ - it('HUKS_ABNORMAL_CALLBACK_05500', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(3, 1); - hks.importKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_05600 - * @tc.name InvalidAlgTagForImportKeyCallback - * @tc.desc Invalid value of alg tag for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_05600', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[0].value = invalidValue; - hks.importKey(aliasNotExist, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_05700 - * @tc.name InvalidPurposeTagForImportKeyCallback - * @tc.desc Invalid value of alg tag for purpose key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_05700', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[1].value = invalidValue; - hks.importKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_05800 - * @tc.name InvalidPaddingTagForImportKeyCallback - * @tc.desc Invalid value of alg tag for padding key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_05800', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[2].value = invalidValue; - hks.importKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_05900 - * @tc.name InvalidDigestTagForImportKeyCallback - * @tc.desc Invalid value of alg tag for digest key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_05900', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[3].value = invalidValue; - hks.importKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_06000 - * @tc.name InvalidIndataOfOptionForImportKeyCallback - * @tc.desc Invalid indata of option for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_06000', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.inData = new Uint8Array(0); - hks.importKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done() - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_06100 - * @tc.name ExportKeyCallbackNotExistAlias - * @tc.desc Export key callback with not exist alias. - */ - it('HUKS_ABNORMAL_CALLBACK_06100', 0, async function (done) { - hks.exportKey(aliasNotExist, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_NOT_EXIST); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_06200 - * @tc.name ExportKeyCallbackLongAlias - * @tc.desc Export key callback with too long alias. - */ - it('HUKS_ABNORMAL_CALLBACK_06200', 0, async function (done) { - hks.exportKey(aliasTooLong, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_06300 - * @tc.name ExportKeyCallbackEmptyAlias - * @tc.desc Export key callback with empty alias. - */ - it('HUKS_ABNORMAL_CALLBACK_06300', 0, async function (done) { - hks.exportKey(aliasEmpty, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_06400 - * @tc.name SignCallbackNotExistAlias - * @tc.desc Sign callback with not exist alias. - */ - it('HUKS_ABNORMAL_CALLBACK_06400', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - hks.sign(aliasNotExist, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_NOT_EXIST); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_06500 - * @tc.name SignCallbackLongAlias - * @tc.desc Sign callback with too long alias. - */ - it('HUKS_ABNORMAL_CALLBACK_06500', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - hks.sign(aliasTooLong, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_06600 - * @tc.name SignCallbackEmptyAlias - * @tc.desc Sign callback with empty alias. - */ - it('HUKS_ABNORMAL_CALLBACK_06600', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - hks.sign(aliasEmpty, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_06700 - * @tc.name InvalidAlgTagForSignCallback - * @tc.desc Invalid value of alg tag for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_06700', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[0].value = invalidValue; - hks.sign(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_06800 - * @tc.name InvalidPurposeTagForSignCallback - * @tc.desc Invalid value of purpose tag for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_06800', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[1].value = invalidValue; - hks.sign(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_06900 - * @tc.name InvalidPaddingTagForSignCallback - * @tc.desc Invalid value of padding tag for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_06900', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties[2].value = invalidValue; - hks.sign(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_07000 - * @tc.name InvalidDigestTagForSignCallback - * @tc.desc Invalid value of digest tag for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_07000', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties[3].value = invalidValue; - hks.sign(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_07100 - * @tc.name InvalidIndataOfOptionForSignCallback - * @tc.desc Invalid indata of option for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_07100', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.inData = new Uint8Array(0); - hks.sign(aliasEmpty, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_07200 - * @tc.name SignCallbackLackAlgTag - * @tc.desc Sign callback lack of alg tag. - */ - it('HUKS_ABNORMAL_CALLBACK_07200', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(0, 1); - hks.sign(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_ALG_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_07300 - * @tc.name SignCallbackLackPurposeTag - * @tc.desc Sign callback lack of purpose tag. - */ - it('HUKS_ABNORMAL_CALLBACK_07300', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(1, 1); - hks.sign(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_07400 - * @tc.name SignCallbackLackPaddingTag - * @tc.desc Sign callback lack of padding tag. - */ - it('HUKS_ABNORMAL_CALLBACK_07400', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties.splice(2, 1); - hks.sign(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_07500 - * @tc.name SignCallbackLackDigestTag - * @tc.desc Sign callback lack of digest tag. - */ - it('HUKS_ABNORMAL_CALLBACK_07500', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties.splice(3, 1); - hks.sign(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_07600 - * @tc.name VerifyCallbackNotExistAlias - * @tc.desc Verify callback with not exist alias. - */ - it('HUKS_ABNORMAL_CALLBACK_07600', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - hks.verify(aliasNotExist, option, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_NOT_EXIST); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_07700 - * @tc.name VerifyCallbackLongAlias - * @tc.desc Verify callback with too long alias. - */ - it('HUKS_ABNORMAL_CALLBACK_07700', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - hks.verify(aliasTooLong, option, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_07800 - * @tc.name VerifyCallbackEmptyAlias - * @tc.desc Verify callback with empty alias. - */ - it('HUKS_ABNORMAL_CALLBACK_07800', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - hks.verify(aliasEmpty, option, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_07900 - * @tc.name InvalidAlgTagForVerifyCallback - * @tc.desc Invalid value of alg tag for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_07900', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[0].value = invalidValue; - hks.verify(alias, option, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_08000 - * @tc.name InvalidPurposeTagForVerifyCallback - * @tc.desc Invalid value of purpose tag for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_08000', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties[1].value = invalidValue; - hks.verify(alias, option, plainTextSize8, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_08100 - * @tc.name InvalidPaddingTagForVerifyCallback - * @tc.desc Invalid value of padding tag for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_08100', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties[2].value = invalidValue; - hks.verify(alias, option, plainTextSize8, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_08200 - * @tc.name InvalidDigestTagForVerifyCallback - * @tc.desc Invalid value of digest tag for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_08200', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties[3].value = invalidValue; - hks.verify(alias, option, plainTextSize8, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_08300 - * @tc.name InvalidIndataOfOptionForVerifyCallback - * @tc.desc Invalid indata of option for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_08300', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize16); - option.inData = new Uint8Array(0); - hks.verify(alias, option, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_08400 - * @tc.name VerifyCallbackLackAlgTag - * @tc.desc Verify callback lack of alg tag. - */ - it('HUKS_ABNORMAL_CALLBACK_08400', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(0, 1); - hks.verify(alias, option, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_ALG_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_08500 - * @tc.name VerifyCallbackLackPurposeTag - * @tc.desc Verify callback lack of purpose tag. - */ - it('HUKS_ABNORMAL_CALLBACK_08500', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(1, 1); - hks.verify(aliasNotExist, option, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_NOT_EXIST); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_08600 - * @tc.name VerifyCallbackLackPaddingTag - * @tc.desc Verify callback lack of padding tag. - */ - it('HUKS_ABNORMAL_CALLBACK_08600', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties.splice(2, 1); - hks.verify(alias, option, plainTextSize8, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_08700 - * @tc.name VerifyCallbackLackDigestTag - * @tc.desc Verify callback lack of digest tag. - */ - it('HUKS_ABNORMAL_CALLBACK_08700', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(3, 1); - hks.verify(alias, option, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_08800 - * @tc.name InvalidIvTagForEncryptCallback - * @tc.desc Invalid value of iv tag for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_08800', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties[4].value = invalidValueUint8Array; - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_08900 - * @tc.name AgreeKeyCallbackEmptyAlias - * @tc.desc Agree key callback with empty alias. - */ - it('HUKS_ABNORMAL_CALLBACK_08900', 0, async function (done) { - var option = makeAgreeOption(); - hks.agreeKey(aliasEmpty, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_09000 - * @tc.name InvalidAlgTagForAgreeKeyCallback - * @tc.desc Invalid value of alg tag for agree key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_09000', 0, async function (done) { - await generateEccKey(); - var option = makeAgreeOption(); - option.properties[0].value = invalidValue; - hks.agreeKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_09100 - * @tc.name InvalidSizeTagForAgreeKeyCallback - * @tc.desc Invalid value of size tag for agree key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_09100', 0, async function (done) { - await generateEccKey(); - var option = makeAgreeOption(); - option.properties[1].value = invalidValue; - hks.agreeKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_09200 - * @tc.name InvalidIndataOfOptionForAgreeKeyCallback - * @tc.desc Invalid indata of option for agree key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_09200', 0, async function (done) { - await generateEccKey(); - var option = makeAgreeOption(); - option.inData = new Uint8Array(0); - hks.agreeKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_09300 - * @tc.name AgreeKeyCallbackLackAlgTag - * @tc.desc Agree key callback lack of alg tag. - */ - it('HUKS_ABNORMAL_CALLBACK_09300', 0, async function (done) { - await generateEccKey(); - var option = makeAgreeOption(); - option.properties.splice(0, 1); - hks.agreeKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_ALG_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_09400 - * @tc.name AgreeKeyCallbackLackSizeTag - * @tc.desc Agree key callback lack of size tag. - */ - it('HUKS_ABNORMAL_CALLBACK_09400', 0, async function (done) { - await generateEccKey(); - var option = makeAgreeOption(); - option.properties[1].value = invalidValue; - hks.agreeKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_09500 - * @tc.name MacCallbackEmptyAlias - * @tc.desc Mac callback with empty alias. - */ - it('HUKS_ABNORMAL_CALLBACK_09500', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - hks.mac(aliasNotExist, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_NOT_EXIST); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_09600 - * @tc.name MacCallbackTooLongAlias - * @tc.desc Mac callback with too long alias. - */ - it('HUKS_ABNORMAL_CALLBACK_09600', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - hks.mac(aliasTooLong, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_09700 - * @tc.name MacCallbackEmptyAlias - * @tc.desc Mac callback with empty alias. - */ - it('HUKS_ABNORMAL_CALLBACK_09700', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - hks.mac(aliasEmpty, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_09800 - * @tc.name InvalidPurposeTagForMacCallback - * @tc.desc Invalid value of purpose tag for mac callback. - */ - it('HUKS_ABNORMAL_CALLBACK_09800', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - option.properties[0].value = invalidValue; - hks.mac(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_09900 - * @tc.name InvalidDigestTagForMacCallback - * @tc.desc Invalid value of digest tag for mac callback. - */ - it('HUKS_ABNORMAL_CALLBACK_09900', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - option.properties[1].value = invalidValue; - hks.mac(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_10000 - * @tc.name InvalidIndataOfOptionForMacCallback - * @tc.desc Invalid indata of option for mac callback. - */ - it('HUKS_ABNORMAL_CALLBACK_10000', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - option.inData = new Uint8Array(0); - hks.mac(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_10100 - * @tc.name MacCallbackLackPurposeTag - * @tc.desc Mac callback lack of purpose tag. - */ - it('HUKS_ABNORMAL_CALLBACK_10100', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - option.properties.splice(0, 1); - hks.mac(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_PURPOSE_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_10200 - * @tc.name MacCallbackLackDigestTag - * @tc.desc Mac callback lack of digest tag. - */ - it('HUKS_ABNORMAL_CALLBACK_10200', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - option.properties.splice(1, 1); - hks.mac(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_DIGEST_FAIL); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_10300 - * @tc.name LongIndataOfOptionForEncryptCallback - * @tc.desc Too long indata of option for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_10300', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.inData = inDataTooLong; - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_10400 - * @tc.name GenerateKeyCallbackStrangeAlias - * @tc.desc Generate key callback with strange alias. - */ - it('HUKS_ABNORMAL_CALLBACK_10400', 0, async function (done) { - hks.generateKey(aliasStrange, generateAesCBCKeyOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - deleteKeyCallback(aliasStrange, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_10500 - * @tc.name InvalidNonceTagForEncryptCallback - * @tc.desc Invalid value of nonce tag for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_10500', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_GCM); - option.properties[4].value = invalidValueUint8Array; - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_10600 - * @tc.name InvalidASSOCIATEDDATATagForEncryptCallback - * @tc.desc Invalid value of associated data tag for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_10600', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_GCM); - option.properties[5].value = invalidValueUint8Array; - hks.encrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_10700 - * @tc.name InvalidIvTagForDecryptCallback - * @tc.desc Invalid value of iv tag for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_10700', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties[4].value = invalidValueUint8Array; - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_10800 - * @tc.name InvalidNonceTagForDecryptCallback - * @tc.desc Invalid value of nonce tag for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_10800', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_GCM); - option.properties[4].value = invalidValueUint8Array; - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_10900 - * @tc.name InvalidAssociatedDataTagForDecryptCallback - * @tc.desc Invalid value of associated data tag for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_10900', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_GCM); - option.properties[5].value = invalidValueUint8Array; - hks.decrypt(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyCallback(alias, done); - }); - }); -}); \ No newline at end of file diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_callback_part2.test.js b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_callback_part2.test.js deleted file mode 100644 index ec2ebf1bc2c316d54b33731c69f4d7fe3fa28a3f..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_callback_part2.test.js +++ /dev/null @@ -1,1992 +0,0 @@ -/* - * 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 hks from '@ohos.security.huks' -import { describe, it, expect } from 'deccjsunit/index' -import { - alias, -} from '../../../../../../hks_xts_common.test' -import { - aesGenerateKeyInvalidSizeOption, - aesGenerateKeyInvalidModeOption, - aesGenerateKeyInvalidAlgOption, - aesGenerateKeyInvalidPurposeOption, - rsaGenerateKeyInvalidSizeOption, - rsaGenerateKeyInvalidPaddingOption, - rsaGenerateKeyInvalidPurposeOption, - eccGenerateKeyInvalidSizeOption, - eccGenerateKeyInvalidDigestOption, - eccGenerateKeyInvalidPurposeOption, - ecdhGenerateKeyInvalidAlgOption, - hkdfGenerateKeyInvalidAlgOption, - pbkdf2GenerateKeyInvalidAlgOption, - ed25519GenerateKeyInvalidPurposeOption, - x25519GenerateKeyInvalidPurposeOption, - hmacGenerateKeyInvalidSizeOption, - hmacGenerateKeyInvalidPurposeOption, - dsaGenerateKeyInvalidSizeOption, - dsaGenerateKeyInvalidPurposeOption, - dhGenerateKeyInvalidPurposeOption, -} from './hks_abnormal_common.test.js' - -describe('Hks_Abnormal_Callback_Part2', function () { - var errHmacKeySizeA = 0; - var errHmacKeySizeB = 9; - var errDsaKeySizeA = 0; - var errDsaKeySizeB = 9; - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_11000 - * @tc.name InvalidAesKeySize512AlgAesForGenerateGKeyCallback - * @tc.desc Invalid aes key size 512 alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_11000', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_512); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_11100 - * @tc.name InvalidRsaKeySize512AlgAesForGenerateGKeyCallback - * @tc.desc Invalid rsa key size 512 alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_11100', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_11200 - * @tc.name InvalidRsaKeySize768AlgAesForGenerateGKeyCallback - * @tc.desc Invalid rsa key size 768 alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_11200', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_768); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_11300 - * @tc.name InvalidRsaKeySize1024AlgAesForGenerateGKeyCallback - * @tc.desc Invalid rsa key size 1024 alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_11300', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_11400 - * @tc.name InvalidRsaKeySize2048AlgAesForGenerateGKeyCallback - * @tc.desc Invalid rsa key size 2048 alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_11400', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_11500 - * @tc.name InvalidRsaKeySize3072AlgAesForGenerateGKeyCallback - * @tc.desc Invalid rsa key size 3072 alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_11500', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_11600 - * @tc.name InvalidRsaKeySize4096AlgAesForGenerateGKeyCallback - * @tc.desc Invalid rsa key size 4096 alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_11600', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_11700 - * @tc.name InvalidEccKeySize224AlgAesForGenerateGKeyCallback - * @tc.desc Invalid ecc key size 224 alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_11700', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_224); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_11800 - * @tc.name InvalidEccKeySize256AlgAesForGenerateGKeyCallback - * @tc.desc Ecc key size 256 alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_11800', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_11900 - * @tc.name InvalidEccKeySize384AlgAesForGenerateGKeyCallback - * @tc.desc Invalid ecc key size 384 alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_11900', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_384); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_12000 - * @tc.name InvalidEccKeySize521AlgAesForGenerateGKeyCallback - * @tc.desc Invalid ecc key size 521 alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_12000', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_521); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_12100 - * @tc.name InvalidCurve25519KeySize256AlgAesForGenerateGKeyCallback - * @tc.desc Curve25519 key size 256 alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_12100', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_12200 - * @tc.name InvaliddhKeySize2048AlgAesForGenerateGKeyCallback - * @tc.desc Invalid dh key size 2048 alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_12200', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_2048); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_12300 - * @tc.name InvaliddhKeySize3072AlgAesForGenerateGKeyCallback - * @tc.desc Invalid dh key size 2048 alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_12300', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_3072); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_12400 - * @tc.name InvaliddhKeySize4096AlgAesForGenerateGKeyCallback - * @tc.desc Invalid dh key size 4096 alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_12400', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_4096); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_12500 - * @tc.name InvalidPaddingOaepModeCbcAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding oaep mode cbc alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_12500', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_CBC, - hks.HuksKeyPadding.HUKS_PADDING_OAEP); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_12600 - * @tc.name InvalidPaddingPssModeCbcAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding pss mode cbc alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_12600', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption(hks.HuksCipherMode.HUKS_MODE_CBC, hks.HuksKeyPadding.HUKS_PADDING_PSS); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_12700 - * @tc.name InvalidPaddingPkcs1_v1_5ModeCbcAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding pkcs1_v1_5 mode cbc alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_12700', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_CBC, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_12800 - * @tc.name InvalidPaddingPkcs5ModeCbcAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding pkcs5 mode cbc alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_12800', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_CBC, - hks.HuksKeyPadding.HUKS_PADDING_PKCS5); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_12900 - * @tc.name InvalidPaddingOaepModeCtrAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding oaep mode ctr alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_12900', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_CTR, - hks.HuksKeyPadding.HUKS_PADDING_OAEP); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_13000 - * @tc.name InvalidPaddingPssModeCtrAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding pss mode ctr alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_13000', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption(hks.HuksCipherMode.HUKS_MODE_CTR, hks.HuksKeyPadding.HUKS_PADDING_PSS); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_13100 - * @tc.name InvalidPaddingPkcs1_v1_5ModeCtrAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding pkcs1_v1_5 mode ctr alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_13100', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_CTR, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_13200 - * @tc.name InvalidPaddingPkcs5ModeCtrAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding pkcs5 mode ctr alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_13200', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_CTR, - hks.HuksKeyPadding.HUKS_PADDING_PKCS5); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_13300 - * @tc.name InvalidPaddingPkcs7ModeCtrAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding pkcs7 mode ctr alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_13300', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_CTR, - hks.HuksKeyPadding.HUKS_PADDING_PKCS7); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_13400 - * @tc.name InvalidPaddingOaepModeEcbAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding oaep mode ecb alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_13400', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeyPadding.HUKS_PADDING_OAEP); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_13500 - * @tc.name InvalidPaddingPssModeEcbAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding pss mode ecb alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_13500', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption(hks.HuksCipherMode.HUKS_MODE_ECB, hks.HuksKeyPadding.HUKS_PADDING_PSS); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_13600 - * @tc.name InvalidPaddingPkcs1_v1_5ModeEcbAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding pkcs1_v1_5 mode ecb alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_13600', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_13700 - * @tc.name InvalidPaddingPkcs5ModeEcbAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding pkcs5 mode ecb alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_13700', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeyPadding.HUKS_PADDING_PKCS5); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_13800 - * @tc.name InvalidPaddingOaepModeGcmAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding oaep mode gcm alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_13800', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_GCM, - hks.HuksKeyPadding.HUKS_PADDING_OAEP); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_13900 - * @tc.name InvalidPaddingpssModeGcmAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding pss mode gcm alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_13900', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption(hks.HuksCipherMode.HUKS_MODE_GCM, hks.HuksKeyPadding.HUKS_PADDING_PSS); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_14000 - * @tc.name InvalidPaddingPkcs1_v1_5ModeGcmAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding pkcs1_v1_5 mode gcm alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_14000', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_GCM, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_14100 - * @tc.name InvalidPaddingPkcs5ModeGcmAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding pkcs5 mode gcm alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_14100', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_GCM, - hks.HuksKeyPadding.HUKS_PADDING_PKCS5); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_14200 - * @tc.name InvalidPaddingPkcs7ModeGcmAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding pkcs7 mode gcm alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_14200', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_GCM, - hks.HuksKeyPadding.HUKS_PADDING_PKCS7); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_14300 - * @tc.name InvalidPaddingOaepModeCcmAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding oaep mode ccm alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_14300', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_CCM, - hks.HuksKeyPadding.HUKS_PADDING_OAEP); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_14400 - * @tc.name InvalidPaddingPssModeCcmAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding pss mode ccm alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_14400', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption(hks.HuksCipherMode.HUKS_MODE_CCM, hks.HuksKeyPadding.HUKS_PADDING_PSS); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_14500 - * @tc.name InvalidPaddingPkcs1_v1_5ModeCcmAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding pkcs1_v1_5 mode ccm alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_14500', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_CCM, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_14600 - * @tc.name InvalidPaddingPkcs5ModeCcmAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding pkcs5 mode ccm alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_14600', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_CCM, - hks.HuksKeyPadding.HUKS_PADDING_PKCS5); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_14700 - * @tc.name InvalidPaddingPkcs7ModeCcmAlgAesForGenerateGKeyCallback - * @tc.desc Invalid padding pkcs7 mode ccm alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_14700', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_CCM, - hks.HuksKeyPadding.HUKS_PADDING_PKCS7); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_14800 - * @tc.name InvalidModeOfbAlgAesForGenerateGKeyCallback - * @tc.desc Invalid mode ofb alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_14800', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_OFB, - hks.HuksKeyPadding.HUKS_PADDING_NONE); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_MODE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_14900 - * @tc.name InvalidPurposeDeriveAlgRsaAlgAesForGenerateKeyCallback. - * @tc.desc Invalid purpose derive alg rsa alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_14900', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_RSA, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_15000 - * @tc.name InvalidPurposeDeriveAlgEccAlgAesForGenerateKeyCallback - * @tc.desc Invalid purpose derive alg ecc alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_15000', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_ECC, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_15100 - * @tc.name InvalidPurposeDeriveAlgDsaAlgAesForGenerateKeyCallback - * @tc.desc Invalid purpose derive alg dsa alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_15100', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_DSA, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_15200 - * @tc.name InvalidPurposeDeriveAlgHkdfAlgAesForGenerateKeyCallback - * @tc.desc Invalid purpose derive alg hkdf alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_15200', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_HKDF, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_15300 - * @tc.name InvalidPurposeDeriveAlgPbkdf2AlgAesForGenerateKeyCallback - * @tc.desc Invalid purpose derive alg pbkdf2 alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_15300', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_PBKDF2, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_15400 - * @tc.name InvalidPurposeDeriveAlgEcdhAlgAesForGenerateKeyCallback - * @tc.desc Invalid purpose derive alg ecdh alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_15400', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_ECDH, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_15500 - * @tc.name InvalidPurposeDeriveAlgX25519AlgAesForGenerateKeyCallback - * @tc.desc Invalid purpose derive alg x25519 alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_15500', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_X25519, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_15600 - * @tc.name InvalidPurposeDeriveAlgEd25519AlgAesForGenerateKeyCallback - * @tc.desc Invalid purpose derive alg ed25519 alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_15600', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_ED25519, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_15700 - * @tc.name InvalidPurposeDeriveAlgDhAlgAesForGenerateKeyCallback - * @tc.desc Invalid purpose derive alg dh alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_15700', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_DH, hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_15800 - * @tc.name InvalidPurposeMacAlgRsaAlgAesForGenerateKeyCallback - * @tc.desc Invalid purpose mac alg rsa alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_15800', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_RSA, hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_15900 - * @tc.name InvalidPurposeMacAlgEccAlgAesForGenerateKeyCallback - * @tc.desc Invalid purpose mac alg ecc alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_15900', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ECC, hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_16000 - * @tc.name InvalidPurposeMacAlgDsaAlgAesForGenerateKeyCallback - * @tc.desc Invalid purpose mac alg dsa alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_16000', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_DSA, hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_16100 - * @tc.name InvalidPurposeMacAlgHkdfAlgAesForGenerateKeyCallback - * @tc.desc Invalid purpose mac alg hkdf alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_16100', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_HKDF, hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_16200 - * @tc.name InvalidPurposeMacAlgPbkdf2AlgAesForGenerateKeyCallback - * @tc.desc Invalid purpose mac alg pbkdf2 alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_16200', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_PBKDF2, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_16300 - * @tc.name InvalidPurposeMacAlgEcdhAlgAesForGenerateKeyCallback - * @tc.desc Invalid purpose mac alg ecdh alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_16300', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ECDH, hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_16400 - * @tc.name InvalidPurposeMacAlgX25519AlgAesForGenerateKeyCallback - * @tc.desc Invalid purpose mac alg x25519 alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_16400', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_X25519, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_16500 - * @tc.name InvalidPurposeMacAlgEd25519AlgAesForGenerateKeyCallback - * @tc.desc Invalid purpose mac alg ed25519 alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_16500', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_ED25519, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_16600 - * @tc.name InvalidPurposeMacAlgDhAlgAesForGenerateKeyCallback - * @tc.desc Invalid purpose mac alg dh alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_16600', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_DH, hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_16700 - * @tc.name InvalidPurposeSignAlgAesForGenerateKeyCallback - * @tc.desc Invalid purpose sign alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_16700', 0, async function (done) { - var option = JSON.parse(JSON.stringify(aesGenerateKeyInvalidPurposeOption)); - option.properties[2].value = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN; - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_16800 - * @tc.name InvalidPurposeVerifyAlgAesForGenerateKeyCallback - * @tc.desc Invalid purpose verify alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_16800', 0, async function (done) { - var option = JSON.parse(JSON.stringify(aesGenerateKeyInvalidPurposeOption)); - option.properties[2].value = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY; - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_16900 - * @tc.name InvalidPurposeAgreeAlgAesForGenerateKeyCallback - * @tc.desc Invalid purpose agree alg aes for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_16900', 0, async function (done) { - var option = JSON.parse(JSON.stringify(aesGenerateKeyInvalidPurposeOption)); - option.properties[2].value = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE; - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_17000 - * @tc.name InvalidEccKeySize224AlgRsaForGenerateGKeyCallback - * @tc.desc Invalid ecc key size 224 alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_17000', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_224); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_17100 - * @tc.name InvalidEccKeySize256AlgRsaForGenerateGKeyCallback - * @tc.desc Invalid ecc key size 256 alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_17100', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_17200 - * @tc.name InvalidEccKeySize384AlgRsaForGenerateGKeyCallback - * @tc.desc Invalid ecc key size 384 alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_17200', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_384); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_17300 - * @tc.name InvalidEccKeySize521AlgRsaForGenerateGKeyCallback - * @tc.desc Invalid ecc key size 521 alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_17300', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_521); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_17400 - * @tc.name InvalidAesKeySize128AlgRsaForGenerateGKeyCallback - * @tc.desc Invalid aes key size 128 alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_17400', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_128); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_17500 - * @tc.name InvalidAesKeySize192AlgRsaForGenerateGKeyCallback - * @tc.desc Invalid aes key size 192 alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_17500', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_192); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_17600 - * @tc.name InvalidAesKeySize256AlgRsaForGenerateGKeyCallback - * @tc.desc Invalid aes key size 256 alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_17600', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_256); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_17700 - * @tc.name InvalidAesKeySize512AlgRsaForGenerateGKeyCallback - * @tc.desc Invalid aes key size 512 alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_17700', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_512); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_17800 - * @tc.name InvalidCurve25519KeySize256AlgRsaForGenerateGKeyCallback - * @tc.desc Invalid curve25519 key size 256 alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_17800', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_17900 - * @tc.name InvalidDhKeySize2048AlgRsaForGenerateGKeyCallback - * @tc.desc Invalid dh key size 2048 alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_17900', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_2048); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_18000 - * @tc.name InvalidDhKeySize3072AlgRsaForGenerateGKeyCallback - * @tc.desc Invalid dh key size 3072 alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_18000', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_3072); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_18100 - * @tc.name InvalidDhKeySize4096AlgRsaForGenerateGKeyCallback - * @tc.desc Invalid dh key size 4096 alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_18100', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_4096); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_18200 - * @tc.name InvalidPaddingPssPurposeEncryptDecryptAlgRsaForGenerateKeyCallback. - * @tc.desc Invalid padding pss purpose encrypt decrypt alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_18200', 0, async function (done) { - var option = rsaGenerateKeyInvalidPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyPadding.HUKS_PADDING_PSS); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_18300 - * @tc.name InvalidPaddingPkcs5PurposeEncryptDecryptAlgRsaForGenerateKeyCallback - * @tc.desc Invalid padding pkcs5 purpose encrypt decrypt alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_18300', 0, async function (done) { - var option = rsaGenerateKeyInvalidPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyPadding.HUKS_PADDING_PKCS5); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_18400 - * @tc.name InvalidPaddingPkcs7PurposeEncryptDecryptAlgRsaForGenerateKeyCallback - * @tc.desc Invalid padding pkcs7 purpose encrypt decrypt alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_18400', 0, async function (done) { - var option = rsaGenerateKeyInvalidPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyPadding.HUKS_PADDING_PKCS7); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_18500 - * @tc.name InvalidPaddingNonePurposeSignVerifyAlgRsaForGenerateKeyCallback - * @tc.desc Invalid padding none purpose sign verify alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_18500', 0, async function (done) { - var option = rsaGenerateKeyInvalidPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_NONE); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_18600 - * @tc.name InvalidPaddingOaepPurposeSignVerifyAlgRsaForGenerateKeyCallback - * @tc.desc Invalid padding oaep purpose sign verify alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_18600', 0, async function (done) { - var option = rsaGenerateKeyInvalidPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_OAEP); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_18700 - * @tc.name InvalidPaddingPkcs5PurposeSignVerifyAlgRsaForGenerateKeyCallback - * @tc.desc Invalid padding pkcs5 purpose sign verify alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_18700', 0, async function (done) { - var option = rsaGenerateKeyInvalidPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_PKCS5); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_18800 - * @tc.name InvalidPaddingPkcs7PurposeSignVerifyAlgRsaForGenerateKeyCallback - * @tc.desc Invalid padding pkcs7 purpose sign verify alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_18800', 0, async function (done) { - var option = rsaGenerateKeyInvalidPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_PKCS7); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_18900 - * @tc.name InvalidPurposeDeriveAlgRsaForGenerateKeyCallback - * @tc.desc Invalid purpose derive alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_18900', 0, async function (done) { - var option = JSON.parse(JSON.stringify(rsaGenerateKeyInvalidPurposeOption)); - option.properties[2].value = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE; - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_19000 - * @tc.name InvalidPurposeMacAlgRsaForGenerateKeyCallback - * @tc.desc Invalid purpose mac alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_19000', 0, async function (done) { - var option = JSON.parse(JSON.stringify(rsaGenerateKeyInvalidPurposeOption)); - option.properties[2].value = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC; - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_19100 - * @tc.name InvalidPurposeWrapAlgRsaForGenerateKeyCallback - * @tc.desc Invalid purpose wrap alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_19100', 0, async function (done) { - var option = JSON.parse(JSON.stringify(rsaGenerateKeyInvalidPurposeOption)); - option.properties[2].value = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_WRAP; - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_19200 - * @tc.name InvalidPurposeUnwrapAlgRsaForGenerateKeyCallback - * @tc.desc Invalid purpose unwrap alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_19200', 0, async function (done) { - var option = JSON.parse(JSON.stringify(rsaGenerateKeyInvalidPurposeOption)); - option.properties[2].value = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP; - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_19300 - * @tc.name InvalidPurposeagreeAlgRsaForGenerateKeyCallback - * @tc.desc Invalid purpose agree alg rsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_19300', 0, async function (done) { - var option = JSON.parse(JSON.stringify(rsaGenerateKeyInvalidPurposeOption)); - option.properties[2].value = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE; - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_19400 - * @tc.name InvalidRsaKeySize512AlgEccForGenerateGKeyCallback - * @tc.desc Invalid rsa key size 512 alg ecc for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_19400', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_19500 - * @tc.name InvalidRsaKeySize768AlgEccForGenerateGKeyCallback - * @tc.desc Invalid rsa key size 768 alg ecc for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_19500', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_768); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_19600 - * @tc.name InvalidRsaKeySize1024AlgEccForGenerateGKeyCallback - * @tc.desc Invalid rsa key size 1024 alg ecc for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_19600', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_19700 - * @tc.name InvalidRsaKeySize2048AlgEccForGenerateGKeyCallback - * @tc.desc Invalid rsa key size 2048 alg ecc for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_19700', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_19800 - * @tc.name InvalidRsaKeySize3072AlgEccForGenerateGKeyCallback - * @tc.desc Invalid rsa key size 3072 alg ecc for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_19800', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_19900 - * @tc.name InvalidRsaKeySize4096AlgEccForGenerateGKeyCallback - * @tc.desc Invalid rsa key size 4096 alg ecc for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_19900', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_20000 - * @tc.name InvalidAesKeySize128AlgEccForGenerateGKeyCallback - * @tc.desc Invalid aes key size 128 alg ecc for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_20000', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_128); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_20100 - * @tc.name InvalidAesKeySize192AlgEccForGenerateGKeyCallback - * @tc.desc Invalid aes key size 192 alg ecc for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_20100', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_192); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_20200 - * @tc.name InvalidAesKeySize256AlgEccForGenerateGKeyCallback - * @tc.desc Invalid aes key size 256 alg ecc for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_20200', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_256); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_20300 - * @tc.name InvalidAesKeySize512AlgEccForGenerateGKeyCallback - * @tc.desc Invalid aes key size 512 alg ecc for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_20300', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_512); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_20400 - * @tc.name InvalidCurve25519KeySize256AlgEccForGenerateGKeyCallback - * @tc.desc Invalid curve25519 key size 256 alg ecc for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_20400', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_20500 - * @tc.name InvalidDhKeySize2048AlgEccForGenerateGKeyCallback - * @tc.desc Invalid dh key size 2048 alg ecc for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_20500', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_2048); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_20600 - * @tc.name InvalidDhKeySize3072AlgEccForGenerateGKeyCallback - * @tc.desc Invalid dh key size 3072 alg ecc for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_20600', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_3072); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_20700 - * @tc.name InvalidDhKeySize4096AlgEccForGenerateGKeyCallback - * @tc.desc Invalid dh key size 4096 alg ecc for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_20700', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_4096); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_20800 - * @tc.name InvalidDigestMd5AlgEccForGenerateGKeyCallback - * @tc.desc Invalid digest md5 alg ecc for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_20800', 0, async function (done) { - var option = eccGenerateKeyInvalidDigestOption(hks.HuksKeyDigest.HUKS_DIGEST_MD5); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_20900 - * @tc.name InvalidPurposeDeriveAlgEccForGenerateGKeyCallback - * @tc.desc Invalid purpose derive alg ecc for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_20900', 0, async function (done) { - var option = eccGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_21000 - * @tc.name InvalidPurposeMacAlgEccForGenerateGKeyCallback - * @tc.desc Invalid purpose mac alg ecc for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_21000', 0, async function (done) { - var option = eccGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_21100 - * @tc.name InvalidPurposeWrapAlgEccForGenerateGKeyCallback - * @tc.desc Invalid purpose wrap alg ecc for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_21100', 0, async function (done) { - var option = eccGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_WRAP); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_21300 - * @tc.name InvalidPurposeencryptAlgEccForGenerateGKeyCallback - * @tc.desc Invalid purpose encrypt alg ecc for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_21300', 0, async function (done) { - var option = eccGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_21400 - * @tc.name InvalidPurposeDecryptAlgEccForGenerateGKeyCallback - * @tc.desc Invalid purpose decrypt alg ecc for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_21400', 0, async function (done) { - var option = eccGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_21500 - * @tc.name InvalidArgumentAlgEcdhForGenerateGKeyCallback - * @tc.desc Invalid argument alg ecdh for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_21500', 0, async function (done) { - var option = ecdhGenerateKeyInvalidAlgOption(); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_21600 - * @tc.name InvalidAlgorithmAlgHkdfForGenerateGKeyCallback - * @tc.desc Invalid algorithm alg hkdf for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_21600', 0, async function (done) { - var option = hkdfGenerateKeyInvalidAlgOption(); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_21700 - * @tc.name InvalidAlgorithmAlgPbkdf2ForGenerateGKeyCallback - * @tc.desc Invalid algorithm alg pbkdf2 for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_21700', 0, async function (done) { - var option = pbkdf2GenerateKeyInvalidAlgOption(); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_21800 - * @tc.name InvalidPurposeDeriveAlgEd25519ForGenerateKeyCallback. - * @tc.desc Invalid purpose derive alg ed25519 for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_21800', 0, async function (done) { - var option = ed25519GenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_21900 - * @tc.name InvalidPurposeMacAlgEd25519ForGenerateKeyCallback - * @tc.desc Invalid purpose mac alg ed25519 for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_21900', 0, async function (done) { - var option = ed25519GenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_22000 - * @tc.name InvalidPurposeWrapAlgEd25519ForGenerateKeyCallback - * @tc.desc Invalid purpose wrap alg ed25519 for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_22000', 0, async function (done) { - var option = ed25519GenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_WRAP); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_22100 - * @tc.name InvalidPurposeUnwrapAlgEd25519ForGenerateKeyCallback - * @tc.desc Invalid purpose unwrap alg ed25519 for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_22100', 0, async function (done) { - var option = ed25519GenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_22200 - * @tc.name InvalidPurposeEncryptAlgEd25519ForGenerateKeyCallback - * @tc.desc Invalid purpose encrypt alg ed25519 for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_22200', 0, async function (done) { - var option = ed25519GenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_22300 - * @tc.name InvalidPurposeDecryptAlgEd25519ForGenerateKeyCallback - * @tc.desc Invalid purpose decrypt alg ed25519 for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_22300', 0, async function (done) { - var option = ed25519GenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_22400 - * @tc.name InvalidPurposeDeriveAlgX25519ForGenerateKeyCallback - * @tc.desc Invalid purpose derive alg x25519 for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_22400', 0, async function (done) { - var option = x25519GenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_22500 - * @tc.name InvalidPurposeMacAlgX25519ForGenerateKeyCallback - * @tc.desc Invalid purpose mac alg x25519 for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_22500', 0, async function (done) { - var option = x25519GenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_22600 - * @tc.name InvalidPurposeEncryptAlgX25519ForGenerateKeyCallback - * @tc.desc Invalid purpose encrypt alg x25519 for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_22600', 0, async function (done) { - var option = x25519GenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_22700 - * @tc.name InvalidPurposeDecryptAlgX25519ForGenerateKeyCallback - * @tc.desc Invalid purpose decrypt alg x25519 for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_22700', 0, async function (done) { - var option = x25519GenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_22800 - * @tc.name InvalidArgumentSizeaAlgHmacForGenerateKeyCallback - * @tc.desc Invalid argument sizea alg hmac for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_22800', 0, async function (done) { - var option = hmacGenerateKeyInvalidSizeOption(errHmacKeySizeA); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_22900 - * @tc.name InvalidArgumentSizebAlgHmacForGenerateKeyCallback - * @tc.desc Invalid argument sizeb alg hmac for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_22900', 0, async function (done) { - var option = hmacGenerateKeyInvalidSizeOption(errHmacKeySizeB); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_23000 - * @tc.name InvalidPurposeDeriveAlgHmacForGenerateKeyCallback - * @tc.desc Invalid purpose derive alg hmac for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_23000', 0, async function (done) { - var option = hmacGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_23100 - * @tc.name InvalidPurposeSignAlgHmacForGenerateKeyCallback - * @tc.desc Invalid purpose sign alg hmac for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_23100', 0, async function (done) { - var option = hmacGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_23200 - * @tc.name InvalidPurposeVerifyAlgHmacForGenerateKeyCallback - * @tc.desc Invalid purpose verify alg hmac for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_23200', 0, async function (done) { - var option = hmacGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_23300 - * @tc.name InvalidPurposeWrapAlgHmacForGenerateKeyCallback - * @tc.desc Invalid purpose wrap alg hmac for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_23300', 0, async function (done) { - var option = hmacGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_WRAP); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_23400 - * @tc.name InvalidPurposeUnwrapAlgHmacForGenerateKeyCallback - * @tc.desc Invalid purpose unwrap alg hmac for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_23400', 0, async function (done) { - var option = hmacGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_23500 - * @tc.name InvalidPurposeEncryptAlgHmacForGenerateKeyCallback - * @tc.desc Invalid purpose encrypt alg hmac for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_23500', 0, async function (done) { - var option = hmacGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_23600 - * @tc.name InvalidPurposeDecryptAlgHmacForGenerateKeyCallback - * @tc.desc Invalid purpose decrypt alg hmac for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_23600', 0, async function (done) { - var option = hmacGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_23700 - * @tc.name InvalidPurposeAgreeAlgHmacForGenerateKeyCallback - * @tc.desc Invalid purpose agree alg hmac for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_23700', 0, async function (done) { - var option = hmacGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_23800 - * @tc.name InvalidArgumentSizeaAlgDsaForGenerateKeyCallback - * @tc.desc Invalid argument sizea alg dsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_23800', 0, async function (done) { - var option = dsaGenerateKeyInvalidSizeOption(errDsaKeySizeA); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_23900 - * @tc.name InvalidArgumentSizebAlgDsaForGenerateKeyCallback - * @tc.desc Invalid argument sizeb alg dsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_23900', 0, async function (done) { - var option = dsaGenerateKeyInvalidSizeOption(errDsaKeySizeB); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_24000 - * @tc.name InvalidPurposeDeriveAlgDsaForGenerateKeyCallback - * @tc.desc Invalid purpose derive alg dsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_24000', 0, async function (done) { - var option = dsaGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_24100 - * @tc.name InvalidPurposeMacAlgDsaForGenerateKeyCallback - * @tc.desc Invalid purpose mac alg dsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_24100', 0, async function (done) { - var option = dsaGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_24200 - * @tc.name InvalidPurposeWrapAlgDsaForGenerateKeyCallback - * @tc.desc Invalid purpose wrap alg dsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_24200', 0, async function (done) { - var option = dsaGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_WRAP); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_24300 - * @tc.name InvalidPurposeUnwrapAlgDsaForGenerateKeyCallback - * @tc.desc Invalid purpose unwrap alg dsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_24300', 0, async function (done) { - var option = dsaGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_24400 - * @tc.name InvalidPurposeEncryptAlgDsaForGenerateKeyCallback - * @tc.desc Invalid purpose encrypt alg dsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_24400', 0, async function (done) { - var option = dsaGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_24500 - * @tc.name InvalidPurposeDecryptAlgDsaForGenerateKeyCallback - * @tc.desc Invalid purpose decrypt alg dsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_24500', 0, async function (done) { - var option = dsaGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_24600 - * @tc.name InvalidPurposeAgreeAlgDsaForGenerateKeyCallback - * @tc.desc Invalid purpose agree alg dsa for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_24600', 0, async function (done) { - var option = dsaGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_24700 - * @tc.name InvalidPurposeDeriveAlgDhForGenerateKeyCallback - * @tc.desc Invalid purpose derive alg dh for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_24700', 0, async function (done) { - var option = dhGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_24800 - * @tc.name InvalidPurposeMacAlgDhForGenerateKeyCallback - * @tc.desc Invalid purpose mac alg dh for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_24800', 0, async function (done) { - var option = dhGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_24900 - * @tc.name InvalidPurposeWrapAlgDhForGenerateKeyCallback - * @tc.desc Invalid purpose wrap alg dh for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_24900', 0, async function (done) { - var option = dhGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_WRAP); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_25100 - * @tc.name InvalidPurposeEncryptAlgDhForGenerateKeyCallback - * @tc.desc Invalid purpose encrypt alg dh for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_25100', 0, async function (done) { - var option = dhGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_25200 - * @tc.name InvalidPurposeDecryptAlgDhForGenerateKeyCallback - * @tc.desc Invalid purpose decrypt alg dh for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_25200', 0, async function (done) { - var option = dhGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_25300 - * @tc.name InvalidPurposeSignAlgDhForGenerateKeyCallback - * @tc.desc Invalid purpose sign alg dh for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_25300', 0, async function (done) { - var option = dhGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_25400 - * @tc.name InvalidPurposeVerifyAlgDhForGenerateKeyCallback - * @tc.desc Invalid purpose verify alg dh for generate key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_25400', 0, async function (done) { - var option = dhGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY); - hks.generateKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); -}); - diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_callback_part3.test.js b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_callback_part3.test.js deleted file mode 100644 index 8a98cf26364df2851291bac175efcf84368891e9..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_callback_part3.test.js +++ /dev/null @@ -1,1484 +0,0 @@ -/* - * 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 hks from '@ohos.security.huks' -import { describe, it, expect } from 'deccjsunit/index' -import { - alias, -} from '../../../../../../hks_xts_common.test' - -import { - generateRSAKeyOption, - generateAesCBCKeyOption, - generateAesGCMKeyOption, - encryptOrDecryptGenerateKeyOption, - encryptOrDecryptOption, - encryptOrDecryptInvalidAlgOption, - rsaEncryptInvalidSizeOption, - aesEncryptOrDecryptInvalidSizeOption, - aesEncryptOrDecryptInvalidPaddingOption, - aesEncryptOrDecryptInvalidDigestOption, - rsaEncryptOrDecryptInvalidIndataOption, - aesEncryptOrDecryptInvalidIndataOption, - aesEncryptOrDecryptInvalidPurposeOption, - rsaDecryptInvalidSizeOption, -} from './hks_abnormal_common.test.js' - -describe('Hks_Abnormal_Callback_Part3', function () { - var cipherText = []; - - async function generateKey() { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - }; - - async function generateRSAKey() { - var option = generateRSAKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - }; - - async function generateAesCBCKey() { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - }; - async function generateAesGCMKey() { - var option = generateAesGCMKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - }; - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_25500 - * @tc.name InvalidAlgorithmAlgEccForEncryptCallback - * @tc.desc Invalid algorithm alg ecc for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_25500', 0, async function (done) { - await generateKey(); - var encryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ECC); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_25600 - * @tc.name InvalidAlgorithmAlgDsaForEncryptCallback - * @tc.desc Invalid algorithm alg dsa for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_25600', 0, async function (done) { - await generateKey(); - var encryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_DSA); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_25700 - * @tc.name InvalidAlgorithmAlgHmacForEncryptCallback - * @tc.desc Invalid algorithm alg hmac for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_25700', 0, async function (done) { - await generateKey(); - var encryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_HMAC); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_25800 - * @tc.name InvalidAlgorithmAlgHkdfForEncryptCallback - * @tc.desc Invalid algorithm alg hkdf for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_25800', 0, async function (done) { - await generateKey(); - var encryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_HKDF); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_25900 - * @tc.name InvalidAlgorithmAlgPbkdf2ForEncryptCallback - * @tc.desc Invalid algorithm alg pbkdf2 for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_25900', 0, async function (done) { - await generateKey(); - var encryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_PBKDF2); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_26000 - * @tc.name InvalidAlgorithmAlgEcdhForEncryptCallback - * @tc.desc Invalid algorithm alg ecdh for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_26000', 0, async function (done) { - await generateKey(); - var encryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ECDH); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_26100 - * @tc.name InvalidAlgorithmAlgX25519ForEncryptCallback - * @tc.desc Invalid algorithm alg x25519 for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_26100', 0, async function (done) { - await generateKey(); - var encryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_X25519); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_26200 - * @tc.name InvalidAlgorithmAlgEd25519ForEncryptCallback - * @tc.desc Invalid algorithm alg ed25519 for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_26200', 0, async function (done) { - await generateKey(); - var encryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ED25519); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_26300 - * @tc.name InvalidAlgorithmAlgDhForEncryptCallback - * @tc.desc Invalid algorithm alg dh for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_26300', 0, async function (done) { - await generateKey(); - var encryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_DH); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_26400 - * @tc.name SuccessEcc224AlgRsaForEncryptCallback - * @tc.desc Success ecc 224 alg rsa for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_26400', 0, async function (done) { - await generateKey(); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_224); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_26500 - * @tc.name SuccessEcc256AlgRsaForEncryptCallback - * @tc.desc Success ecc 256 alg rsa for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_26500', 0, async function (done) { - await generateKey(); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_26600 - * @tc.name SuccessEcc384AlgRsaForEncryptCallback - * @tc.desc Success ecc 384 alg rsa for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_26600', 0, async function (done) { - await generateKey(); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_384); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_26700 - * @tc.name SuccessEcc521AlgRsaForEncryptCallback - * @tc.desc Success ecc 521 alg rsa for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_26700', 0, async function (done) { - await generateKey(); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_521); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_26800 - * @tc.name SuccessAes128AlgRsaForEncryptCallback - * @tc.desc Success aes 128 alg rsa for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_26800', 0, async function (done) { - await generateKey(); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_128); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_26900 - * @tc.name SuccessAes192AlgRsaForEncryptCallback - * @tc.desc Success aes 192 alg rsa for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_26900', 0, async function (done) { - await generateKey(); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_192); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_27000 - * @tc.name SuccessAes256AlgRsaForEncryptCallback - * @tc.desc Success aes 256 alg rsa for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_27000', 0, async function (done) { - await generateKey(); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_256); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_27100 - * @tc.name SuccessAes512AlgRsaForEncryptCallback - * @tc.desc Success aes 512 alg rsa for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_27100', 0, async function (done) { - await generateKey(); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_512); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_27200 - * @tc.name SuccessCurve25519256AlgRsaForEncryptCallback - * @tc.desc Success curve25519 256 alg rsa for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_27200', 0, async function (done) { - await generateKey(); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_27300 - * @tc.name SuccessDh2048AlgRsaForEncryptCallback - * @tc.desc Success dh 2048 alg rsa for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_27300', 0, async function (done) { - await generateKey(); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_2048); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_27400 - * @tc.name SuccessDh3072AlgRsaForEncryptCallback - * @tc.desc Success dh 3072 alg rsa for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_27400', 0, async function (done) { - await generateKey(); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_3072); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_27500 - * @tc.name SuccessDh4096AlgRsaForEncryptCallback - * @tc.desc Success dh 4096 alg rsa for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_27500', 0, async function (done) { - await generateKey(); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_4096); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_27600 - * @tc.name SuccessRsa512AlgAesForEncryptCallback - * @tc.desc Success rsa 512 alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_27600', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_27700 - * @tc.name SuccessRsa768AlgAesForEncryptCallback - * @tc.desc Success rsa 768 alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_27700', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_768); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_27800 - * @tc.name SuccessRsa1024AlgAesForEncryptCallback - * @tc.desc Success rsa 1024 alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_27800', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_27900 - * @tc.name SuccessRsa2048AlgAesForEncryptCallback - * @tc.desc Success rsa 2048 alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_27900', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_28000 - * @tc.name SuccessRsa3072AlgAesForEncryptCallback - * @tc.desc Success rsa 3072 alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_28000', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_28100 - * @tc.name SuccessRsa4096AlgAesForEncryptCallback - * @tc.desc Success rsa 4096 alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_28100', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_28200 - * @tc.name SuccessEcc224AlgAesForEncryptCallback - * @tc.desc Success ecc 224 alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_28200', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_224); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_28300 - * @tc.name SuccessEcc256AlgAesForEncryptCallback - * @tc.desc Success ecc 256 alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_28300', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_28400 - * @tc.name SuccessEcc384AlgAesForEncryptCallback - * @tc.desc Success ecc 384 alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_28400', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_384); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_28500 - * @tc.name SuccessEcc521AlgAesForEncryptCallback - * @tc.desc Success ecc 521 alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_28500', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_521); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_28600 - * @tc.name SuccessCurve25519256AlgAesForEncryptCallback - * @tc.desc Success curve25519 256 alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_28600', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_28700 - * @tc.name SuccessDh2048AlgAesForEncryptCallback - * @tc.desc Success dh 2048 alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_28700', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_2048); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_28800 - * @tc.name SuccessDh3072AlgAesForEncryptCallback - * @tc.desc Success dh 3072 alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_28800', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_3072); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_28900 - * @tc.name SuccessDh4096AlgAesForEncryptCallback - * @tc.desc Success dh 4096 alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_28900', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_4096); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_29000 - * @tc.name InvalidPaddingPssPurposeEncryptDecryptAlgAesForEncryptCallback - * @tc.desc Invalid padding pss purpose encrypt decrypt alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_29000', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_PSS); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_29100 - * @tc.name InvalidPaddingPkcs5PurposeEncryptDecryptAlgAesForEncryptCallback - * @tc.desc Invalid padding pkcs5 purpose encrypt decrypt alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_29100', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_PKCS5); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_29200 - * @tc.name InvalidPaddingPkcs7PurposeEncryptDecryptAlgAesForEncryptCallback - * @tc.desc Invalid padding pkcs7 purpose encrypt decrypt alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_29200', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_PKCS7); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_29300 - * @tc.name SuccessDigestMd5AlgAesForEncryptCallback - * @tc.desc Success digest md5 alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_29300', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidDigestOption(hks.HuksKeyDigest.HUKS_DIGEST_MD5); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_29400 - * @tc.name InvalidArgumentIndataLargerThanKeySizeRsaPaddingNoneForEncryptCallback - * @tc.desc Invalid argument indata is larger than key size rsa padding none for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_29400', 0, async function (done) { - await generateRSAKey(); - var encryptOption = rsaEncryptOrDecryptInvalidIndataOption(); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_29500 - * @tc.name InvalidArgumentIndataLargerThanKeySizeAesPaddingNoneForEncryptCallback - * @tc.desc Invalid argument indata is larger than key size aes padding none for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_29500', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidIndataOption(); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_29600 - * @tc.name InvalidPurposeDecryptAlgAesForEncryptCallback - * @tc.desc Invalid purpose decrypt alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_29600', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_29700 - * @tc.name InvalidPurposeSignAlgAesForEncryptCallback - * @tc.desc Invalid purpose sign alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_29700', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_29800 - * @tc.name InvalidPurposeVerifyAlgAesForEncryptCallback - * @tc.desc Invalid purpose verify alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_29800', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_29900 - * @tc.name InvalidPurposeDeriveAlgAesForEncryptCallback - * @tc.desc Invalid purpose derive alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_29900', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_30000 - * @tc.name InvalidPurposeWrapAlgAesForEncryptCallback - * @tc.desc Invalid purpose wrap alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_30000', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_WRAP); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_30100 - * @tc.name InvalidPurposeUnwrapAlgAesForEncryptCallback - * @tc.desc Invalid purpose unwrap alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_30100', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_30200 - * @tc.name InvalidPurposeMacAlgAesForEncryptCallback - * @tc.desc Invalid purpose mac alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_30200', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_30300 - * @tc.name InvalidPurposeagreeAlgAesForEncryptCallback - * @tc.desc Invalid purpose agree alg aes for encrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_30300', 0, async function (done) { - await generateAesCBCKey(); - var encryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE); - hks.encrypt(alias, encryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_30400 - * @tc.name InvalidAlgorithmEccForDecryptCallback - * @tc.desc Invalid algorithm ecc for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_30400', 0, async function (done) { - await generateKey(); - var decryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ECC); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_30500 - * @tc.name InvalidAlgorithmDsaForDecryptCallback - * @tc.desc Invalid algorithm dsa for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_30500', 0, async function (done) { - await generateKey(); - var decryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_DSA); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_30600 - * @tc.name InvalidAlgorithmHmacForDecryptCallback - * @tc.desc Invalid algorithm hmac for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_30600', 0, async function (done) { - await generateKey(); - var decryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_HMAC); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_30700 - * @tc.name InvalidAlgorithmHkdfForDecryptCallback - * @tc.desc Invalid algorithm hkdf for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_30700', 0, async function (done) { - await generateKey(); - var decryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_HKDF); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_30800 - * @tc.name InvalidAlgorithmPbkdf2ForDecryptCallback - * @tc.desc Invalid algorithm pbkdf2 for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_30800', 0, async function (done) { - await generateKey(); - var decryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_PBKDF2); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_30900 - * @tc.name InvalidAlgorithmEcdhForDecryptCallback - * @tc.desc Invalid algorithm ecdh for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_30900', 0, async function (done) { - await generateKey(); - var decryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ECDH); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_31000 - * @tc.name InvalidAlgorithmX25519ForDecryptCallback - * @tc.desc Invalid algorithm x25519 for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_31000', 0, async function (done) { - await generateKey(); - var decryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_X25519); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_31100 - * @tc.name InvalidAlgorithmEd25519ForDecryptCallback - * @tc.desc Invalid algorithm ed25519 for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_31100', 0, async function (done) { - await generateKey(); - var decryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ED25519); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_31200 - * @tc.name InvalidAlgorithmDhForDecryptCallback - * @tc.desc Invalid algorithm dh for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_31200', 0, async function (done) { - await generateKey(); - var decryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_DH); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_31300 - * @tc.name SuccessEcc224AlgRsaForDecryptCallback - * @tc.desc Success ecc 224 alg rsa for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_31300', 0, async function (done) { - await generateKey(); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, cipherText); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_31400 - * @tc.name SuccessEcc256AlgRsaForDecryptCallback - * @tc.desc Success ecc 256 alg rsa for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_31400', 0, async function (done) { - await generateKey(); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, cipherText); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_31500 - * @tc.name SuccessEcc384AlgRsaForDecryptCallback - * @tc.desc Success ecc 384 alg rsa for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_31500', 0, async function (done) { - await generateKey(); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_384, cipherText); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_31600 - * @tc.name SuccessEcc521AlgRsaForDecryptCallback - * @tc.desc Success ecc 521 alg rsa for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_31600', 0, async function (done) { - await generateKey(); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_521, cipherText); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_31700 - * @tc.name SuccessAes128AlgRsaForDecryptCallback - * @tc.desc Success aes 128 alg rsa for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_31700', 0, async function (done) { - await generateKey(); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_128, cipherText); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_31800 - * @tc.name SuccessAes192AlgRsaForDecryptCallback - * @tc.desc Success aes 192 alg rsa for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_31800', 0, async function (done) { - await generateKey(); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_192, cipherText); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_31900 - * @tc.name SuccessAes256AlgRsaForDecryptCallback - * @tc.desc Success aes 256 alg rsa for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_31900', 0, async function (done) { - await generateKey(); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_256, cipherText); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_32000 - * @tc.name SuccessAes512AlgRsaForDecryptCallback - * @tc.desc Success aes 512 alg rsa for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_32000', 0, async function (done) { - await generateKey(); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_512, cipherText); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_32100 - * @tc.name SuccessCurve25519256AlgRsaForDecryptCallback - * @tc.desc Success curve25519 256 alg rsa for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_32100', 0, async function (done) { - await generateKey(); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256, cipherText); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_32200 - * @tc.name SuccessDh2048AlgRsaForDecryptCallback - * @tc.desc Success dh 2048 alg rsa for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_32200', 0, async function (done) { - await generateKey(); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_2048, cipherText); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_32300 - * @tc.name SuccessDh3072AlgRsaForDecryptCallback - * @tc.desc Success dh 3072 alg rsa for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_32300', 0, async function (done) { - await generateKey(); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_3072, cipherText); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_32400 - * @tc.name SuccessDh4096AlgRsaForDecryptCallback - * @tc.desc Success dh 4096 alg rsa for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_32400', 0, async function (done) { - await generateKey(); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_4096, cipherText); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_32500 - * @tc.name SuccessRsa512AlgAesForDecryptCallback - * @tc.desc Success rsa 512 alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_32500', 0, async function (done) { - await generateAesCBCKey(); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_32600 - * @tc.name SuccessRsa768AlgAesForDecryptCallback - * @tc.desc Success rsa 768 alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_32600', 0, async function (done) { - await generateAesCBCKey(); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_768); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_32700 - * @tc.name SuccessRsa1024AlgAesForDecryptCallback - * @tc.desc Success rsa 1024 alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_32700', 0, async function (done) { - await generateAesCBCKey(); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_32800 - * @tc.name SuccessRsa2048AlgAesForDecryptCallback - * @tc.desc Success rsa 2048 alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_32800', 0, async function (done) { - await generateAesCBCKey(); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_32900 - * @tc.name SuccessRsa3072AlgAesForDecryptCallback - * @tc.desc Success rsa 3072 alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_32900', 0, async function (done) { - await generateAesCBCKey(); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_33000 - * @tc.name SuccessRsa4096AlgAesForDecryptCallback - * @tc.desc Success rsa 4096 alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_33000', 0, async function (done) { - await generateAesCBCKey(); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_33100 - * @tc.name SuccessEcc224AlgAesForDecryptCallback - * @tc.desc Success ecc 224 alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_33100', 0, async function (done) { - await generateAesCBCKey(); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_224); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_33200 - * @tc.name SuccessEcc256AlgAesForDecryptCallback - * @tc.desc Success ecc 256 alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_33200', 0, async function (done) { - await generateAesCBCKey(); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_33300 - * @tc.name SuccessEcc384AlgAesForDecryptCallback - * @tc.desc Success ecc 384 alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_33300', 0, async function (done) { - await generateAesCBCKey(); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_384); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_33400 - * @tc.name SuccessEcc521AlgAesForDecryptCallback - * @tc.desc Success ecc 521 alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_33400', 0, async function (done) { - await generateAesCBCKey(); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_521); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_33500 - * @tc.name Successcurve25519256AlgAesForDecryptCallback - * @tc.desc Success curve25519 256 alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_33500', 0, async function (done) { - await generateAesCBCKey(); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_33600 - * @tc.name SuccessDh2048AlgAesForDecryptCallback - * @tc.desc Success dh 2048 alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_33600', 0, async function (done) { - await generateAesCBCKey(); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_2048); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_33700 - * @tc.name SuccessDh3072AlgAesForDecryptCallback - * @tc.desc Success dh 3072 alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_33700', 0, async function (done) { - await generateAesCBCKey(); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_3072); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_33800 - * @tc.name SuccessDh4096AlgAesForDecryptCallback - * @tc.desc Success dh 4096 alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_33800', 0, async function (done) { - await generateAesCBCKey(); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_4096); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_33900 - * @tc.name InvalidPaddingPssPurposeEncryptDecryptAlgAesForDecryptCallback - * @tc.desc Invalid padding pss purpose encrypt decrypt alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_33900', 0, async function (done) { - await generateAesCBCKey(); - var decryptOption = aesEncryptOrDecryptInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_PSS); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_34000 - * @tc.name InvalidPaddingPkcs5PurposeEncryptDecryptAlgAesForDecryptCallback - * @tc.desc Invalid padding pkcs5 purpose encrypt decrypt alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_34000', 0, async function (done) { - await generateAesCBCKey(); - var decryptOption = aesEncryptOrDecryptInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_PKCS5); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_34100 - * @tc.name InvalidPaddingPkcs7PurposeEncryptDecryptAlgAesForDecryptCallback - * @tc.desc Invalid padding pkcs7 purpose encrypt decrypt alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_34100', 0, async function (done) { - await generateAesCBCKey(); - var decryptOption = aesEncryptOrDecryptInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_PKCS7); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_34200 - * @tc.name SuccessDigestMd5AlgAesForDecryptCallback - * @tc.desc Success digest md5 alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_34200', 0, async function (done) { - await generateAesCBCKey(); - var decryptOption = aesEncryptOrDecryptInvalidDigestOption(hks.HuksKeyDigest.HUKS_DIGEST_MD5); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_34300 - * @tc.name InvalidArgumentIndataLargerThanKeySizeRsaPaddingNoneForDecryptCallback - * @tc.desc Invalid argument indata is larger than key size rsa padding none for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_34300', 0, async function (done) { - await generateRSAKey(); - var decryptOption = rsaEncryptOrDecryptInvalidIndataOption(); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_34400 - * @tc.name InvalidArgumentIndataLargerThanKeySizeAesPaddingNoneForDecryptCallback - * @tc.desc Invalid argument indata is larger than key size aes padding none for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_34400', 0, async function (done) { - await generateAesCBCKey(); - var decryptOption = aesEncryptOrDecryptInvalidIndataOption(); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_34500 - * @tc.name InvalidPurposeEncryptAlgAesForDecryptCallback - * @tc.desc Invalid purpose encrypt alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_34500', 0, async function (done) { - await generateAesGCMKey(); - var decryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_34600 - * @tc.name InvalidPurposeSignAlgAesForDecryptCallback - * @tc.desc Invalid purpose sign alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_34600', 0, async function (done) { - await generateAesGCMKey(); - var decryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_34700 - * @tc.name InvalidPurposeVerifyAlgAesForDecryptCallback - * @tc.desc Invalid purpose verify alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_34700', 0, async function (done) { - await generateAesGCMKey(); - var decryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_34800 - * @tc.name InvalidPurposeDeriveAlgAesForDecryptCallback - * @tc.desc Invalid purpose derive alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_34800', 0, async function (done) { - await generateAesGCMKey(); - var decryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_34900 - * @tc.name InvalidPurposeWrapAlgAesForDecryptCallback - * @tc.desc Invalid purpose wrap alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_34900', 0, async function (done) { - await generateAesGCMKey(); - var decryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_WRAP); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_35000 - * @tc.name InvalidPurposeUnwrapAlgAesForDecryptCallback - * @tc.desc Invalid purpose unwrap alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_35000', 0, async function (done) { - await generateAesGCMKey(); - var decryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_35100 - * @tc.name InvalidPurposeMacAlgAesForDecryptCallback - * @tc.desc Invalid purpose mac alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_35100', 0, async function (done) { - await generateAesGCMKey(); - var decryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_35200 - * @tc.name InvalidPurposeAgreeAlgAesForDecryptCallback - * @tc.desc Invalid purpose agree alg aes for decrypt callback. - */ - it('HUKS_ABNORMAL_CALLBACK_35200', 0, async function (done) { - await generateAesGCMKey(); - var decryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE); - hks.decrypt(alias, decryptOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); -}); \ No newline at end of file diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_callback_part4.test.js b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_callback_part4.test.js deleted file mode 100644 index d1553ec950720ea289a91d5fbf93a8af05aa65c2..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_callback_part4.test.js +++ /dev/null @@ -1,568 +0,0 @@ -/* - * 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 hks from '@ohos.security.huks' -import { describe, it, expect } from 'deccjsunit/index' -import { - alias, -} from '../../../../../../hks_xts_common.test' -import { - plainTextSize64, - signOrVerifyGenerateKeyOption, - signOrVerifyInvalidAlgOption, - signOrVerifyInvalidPurposeOption, - signOrVerifyInvalidPaddingOption, -} from './hks_abnormal_common.test.js' - -describe('Hks_Abnormal_Callback_Part4', function () { - - async function generateKey() { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - }; - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_35300 - * @tc.name InvalidAlgorithmAlgAesForSignCallback - * @tc.desc Invalid algorithm alg aes for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_35300', 0, async function (done) { - await generateKey(); - var signOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_AES); - hks.sign(alias, signOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_35400 - * @tc.name InvalidAlgorithmAlghmacForSignCallback - * @tc.desc Invalid algorithm alg hmac for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_35400', 0, async function (done) { - await generateKey(); - var signOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_HMAC); - hks.sign(alias, signOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_35500 - * @tc.name InvalidAlgorithmAlgHkdfForSignCallback - * @tc.desc Invalid algorithm alg hkdf for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_35500', 0, async function (done) { - await generateKey(); - var signOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_HKDF); - hks.sign(alias, signOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_35600 - * @tc.name InvalidAlgorithmAlgPbkdf2ForSignCallback - * @tc.desc Invalid algorithm alg pbkdf2 for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_35600', 0, async function (done) { - await generateKey(); - var signOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_PBKDF2); - hks.sign(alias, signOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_35700 - * @tc.name InvalidAlgorithmAlgEcdhForSignCallback - * @tc.desc Invalid algorithm alg ecdh for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_35700', 0, async function (done) { - await generateKey(); - var signOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ECDH); - hks.sign(alias, signOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_35800 - * @tc.name InvalidAlgorithmAlgX25519ForSignCallback - * @tc.desc Invalid algorithm alg x25519 for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_35800', 0, async function (done) { - await generateKey(); - var signOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_X25519); - hks.sign(alias, signOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_35900 - * @tc.name InvalidAlgorithmAlgDhForSignCallback - * @tc.desc Invalid algorithm alg dh for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_35900', 0, async function (done) { - await generateKey(); - var signOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_DH); - hks.sign(alias, signOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_36000 - * @tc.name InvalidPurposeEncryptForSignCallback - * @tc.desc Invalid purpose encrypt for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_36000', 0, async function (done) { - await generateKey(); - var signOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT); - hks.sign(alias, signOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_36100 - * @tc.name InvalidPurposeDecryptForSignCallback - * @tc.desc Invalid purpose decrypt for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_36100', 0, async function (done) { - await generateKey(); - var signOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT); - hks.sign(alias, signOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_36200 - * @tc.name InvalidPurposeVerifyForSignCallback - * @tc.desc Invalid purpose verify for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_36200', 0, async function (done) { - await generateKey(); - var signOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY); - hks.sign(alias, signOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_36300 - * @tc.name InvalidPurposeDeriveForSignCallback - * @tc.desc Invalid purpose derive for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_36300', 0, async function (done) { - await generateKey(); - var signOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - hks.sign(alias, signOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_36400 - * @tc.name InvalidPurposeWrapForSignCallback - * @tc.desc Invalid purpose wrap for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_36400', 0, async function (done) { - await generateKey(); - var signOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_WRAP); - hks.sign(alias, signOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_36500 - * @tc.name InvalidPurposeUnwrapForSignCallback - * @tc.desc Invalid purpose unwrap for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_36500', 0, async function (done) { - await generateKey(); - var signOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP); - hks.sign(alias, signOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_36600 - * @tc.name InvalidPurposeMacForSignCallback - * @tc.desc Invalid purpose mac for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_36600', 0, async function (done) { - await generateKey(); - var signOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - hks.sign(alias, signOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_36700 - * @tc.name InvalidPurposeAgreeForSignCallback - * @tc.desc Invalid purpose agree for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_36700', 0, async function (done) { - await generateKey(); - var signOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE); - hks.sign(alias, signOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_36800 - * @tc.name InvalidPaddingNoneAlgRsaForSignCallback - * @tc.desc Invalid padding none alg rsa for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_36800', 0, async function (done) { - await generateKey(); - var signOption = signOrVerifyInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_NONE); - hks.sign(alias, signOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_36900 - * @tc.name InvalidPaddingOaepAlgRsaForSignCallback - * @tc.desc Invalid padding oaep alg rsa for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_36900', 0, async function (done) { - await generateKey(); - var signOption = signOrVerifyInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_OAEP); - hks.sign(alias, signOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_37000 - * @tc.name InvalidPaddingPkcs5AlgRsaForSignCallback - * @tc.desc Invalid padding pkcs5 alg rsa for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_37000', 0, async function (done) { - await generateKey(); - var signOption = signOrVerifyInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_PKCS5); - hks.sign(alias, signOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_37100 - * @tc.name InvalidPaddingPkcs7AlgRsaForSignCallback - * @tc.desc Invalid padding pkcs7 alg rsa for sign callback. - */ - it('HUKS_ABNORMAL_CALLBACK_37100', 0, async function (done) { - await generateKey(); - var signOption = signOrVerifyInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_PKCS7); - hks.sign(alias, signOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_37200 - * @tc.name InvalidAlgorithmAlgAesForVerifyCallback - * @tc.desc Invalid algorithm alg aes for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_37200', 0, async function (done) { - await generateKey(); - var verifyOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_AES); - hks.verify(alias, verifyOption, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_37300 - * @tc.name InvalidAlgorithmAlgHmacForVerifyCallback - * @tc.desc Invalid algorithm alg hmac for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_37300', 0, async function (done) { - await generateKey(); - var verifyOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_HMAC); - hks.verify(alias, verifyOption, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_37400 - * @tc.name InvalidAlgorithmAlgHkdfForVerifyCallback - * @tc.desc Invalid algorithm alg hkdf for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_37400', 0, async function (done) { - await generateKey(); - var verifyOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_HKDF); - hks.verify(alias, verifyOption, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_37500 - * @tc.name InvalidAlgorithmAlgPbkdf2ForVerifyCallback - * @tc.desc Invalid algorithm alg pbkdf2 for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_37500', 0, async function (done) { - await generateKey(); - var verifyOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_PBKDF2); - hks.verify(alias, verifyOption, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_37600 - * @tc.name InvalidAlgorithmAlgEcdhForVerifyCallback - * @tc.desc Invalid algorithm alg ecdh for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_37600', 0, async function (done) { - await generateKey(); - var verifyOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ECDH); - hks.verify(alias, verifyOption, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_37700 - * @tc.name InvalidAlgorithmAlgX25519ForVerifyCallback - * @tc.desc Invalid algorithm alg x25519 for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_37700', 0, async function (done) { - await generateKey(); - var verifyOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_X25519); - hks.verify(alias, verifyOption, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_37800 - * @tc.name InvalidAlgorithmAlgDhForVerifyCallback - * @tc.desc Invalid algorithm alg dh for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_37800', 0, async function (done) { - await generateKey(); - var verifyOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_DH); - hks.verify(alias, verifyOption, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_37900 - * @tc.name InvalidAlgorithmEncryptForVerifyCallback - * @tc.desc Invalid purpose encrypt for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_37900', 0, async function (done) { - await generateKey(); - var verifyOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT); - hks.verify(alias, verifyOption, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_38000 - * @tc.name InvalidAlgorithmDecryptForVerifyCallback - * @tc.desc Invalid purpose decrypt for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_38000', 0, async function (done) { - await generateKey(); - var verifyOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT); - hks.verify(alias, verifyOption, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_38100 - * @tc.name InvalidAlgorithmSignForVerifyCallback - * @tc.desc Invalid purpose sign for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_38100', 0, async function (done) { - await generateKey(); - var verifyOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN); - hks.verify(alias, verifyOption, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_38200 - * @tc.name InvalidAlgorithmDeriveForVerifyCallback - * @tc.desc Invalid purpose derive for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_38200', 0, async function (done) { - await generateKey(); - var verifyOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - hks.verify(alias, verifyOption, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_38300 - * @tc.name InvalidAlgorithmWrapForVerifyCallback - * @tc.desc Invalid purpose wrap for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_38300', 0, async function (done) { - await generateKey(); - var verifyOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_WRAP); - hks.verify(alias, verifyOption, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_38400 - * @tc.name InvalidAlgorithmUnwrapForVerifyCallback - * @tc.desc Invalid purpose unwrap for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_38400', 0, async function (done) { - await generateKey(); - var verifyOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP); - hks.verify(alias, verifyOption, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_38500 - * @tc.name InvalidAlgorithmMacForVerifyCallback - * @tc.desc Invalid purpose mac for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_38500', 0, async function (done) { - await generateKey(); - var verifyOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - hks.verify(alias, verifyOption, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_38600 - * @tc.name InvalidAlgorithmAgreeForVerifyCallback - * @tc.desc Invalid purpose agree for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_38600', 0, async function (done) { - await generateKey(); - var verifyOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE); - hks.verify(alias, verifyOption, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_38700 - * @tc.name InvalidPaddingNoneAlgRsaForVerifyCallback - * @tc.desc Invalid padding none alg rsa for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_38700', 0, async function (done) { - await generateKey(); - var verifyOption = signOrVerifyInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_NONE); - hks.verify(alias, verifyOption, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_38800 - * @tc.name InvalidPaddingOaepAlgRsaForVerifyCallback - * @tc.desc Invalid padding oaep alg rsa for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_38800', 0, async function (done) { - await generateKey(); - var verifyOption = signOrVerifyInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_OAEP); - hks.verify(alias, verifyOption, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_38900 - * @tc.name InvalidPaddingPksc5AlgRsaForVerifyCallback - * @tc.desc Invalid padding pksc5 alg rsa for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_38900', 0, async function (done) { - await generateKey(); - var verifyOption = signOrVerifyInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_PKCS5); - hks.verify(alias, verifyOption, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_39000 - * @tc.name InvalidPaddingPkcs7AlgRsaForVerifyCallback - * @tc.desc Invalid padding pkcs7 alg rsa for verify callback. - */ - it('HUKS_ABNORMAL_CALLBACK_39000', 0, async function (done) { - await generateKey(); - var verifyOption = signOrVerifyInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_PKCS7); - hks.verify(alias, verifyOption, plainTextSize64, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); -}); \ No newline at end of file diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_callback_part5.test.js b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_callback_part5.test.js deleted file mode 100644 index 65ff37c62f41b32afd9212f1f3b667395da6e443..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_callback_part5.test.js +++ /dev/null @@ -1,347 +0,0 @@ -/* - * 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 hks from '@ohos.security.huks' -import { describe, it, expect } from 'deccjsunit/index' -import { - alias, -} from '../../../../../../hks_xts_common.test' -import { - generateAgreeKeyOption, - hmacGenerateKeyOption, - agreeInvalidAlgOption, - hmacInvalidPurposeOption, -} from './hks_abnormal_common.test.js' - -describe('Hks_Abnormal_Callback_Part5', function () { - async function hmacGenerateKey() { - var option = hmacGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - }; - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_39100 - * @tc.name InvalidAlgorithmAlgRsaForAgreeKeyCallback - * @tc.desc Invalid algorithm alg rsa for agree key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_39100', 0, async function (done) { - var option = generateAgreeKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(alias, option); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var agreeOption = agreeInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_RSA); - agreeOption.inData = exportKeyRet.outData - hks.agreeKey(alias, agreeOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_39200 - * @tc.name InvalidAlgorithmAlgEccForAgreeKeyCallback - * @tc.desc Invalid algorithm alg ecc for agree key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_39200', 0, async function (done) { - var option = generateAgreeKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(alias, option); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var agreeOption = agreeInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ECC); - agreeOption.inData = exportKeyRet.outData - hks.agreeKey(alias, agreeOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_39300 - * @tc.name InvalidAlgorithmAlgDsaForAgreeKeyCallback - * @tc.desc Invalid algorithm alg dsa for agree key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_39300', 0, async function (done) { - var option = generateAgreeKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(alias, option); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var agreeOption = agreeInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_DSA); - agreeOption.inData = exportKeyRet.outData - hks.agreeKey(alias, agreeOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_39400 - * @tc.name InvalidAlgorithmAlgAesForAgreeKeyCallback - * @tc.desc Invalid algorithm alg aes for agree key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_39400', 0, async function (done) { - var option = generateAgreeKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(alias, option); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var agreeOption = agreeInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_AES); - agreeOption.properties[1].value = hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256; - agreeOption.inData = exportKeyRet.outData - hks.agreeKey(alias, agreeOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_INFO); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_39500 - * @tc.name InvalidAlgorithmAlgHmacForAgreeKeyCallback - * @tc.desc Invalid algorithm alg hmac for agree key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_39500', 0, async function (done) { - var option = generateAgreeKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(alias, option); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var agreeOption = agreeInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_HMAC); - agreeOption.inData = exportKeyRet.outData - hks.agreeKey(alias, agreeOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_39600 - * @tc.name InvalidAlgorithmAlgHkdfForAgreeKeyCallback - * @tc.desc Invalid algorithm alg hkdf for agree key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_39600', 0, async function (done) { - var option = generateAgreeKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(alias, option); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var agreeOption = agreeInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_HKDF); - agreeOption.inData = exportKeyRet.outData - hks.agreeKey(alias, agreeOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_39700 - * @tc.name InvalidAlgorithmAlgPbkdf2ForAgreeKeyCallback - * @tc.desc Invalid algorithm alg pbkdf2 for agree key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_39700', 0, async function (done) { - var option = generateAgreeKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(alias, option); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var agreeOption = agreeInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_PBKDF2); - agreeOption.inData = exportKeyRet.outData - hks.agreeKey(alias, agreeOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_39800 - * @tc.name InvalidAlgorithmAlgEd25519ForAgreeKeyCallback - * @tc.desc Invalid algorithm alg ed25519 for agree key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_39800', 0, async function (done) { - var option = generateAgreeKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(alias, option); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var agreeOption = agreeInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ED25519); - agreeOption.properties[1].value = hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256; - agreeOption.inData = exportKeyRet.outData - hks.agreeKey(alias, agreeOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_INFO); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_39900 - * @tc.name InvalidPurposeEncryptForMacCallback - * @tc.desc Invalid purpose encrypt for mac callback. - */ - it('HUKS_ABNORMAL_CALLBACK_39900', 0, async function (done) { - await hmacGenerateKey(); - var macOption = hmacInvalidPurposeOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, hks.HuksKeyDigest.HUKS_DIGEST_SHA1); - hks.mac(alias, macOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_40000 - * @tc.name InvalidPurposeDecryptForMacCallback - * @tc.desc Invalid purpose decrypt for mac callback. - */ - it('HUKS_ABNORMAL_CALLBACK_40000', 0, async function (done) { - await hmacGenerateKey(); - var macOption = hmacInvalidPurposeOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1); - hks.mac(alias, macOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_40100 - * @tc.name InvalidPurposeSignForMacCallback - * @tc.desc Invalid purpose sign for mac callback. - */ - it('HUKS_ABNORMAL_CALLBACK_40100', 0, async function (done) { - await hmacGenerateKey(); - var macOption = hmacInvalidPurposeOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1); - hks.mac(alias, macOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_40200 - * @tc.name InvalidPurposeVerifyForMacCallback - * @tc.desc Invalid purpose verify for mac callback. - */ - it('HUKS_ABNORMAL_CALLBACK_40200', 0, async function (done) { - await hmacGenerateKey(); - var macOption = hmacInvalidPurposeOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1); - hks.mac(alias, macOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_40300 - * @tc.name InvalidPurposeDeriveForMacCallback - * @tc.desc Invalid purpose derive for mac callback. - */ - it('HUKS_ABNORMAL_CALLBACK_40300', 0, async function (done) { - await hmacGenerateKey(); - var macOption = hmacInvalidPurposeOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1); - hks.mac(alias, macOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_40400 - * @tc.name InvalidPurposeWrapForMacCallback - * @tc.desc Invalid purpose wrap for mac callback. - */ - it('HUKS_ABNORMAL_CALLBACK_40400', 0, async function (done) { - await hmacGenerateKey(); - var macOption = hmacInvalidPurposeOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_WRAP, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1); - hks.mac(alias, macOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_40500 - * @tc.name InvalidPurposeUnwrapForMacCallback - * @tc.desc Invalid purpose unwrap for mac callback. - */ - it('HUKS_ABNORMAL_CALLBACK_40500', 0, async function (done) { - await hmacGenerateKey(); - var macOption = hmacInvalidPurposeOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1); - hks.mac(alias, macOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_40600 - * @tc.name InvalidPurposeAgreeForMacCallback - * @tc.desc Invalid purpose agree for mac callback. - */ - it('HUKS_ABNORMAL_CALLBACK_40600', 0, async function (done) { - await hmacGenerateKey(); - var macOption = hmacInvalidPurposeOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1); - hks.mac(alias, macOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_40700 - * @tc.name InvalidDigestNoneForMacCallback - * @tc.desc Invalid digest none for mac callback. - */ - it('HUKS_ABNORMAL_CALLBACK_40700', 0, async function (done) { - await hmacGenerateKey(); - var macOption = hmacInvalidPurposeOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - hks.HuksKeyDigest.HUKS_DIGEST_NONE); - hks.mac(alias, macOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_40800 - * @tc.name InvalidDigestMd5ForMacCallback - * @tc.desc Invalid digest md5 for mac callback. - */ - it('HUKS_ABNORMAL_CALLBACK_40800', 0, async function (done) { - await hmacGenerateKey(); - var macOption = hmacInvalidPurposeOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - hks.HuksKeyDigest.HUKS_DIGEST_MD5); - hks.mac(alias, macOption, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - done(); - }); - }); -}); diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_callback_part6.test.js b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_callback_part6.test.js deleted file mode 100644 index 591e394f580233f955d8ea1f6b0fafc85aa8a638..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_callback_part6.test.js +++ /dev/null @@ -1,658 +0,0 @@ -/* - * 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 hks from '@ohos.security.huks' -import { describe, it, expect } from 'deccjsunit/index' -import { - aliasA, - aliasB, -} from '../../../../../../hks_xts_common.test' -import { - generateImportKeyOption, - eccGenerateKeyOption, - importOptionsInvalidAlgOption, - importOptionsInvalidSizeOption, - importOptionsInvalidPurposeOrPaddingOption, -} from './hks_abnormal_common.test.js' - -describe('Hks_Abnormal_Callback_Part6', function () { - var publicKey = []; - - var emptyOption = makeEmptyOptions(); - - function makeEmptyOptions() { - var emptyOptions = { - properties: [] - }; - return emptyOptions; - }; - - async function generateKeyAndExportKey() { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - }; - async function eccGenerateKey() { - var option = eccGenerateKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - }; - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_40900 - * @tc.name InvalidPurposeDeriveAlgRsaForImportKeyCallback - * @tc.desc Invalid purpose derive alg rsa for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_40900', 0, async function (done) { - await generateKeyAndExportKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_RSA, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_41000 - * @tc.name InvalidPurposeDeriveAlgEccForImportKeyCallback - * @tc.desc Invalid purpose derive alg ecc for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_41000', 0, async function (done) { - await generateKeyAndExportKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_ECC, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_41100 - * @tc.name InvalidPurposeDeriveAlgDsaForImportKeyCallback - * @tc.desc Invalid purpose derive alg dsa for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_41100', 0, async function (done) { - await generateKeyAndExportKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_DSA, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_41200 - * @tc.name InvalidPurposeDeriveAlgHkdfForImportKeyCallback - * @tc.desc Invalid purpose derive alg hkdf for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_41200', 0, async function (done) { - await generateKeyAndExportKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_HKDF, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_41300 - * @tc.name InvalidPurposeDeriveAlgPbkdf2ForImportKeyCallback - * @tc.desc Invalid purpose derive alg pbkdf2 for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_41300', 0, async function (done) { - await generateKeyAndExportKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_PBKDF2, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_41400 - * @tc.name InvalidPurposeDeriveAlgEcdhForImportKeyCallback - * @tc.desc Invalid purpose derive alg ecdh for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_41400', 0, async function (done) { - await generateKeyAndExportKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_ECDH, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_41500 - * @tc.name InvalidPurposeDeriveAlgX25519ForImportKeyCallback - * @tc.desc Invalid purpose derive alg x25519 for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_41500', 0, async function (done) { - await eccGenerateKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_X25519, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_INFO); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_41600 - * @tc.name InvalidPurposeDeriveAlgEd25519ForImportKeyCallback - * @tc.desc Invalid purpose derive alg ed25519 for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_41600', 0, async function (done) { - await eccGenerateKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_ED25519, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_INFO); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_41700 - * @tc.name InvalidPurposeDeriveAlgDhForImportKeyCallback - * @tc.desc Invalid purpose derive alg dh for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_41700', 0, async function (done) { - await generateKeyAndExportKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_DH, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_41800 - * @tc.name InvalidPurposeMacAlgRsaForImportKeyCallback - * @tc.desc Invalid purpose mac alg rsa for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_41800', 0, async function (done) { - await generateKeyAndExportKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_RSA, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_41900 - * @tc.name InvalidPurposeMacAlgEccForImportKeyCallback - * @tc.desc Invalid purpose mac alg ecc for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_41900', 0, async function (done) { - await generateKeyAndExportKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_ECC, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_42000 - * @tc.name InvalidPurposeMacAlgDsaForImportKeyCallback - * @tc.desc Invalid purpose mac alg dsa for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_42000', 0, async function (done) { - await generateKeyAndExportKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_DSA, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_42100 - * @tc.name InvalidPurposeMacAlgHkdfForImportKeyCallback - * @tc.desc Invalid purpose mac alg hkdf for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_42100', 0, async function (done) { - await generateKeyAndExportKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_HKDF, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_42200 - * @tc.name InvalidPurposeMacAlgPbkdf2ForImportKeyCallback - * @tc.desc Invalid purpose mac alg pbkdf2 for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_42200', 0, async function (done) { - await generateKeyAndExportKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_PBKDF2, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_42300 - * @tc.name InvalidPurposeMacAlgEcdhForImportKeyCallback - * @tc.desc Invalid purpose mac alg ecdh for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_42300', 0, async function (done) { - await generateKeyAndExportKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_ECDH, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_42400 - * @tc.name InvalidPurposeMacAlgX25519ForImportKeyCallback - * @tc.desc Invalid purpose mac alg x25519 for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_42400', 0, async function (done) { - await eccGenerateKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_X25519, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_INFO); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_42500 - * @tc.name InvalidPurposeMacAlgEd25519ForImportKeyCallback - * @tc.desc Invalid purpose mac alg ed25519 for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_42500', 0, async function (done) { - await eccGenerateKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_ED25519, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_INFO); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_42600 - * @tc.name InvalidPurposeMacAlgDhForImportKeyCallback - * @tc.desc Invalid purpose mac alg dh for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_42600', 0, async function (done) { - await generateKeyAndExportKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_DH, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_42700 - * @tc.name GenerateAndImportKeySizeDifferentAesForImportKeyCallback - * @tc.desc Generate key and import key have different key size aes for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_42700', 0, async function (done) { - await generateKeyAndExportKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidSizeOption(hks.HuksKeyAlg.HUKS_ALG_AES, publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_INFO); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_42800 - * @tc.name GenerateAndImportKeySizeDifferentRsaForImportKeyCallback - * @tc.desc Generate key and import key have different key size rsa for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_42800', 0, async function (done) { - await generateKeyAndExportKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidSizeOption(hks.HuksKeyAlg.HUKS_ALG_RSA, publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_INFO); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_42900 - * @tc.name GenerateAndImportKeySizeDifferentEccForImportKeyCallback - * @tc.desc Generate key and import key have different key size ecc for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_42900', 0, async function (done) { - var option = eccGenerateKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidSizeOption(hks.HuksKeyAlg.HUKS_ALG_ECC, publicKey); - importOptions.properties[1].value = hks.HuksKeySize.HUKS_ECC_KEY_SIZE_521; - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_INFO); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_43000 - * @tc.name InvalidPurposeDecryptForImportKeyCallback - * @tc.desc Invalid purpose decrypt for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_43000', 0, async function (done) { - await generateKeyAndExportKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidPurposeOrPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_43100 - * @tc.name InvalidPurposeSignForImportKeyCallback - * @tc.desc Invalid purpose sign for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_43100', 0, async function (done) { - await generateKeyAndExportKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidPurposeOrPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_43200 - * @tc.name InvalidPaddingNonePurposeEncryptForImportKeyCallback - * @tc.desc Invalid padding none purpose encrypt for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_43200', 0, async function (done) { - var option = generateImportKeyOption(); - var purpose = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT; - option.properties[2].value = purpose; - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidPurposeOrPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - hks.HuksKeyPadding.HUKS_PADDING_PSS, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_43300 - * @tc.name InvalidPaddingPkcs5PurposeEncryptForImportKeyCallback - * @tc.desc Invalid padding pkcs5 purpose encrypt for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_43300', 0, async function (done) { - var option = generateImportKeyOption(); - var purpose = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT; - option.properties[2].value = purpose; - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidPurposeOrPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - hks.HuksKeyPadding.HUKS_PADDING_PKCS5, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_43400 - * @tc.name InvalidPaddingPkcs7PurposeEncryptForImportKeyCallback - * @tc.desc Invalid padding pkcs7 purpose encrypt for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_43400', 0, async function (done) { - var option = generateImportKeyOption(); - var purpose = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT; - option.properties[2].value = purpose; - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidPurposeOrPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - hks.HuksKeyPadding.HUKS_PADDING_PKCS7, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_43500 - * @tc.name InvalidPaddingNonePurposeVerifyForImportKeyCallback - * @tc.desc Invalid padding none purpose verify for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_43500', 0, async function (done) { - await generateKeyAndExportKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidPurposeOrPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_NONE, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_43600 - * @tc.name InvalidPaddingOaepPurposeVerifyForImportKeyCallback - * @tc.desc Invalid padding oaep purpose verify for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_43600', 0, async function (done) { - await generateKeyAndExportKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidPurposeOrPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_OAEP, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_43700 - * @tc.name InvalidPaddingPkcs5PurposeVerifyForImportKeyCallback - * @tc.desc Invalid padding pkcs5 purpose verify for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_43700', 0, async function (done) { - await generateKeyAndExportKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidPurposeOrPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_PKCS5, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_43800 - * @tc.name InvalidPaddingPkcs7PurposeVerifyForImportKeyCallback - * @tc.desc Invalid padding pkcs7 purpose verify for import key callback. - */ - it('HUKS_ABNORMAL_CALLBACK_43800', 0, async function (done) { - await generateKeyAndExportKey(); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidPurposeOrPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_PKCS7, - publicKey); - hks.importKey(aliasB, importOptions, function (err, data) { - expect(data.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - }); -}); \ No newline at end of file diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_common.test.js b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_common.test.js deleted file mode 100644 index 677bf8dde815ed20a72545d387047766608a417f..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_common.test.js +++ /dev/null @@ -1,790 +0,0 @@ -/* - * 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 hks from '@ohos.security.huks' -import { - makeGenerateKeyOption, - makeImportOption, - makeEncryptAndDecryptOption, - makeSignAndVerifyOption -} from '../../../../../../hks_xts_common.test' -export var alias = 'alias'; -export var aliasEmpty = ''; -export var aliasTooLong = '01234567890123456789012345678901234567890123456789012345678901234'; -export var aliasCritical = '0123456789012345678901234567890123456789012345678901234567890123'; -export var aliasNotExist = 'aliasNotExist'; -export var emptyOption = makeEmptyOption(); -export var plainTextSize128 = makeRandomArr(128); -export var plainTextSize64 = makeRandomArr(64); -export var plainTextSize17 = makeRandomArr(17); -export var plainTextSize16 = makeRandomArr(16); -export var plainTextSize8 = makeRandomArr(8); -export var plainTextSize4 = makeRandomArr(4); -export var invalidValue = 99999; -export var inDataTooLong = makeRandomArr(1000); -export var aliasStrange = '+++++++++++'; -export var invalidValueUint8Array = new Uint8Array(99999); - -export var generateAesCBCKeyOption = makeGenerateKeyOptionForAbnormal( - hks.HuksKeyAlg.HUKS_ALG_AES, - hks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyPadding.HUKS_PADDING_NONE, - hks.HuksCipherMode.HUKS_MODE_CBC, - null -); - -export var generateAesGCMKeyOption = makeGenerateKeyOptionForAbnormal( - hks.HuksKeyAlg.HUKS_ALG_AES, - hks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyPadding.HUKS_PADDING_NONE, - hks.HuksCipherMode.HUKS_MODE_GCM, - null -); - -export var generateRSAKeyOption = makeGenerateKeyOptionForAbnormal( - hks.HuksKeyAlg.HUKS_ALG_RSA, - hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - null, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1 -); - -export var generateECCKeyOption = makeGenerateKeyOptionForAbnormal( - hks.HuksKeyAlg.HUKS_ALG_ECC, - hks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, - null, - null, - hks.HuksKeyDigest.HUKS_DIGEST_NONE -); - -export var generateMACKeyOption = makeGenerateKeyOptionForAbnormal( - hks.HuksKeyAlg.HUKS_ALG_HMAC, - 160, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - null, - null, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1 -); - -export function makeEmptyOption() { - var emptyOptions = { - properties: [] - }; - return emptyOptions; -}; - -export function makeRandomArr(size) { - var arr = new Uint8Array(size); - for (var i = 0; i < size; i++) { - arr[i] = Math.floor(Math.random() * 10); - } - return arr; -}; - -function makeAlgTag(alg) { - var tag = { - tag: hks.HuksTag.HUKS_TAG_ALGORITHM, - value: alg - }; - return tag; -}; - -function makeSizeTag(size) { - var tag = { - tag: hks.HuksTag.HUKS_TAG_KEY_SIZE, - value: size - }; - return tag; -}; - -function makePurposeTag(purpose) { - var tag = { - tag: hks.HuksTag.HUKS_TAG_PURPOSE, - value: purpose - }; - return tag; -}; - -function makePaddingTag(padding) { - var tag = { - tag: hks.HuksTag.HUKS_TAG_PADDING, - value: padding - }; - return tag; -}; - -function makeDigestTag(digest) { - var tag = { - tag: hks.HuksTag.HUKS_TAG_DIGEST, - value: digest - }; - return tag; -}; - -function makeModeTag(mode) { - var tag = { - tag: hks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: mode - }; - return tag; -}; - -export function makeGenerateKeyOptionForAbnormal(alg, size, purpose, padding, mode, digest) { - var properties = new Array(); - properties[0] = makeAlgTag(alg); - properties[1] = makeSizeTag(size); - properties[2] = makePurposeTag(purpose); - if (purpose == (hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT)) { - properties[3] = makePaddingTag(padding); - properties[4] = makeModeTag(mode); - } else if (purpose == (hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY)) { - properties[3] = makePaddingTag(padding); - properties[4] = makeDigestTag(digest); - } else { - properties[3] = makeDigestTag(digest); - } - var option = { - properties: properties - }; - return option; -}; - -export function makeEncryptAndDecryptOptionForAbnormal(mode) { - var properties = new Array(); - var purpose = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT; - properties[0] = makeAlgTag(hks.HuksKeyAlg.HUKS_ALG_AES); - properties[1] = makePurposeTag(purpose); - properties[2] = makeModeTag(mode); - properties[3] = makePaddingTag(hks.HuksKeyPadding.HUKS_PADDING_NONE); - if (mode == hks.HuksCipherMode.HUKS_MODE_CBC) { - properties[4] = { - tag: hks.HuksTag.HUKS_TAG_IV, - value: new Uint8Array(16) - }; - } else { - properties[4] = { - tag: hks.HuksTag.HUKS_TAG_NONCE, - value: new Uint8Array(16) - }; - properties[5] = { - tag: hks.HuksTag.HUKS_TAG_ASSOCIATED_DATA, - value: new Uint8Array(16) - }; - } - var option = { - properties: properties, - inData: plainTextSize64 - }; - return option; -}; - -export function makeSignVerifyAndImportOption(text) { - var properties = new Array(); - properties[0] = makeAlgTag(hks.HuksKeyAlg.HUKS_ALG_RSA); - properties[1] = makePurposeTag(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY); - properties[2] = makePaddingTag(hks.HuksKeyPadding.HUKS_PADDING_NONE); - properties[3] = makeDigestTag(hks.HuksKeyDigest.HUKS_DIGEST_SHA1); - var option = { - properties: properties, - inData: text - }; - return option; -}; - -export function makeAgreeOption() { - var properties = new Array(); - properties[0] = makeAlgTag(hks.HuksKeyAlg.HUKS_ALG_ECDH); - properties[1] = makeSizeTag(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_224); - var options = { - properties: properties, - inData: new Uint8Array(76) - }; - return options; -}; - -export function makeMacOption() { - var properties = new Array(); - properties[0] = { - tag: hks.HuksTag.HUKS_TAG_PURPOSE, - value: hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC - }; - properties[1] = { - tag: hks.HuksTag.HUKS_TAG_DIGEST, - value: hks.HuksKeyDigest.HUKS_DIGEST_SHA1 - }; - var options = { - properties: properties, - inData: plainTextSize16 - }; - return options; -}; - -export function makeAgreeAlgOptions(alg) { - var properties = new Array(); - properties[0] = makeAlgTag(alg); - properties[1] = makeSizeTag(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_224); - var options = { - properties: properties, - inData: new Uint8Array(76) - }; - return options; -}; - -export function makeMacOptions(purpose, digest) { - var properties = new Array(); - properties[0] = { - tag: hks.HuksTag.HUKS_TAG_PURPOSE, - value: purpose - }; - properties[1] = { - tag: hks.HuksTag.HUKS_TAG_DIGEST, - value: digest - }; - var options = { - properties: properties, - inData: plainTextSize16 - }; - return options; -}; - -export function generateAgreeKeyOption() { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_ECC, - hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, - null, - null, - hks.HuksKeyDigest.HUKS_DIGEST_SHA224 - ); - return option; -}; - -export function hmacGenerateKeyOption() { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_HMAC, - hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - null, - null, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1 - ); - return option; -}; - -export function agreeInvalidAlgOption(alg) { - var option = makeAgreeAlgOptions( - alg - ); - return option; -}; - -export function hmacInvalidPurposeOption(purpose, digest) { - var option = makeMacOptions( - purpose, - digest - ); - return option; -}; - -export function encryptOrDecryptGenerateKeyOption() { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_RSA, - hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1 - ); - return option; -}; - -export function encryptOrDecryptOption() { - var option = makeEncryptAndDecryptOption( - hks.HuksKeyAlg.HUKS_ALG_RSA, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1, - plainTextSize16 - ); - return option; -}; - -export function encryptOrDecryptInvalidAlgOption(alg) { - var option = makeEncryptAndDecryptOption( - alg, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - hks.HuksKeyDigest.HUKS_DIGEST_NONE, - plainTextSize16 - ); - return option; -}; - -export function rsaEncryptInvalidSizeOption(size) { - var option = makeEncryptAndDecryptOption( - hks.HuksKeyAlg.HUKS_ALG_RSA, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - hks.HuksCipherMode.HUKS_MODE_ECB, - size, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1, - plainTextSize4 - ); - return option; -}; - -export function aesEncryptOrDecryptInvalidSizeOption(size) { - var option = makeEncryptAndDecryptOption( - hks.HuksKeyAlg.HUKS_ALG_AES, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyPadding.HUKS_PADDING_NONE, - hks.HuksCipherMode.HUKS_MODE_CBC, - size, - hks.HuksKeyDigest.HUKS_DIGEST_NONE, - plainTextSize16 - ); - return option; -}; - -export function aesEncryptOrDecryptInvalidPaddingOption(padding) { - var option = makeEncryptAndDecryptOption( - hks.HuksKeyAlg.HUKS_ALG_AES, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - padding, - hks.HuksCipherMode.HUKS_MODE_GCM, - hks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - hks.HuksKeyDigest.HUKS_DIGEST_NONE, - plainTextSize64 - ); - return option; -}; - -export function aesEncryptOrDecryptInvalidDigestOption(digest) { - var option = makeEncryptAndDecryptOption( - hks.HuksKeyAlg.HUKS_ALG_AES, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyPadding.HUKS_PADDING_NONE, - hks.HuksCipherMode.HUKS_MODE_CBC, - hks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - digest, - plainTextSize16 - ); - return option; -}; - -export function rsaEncryptOrDecryptInvalidIndataOption() { - var option = makeEncryptAndDecryptOption( - hks.HuksKeyAlg.HUKS_ALG_RSA, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyPadding.HUKS_PADDING_NONE, - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - hks.HuksKeyDigest.HUKS_DIGEST_NONE, - plainTextSize128 - ); - return option; -}; - -export function aesEncryptOrDecryptInvalidIndataOption() { - var option = makeEncryptAndDecryptOption( - hks.HuksKeyAlg.HUKS_ALG_AES, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyPadding.HUKS_PADDING_NONE, - hks.HuksCipherMode.HUKS_MODE_GCM, - hks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - hks.HuksKeyDigest.HUKS_DIGEST_NONE, - plainTextSize17 - ); - return option; -}; - -export function aesEncryptOrDecryptInvalidPurposeOption(purpose) { - var option = makeEncryptAndDecryptOption( - hks.HuksKeyAlg.HUKS_ALG_AES, - purpose, - hks.HuksKeyPadding.HUKS_PADDING_NONE, - hks.HuksCipherMode.HUKS_MODE_GCM, - hks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - hks.HuksKeyDigest.HUKS_DIGEST_NONE, - plainTextSize64 - ); - return option; -}; - -export function rsaDecryptInvalidSizeOption(size, cipherText) { - var option = makeEncryptAndDecryptOption( - hks.HuksKeyAlg.HUKS_ALG_RSA, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - hks.HuksCipherMode.HUKS_MODE_ECB, - size, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1, - cipherText - ); - return option; -}; - -export function aesGenerateKeyInvalidSizeOption(size) { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_AES, - size, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyPadding.HUKS_PADDING_NONE, - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeyDigest.HUKS_DIGEST_NONE - ); - return option; -}; - -export function aesGenerateKeyInvalidModeOption(mode, padding) { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_AES, - hks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - padding, - mode, - hks.HuksKeyDigest.HUKS_DIGEST_NONE - ); - return option; -}; - -export function aesGenerateKeyInvalidAlgOption(alg, purpose) { - var option = makeGenerateKeyOption( - alg, - hks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - purpose, - hks.HuksKeyPadding.HUKS_PADDING_NONE, - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeyDigest.HUKS_DIGEST_NONE - ); - return option; -}; - -export var aesGenerateKeyInvalidPurposeOption = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_AES, - hks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyPadding.HUKS_PADDING_NONE, - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeyDigest.HUKS_DIGEST_NONE -); - -export function rsaGenerateKeyInvalidSizeOption(size) { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_RSA, - size, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1 - ); - return option; -}; - -export function rsaGenerateKeyInvalidPaddingOption(purpose, padding) { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_RSA, - hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - purpose, - padding, - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1 - ); - return option; -}; - -export var rsaGenerateKeyInvalidPurposeOption = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_RSA, - hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1 -); - -export function eccGenerateKeyInvalidSizeOption(size) { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_ECC, - size, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - null, - hks.HuksKeyDigest.HUKS_DIGEST_SHA224 - ); - return option; -}; - -export function eccGenerateKeyInvalidDigestOption(digest) { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_ECC, - hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - null, - digest - ); - return option; -}; - -export function eccGenerateKeyInvalidPurposeOption(purpose) { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_ECC, - hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - purpose, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - null, - hks.HuksKeyDigest.HUKS_DIGEST_SHA224 - ); - return option; -}; - -export function ecdhGenerateKeyInvalidAlgOption() { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_ECDH, - hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - null, - hks.HuksKeyDigest.HUKS_DIGEST_SHA224 - ); - return option; -}; - -export function hkdfGenerateKeyInvalidAlgOption() { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_HKDF, - hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - null, - hks.HuksKeyDigest.HUKS_DIGEST_SHA224 - ); - return option; -}; - -export function pbkdf2GenerateKeyInvalidAlgOption() { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_PBKDF2, - hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - null, - hks.HuksKeyDigest.HUKS_DIGEST_SHA224 - ); - return option; -}; - -export function ed25519GenerateKeyInvalidPurposeOption(purpose) { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_ED25519, - hks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256, - purpose, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - null, - hks.HuksKeyDigest.HUKS_DIGEST_NONE - ); - return option; -}; - -export function x25519GenerateKeyInvalidPurposeOption(purpose) { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_X25519, - hks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256, - purpose, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - null, - hks.HuksKeyDigest.HUKS_DIGEST_NONE - ); - return option; -}; - -export function hmacGenerateKeyInvalidSizeOption(size) { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_HMAC, - size, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - null, - hks.HuksKeyDigest.HUKS_DIGEST_SHA256 - ); - return option; -}; - -export function hmacGenerateKeyInvalidPurposeOption(purpose) { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_HMAC, - hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - purpose, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - null, - hks.HuksKeyDigest.HUKS_DIGEST_SHA256 - ); - return option; -}; - -export function dsaGenerateKeyInvalidSizeOption(size) { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_DSA, - size, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1 - ); - return option; -}; - -export function dsaGenerateKeyInvalidPurposeOption(purpose) { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_DSA, - hks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - purpose, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1 - ); - return option; -}; - -export function dhGenerateKeyInvalidPurposeOption(purpose) { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_DH, - hks.HuksKeySize.HUKS_DH_KEY_SIZE_2048, - purpose, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - null, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1 - ); - return option; -}; - -export function generateImportKeyOption() { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_RSA, - hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeyDigest.HUKS_DIGEST_MD5 - ); - return option; -}; - -export function eccGenerateKeyOption() { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_ECC, - hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - null, - hks.HuksKeyDigest.HUKS_DIGEST_SHA224 - ); - return option; -}; - -export function importOptionsInvalidAlgOption(alg, purpose, publicKey) { - var option = makeImportOption( - alg, - hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - purpose, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeyDigest.HUKS_DIGEST_NONE, - publicKey - ); - return option; -}; - -export function importOptionsInvalidSizeOption(alg, publicKey) { - var option = makeImportOption( - alg, - hks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeyDigest.HUKS_DIGEST_NONE, - publicKey - ); - return option; -}; - -export function importOptionsInvalidPurposeOrPaddingOption(purpose, padding, publicKey) { - var option = makeImportOption( - hks.HuksKeyAlg.HUKS_ALG_RSA, - hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - purpose, - padding, - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeyDigest.HUKS_DIGEST_NONE, - publicKey - ); - return option; -}; - -export function signOrVerifyGenerateKeyOption() { - var option = makeGenerateKeyOption( - hks.HuksKeyAlg.HUKS_ALG_RSA, - hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeyDigest.HUKS_DIGEST_NONE - ); - return option; -}; - -export function signOrVerifyInvalidAlgOption(alg) { - var option = makeSignAndVerifyOption( - alg, - hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - hks.HuksKeyDigest.HUKS_DIGEST_NONE, - plainTextSize64 - ); - return option; -}; - -export function signOrVerifyInvalidPurposeOption(purpose) { - var option = makeSignAndVerifyOption( - hks.HuksKeyAlg.HUKS_ALG_RSA, - hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - purpose, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - hks.HuksKeyDigest.HUKS_DIGEST_NONE, - plainTextSize64 - ); - return option; -}; - -export function signOrVerifyInvalidPaddingOption(padding) { - var option = makeSignAndVerifyOption( - hks.HuksKeyAlg.HUKS_ALG_RSA, - hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - padding, - hks.HuksKeyDigest.HUKS_DIGEST_NONE, - plainTextSize64 - ); - return option; -}; \ No newline at end of file diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_promise.test.js b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_promise.test.js deleted file mode 100644 index d4afc8f2d9dc197fb9a2dc2a32b1c3d6bd7a8df5..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_promise.test.js +++ /dev/null @@ -1,1425 +0,0 @@ -/* - * 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 hks from '@ohos.security.huks' -import {describe, it, expect} from 'deccjsunit/index' -import { - alias, - aliasEmpty, - aliasTooLong, - aliasCritical, - aliasNotExist, - emptyOption, - invalidValue, - generateAesCBCKeyOption, - generateAesGCMKeyOption, - generateRSAKeyOption, - generateECCKeyOption, - generateMACKeyOption, - plainTextSize8, - plainTextSize16, - plainTextSize64, - makeAgreeOption, - makeEncryptAndDecryptOption, - makeMacOption, - makeSignVerifyAndImportOption -} from './hks_abnormal_common.test.js' - -describe('Hks_XtsTest_Abnormal_Promise', function () { - - async function generateAesKey(mode){ - var option = {}; - if (mode == 'CBC') { - option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - } else { - option = JSON.parse(JSON.stringify(generateAesGCMKeyOption)); - } - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_SUCCESS); - }; - - async function deleteKeyPromise(alias, done){ - var ret = await hks.deleteKey(alias, emptyOption); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_SUCCESS); - done(); - }; - - async function generateRsaKey(){ - var option = generateRSAKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_SUCCESS); - }; - - async function generateEccKey(){ - var option = generateECCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_SUCCESS); - }; - - async function generateMacKey(){ - var option = generateMACKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_SUCCESS); - }; - - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_00100 - * @tc.name HUKS_ABNORMAL_PROMISE_00100 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_00100', 0, async function (done) { - var genKeyRet = await hks.generateKey(aliasEmpty, generateAesCBCKeyOption); - expect(genKeyRet.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_00200 - * @tc.name HUKS_ABNORMAL_PROMISE_00200 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_00200', 0, async function (done) { - var genKeyRet = await hks.generateKey(aliasCritical, generateAesCBCKeyOption); - expect(genKeyRet.errorCode).assertEqual(hks.HksErrorCode.HKS_SUCCESS); - var deleteKeyRet = await hks.deleteKey(aliasCritical, emptyOption); - expect(deleteKeyRet.errorCode).assertEqual(hks.HksErrorCode.HKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_00300 - * @tc.name HUKS_ABNORMAL_PROMISE_00300 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_00300', 0, async function (done) { - var genKeyRet = await hks.generateKey(aliasTooLong, generateAesCBCKeyOption); - expect(genKeyRet.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_00400 - * @tc.name HUKS_ABNORMAL_PROMISE_00400 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_00400', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties.splice(0, 1); - var genKeyRet = await hks.generateKey(alias, option); - expect(genKeyRet.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_ALG_FAIL); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_00500 - * @tc.name HUKS_ABNORMAL_PROMISE_00500 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_00500', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties.splice(1, 1); - var genKeyRet = await hks.generateKey(alias, option); - expect(genKeyRet.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_00600 - * @tc.name HUKS_ABNORMAL_PROMISE_00600 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_00600', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties.splice(2, 1); - var genKeyRet = await hks.generateKey(alias, option); - expect(genKeyRet.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_PURPOSE_FAIL); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_00700 - * @tc.name HUKS_ABNORMAL_PROMISE_00700 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_00700', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties.splice(3, 1); - var genKeyRet = await hks.generateKey(alias, option); - expect(genKeyRet.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_PADDING_FAIL); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_00800 - * @tc.name HUKS_ABNORMAL_PROMISE_00800 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_00800', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties.splice(4, 1); - var genKeyRet = await hks.generateKey(alias, option); - expect(genKeyRet.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_MODE_FAIL); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_00900 - * @tc.name HUKS_ABNORMAL_PROMISE_00900 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_00900', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties[0].value = invalidValue; - var genKeyRet = await hks.generateKey(alias, option); - expect(genKeyRet.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_01000 - * @tc.name HUKS_ABNORMAL_PROMISE_01000 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_01000', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties[1].value = invalidValue; - var genKeyRet = await hks.generateKey(alias, option); - expect(genKeyRet.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_01100 - * @tc.name HUKS_ABNORMAL_PROMISE_01100 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_01100', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties[2].value = invalidValue; - var genKeyRet = await hks.generateKey(alias, option); - expect(genKeyRet.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_01200 - * @tc.name HUKS_ABNORMAL_PROMISE_01200 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_01200', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties[3].value = invalidValue; - var genKeyRet = await hks.generateKey(alias, option); - expect(genKeyRet.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_01300 - * @tc.name HUKS_ABNORMAL_PROMISE_01300 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_01300', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties[4].value = invalidValue; - var genKeyRet = await hks.generateKey(alias, option); - expect(genKeyRet.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_MODE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_01400 - * @tc.name HUKS_ABNORMAL_PROMISE_01400 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_01400', 0, async function (done) { - var ret = await hks.deleteKey(aliasNotExist, emptyOption); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_NOT_EXIST); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_01500 - * @tc.name HUKS_ABNORMAL_PROMISE_01500 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_01500', 0, async function (done) { - var ret = await hks.deleteKey(aliasEmpty, emptyOption); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_01600 - * @tc.name HUKS_ABNORMAL_PROMISE_01600 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_01600', 0, async function (done) { - var ret = await hks.deleteKey(aliasTooLong, emptyOption); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_01700 - * @tc.name HUKS_ABNORMAL_PROMISE_01700 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_01700', 0, async function (done) { - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - var ret = await hks.encrypt(aliasEmpty, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_01800 - * @tc.name HUKS_ABNORMAL_PROMISE_01800 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_01800', 0, async function (done) { - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - var ret = await hks.encrypt(aliasNotExist, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_NOT_EXIST); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_01900 - * @tc.name HUKS_ABNORMAL_PROMISE_01900 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_01900', 0, async function (done) { - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - var ret = await hks.encrypt(aliasTooLong, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_02000 - * @tc.name HUKS_ABNORMAL_PROMISE_02000 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_02000', 0, async function (done) { - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - var ret = await hks.encrypt(aliasTooLong, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_02100 - * @tc.name HUKS_ABNORMAL_PROMISE_02100 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_02100', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties.splice(0, 1); - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_ALG_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_02200 - * @tc.name HUKS_ABNORMAL_PROMISE_02200 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_02200', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties.splice(1, 1); - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_PURPOSE_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_02300 - * @tc.name HUKS_ABNORMAL_PROMISE_02300 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_02300', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties.splice(2, 1); - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_MODE_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_02400 - * @tc.name HUKS_ABNORMAL_PROMISE_02400 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_02400', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties.splice(3, 1); - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_PADDING_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_02500 - * @tc.name HUKS_ABNORMAL_PROMISE_02500 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_02500', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties.splice(4, 1); - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_IV_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_02600 - * @tc.name HUKS_ABNORMAL_PROMISE_02600 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_02600', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_GCM); - option.properties.splice(4, 1); - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_NONCE_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_02700 - * @tc.name HUKS_ABNORMAL_PROMISE_02700 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_02700', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_GCM); - option.properties.splice(5, 1); - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_AAD_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_02800 - * @tc.name HUKS_ABNORMAL_PROMISE_02800 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_02800', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties[0].value = invalidValue; - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ALGORITHM); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_02900 - * @tc.name HUKS_ABNORMAL_PROMISE_02900 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_02900', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties[1].value = invalidValue; - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_03000 - * @tc.name HUKS_ABNORMAL_PROMISE_03000 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_03000', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties[2].value = invalidValue; - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_MODE); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_03100 - * @tc.name HUKS_ABNORMAL_PROMISE_03100 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_03100', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties[3].value = invalidValue; - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_PADDING); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_03200 - * @tc.name HUKS_ABNORMAL_PROMISE_03200 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_03200', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_GCM); - option.inData = new Uint8Array(0); - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_03300 - * @tc.name HUKS_ABNORMAL_PROMISE_03300 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_03300', 0, async function (done) { - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - var ret = await hks.decrypt(aliasEmpty, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_03400 - * @tc.name HUKS_ABNORMAL_PROMISE_03400 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_03400', 0, async function (done) { - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - var ret = await hks.decrypt(aliasNotExist, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_NOT_EXIST); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_03500 - * @tc.name HUKS_ABNORMAL_PROMISE_03500 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_03500', 0, async function (done) { - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - var ret = await hks.decrypt(aliasTooLong, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_03600 - * @tc.name HUKS_ABNORMAL_PROMISE_03600 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_03600', 0, async function (done) { - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - var ret = await hks.decrypt(aliasTooLong, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_03700 - * @tc.name HUKS_ABNORMAL_PROMISE_03700 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_03700', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties.splice(0, 1); - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_ALG_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_03800 - * @tc.name HUKS_ABNORMAL_PROMISE_03800 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_03800', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties.splice(1, 1); - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_PURPOSE_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_03900 - * @tc.name HUKS_ABNORMAL_PROMISE_03900 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_03900', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties.splice(2, 1); - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_MODE_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_04000 - * @tc.name HUKS_ABNORMAL_PROMISE_04000 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_04000', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties.splice(3, 1); - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_PADDING_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_04100 - * @tc.name HUKS_ABNORMAL_PROMISE_04100 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_04100', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties.splice(4, 1); - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_IV_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_04200 - * @tc.name HUKS_ABNORMAL_PROMISE_04200 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_04200', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_GCM); - option.properties.splice(4, 1); - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_NONCE_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_04300 - * @tc.name HUKS_ABNORMAL_PROMISE_04300 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_04300', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_GCM); - option.properties.splice(5, 1); - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_AAD_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_04400 - * @tc.name HUKS_ABNORMAL_PROMISE_04400 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_04400', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties[0].value = invalidValue; - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ALGORITHM); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_04500 - * @tc.name HUKS_ABNORMAL_PROMISE_04500 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_04500', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties[1].value = invalidValue; - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_04600 - * @tc.name HUKS_ABNORMAL_PROMISE_04600 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_04600', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties[2].value = invalidValue; - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_MODE); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_04700 - * @tc.name HUKS_ABNORMAL_PROMISE_04700 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_04700', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_CBC); - option.properties[3].value = invalidValue; - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_PADDING); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_04800 - * @tc.name HUKS_ABNORMAL_PROMISE_04800 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_04800', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOption(hks.HksCipherMode.HKS_MODE_GCM); - option.inData = new Uint8Array(0); - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_04900 - * @tc.name HUKS_ABNORMAL_PROMISE_04900 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_04900', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - var ret = await hks.importKey(aliasEmpty, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_05000 - * @tc.name HUKS_ABNORMAL_PROMISE_05000 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_05000', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - var ret = await hks.importKey(aliasCritical, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_05100 - * @tc.name HUKS_ABNORMAL_PROMISE_05100 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_05100', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - var ret = await hks.importKey(aliasTooLong, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_05200 - * @tc.name HUKS_ABNORMAL_PROMISE_05200 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_05200', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(0, 1); - var ret = await hks.importKey(aliasNotExist, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_ALG_FAIL); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_05300 - * @tc.name HUKS_ABNORMAL_PROMISE_05300 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_05300', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(1, 1); - var ret = await hks.importKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_05400 - * @tc.name HUKS_ABNORMAL_PROMISE_05400 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_05400', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(2, 1); - var ret = await hks.importKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_05500 - * @tc.name HUKS_ABNORMAL_PROMISE_05500 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_05500', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(3, 1); - var ret = await hks.importKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_05600 - * @tc.name HUKS_ABNORMAL_PROMISE_05600 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_05600', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[0].value = invalidValue; - var ret = await hks.importKey(aliasNotExist, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ALGORITHM); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_05700 - * @tc.name HUKS_ABNORMAL_PROMISE_05700 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_05700', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[1].value = invalidValue; - var ret = await hks.importKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_05800 - * @tc.name HUKS_ABNORMAL_PROMISE_05800 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_05800', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[2].value = invalidValue; - var ret = await hks.importKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_05900 - * @tc.name HUKS_ABNORMAL_PROMISE_05900 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_05900', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[3].value = invalidValue; - var ret = await hks.importKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_06000 - * @tc.name HUKS_ABNORMAL_PROMISE_06000 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_06000', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.inData = new Uint8Array(0); - var ret = await hks.importKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_06100 - * @tc.name HUKS_ABNORMAL_PROMISE_06100 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_06100', 0, async function (done) { - var ret = await hks.exportKey(aliasNotExist, emptyOption); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_NOT_EXIST); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_06200 - * @tc.name HUKS_ABNORMAL_PROMISE_06200 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_06200', 0, async function (done) { - var ret = await hks.exportKey(aliasTooLong, emptyOption); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_06300 - * @tc.name HUKS_ABNORMAL_PROMISE_06300 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_06300', 0, async function (done) { - var ret = await hks.exportKey(aliasEmpty, emptyOption); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_06400 - * @tc.name HUKS_ABNORMAL_PROMISE_06400 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_06400', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - var ret = await hks.sign(aliasNotExist, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_NOT_EXIST); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_06500 - * @tc.name HUKS_ABNORMAL_PROMISE_06500 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_06500', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - var ret = await hks.sign(aliasTooLong, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_06600 - * @tc.name HUKS_ABNORMAL_PROMISE_06600 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_06600', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - var ret = await hks.sign(aliasEmpty, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_06700 - * @tc.name HUKS_ABNORMAL_PROMISE_06700 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_06700', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[0].value = invalidValue; - var ret = await hks.sign(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ALGORITHM); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_06800 - * @tc.name HUKS_ABNORMAL_PROMISE_06800 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_06800', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[1].value = invalidValue; - var ret = await hks.sign(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_06900 - * @tc.name HUKS_ABNORMAL_PROMISE_06900 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_06900', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties[2].value = invalidValue; - var ret = await hks.sign(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_07000 - * @tc.name HUKS_ABNORMAL_PROMISE_07000 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_07000', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties[3].value = invalidValue; - var ret = await hks.sign(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_07100 - * @tc.name HUKS_ABNORMAL_PROMISE_07100 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_07100', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.inData = new Uint8Array(0); - var ret = await hks.sign(aliasEmpty, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_07200 - * @tc.name HUKS_ABNORMAL_PROMISE_07200 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_07200', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(0, 1); - var ret = await hks.sign(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_ALG_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_07300 - * @tc.name HUKS_ABNORMAL_PROMISE_07300 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_07300', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(1, 1); - var ret = await hks.sign(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_07400 - * @tc.name HUKS_ABNORMAL_PROMISE_07400 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_07400', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties.splice(2, 1); - var ret = await hks.sign(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_07500 - * @tc.name HUKS_ABNORMAL_PROMISE_07500 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_07500', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties.splice(3, 1); - var ret = await hks.sign(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_07600 - * @tc.name HUKS_ABNORMAL_PROMISE_07600 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_07600', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - var ret = await hks.verify(aliasNotExist, option, plainTextSize64); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_NOT_EXIST); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_07700 - * @tc.name HUKS_ABNORMAL_PROMISE_07700 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_07700', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - var ret = await hks.verify(aliasTooLong, option, plainTextSize64); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_07800 - * @tc.name HUKS_ABNORMAL_PROMISE_07800 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_07800', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - var ret = await hks.verify(aliasEmpty, option, plainTextSize64); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_07900 - * @tc.name HUKS_ABNORMAL_PROMISE_07900 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_07900', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[0].value = invalidValue; - var ret = await hks.verify(alias, option, plainTextSize64); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ALGORITHM); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_08000 - * @tc.name HUKS_ABNORMAL_PROMISE_08000 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_08000', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties[1].value = invalidValue; - var ret = await hks.verify(alias, option, plainTextSize8); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_08100 - * @tc.name HUKS_ABNORMAL_PROMISE_08100 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_08100', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties[2].value = invalidValue; - var ret = await hks.verify(alias, option, plainTextSize8); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_08200 - * @tc.name HUKS_ABNORMAL_PROMISE_08200 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_08200', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties[3].value = invalidValue; - var ret = await hks.verify(alias, option, plainTextSize8); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_08300 - * @tc.name HUKS_ABNORMAL_PROMISE_08300 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_08300', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize16); - option.inData = new Uint8Array(0); - var ret = await hks.verify(alias, option, plainTextSize64); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_08400 - * @tc.name HUKS_ABNORMAL_PROMISE_08400 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_08400', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(0, 1); - var ret = await hks.verify(alias, option, plainTextSize64); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_ALG_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_08500 - * @tc.name HUKS_ABNORMAL_PROMISE_08500 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_08500', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(1, 1); - var ret = await hks.verify(aliasNotExist, option, plainTextSize64); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_NOT_EXIST); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_08600 - * @tc.name HUKS_ABNORMAL_PROMISE_08600 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_08600', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties.splice(2, 1); - var ret = await hks.verify(alias, option, plainTextSize8); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_08700 - * @tc.name HUKS_ABNORMAL_PROMISE_08700 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_08700', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(3, 1); - var ret = await hks.verify(alias, option, plainTextSize64); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_08800 - * @tc.name HUKS_ABNORMAL_PROMISE_08800 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_08800', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[0].value = invalidValue; - var ret = await hks.verify(alias, option, plainTextSize64); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ALGORITHM); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_08900 - * @tc.name HUKS_ABNORMAL_PROMISE_08900 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_08900', 0, async function (done) { - var option = makeAgreeOption(); - var ret = await hks.agreeKey(aliasEmpty, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_09000 - * @tc.name HUKS_ABNORMAL_PROMISE_09000 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_09000', 0, async function (done) { - await generateEccKey(); - var option = makeAgreeOption(); - option.properties[0].value = invalidValue; - var ret = await hks.agreeKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ALGORITHM); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_09100 - * @tc.name HUKS_ABNORMAL_PROMISE_09100 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_09100', 0, async function (done) { - await generateEccKey(); - var option = makeAgreeOption(); - option.properties[1].value = invalidValue; - var ret = await hks.agreeKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_09200 - * @tc.name HUKS_ABNORMAL_PROMISE_09200 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_09200', 0, async function (done) { - await generateEccKey(); - var option = makeAgreeOption(); - option.inData = new Uint8Array(0); - var ret = await hks.agreeKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_09300 - * @tc.name HUKS_ABNORMAL_PROMISE_09300 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_09300', 0, async function (done) { - await generateEccKey(); - var option = makeAgreeOption(); - option.properties.splice(0, 1); - var ret = await hks.agreeKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_ALG_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_09400 - * @tc.name HUKS_ABNORMAL_PROMISE_09400 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_09400', 0, async function (done) { - await generateEccKey(); - var option = makeAgreeOption(); - option.properties[1].value = invalidValue; - var ret = await hks.agreeKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_09500 - * @tc.name HUKS_ABNORMAL_PROMISE_09500 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_09500', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - var ret = await hks.mac(aliasNotExist, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_NOT_EXIST); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_09600 - * @tc.name HUKS_ABNORMAL_PROMISE_09600 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_09600', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - var ret = await hks.mac(aliasTooLong, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_09700 - * @tc.name HUKS_ABNORMAL_PROMISE_09700 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_09700', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - var ret = await hks.mac(aliasEmpty, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_09800 - * @tc.name HUKS_ABNORMAL_PROMISE_09800 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_09800', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - option.properties[0].value = invalidValue; - var ret = await hks.mac(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_PURPOSE); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_09900 - * @tc.name HUKS_ABNORMAL_PROMISE_09900 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_09900', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - option.properties[1].value = invalidValue; - var ret = await hks.mac(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_DIGEST); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_10000 - * @tc.name HUKS_ABNORMAL_PROMISE_10000 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_10000', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - option.inData = new Uint8Array(0); - var ret = await hks.mac(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_INVALID_ARGUMENT); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_10100 - * @tc.name HUKS_ABNORMAL_PROMISE_10100 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_10100', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - option.properties.splice(0, 1); - var ret = await hks.mac(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_PURPOSE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_10200 - * @tc.name HUKS_ABNORMAL_PROMISE_10200 - * @tc.desc Abnormal with promise. - */ - it('HUKS_ABNORMAL_PROMISE_10200', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - option.properties.splice(1, 1); - var ret = await hks.mac(alias, option); - expect(ret.errorCode).assertEqual(hks.HksErrorCode.HKS_ERROR_CHECK_GET_DIGEST_FAIL); - deleteKeyPromise(alias, done); - }); -}); \ No newline at end of file diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_promise_part1.test.js b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_promise_part1.test.js deleted file mode 100644 index 6fd66247c2773bde33c2fdaf989b9764769e65a5..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_promise_part1.test.js +++ /dev/null @@ -1,1525 +0,0 @@ -/* - * 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 hks from '@ohos.security.huks' -import { describe, it, expect } from 'deccjsunit/index' -import { - alias, - aliasEmpty, - aliasTooLong, - aliasCritical, - aliasNotExist, - emptyOption, - invalidValue, - generateAesCBCKeyOption, - generateAesGCMKeyOption, - generateRSAKeyOption, - generateECCKeyOption, - generateMACKeyOption, - plainTextSize8, - plainTextSize16, - plainTextSize64, - makeAgreeOption, - makeEncryptAndDecryptOptionForAbnormal, - makeMacOption, - makeSignVerifyAndImportOption, - inDataTooLong, - aliasStrange, - invalidValueUint8Array -} from './hks_abnormal_common.test.js' - -describe('Hks_Abnormal_Promise_Part1', function () { - - async function generateAesKey(mode) { - var option = {}; - if (mode == 'CBC') { - option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - } else { - option = JSON.parse(JSON.stringify(generateAesGCMKeyOption)); - } - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - }; - - async function deleteKeyPromise(alias, done) { - var ret = await hks.deleteKey(alias, emptyOption); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }; - - async function generateRsaKey() { - var option = generateRSAKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - }; - - async function generateEccKey() { - var option = generateECCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - }; - - async function generateMacKey() { - var option = generateMACKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - }; - - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_00100 - * @tc.name GenerateKeyPromiseEmptyAlias - * @tc.desc Generate key promise with empty alias. - */ - it('HUKS_ABNORMAL_PROMISE_00100', 0, async function (done) { - var genKeyRet = await hks.generateKey(aliasEmpty, generateAesCBCKeyOption); - expect(genKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_00200 - * @tc.name GenerateKeyPromiseCriticalAlias - * @tc.desc Generate key promise with critical length alias. - */ - it('HUKS_ABNORMAL_PROMISE_00200', 0, async function (done) { - var genKeyRet = await hks.generateKey(aliasCritical, generateAesCBCKeyOption); - expect(genKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var deleteKeyRet = await hks.deleteKey(aliasCritical, emptyOption); - expect(deleteKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_00300 - * @tc.name GenerateKeyPromiseLongAlias - * @tc.desc Generate key promise with too long alias. - */ - it('HUKS_ABNORMAL_PROMISE_00300', 0, async function (done) { - var genKeyRet = await hks.generateKey(aliasTooLong, generateAesCBCKeyOption); - expect(genKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_00400 - * @tc.name GenerateKeyPromiseLackAlgTag - * @tc.desc Generate key promise lack of alg tag. - */ - it('HUKS_ABNORMAL_PROMISE_00400', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties.splice(0, 1); - var genKeyRet = await hks.generateKey(alias, option); - expect(genKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_ALG_FAIL); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_00500 - * @tc.name GenerateKeyPromiseLackSizeTag - * @tc.desc Generate key promise lack of size tag. - */ - it('HUKS_ABNORMAL_PROMISE_00500', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties.splice(1, 1); - var genKeyRet = await hks.generateKey(alias, option); - expect(genKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_00600 - * @tc.name GenerateKeyPromiseLackPurposeTag - * @tc.desc Generate key promise lack of purpose tag. - */ - it('HUKS_ABNORMAL_PROMISE_00600', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties.splice(2, 1); - var genKeyRet = await hks.generateKey(alias, option); - expect(genKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_PURPOSE_FAIL); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_00700 - * @tc.name GenerateKeyPromiseLackPaddingTag - * @tc.desc Generate key promise lack of padding tag. - */ - it('HUKS_ABNORMAL_PROMISE_00700', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties.splice(3, 1); - var genKeyRet = await hks.generateKey(alias, option); - expect(genKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_PADDING_FAIL); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_00800 - * @tc.name GenerateKeyPromiseLackModeTag - * @tc.desc Generate key promise lack of mode tag. - */ - it('HUKS_ABNORMAL_PROMISE_00800', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties.splice(4, 1); - var genKeyRet = await hks.generateKey(alias, option); - expect(genKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_MODE_FAIL); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_00900 - * @tc.name InvalidAlgTagForGeneratingKeyPromise - * @tc.desc Invalid value of alg tag for generating key promise. - */ - it('HUKS_ABNORMAL_PROMISE_00900', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties[0].value = invalidValue; - var genKeyRet = await hks.generateKey(alias, option); - expect(genKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_01000 - * @tc.name InvalidSizeTagForGeneratingKeyPromise - * @tc.desc Invalid value of size tag for generating key promise. - */ - it('HUKS_ABNORMAL_PROMISE_01000', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties[1].value = invalidValue; - var genKeyRet = await hks.generateKey(alias, option); - expect(genKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_01100 - * @tc.name InvalidPurposeTagForGeneratingKeyPromise - * @tc.desc Invalid value of purpose tag for generating key promise. - */ - it('HUKS_ABNORMAL_PROMISE_01100', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties[2].value = invalidValue; - var genKeyRet = await hks.generateKey(alias, option); - expect(genKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_01200 - * @tc.name InvalidPaddingTagForGeneratingKeyPromise - * @tc.desc Invalid value of padding tag for generating key promise. - */ - it('HUKS_ABNORMAL_PROMISE_01200', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties[3].value = invalidValue; - var genKeyRet = await hks.generateKey(alias, option); - expect(genKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_01300 - * @tc.name InvalidModeTagForGeneratingKeyPromise - * @tc.desc Invalid value of mode tag for generating key promise. - */ - it('HUKS_ABNORMAL_PROMISE_01300', 0, async function (done) { - var option = JSON.parse(JSON.stringify(generateAesCBCKeyOption)); - option.properties[4].value = invalidValue; - var genKeyRet = await hks.generateKey(alias, option); - expect(genKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_MODE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_01400 - * @tc.name DeletekeyPromiseNotExistAlias - * @tc.desc Delete key promise with not exist alias. - */ - it('HUKS_ABNORMAL_PROMISE_01400', 0, async function (done) { - var ret = await hks.deleteKey(aliasNotExist, emptyOption); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_NOT_EXIST); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_01500 - * @tc.name DeletekeyPromiseEmptyAlias - * @tc.desc Delete key promise with empty alias. - */ - it('HUKS_ABNORMAL_PROMISE_01500', 0, async function (done) { - var ret = await hks.deleteKey(aliasEmpty, emptyOption); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_01600 - * @tc.name DeletekeyPromiseLongAlias - * @tc.desc Delete key promise with too long alias. - */ - it('HUKS_ABNORMAL_PROMISE_01600', 0, async function (done) { - var ret = await hks.deleteKey(aliasTooLong, emptyOption); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_01700 - * @tc.name EncryptPromiseEmptyAlias - * @tc.desc Encrypt promise with empty alias. - */ - it('HUKS_ABNORMAL_PROMISE_01700', 0, async function (done) { - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - var ret = await hks.encrypt(aliasEmpty, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_01800 - * @tc.name EncryptPromiseNotExistAlias - * @tc.desc Encrypt promise with not exist alias. - */ - it('HUKS_ABNORMAL_PROMISE_01800', 0, async function (done) { - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - var ret = await hks.encrypt(aliasNotExist, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_NOT_EXIST); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_01900 - * @tc.name EncryptPromiseCriticalAlias - * @tc.desc Encrypt promise with critical length alias. - */ - it('HUKS_ABNORMAL_PROMISE_01900', 0, async function (done) { - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - var ret = await hks.encrypt(aliasCritical, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_NOT_EXIST); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_02000 - * @tc.name EncryptPromiseLongAlias - * @tc.desc Encrypt promise with too long alias. - */ - it('HUKS_ABNORMAL_PROMISE_02000', 0, async function (done) { - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - var ret = await hks.encrypt(aliasTooLong, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_02100 - * @tc.name EncryptPromiseLackAlgTag - * @tc.desc Encrypt promise lack of alg tag. - */ - it('HUKS_ABNORMAL_PROMISE_02100', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties.splice(0, 1); - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_ALG_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_02200 - * @tc.name EncryptPromiseLackPurposeTag - * @tc.desc Encrypt promise lack of purpose tag. - */ - it('HUKS_ABNORMAL_PROMISE_02200', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties.splice(1, 1); - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_PURPOSE_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_02300 - * @tc.name EncryptPromiseLackModeTag - * @tc.desc Encrypt promise lack of mode tag. - */ - it('HUKS_ABNORMAL_PROMISE_02300', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties.splice(2, 1); - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_MODE_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_02400 - * @tc.name EncryptPromiseLackPaddingTag - * @tc.desc Encrypt promise lack of padding tag. - */ - it('HUKS_ABNORMAL_PROMISE_02400', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties.splice(3, 1); - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_PADDING_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_02500 - * @tc.name EncryptPromiseLackIvTag - * @tc.desc Encrypt promise lack of iv tag. - */ - it('HUKS_ABNORMAL_PROMISE_02500', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties.splice(4, 1); - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_IV_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_02600 - * @tc.name EncryptPromiseLackNonceTag - * @tc.desc Encrypt promise lack of nonce tag. - */ - it('HUKS_ABNORMAL_PROMISE_02600', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_GCM); - option.properties.splice(4, 1); - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_NONCE_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_02700 - * @tc.name EncryptPromiseLackAssociatedDataTag - * @tc.desc Encrypt promise lack of associated data tag. - */ - it('HUKS_ABNORMAL_PROMISE_02700', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_GCM); - option.properties.splice(5, 1); - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_AAD_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_02800 - * @tc.name InvalidAlgTagForEncryptPromise - * @tc.desc Invalid value of alg tag for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_02800', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties[0].value = invalidValue; - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_02900 - * @tc.name InvalidPurposeTagForEncryptPromise - * @tc.desc Invalid value of purpose tag for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_02900', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties[1].value = invalidValue; - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_03000 - * @tc.name InvalidModeTagForEncryptPromise - * @tc.desc Invalid value of mode tag for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_03000', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties[2].value = invalidValue; - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_MODE); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_03100 - * @tc.name InvalidPaddingTagForEncryptPromise - * @tc.desc Invalid value of padding tag for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_03100', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties[3].value = invalidValue; - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_03200 - * @tc.name InvalidIndataOfOptionForEncryptPromise - * @tc.desc Invalid indata of option for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_03200', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_GCM); - option.inData = new Uint8Array(0); - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_03300 - * @tc.name DecryptPromiseEmptyAlias - * @tc.desc Decrypt promise with empty alias. - */ - it('HUKS_ABNORMAL_PROMISE_03300', 0, async function (done) { - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - var ret = await hks.decrypt(aliasEmpty, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_03400 - * @tc.name DecryptPromiseNotExistAlias - * @tc.desc Decrypt promise with not exist alias. - */ - it('HUKS_ABNORMAL_PROMISE_03400', 0, async function (done) { - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - var ret = await hks.decrypt(aliasNotExist, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_NOT_EXIST); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_03500 - * @tc.name DecryptPromiseCriticalAlias - * @tc.desc Decrypt promise with critical length alias. - */ - it('HUKS_ABNORMAL_PROMISE_03500', 0, async function (done) { - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - var ret = await hks.decrypt(aliasCritical, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_NOT_EXIST); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_03600 - * @tc.name DecryptPromiseLongAlias - * @tc.desc Decrypt promise with too long alias. - */ - it('HUKS_ABNORMAL_PROMISE_03600', 0, async function (done) { - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - var ret = await hks.decrypt(aliasTooLong, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_03700 - * @tc.name DecryptPromiseLackAlgTag - * @tc.desc Decrypt promise lack of alg tag. - */ - it('HUKS_ABNORMAL_PROMISE_03700', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties.splice(0, 1); - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_ALG_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_03800 - * @tc.name DecryptPromiseLackPurposeTag - * @tc.desc Decrypt promise lack of purpose tag. - */ - it('HUKS_ABNORMAL_PROMISE_03800', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties.splice(1, 1); - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_PURPOSE_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_03900 - * @tc.name DecryptPromiseLackModeTag - * @tc.desc Decrypt promise lack of mode tag. - */ - it('HUKS_ABNORMAL_PROMISE_03900', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties.splice(2, 1); - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_MODE_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_04000 - * @tc.name DecryptPromiseLackPaddingTag - * @tc.desc Decrypt promise lack of padding tag. - */ - it('HUKS_ABNORMAL_PROMISE_04000', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties.splice(3, 1); - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_PADDING_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_04100 - * @tc.name DecryptPromiseLackIvTag - * @tc.desc Decrypt promise lack of iv tag. - */ - it('HUKS_ABNORMAL_PROMISE_04100', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties.splice(4, 1); - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_IV_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_04200 - * @tc.name DecryptPromiseLackNonceTag - * @tc.desc Decrypt promise lack of nonce tag. - */ - it('HUKS_ABNORMAL_PROMISE_04200', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_GCM); - option.properties.splice(4, 1); - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_NONCE_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_04300 - * @tc.name DecryptPromiseLackAssociatedDataTag - * @tc.desc Decrypt promise lack of associated data tag. - */ - it('HUKS_ABNORMAL_PROMISE_04300', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_GCM); - option.properties.splice(5, 1); - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_AAD_FAIL); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_04400 - * @tc.name InvalidAlgTagForDecryptPromise - * @tc.desc Invalid value of alg tag for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_04400', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties[0].value = invalidValue; - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_04500 - * @tc.name InvalidPurposeTagForDecryptPromise - * @tc.desc Invalid value of purpose tag for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_04500', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties[1].value = invalidValue; - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_04600 - * @tc.name InvalidModeTagForDecryptPromise - * @tc.desc Invalid value of mode tag for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_04600', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties[2].value = invalidValue; - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_MODE); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_04700 - * @tc.name InvalidPaddingTagForDecryptPromise - * @tc.desc Invalid value of padding tag for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_04700', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties[3].value = invalidValue; - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_04800 - * @tc.name InvalidIndataOfOptionForDecryptPromise - * @tc.desc Invalid indata of option for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_04800', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_GCM); - option.inData = new Uint8Array(0); - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_04900 - * @tc.name ImportKeyPromiseEmptyAlias - * @tc.desc Import key promise with empty alias. - */ - it('HUKS_ABNORMAL_PROMISE_04900', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - var ret = await hks.importKey(aliasEmpty, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_05000 - * @tc.name ImportKeyPromiseCriticalAlias - * @tc.desc Import key promise with critical length alias. - */ - it('HUKS_ABNORMAL_PROMISE_05000', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - var ret = await hks.importKey(aliasCritical, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_05100 - * @tc.name ImportKeyPromiseLongAlias - * @tc.desc Import key promise with too long alias. - */ - it('HUKS_ABNORMAL_PROMISE_05100', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - var ret = await hks.importKey(aliasTooLong, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_05200 - * @tc.name ImportKeyPromiseLackAlgTag - * @tc.desc Import key promise lack of alg tag. - */ - it('HUKS_ABNORMAL_PROMISE_05200', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(0, 1); - var ret = await hks.importKey(aliasNotExist, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_ALG_FAIL); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_05300 - * @tc.name ImportKeyPromiseLackPurposeTag - * @tc.desc Import key promise lack of purpose tag. - */ - it('HUKS_ABNORMAL_PROMISE_05300', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(1, 1); - var ret = await hks.importKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_05400 - * @tc.name ImportKeyPromiseLackPaddingTag - * @tc.desc Import key promise lack of padding tag. - */ - it('HUKS_ABNORMAL_PROMISE_05400', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(2, 1); - var ret = await hks.importKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_05500 - * @tc.name ImportKeyPromiseLackDigestTag - * @tc.desc Import key promise lack of digest tag. - */ - it('HUKS_ABNORMAL_PROMISE_05500', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(3, 1); - var ret = await hks.importKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_05600 - * @tc.name InvalidAlgTagForImportKeyPromise - * @tc.desc Invalid value of alg tag for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_05600', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[0].value = invalidValue; - var ret = await hks.importKey(aliasNotExist, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_05700 - * @tc.name InvalidPurposeTagForImportKeyPromise - * @tc.desc Invalid value of alg tag for purpose key promise. - */ - it('HUKS_ABNORMAL_PROMISE_05700', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[1].value = invalidValue; - var ret = await hks.importKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_05800 - * @tc.name InvalidPaddingTagForImportKeyPromise - * @tc.desc Invalid value of alg tag for padding key promise. - */ - it('HUKS_ABNORMAL_PROMISE_05800', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[2].value = invalidValue; - var ret = await hks.importKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_05900 - * @tc.name InvalidDigestTagForImportKeyPromise - * @tc.desc Invalid value of alg tag for digest key promise. - */ - it('HUKS_ABNORMAL_PROMISE_05900', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[3].value = invalidValue; - var ret = await hks.importKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_06000 - * @tc.name InvalidIndataOfOptionForImportKeyPromise - * @tc.desc Invalid indata of option for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_06000', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.inData = new Uint8Array(0); - var ret = await hks.importKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done() - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_06100 - * @tc.name ExportKeyPromiseNotExistAlias - * @tc.desc Export key promise with not exist alias. - */ - it('HUKS_ABNORMAL_PROMISE_06100', 0, async function (done) { - var ret = await hks.exportKey(aliasNotExist, emptyOption); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_NOT_EXIST); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_06200 - * @tc.name ExportKeyPromiseLongAlias - * @tc.desc Export key promise with too long alias. - */ - it('HUKS_ABNORMAL_PROMISE_06200', 0, async function (done) { - var ret = await hks.exportKey(aliasTooLong, emptyOption); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_06300 - * @tc.name ExportKeyPromiseEmptyAlias - * @tc.desc Export key promise with empty alias. - */ - it('HUKS_ABNORMAL_PROMISE_06300', 0, async function (done) { - var ret = await hks.exportKey(aliasEmpty, emptyOption); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_06400 - * @tc.name SignPromiseNotExistAlias - * @tc.desc Sign promise with not exist alias. - */ - it('HUKS_ABNORMAL_PROMISE_06400', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - var ret = await hks.sign(aliasNotExist, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_NOT_EXIST); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_06500 - * @tc.name SignPromiseLongAlias - * @tc.desc Sign promise with too long alias. - */ - it('HUKS_ABNORMAL_PROMISE_06500', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - var ret = await hks.sign(aliasTooLong, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_06600 - * @tc.name SignPromiseEmptyAlias - * @tc.desc Sign promise with empty alias. - */ - it('HUKS_ABNORMAL_PROMISE_06600', 0, async function (done) { - var option = makeSignVerifyAndImportOption(plainTextSize64); - var ret = await hks.sign(aliasEmpty, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_06700 - * @tc.name InvalidAlgTagForSignPromise - * @tc.desc Invalid value of alg tag for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_06700', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[0].value = invalidValue; - var ret = await hks.sign(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_06800 - * @tc.name InvalidPurposeTagForSignPromise - * @tc.desc Invalid value of purpose tag for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_06800', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[1].value = invalidValue; - var ret = await hks.sign(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_06900 - * @tc.name InvalidPaddingTagForSignPromise - * @tc.desc Invalid value of padding tag for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_06900', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties[2].value = invalidValue; - var ret = await hks.sign(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_07000 - * @tc.name InvalidDigestTagForSignPromise - * @tc.desc Invalid value of digest tag for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_07000', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties[3].value = invalidValue; - var ret = await hks.sign(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_07100 - * @tc.name InvalidIndataOfOptionForSignPromise - * @tc.desc Invalid indata of option for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_07100', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.inData = new Uint8Array(0); - var ret = await hks.sign(aliasEmpty, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_07200 - * @tc.name SignPromiseLackAlgTag - * @tc.desc Sign promise lack of alg tag. - */ - it('HUKS_ABNORMAL_PROMISE_07200', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(0, 1); - var ret = await hks.sign(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_ALG_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_07300 - * @tc.name SignPromiseLackPurposeTag - * @tc.desc Sign promise lack of purpose tag. - */ - it('HUKS_ABNORMAL_PROMISE_07300', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(1, 1); - var ret = await hks.sign(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_07400 - * @tc.name SignPromiseLackPaddingTag - * @tc.desc Sign promise lack of padding tag. - */ - it('HUKS_ABNORMAL_PROMISE_07400', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties.splice(2, 1); - var ret = await hks.sign(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_07500 - * @tc.name SignPromiseLackDigestTag - * @tc.desc Sign promise lack of digest tag. - */ - it('HUKS_ABNORMAL_PROMISE_07500', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties.splice(3, 1); - var ret = await hks.sign(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_07600 - * @tc.name VerifyPromiseNotExistAlias - * @tc.desc Verify promise with not exist alias. - */ - it('HUKS_ABNORMAL_PROMISE_07600', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - var ret = await hks.verify(aliasNotExist, option, plainTextSize64); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_NOT_EXIST); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_07700 - * @tc.name VerifyPromiseLongAlias - * @tc.desc Verify promise with too long alias. - */ - it('HUKS_ABNORMAL_PROMISE_07700', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - var ret = await hks.verify(aliasTooLong, option, plainTextSize64); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_07800 - * @tc.name VerifyPromiseEmptyAlias - * @tc.desc Verify promise with empty alias. - */ - it('HUKS_ABNORMAL_PROMISE_07800', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - var ret = await hks.verify(aliasEmpty, option, plainTextSize64); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_07900 - * @tc.name InvalidAlgTagForVerifyPromise - * @tc.desc Invalid value of alg tag for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_07900', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties[0].value = invalidValue; - var ret = await hks.verify(alias, option, plainTextSize64); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_08000 - * @tc.name InvalidPurposeTagForVerifyPromise - * @tc.desc Invalid value of purpose tag for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_08000', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties[1].value = invalidValue; - var ret = await hks.verify(alias, option, plainTextSize8); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_08100 - * @tc.name InvalidPaddingTagForVerifyPromise - * @tc.desc Invalid value of padding tag for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_08100', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties[2].value = invalidValue; - var ret = await hks.verify(alias, option, plainTextSize8); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_08200 - * @tc.name InvalidDigestTagForVerifyPromise - * @tc.desc Invalid value of digest tag for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_08200', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties[3].value = invalidValue; - var ret = await hks.verify(alias, option, plainTextSize8); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_08300 - * @tc.name InvalidIndataOfOptionForVerifyPromise - * @tc.desc Invalid indata of option for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_08300', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize16); - option.inData = new Uint8Array(0); - var ret = await hks.verify(alias, option, plainTextSize64); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_08400 - * @tc.name VerifyPromiseLackAlgTag - * @tc.desc Verify promise lack of alg tag. - */ - it('HUKS_ABNORMAL_PROMISE_08400', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(0, 1); - var ret = await hks.verify(alias, option, plainTextSize64); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_ALG_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_08500 - * @tc.name VerifyPromiseLackPurposeTag - * @tc.desc Verify promise lack of purpose tag. - */ - it('HUKS_ABNORMAL_PROMISE_08500', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(1, 1); - var ret = await hks.verify(aliasNotExist, option, plainTextSize64); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_NOT_EXIST); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_08600 - * @tc.name VerifyPromiseLackPaddingTag - * @tc.desc Verify promise lack of padding tag. - */ - it('HUKS_ABNORMAL_PROMISE_08600', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize8); - option.properties.splice(2, 1); - var ret = await hks.verify(alias, option, plainTextSize8); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_08700 - * @tc.name VerifyPromiseLackDigestTag - * @tc.desc Verify promise lack of digest tag. - */ - it('HUKS_ABNORMAL_PROMISE_08700', 0, async function (done) { - await generateRsaKey(); - var option = makeSignVerifyAndImportOption(plainTextSize64); - option.properties.splice(3, 1); - var ret = await hks.verify(alias, option, plainTextSize64); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_08800 - * @tc.name InvalidIvTagForEncryptPromise - * @tc.desc Invalid value of iv tag for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_08800', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties[4].value = invalidValueUint8Array; - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_08900 - * @tc.name AgreeKeyPromiseEmptyAlias - * @tc.desc Agree key promise with empty alias. - */ - it('HUKS_ABNORMAL_PROMISE_08900', 0, async function (done) { - var option = makeAgreeOption(); - var ret = await hks.agreeKey(aliasEmpty, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_09000 - * @tc.name InvalidAlgTagForAgreeKeyPromise - * @tc.desc Invalid value of alg tag for agree key promise. - */ - it('HUKS_ABNORMAL_PROMISE_09000', 0, async function (done) { - await generateEccKey(); - var option = makeAgreeOption(); - option.properties[0].value = invalidValue; - var ret = await hks.agreeKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_09100 - * @tc.name InvalidSizeTagForAgreeKeyPromise - * @tc.desc Invalid value of size tag for agree key promise. - */ - it('HUKS_ABNORMAL_PROMISE_09100', 0, async function (done) { - await generateEccKey(); - var option = makeAgreeOption(); - option.properties[1].value = invalidValue; - var ret = await hks.agreeKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_09200 - * @tc.name InvalidIndataOfOptionForAgreeKeyPromise - * @tc.desc Invalid indata of option for agree key promise. - */ - it('HUKS_ABNORMAL_PROMISE_09200', 0, async function (done) { - await generateEccKey(); - var option = makeAgreeOption(); - option.inData = new Uint8Array(0); - var ret = await hks.agreeKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_09300 - * @tc.name AgreeKeyPromiseLackAlgTag - * @tc.desc Agree key promise lack of alg tag. - */ - it('HUKS_ABNORMAL_PROMISE_09300', 0, async function (done) { - await generateEccKey(); - var option = makeAgreeOption(); - option.properties.splice(0, 1); - var ret = await hks.agreeKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_ALG_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_09400 - * @tc.name AgreeKeyPromiseLackSizeTag - * @tc.desc Agree key promise lack of size tag. - */ - it('HUKS_ABNORMAL_PROMISE_09400', 0, async function (done) { - await generateEccKey(); - var option = makeAgreeOption(); - option.properties[1].value = invalidValue; - var ret = await hks.agreeKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_09500 - * @tc.name MacPromiseEmptyAlias - * @tc.desc Mac promise with empty alias. - */ - it('HUKS_ABNORMAL_PROMISE_09500', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - var ret = await hks.mac(aliasNotExist, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_NOT_EXIST); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_09600 - * @tc.name MacPromiseTooLongAlias - * @tc.desc Mac promise with too long alias. - */ - it('HUKS_ABNORMAL_PROMISE_09600', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - var ret = await hks.mac(aliasTooLong, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_09700 - * @tc.name MacPromiseEmptyAlias - * @tc.desc Mac promise with empty alias. - */ - it('HUKS_ABNORMAL_PROMISE_09700', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - var ret = await hks.mac(aliasEmpty, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_09800 - * @tc.name InvalidPurposeTagForMacPromise - * @tc.desc Invalid value of purpose tag for mac promise. - */ - it('HUKS_ABNORMAL_PROMISE_09800', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - option.properties[0].value = invalidValue; - var ret = await hks.mac(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_09900 - * @tc.name InvalidDigestTagForMacPromise - * @tc.desc Invalid value of digest tag for mac promise. - */ - it('HUKS_ABNORMAL_PROMISE_09900', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - option.properties[1].value = invalidValue; - var ret = await hks.mac(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_10000 - * @tc.name InvalidIndataOfOptionForMacPromise - * @tc.desc Invalid indata of option for mac promise. - */ - it('HUKS_ABNORMAL_PROMISE_10000', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - option.inData = new Uint8Array(0); - var ret = await hks.mac(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_10100 - * @tc.name MacPromiseLackPurposeTag - * @tc.desc Mac promise lack of purpose tag. - */ - it('HUKS_ABNORMAL_PROMISE_10100', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - option.properties.splice(0, 1); - var ret = await hks.mac(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_PURPOSE_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_10200 - * @tc.name MacPromiseLackDigestTag - * @tc.desc Mac promise lack of digest tag. - */ - it('HUKS_ABNORMAL_PROMISE_10200', 0, async function (done) { - await generateMacKey(); - var option = makeMacOption(); - option.properties.splice(1, 1); - var ret = await hks.mac(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_CHECK_GET_DIGEST_FAIL); - deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_10300 - * @tc.name LongIndataOfOptionForEncryptPromise - * @tc.desc Too long indata of option for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_10300', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.inData = inDataTooLong; - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_10400 - * @tc.name GenerateKeyPromiseStrangeAlias - * @tc.desc Generate key promise with strange alias. - */ - it('HUKS_ABNORMAL_PROMISE_10400', 0, async function (done) { - var genKeyRet = await hks.generateKey(aliasStrange, generateAesCBCKeyOption); - expect(genKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var deleteKeyRet = await hks.deleteKey(aliasStrange, emptyOption); - expect(deleteKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_10500 - * @tc.name InvalidNonceTagForEncryptPromise - * @tc.desc Invalid value of nonce tag for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_10500', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_GCM); - option.properties[4].value = invalidValueUint8Array; - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_10600 - * @tc.name InvalidASSOCIATEDDATATagForEncryptPromise - * @tc.desc Invalid value of associated data tag for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_10600', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_GCM); - option.properties[5].value = invalidValueUint8Array; - var ret = await hks.encrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_10700 - * @tc.name InvalidIvTagForDecryptPromise - * @tc.desc Invalid value of iv tag for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_10700', 0, async function (done) { - await generateAesKey('CBC'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_CBC); - option.properties[4].value = invalidValueUint8Array; - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_10800 - * @tc.name InvalidNonceTagForDecryptPromise - * @tc.desc Invalid value of nonce tag for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_10800', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_GCM); - option.properties[4].value = invalidValueUint8Array; - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - await deleteKeyPromise(alias, done); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_10900 - * @tc.name InvalidAssociatedDataTagForDecryptPromise - * @tc.desc Invalid value of associated data tag for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_10900', 0, async function (done) { - await generateAesKey('GCM'); - var option = makeEncryptAndDecryptOptionForAbnormal(hks.HuksCipherMode.HUKS_MODE_GCM); - option.properties[5].value = invalidValueUint8Array; - var ret = await hks.decrypt(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - await deleteKeyPromise(alias, done); - }); -}); \ No newline at end of file diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_promise_part2.test.js b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_promise_part2.test.js deleted file mode 100644 index 9d88ba0c2213868a99c11b5ec09dd73e7f0f8ba4..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_promise_part2.test.js +++ /dev/null @@ -1,1847 +0,0 @@ -/* - * 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 hks from '@ohos.security.huks' -import { describe, it, expect } from 'deccjsunit/index' -import { - alias, -} from '../../../../../../hks_xts_common.test' -import { - aesGenerateKeyInvalidSizeOption, - aesGenerateKeyInvalidModeOption, - aesGenerateKeyInvalidAlgOption, - aesGenerateKeyInvalidPurposeOption, - rsaGenerateKeyInvalidSizeOption, - rsaGenerateKeyInvalidPaddingOption, - rsaGenerateKeyInvalidPurposeOption, - eccGenerateKeyInvalidSizeOption, - eccGenerateKeyInvalidDigestOption, - eccGenerateKeyInvalidPurposeOption, - ecdhGenerateKeyInvalidAlgOption, - hkdfGenerateKeyInvalidAlgOption, - pbkdf2GenerateKeyInvalidAlgOption, - ed25519GenerateKeyInvalidPurposeOption, - x25519GenerateKeyInvalidPurposeOption, - hmacGenerateKeyInvalidSizeOption, - hmacGenerateKeyInvalidPurposeOption, - dsaGenerateKeyInvalidSizeOption, - dsaGenerateKeyInvalidPurposeOption, - dhGenerateKeyInvalidPurposeOption, -} from './hks_abnormal_common.test.js' - -describe('Hks_Abnormal_Promise_Part2', function () { - var errHmacKeySizeA = 0; - var errHmacKeySizeB = 9; - var errDsaKeySizeA = 0; - var errDsaKeySizeB = 9; - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_11000 - * @tc.name InvalidAesKeySize512AlgAesForGenerateGKeyPromise - * @tc.desc Invalid aes key size 512 alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_11000', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_512); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_11100 - * @tc.name InvalidRsaKeySize512AlgAesForGenerateGKeyPromise - * @tc.desc Invalid rsa key size 512 alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_11100', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_11200 - * @tc.name InvalidRsaKeySize768AlgAesForGenerateGKeyPromise - * @tc.desc Invalid rsa key size 768 alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_11200', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_768); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_11300 - * @tc.name InvalidRsaKeySize1024AlgAesForGenerateGKeyPromise - * @tc.desc Invalid rsa key size 1024 alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_11300', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_11400 - * @tc.name InvalidRsaKeySize2048AlgAesForGenerateGKeyPromise - * @tc.desc Invalid rsa key size 2048 alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_11400', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_11500 - * @tc.name InvalidRsaKeySize3072AlgAesForGenerateGKeyPromise - * @tc.desc Invalid rsa key size 3072 alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_11500', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_11600 - * @tc.name InvalidRsaKeySize4096AlgAesForGenerateGKeyPromise - * @tc.desc Invalid rsa key size 4096 alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_11600', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_11700 - * @tc.name InvalidEccKeySize224AlgAesForGenerateGKeyPromise - * @tc.desc Invalid ecc key size 224 alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_11700', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_224); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_11800 - * @tc.name InvalidEccKeySize256AlgAesForGenerateGKeyPromise - * @tc.desc Ecc key size 256 alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_11800', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_11900 - * @tc.name InvalidEccKeySize384AlgAesForGenerateGKeyPromise - * @tc.desc Invalid ecc key size 384 alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_11900', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_384); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_12000 - * @tc.name InvalidEccKeySize521AlgAesForGenerateGKeyPromise - * @tc.desc Invalid ecc key size 521 alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_12000', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_521); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_12100 - * @tc.name InvalidCurve25519KeySize256AlgAesForGenerateGKeyPromise - * @tc.desc Curve25519 key size 256 alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_12100', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_12200 - * @tc.name InvaliddhKeySize2048AlgAesForGenerateGKeyPromise - * @tc.desc Invalid dh key size 2048 alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_12200', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_2048); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_12300 - * @tc.name InvaliddhKeySize3072AlgAesForGenerateGKeyPromise - * @tc.desc Invalid dh key size 2048 alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_12300', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_3072); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_12400 - * @tc.name InvaliddhKeySize4096AlgAesForGenerateGKeyPromise - * @tc.desc Invalid dh key size 4096 alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_12400', 0, async function (done) { - var option = aesGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_4096); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_12500 - * @tc.name InvalidPaddingOaepModeCbcAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding oaep mode cbc alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_12500', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_CBC, - hks.HuksKeyPadding.HUKS_PADDING_OAEP); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_12600 - * @tc.name InvalidPaddingPssModeCbcAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding pss mode cbc alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_12600', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption(hks.HuksCipherMode.HUKS_MODE_CBC, hks.HuksKeyPadding.HUKS_PADDING_PSS); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_12700 - * @tc.name InvalidPaddingPkcs1_v1_5ModeCbcAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding pkcs1_v1_5 mode cbc alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_12700', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_CBC, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_12800 - * @tc.name InvalidPaddingPkcs5ModeCbcAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding pkcs5 mode cbc alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_12800', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_CBC, - hks.HuksKeyPadding.HUKS_PADDING_PKCS5); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_12900 - * @tc.name InvalidPaddingOaepModeCtrAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding oaep mode ctr alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_12900', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_CTR, - hks.HuksKeyPadding.HUKS_PADDING_OAEP); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_13000 - * @tc.name InvalidPaddingPssModeCtrAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding pss mode ctr alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_13000', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption(hks.HuksCipherMode.HUKS_MODE_CTR, hks.HuksKeyPadding.HUKS_PADDING_PSS); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_13100 - * @tc.name InvalidPaddingPkcs1_v1_5ModeCtrAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding pkcs1_v1_5 mode ctr alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_13100', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_CTR, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_13200 - * @tc.name InvalidPaddingPkcs5ModeCtrAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding pkcs5 mode ctr alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_13200', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_CTR, - hks.HuksKeyPadding.HUKS_PADDING_PKCS5); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_13300 - * @tc.name InvalidPaddingPkcs7ModeCtrAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding pkcs7 mode ctr alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_13300', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_CTR, - hks.HuksKeyPadding.HUKS_PADDING_PKCS7); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_13400 - * @tc.name InvalidPaddingOaepModeEcbAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding oaep mode ecb alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_13400', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeyPadding.HUKS_PADDING_OAEP); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_13500 - * @tc.name InvalidPaddingPssModeEcbAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding pss mode ecb alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_13500', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption(hks.HuksCipherMode.HUKS_MODE_ECB, hks.HuksKeyPadding.HUKS_PADDING_PSS); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_13600 - * @tc.name InvalidPaddingPkcs1_v1_5ModeEcbAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding pkcs1_v1_5 mode ecb alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_13600', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_13700 - * @tc.name InvalidPaddingPkcs5ModeEcbAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding pkcs5 mode ecb alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_13700', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_ECB, - hks.HuksKeyPadding.HUKS_PADDING_PKCS5); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_13800 - * @tc.name InvalidPaddingOaepModeGcmAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding oaep mode gcm alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_13800', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_GCM, - hks.HuksKeyPadding.HUKS_PADDING_OAEP); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_13900 - * @tc.name InvalidPaddingpssModeGcmAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding pss mode gcm alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_13900', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption(hks.HuksCipherMode.HUKS_MODE_GCM, hks.HuksKeyPadding.HUKS_PADDING_PSS); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_14000 - * @tc.name InvalidPaddingPkcs1_v1_5ModeGcmAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding pkcs1_v1_5 mode gcm alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_14000', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_GCM, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_14100 - * @tc.name InvalidPaddingPkcs5ModeGcmAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding pkcs5 mode gcm alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_14100', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_GCM, - hks.HuksKeyPadding.HUKS_PADDING_PKCS5); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_14200 - * @tc.name InvalidPaddingPkcs7ModeGcmAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding pkcs7 mode gcm alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_14200', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_GCM, - hks.HuksKeyPadding.HUKS_PADDING_PKCS7); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_14300 - * @tc.name InvalidPaddingOaepModeCcmAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding oaep mode ccm alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_14300', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_CCM, - hks.HuksKeyPadding.HUKS_PADDING_OAEP); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_14400 - * @tc.name InvalidPaddingPssModeCcmAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding pss mode ccm alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_14400', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption(hks.HuksCipherMode.HUKS_MODE_CCM, hks.HuksKeyPadding.HUKS_PADDING_PSS); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_14500 - * @tc.name InvalidPaddingPkcs1_v1_5ModeCcmAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding pkcs1_v1_5 mode ccm alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_14500', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_CCM, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_14600 - * @tc.name InvalidPaddingPkcs5ModeCcmAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding pkcs5 mode ccm alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_14600', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_CCM, - hks.HuksKeyPadding.HUKS_PADDING_PKCS5); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_14700 - * @tc.name InvalidPaddingPkcs7ModeCcmAlgAesForGenerateGKeyPromise - * @tc.desc Invalid padding pkcs7 mode ccm alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_14700', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_CCM, - hks.HuksKeyPadding.HUKS_PADDING_PKCS7); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_14800 - * @tc.name InvalidModeOfbAlgAesForGenerateGKeyPromise - * @tc.desc Invalid mode ofb alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_14800', 0, async function (done) { - var option = aesGenerateKeyInvalidModeOption( - hks.HuksCipherMode.HUKS_MODE_OFB, - hks.HuksKeyPadding.HUKS_PADDING_NONE); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_MODE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_14900 - * @tc.name InvalidPurposeDeriveAlgRsaAlgAesForGenerateKeyPromise. - * @tc.desc Invalid purpose derive alg rsa alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_14900', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_RSA, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_15000 - * @tc.name InvalidPurposeDeriveAlgEccAlgAesForGenerateKeyPromise - * @tc.desc Invalid purpose derive alg ecc alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_15000', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_ECC, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_15100 - * @tc.name InvalidPurposeDeriveAlgDsaAlgAesForGenerateKeyPromise - * @tc.desc Invalid purpose derive alg dsa alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_15100', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_DSA, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_15200 - * @tc.name InvalidPurposeDeriveAlgHkdfAlgAesForGenerateKeyPromise - * @tc.desc Invalid purpose derive alg hkdf alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_15200', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_HKDF, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_15300 - * @tc.name InvalidPurposeDeriveAlgPbkdf2AlgAesForGenerateKeyPromise - * @tc.desc Invalid purpose derive alg pbkdf2 alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_15300', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_PBKDF2, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_15400 - * @tc.name InvalidPurposeDeriveAlgEcdhAlgAesForGenerateKeyPromise - * @tc.desc Invalid purpose derive alg ecdh alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_15400', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_ECDH, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_15500 - * @tc.name InvalidPurposeDeriveAlgX25519AlgAesForGenerateKeyPromise - * @tc.desc Invalid purpose derive alg x25519 alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_15500', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_X25519, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_15600 - * @tc.name InvalidPurposeDeriveAlgEd25519AlgAesForGenerateKeyPromise - * @tc.desc Invalid purpose derive alg ed25519 alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_15600', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_ED25519, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_15700 - * @tc.name InvalidPurposeDeriveAlgDhAlgAesForGenerateKeyPromise - * @tc.desc Invalid purpose derive alg dh alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_15700', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_DH, hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_15800 - * @tc.name InvalidPurposeMacAlgRsaAlgAesForGenerateKeyPromise - * @tc.desc Invalid purpose mac alg rsa alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_15800', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_RSA, hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_15900 - * @tc.name InvalidPurposeMacAlgEccAlgAesForGenerateKeyPromise - * @tc.desc Invalid purpose mac alg ecc alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_15900', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ECC, hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_16000 - * @tc.name InvalidPurposeMacAlgDsaAlgAesForGenerateKeyPromise - * @tc.desc Invalid purpose mac alg dsa alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_16000', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_DSA, hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_16100 - * @tc.name InvalidPurposeMacAlgHkdfAlgAesForGenerateKeyPromise - * @tc.desc Invalid purpose mac alg hkdf alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_16100', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_HKDF, hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_16200 - * @tc.name InvalidPurposeMacAlgPbkdf2AlgAesForGenerateKeyPromise - * @tc.desc Invalid purpose mac alg pbkdf2 alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_16200', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_PBKDF2, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_16300 - * @tc.name InvalidPurposeMacAlgEcdhAlgAesForGenerateKeyPromise - * @tc.desc Invalid purpose mac alg ecdh alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_16300', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ECDH, hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_16400 - * @tc.name InvalidPurposeMacAlgX25519AlgAesForGenerateKeyPromise - * @tc.desc Invalid purpose mac alg x25519 alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_16400', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_X25519, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_16500 - * @tc.name InvalidPurposeMacAlgEd25519AlgAesForGenerateKeyPromise - * @tc.desc Invalid purpose mac alg ed25519 alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_16500', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_ED25519, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_16600 - * @tc.name InvalidPurposeMacAlgDhAlgAesForGenerateKeyPromise - * @tc.desc Invalid purpose mac alg dh alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_16600', 0, async function (done) { - var option = aesGenerateKeyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_DH, hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_16700 - * @tc.name InvalidPurposeSignAlgAesForGenerateKeyPromise - * @tc.desc Invalid purpose sign alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_16700', 0, async function (done) { - var option = JSON.parse(JSON.stringify(aesGenerateKeyInvalidPurposeOption)); - option.properties[2].value = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN; - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_16800 - * @tc.name InvalidPurposeVerifyAlgAesForGenerateKeyPromise - * @tc.desc Invalid purpose verify alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_16800', 0, async function (done) { - var option = JSON.parse(JSON.stringify(aesGenerateKeyInvalidPurposeOption)); - option.properties[2].value = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY; - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_16900 - * @tc.name InvalidPurposeAgreeAlgAesForGenerateKeyPromise - * @tc.desc Invalid purpose agree alg aes for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_16900', 0, async function (done) { - var option = JSON.parse(JSON.stringify(aesGenerateKeyInvalidPurposeOption)); - option.properties[2].value = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE; - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_17000 - * @tc.name InvalidEccKeySize224AlgRsaForGenerateGKeyPromise - * @tc.desc Invalid ecc key size 224 alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_17000', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_224); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_17100 - * @tc.name InvalidEccKeySize256AlgRsaForGenerateGKeyPromise - * @tc.desc Invalid ecc key size 256 alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_17100', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_17200 - * @tc.name InvalidEccKeySize384AlgRsaForGenerateGKeyPromise - * @tc.desc Invalid ecc key size 384 alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_17200', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_384); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_17300 - * @tc.name InvalidEccKeySize521AlgRsaForGenerateGKeyPromise - * @tc.desc Invalid ecc key size 521 alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_17300', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_521); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_17400 - * @tc.name InvalidAesKeySize128AlgRsaForGenerateGKeyPromise - * @tc.desc Invalid aes key size 128 alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_17400', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_128); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_17500 - * @tc.name InvalidAesKeySize192AlgRsaForGenerateGKeyPromise - * @tc.desc Invalid aes key size 192 alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_17500', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_192); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_17600 - * @tc.name InvalidAesKeySize256AlgRsaForGenerateGKeyPromise - * @tc.desc Invalid aes key size 256 alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_17600', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_256); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_17700 - * @tc.name InvalidAesKeySize512AlgRsaForGenerateGKeyPromise - * @tc.desc Invalid aes key size 512 alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_17700', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_512); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_17800 - * @tc.name InvalidCurve25519KeySize256AlgRsaForGenerateGKeyPromise - * @tc.desc Invalid curve25519 key size 256 alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_17800', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_17900 - * @tc.name InvalidDhKeySize2048AlgRsaForGenerateGKeyPromise - * @tc.desc Invalid dh key size 2048 alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_17900', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_2048); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_18000 - * @tc.name InvalidDhKeySize3072AlgRsaForGenerateGKeyPromise - * @tc.desc Invalid dh key size 3072 alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_18000', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_3072); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_18100 - * @tc.name InvalidDhKeySize4096AlgRsaForGenerateGKeyPromise - * @tc.desc Invalid dh key size 4096 alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_18100', 0, async function (done) { - var option = rsaGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_4096); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_18200 - * @tc.name InvalidPaddingPssPurposeEncryptDecryptAlgRsaForGenerateKeyPromise. - * @tc.desc Invalid padding pss purpose encrypt decrypt alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_18200', 0, async function (done) { - var option = rsaGenerateKeyInvalidPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyPadding.HUKS_PADDING_PSS); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_18300 - * @tc.name InvalidPaddingPkcs5PurposeEncryptDecryptAlgRsaForGenerateKeyPromise - * @tc.desc Invalid padding pkcs5 purpose encrypt decrypt alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_18300', 0, async function (done) { - var option = rsaGenerateKeyInvalidPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyPadding.HUKS_PADDING_PKCS5); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_18400 - * @tc.name InvalidPaddingPkcs7PurposeEncryptDecryptAlgRsaForGenerateKeyPromise - * @tc.desc Invalid padding pkcs7 purpose encrypt decrypt alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_18400', 0, async function (done) { - var option = rsaGenerateKeyInvalidPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyPadding.HUKS_PADDING_PKCS7); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_18500 - * @tc.name InvalidPaddingNonePurposeSignVerifyAlgRsaForGenerateKeyPromise - * @tc.desc Invalid padding none purpose sign verify alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_18500', 0, async function (done) { - var option = rsaGenerateKeyInvalidPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_NONE); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_18600 - * @tc.name InvalidPaddingOaepPurposeSignVerifyAlgRsaForGenerateKeyPromise - * @tc.desc Invalid padding oaep purpose sign verify alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_18600', 0, async function (done) { - var option = rsaGenerateKeyInvalidPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_OAEP); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_18700 - * @tc.name InvalidPaddingPkcs5PurposeSignVerifyAlgRsaForGenerateKeyPromise - * @tc.desc Invalid padding pkcs5 purpose sign verify alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_18700', 0, async function (done) { - var option = rsaGenerateKeyInvalidPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_PKCS5); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_18800 - * @tc.name InvalidPaddingPkcs7PurposeSignVerifyAlgRsaForGenerateKeyPromise - * @tc.desc Invalid padding pkcs7 purpose sign verify alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_18800', 0, async function (done) { - var option = rsaGenerateKeyInvalidPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_PKCS7); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_18900 - * @tc.name InvalidPurposeDeriveAlgRsaForGenerateKeyPromise - * @tc.desc Invalid purpose derive alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_18900', 0, async function (done) { - var option = JSON.parse(JSON.stringify(rsaGenerateKeyInvalidPurposeOption)); - option.properties[2].value = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE; - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_19000 - * @tc.name InvalidPurposeMacAlgRsaForGenerateKeyPromise - * @tc.desc Invalid purpose mac alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_19000', 0, async function (done) { - var option = JSON.parse(JSON.stringify(rsaGenerateKeyInvalidPurposeOption)); - option.properties[2].value = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC; - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_19100 - * @tc.name InvalidPurposeWrapAlgRsaForGenerateKeyPromise - * @tc.desc Invalid purpose wrap alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_19100', 0, async function (done) { - var option = JSON.parse(JSON.stringify(rsaGenerateKeyInvalidPurposeOption)); - option.properties[2].value = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_WRAP; - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_19200 - * @tc.name InvalidPurposeUnwrapAlgRsaForGenerateKeyPromise - * @tc.desc Invalid purpose unwrap alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_19200', 0, async function (done) { - var option = JSON.parse(JSON.stringify(rsaGenerateKeyInvalidPurposeOption)); - option.properties[2].value = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP; - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_19300 - * @tc.name InvalidPurposeagreeAlgRsaForGenerateKeyPromise - * @tc.desc Invalid purpose agree alg rsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_19300', 0, async function (done) { - var option = JSON.parse(JSON.stringify(rsaGenerateKeyInvalidPurposeOption)); - option.properties[2].value = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE; - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_19400 - * @tc.name InvalidRsaKeySize512AlgEccForGenerateGKeyPromise - * @tc.desc Invalid rsa key size 512 alg ecc for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_19400', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_19500 - * @tc.name InvalidRsaKeySize768AlgEccForGenerateGKeyPromise - * @tc.desc Invalid rsa key size 768 alg ecc for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_19500', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_768); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_19600 - * @tc.name InvalidRsaKeySize1024AlgEccForGenerateGKeyPromise - * @tc.desc Invalid rsa key size 1024 alg ecc for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_19600', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_19700 - * @tc.name InvalidRsaKeySize2048AlgEccForGenerateGKeyPromise - * @tc.desc Invalid rsa key size 2048 alg ecc for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_19700', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_19800 - * @tc.name InvalidRsaKeySize3072AlgEccForGenerateGKeyPromise - * @tc.desc Invalid rsa key size 3072 alg ecc for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_19800', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_19900 - * @tc.name InvalidRsaKeySize4096AlgEccForGenerateGKeyPromise - * @tc.desc Invalid rsa key size 4096 alg ecc for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_19900', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_20000 - * @tc.name InvalidAesKeySize128AlgEccForGenerateGKeyPromise - * @tc.desc Invalid aes key size 128 alg ecc for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_20000', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_128); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_20100 - * @tc.name InvalidAesKeySize192AlgEccForGenerateGKeyPromise - * @tc.desc Invalid aes key size 192 alg ecc for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_20100', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_192); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_20200 - * @tc.name InvalidAesKeySize256AlgEccForGenerateGKeyPromise - * @tc.desc Invalid aes key size 256 alg ecc for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_20200', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_256); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_20300 - * @tc.name InvalidAesKeySize512AlgEccForGenerateGKeyPromise - * @tc.desc Invalid aes key size 512 alg ecc for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_20300', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_512); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_20400 - * @tc.name InvalidCurve25519KeySize256AlgEccForGenerateGKeyPromise - * @tc.desc Invalid curve25519 key size 256 alg ecc for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_20400', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_20500 - * @tc.name InvalidDhKeySize2048AlgEccForGenerateGKeyPromise - * @tc.desc Invalid dh key size 2048 alg ecc for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_20500', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_2048); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_20600 - * @tc.name InvalidDhKeySize3072AlgEccForGenerateGKeyPromise - * @tc.desc Invalid dh key size 3072 alg ecc for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_20600', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_3072); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_20700 - * @tc.name InvalidDhKeySize4096AlgEccForGenerateGKeyPromise - * @tc.desc Invalid dh key size 4096 alg ecc for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_20700', 0, async function (done) { - var option = eccGenerateKeyInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_4096); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_20800 - * @tc.name InvalidDigestMd5AlgEccForGenerateGKeyPromise - * @tc.desc Invalid digest md5 alg ecc for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_20800', 0, async function (done) { - var option = eccGenerateKeyInvalidDigestOption(hks.HuksKeyDigest.HUKS_DIGEST_MD5); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_20900 - * @tc.name InvalidPurposeDeriveAlgEccForGenerateGKeyPromise - * @tc.desc Invalid purpose derive alg ecc for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_20900', 0, async function (done) { - var option = eccGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_21000 - * @tc.name InvalidPurposeMacAlgEccForGenerateGKeyPromise - * @tc.desc Invalid purpose mac alg ecc for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_21000', 0, async function (done) { - var option = eccGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_21100 - * @tc.name InvalidPurposeWrapAlgEccForGenerateGKeyPromise - * @tc.desc Invalid purpose wrap alg ecc for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_21100', 0, async function (done) { - var option = eccGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_WRAP); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_21300 - * @tc.name InvalidPurposeencryptAlgEccForGenerateGKeyPromise - * @tc.desc Invalid purpose encrypt alg ecc for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_21300', 0, async function (done) { - var option = eccGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_21400 - * @tc.name InvalidPurposeDecryptAlgEccForGenerateGKeyPromise - * @tc.desc Invalid purpose decrypt alg ecc for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_21400', 0, async function (done) { - var option = eccGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_21500 - * @tc.name InvalidArgumentAlgEcdhForGenerateGKeyPromise - * @tc.desc Invalid argument alg ecdh for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_21500', 0, async function (done) { - var option = ecdhGenerateKeyInvalidAlgOption(); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_21600 - * @tc.name InvalidAlgorithmAlgHkdfForGenerateGKeyPromise - * @tc.desc Invalid algorithm alg hkdf for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_21600', 0, async function (done) { - var option = hkdfGenerateKeyInvalidAlgOption(); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_21700 - * @tc.name InvalidAlgorithmAlgPbkdf2ForGenerateGKeyPromise - * @tc.desc Invalid algorithm alg pbkdf2 for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_21700', 0, async function (done) { - var option = pbkdf2GenerateKeyInvalidAlgOption(); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_21800 - * @tc.name InvalidPurposeDeriveAlgEd25519ForGenerateKeyPromise. - * @tc.desc Invalid purpose derive alg ed25519 for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_21800', 0, async function (done) { - var option = ed25519GenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_21900 - * @tc.name InvalidPurposeMacAlgEd25519ForGenerateKeyPromise - * @tc.desc Invalid purpose mac alg ed25519 for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_21900', 0, async function (done) { - var option = ed25519GenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_22000 - * @tc.name InvalidPurposeWrapAlgEd25519ForGenerateKeyPromise - * @tc.desc Invalid purpose wrap alg ed25519 for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_22000', 0, async function (done) { - var option = ed25519GenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_WRAP); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_22100 - * @tc.name InvalidPurposeUnwrapAlgEd25519ForGenerateKeyPromise - * @tc.desc Invalid purpose unwrap alg ed25519 for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_22100', 0, async function (done) { - var option = ed25519GenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_22200 - * @tc.name InvalidPurposeEncryptAlgEd25519ForGenerateKeyPromise - * @tc.desc Invalid purpose encrypt alg ed25519 for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_22200', 0, async function (done) { - var option = ed25519GenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_22300 - * @tc.name InvalidPurposeDecryptAlgEd25519ForGenerateKeyPromise - * @tc.desc Invalid purpose decrypt alg ed25519 for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_22300', 0, async function (done) { - var option = ed25519GenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_22400 - * @tc.name InvalidPurposeDeriveAlgX25519ForGenerateKeyPromise - * @tc.desc Invalid purpose derive alg x25519 for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_22400', 0, async function (done) { - var option = x25519GenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_22500 - * @tc.name InvalidPurposeMacAlgX25519ForGenerateKeyPromise - * @tc.desc Invalid purpose mac alg x25519 for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_22500', 0, async function (done) { - var option = x25519GenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_22600 - * @tc.name InvalidPurposeEncryptAlgX25519ForGenerateKeyPromise - * @tc.desc Invalid purpose encrypt alg x25519 for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_22600', 0, async function (done) { - var option = x25519GenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_22700 - * @tc.name InvalidPurposeDecryptAlgX25519ForGenerateKeyPromise - * @tc.desc Invalid purpose decrypt alg x25519 for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_22700', 0, async function (done) { - var option = x25519GenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_22800 - * @tc.name InvalidArgumentSizeaAlgHmacForGenerateKeyPromise - * @tc.desc Invalid argument sizea alg hmac for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_22800', 0, async function (done) { - var option = hmacGenerateKeyInvalidSizeOption(errHmacKeySizeA); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_22900 - * @tc.name InvalidArgumentSizebAlgHmacForGenerateKeyPromise - * @tc.desc Invalid argument sizeb alg hmac for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_22900', 0, async function (done) { - var option = hmacGenerateKeyInvalidSizeOption(errHmacKeySizeB); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_23000 - * @tc.name InvalidPurposeDeriveAlgHmacForGenerateKeyPromise - * @tc.desc Invalid purpose derive alg hmac for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_23000', 0, async function (done) { - var option = hmacGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_23100 - * @tc.name InvalidPurposeSignAlgHmacForGenerateKeyPromise - * @tc.desc Invalid purpose sign alg hmac for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_23100', 0, async function (done) { - var option = hmacGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_23200 - * @tc.name InvalidPurposeVerifyAlgHmacForGenerateKeyPromise - * @tc.desc Invalid purpose verify alg hmac for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_23200', 0, async function (done) { - var option = hmacGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_23300 - * @tc.name InvalidPurposeWrapAlgHmacForGenerateKeyPromise - * @tc.desc Invalid purpose wrap alg hmac for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_23300', 0, async function (done) { - var option = hmacGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_WRAP); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_23400 - * @tc.name InvalidPurposeUnwrapAlgHmacForGenerateKeyPromise - * @tc.desc Invalid purpose unwrap alg hmac for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_23400', 0, async function (done) { - var option = hmacGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_23500 - * @tc.name InvalidPurposeEncryptAlgHmacForGenerateKeyPromise - * @tc.desc Invalid purpose encrypt alg hmac for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_23500', 0, async function (done) { - var option = hmacGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_23600 - * @tc.name InvalidPurposeDecryptAlgHmacForGenerateKeyPromise - * @tc.desc Invalid purpose decrypt alg hmac for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_23600', 0, async function (done) { - var option = hmacGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_23700 - * @tc.name InvalidPurposeAgreeAlgHmacForGenerateKeyPromise - * @tc.desc Invalid purpose agree alg hmac for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_23700', 0, async function (done) { - var option = hmacGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_23800 - * @tc.name InvalidArgumentSizeaAlgDsaForGenerateKeyPromise - * @tc.desc Invalid argument sizea alg dsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_23800', 0, async function (done) { - var option = dsaGenerateKeyInvalidSizeOption(errDsaKeySizeA); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_23900 - * @tc.name InvalidArgumentSizebAlgDsaForGenerateKeyPromise - * @tc.desc Invalid argument sizeb alg dsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_23900', 0, async function (done) { - var option = dsaGenerateKeyInvalidSizeOption(errDsaKeySizeB); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_24000 - * @tc.name InvalidPurposeDeriveAlgDsaForGenerateKeyPromise - * @tc.desc Invalid purpose derive alg dsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_24000', 0, async function (done) { - var option = dsaGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_24100 - * @tc.name InvalidPurposeMacAlgDsaForGenerateKeyPromise - * @tc.desc Invalid purpose mac alg dsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_24100', 0, async function (done) { - var option = dsaGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_24200 - * @tc.name InvalidPurposeWrapAlgDsaForGenerateKeyPromise - * @tc.desc Invalid purpose wrap alg dsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_24200', 0, async function (done) { - var option = dsaGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_WRAP); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_24300 - * @tc.name InvalidPurposeUnwrapAlgDsaForGenerateKeyPromise - * @tc.desc Invalid purpose unwrap alg dsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_24300', 0, async function (done) { - var option = dsaGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_24400 - * @tc.name InvalidPurposeEncryptAlgDsaForGenerateKeyPromise - * @tc.desc Invalid purpose encrypt alg dsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_24400', 0, async function (done) { - var option = dsaGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_24500 - * @tc.name InvalidPurposeDecryptAlgDsaForGenerateKeyPromise - * @tc.desc Invalid purpose decrypt alg dsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_24500', 0, async function (done) { - var option = dsaGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_24600 - * @tc.name InvalidPurposeAgreeAlgDsaForGenerateKeyPromise - * @tc.desc Invalid purpose agree alg dsa for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_24600', 0, async function (done) { - var option = dsaGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_24700 - * @tc.name InvalidPurposeDeriveAlgDhForGenerateKeyPromise - * @tc.desc Invalid purpose derive alg dh for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_24700', 0, async function (done) { - var option = dhGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_24800 - * @tc.name InvalidPurposeMacAlgDhForGenerateKeyPromise - * @tc.desc Invalid purpose mac alg dh for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_24800', 0, async function (done) { - var option = dhGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_24900 - * @tc.name InvalidPurposeWrapAlgDhForGenerateKeyPromise - * @tc.desc Invalid purpose wrap alg dh for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_24900', 0, async function (done) { - var option = dhGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_WRAP); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_25100 - * @tc.name InvalidPurposeEncryptAlgDhForGenerateKeyPromise - * @tc.desc Invalid purpose encrypt alg dh for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_25100', 0, async function (done) { - var option = dhGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_25200 - * @tc.name InvalidPurposeDecryptAlgDhForGenerateKeyPromise - * @tc.desc Invalid purpose decrypt alg dh for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_25200', 0, async function (done) { - var option = dhGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_25300 - * @tc.name InvalidPurposeSignAlgDhForGenerateKeyPromise - * @tc.desc Invalid purpose sign alg dh for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_25300', 0, async function (done) { - var option = dhGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_25400 - * @tc.name InvalidPurposeVerifyAlgDhForGenerateKeyPromise - * @tc.desc Invalid purpose verify alg dh for generate key promise. - */ - it('HUKS_ABNORMAL_PROMISE_25400', 0, async function (done) { - var option = dhGenerateKeyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY); - var result = await hks.generateKey(alias, option); - expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); -}); \ No newline at end of file diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_promise_part3.test.js b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_promise_part3.test.js deleted file mode 100644 index bb393b470648dadafbee349f049a3e1e3abc5e92..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_promise_part3.test.js +++ /dev/null @@ -1,1561 +0,0 @@ -/* - * 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 hks from '@ohos.security.huks' -import { describe, it, expect } from 'deccjsunit/index' -import { - alias, -} from '../../../../../../hks_xts_common.test' - -import { - generateRSAKeyOption, - generateAesCBCKeyOption, - generateAesGCMKeyOption, - encryptOrDecryptGenerateKeyOption, - encryptOrDecryptOption, - encryptOrDecryptInvalidAlgOption, - rsaEncryptInvalidSizeOption, - aesEncryptOrDecryptInvalidSizeOption, - aesEncryptOrDecryptInvalidPaddingOption, - aesEncryptOrDecryptInvalidDigestOption, - rsaEncryptOrDecryptInvalidIndataOption, - aesEncryptOrDecryptInvalidIndataOption, - aesEncryptOrDecryptInvalidPurposeOption, - rsaDecryptInvalidSizeOption, -} from './hks_abnormal_common.test.js' - -describe('Hks_Abnormal_Promise_Part3', function () { - - var cipherText = []; - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_25500 - * @tc.name InvalidAlgorithmAlgEccForEncryptPromise - * @tc.desc Invalid algorithm alg ecc for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_25500', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ECC); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_25600 - * @tc.name InvalidAlgorithmAlgDsaForEncryptPromise - * @tc.desc Invalid algorithm alg dsa for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_25600', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_DSA); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_25700 - * @tc.name InvalidAlgorithmAlgHmacForEncryptPromise - * @tc.desc Invalid algorithm alg hmac for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_25700', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_HMAC); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_25800 - * @tc.name InvalidAlgorithmAlgHkdfForEncryptPromise - * @tc.desc Invalid algorithm alg hkdf for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_25800', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_HKDF); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_25900 - * @tc.name InvalidAlgorithmAlgPbkdf2ForEncryptPromise - * @tc.desc Invalid algorithm alg pbkdf2 for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_25900', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_PBKDF2); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_26000 - * @tc.name InvalidAlgorithmAlgEcdhForEncryptPromise - * @tc.desc Invalid algorithm alg ecdh for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_26000', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ECDH); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_26100 - * @tc.name InvalidAlgorithmAlgX25519ForEncryptPromise - * @tc.desc Invalid algorithm alg x25519 for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_26100', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_X25519); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_26200 - * @tc.name InvalidAlgorithmAlgEd25519ForEncryptPromise - * @tc.desc Invalid algorithm alg ed25519 for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_26200', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ED25519); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_26300 - * @tc.name InvalidAlgorithmAlgDhForEncryptPromise - * @tc.desc Invalid algorithm alg dh for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_26300', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_DH); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_26400 - * @tc.name SuccessEcc224AlgRsaForEncryptPromise - * @tc.desc Success ecc 224 alg rsa for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_26400', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_224); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_26500 - * @tc.name SuccessEcc256AlgRsaForEncryptPromise - * @tc.desc Success ecc 256 alg rsa for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_26500', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_26600 - * @tc.name SuccessEcc384AlgRsaForEncryptPromise - * @tc.desc Success ecc 384 alg rsa for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_26600', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_384); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_26700 - * @tc.name SuccessEcc521AlgRsaForEncryptPromise - * @tc.desc Success ecc 521 alg rsa for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_26700', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_521); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_26800 - * @tc.name SuccessAes128AlgRsaForEncryptPromise - * @tc.desc Success aes 128 alg rsa for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_26800', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_128); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_26900 - * @tc.name SuccessAes192AlgRsaForEncryptPromise - * @tc.desc Success aes 192 alg rsa for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_26900', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_192); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_27000 - * @tc.name SuccessAes256AlgRsaForEncryptPromise - * @tc.desc Success aes 256 alg rsa for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_27000', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_256); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_27100 - * @tc.name SuccessAes512AlgRsaForEncryptPromise - * @tc.desc Success aes 512 alg rsa for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_27100', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_512); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_27200 - * @tc.name SuccessCurve25519256AlgRsaForEncryptPromise - * @tc.desc Success curve25519 256 alg rsa for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_27200', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_27300 - * @tc.name SuccessDh2048AlgRsaForEncryptPromise - * @tc.desc Success dh 2048 alg rsa for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_27300', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_2048); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_27400 - * @tc.name SuccessDh3072AlgRsaForEncryptPromise - * @tc.desc Success dh 3072 alg rsa for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_27400', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_3072); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_27500 - * @tc.name SuccessDh4096AlgRsaForEncryptPromise - * @tc.desc Success dh 4096 alg rsa for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_27500', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = rsaEncryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_4096); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_27600 - * @tc.name SuccessRsa512AlgAesForEncryptPromise - * @tc.desc Success rsa 512 alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_27600', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_27700 - * @tc.name SuccessRsa768AlgAesForEncryptPromise - * @tc.desc Success rsa 768 alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_27700', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_768); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_27800 - * @tc.name SuccessRsa1024AlgAesForEncryptPromise - * @tc.desc Success rsa 1024 alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_27800', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_27900 - * @tc.name SuccessRsa2048AlgAesForEncryptPromise - * @tc.desc Success rsa 2048 alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_27900', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_28000 - * @tc.name SuccessRsa3072AlgAesForEncryptPromise - * @tc.desc Success rsa 3072 alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_28000', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_28100 - * @tc.name SuccessRsa4096AlgAesForEncryptPromise - * @tc.desc Success rsa 4096 alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_28100', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_28200 - * @tc.name SuccessEcc224AlgAesForEncryptPromise - * @tc.desc Success ecc 224 alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_28200', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_224); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_28300 - * @tc.name SuccessEcc256AlgAesForEncryptPromise - * @tc.desc Success ecc 256 alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_28300', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_28400 - * @tc.name SuccessEcc384AlgAesForEncryptPromise - * @tc.desc Success ecc 384 alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_28400', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_384); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_28500 - * @tc.name SuccessEcc521AlgAesForEncryptPromise - * @tc.desc Success ecc 521 alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_28500', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_521); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_28600 - * @tc.name SuccessCurve25519256AlgAesForEncryptPromise - * @tc.desc Success curve25519 256 alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_28600', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_28700 - * @tc.name SuccessDh2048AlgAesForEncryptPromise - * @tc.desc Success dh 2048 alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_28700', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_2048); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_28800 - * @tc.name SuccessDh3072AlgAesForEncryptPromise - * @tc.desc Success dh 3072 alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_28800', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_3072); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_28900 - * @tc.name SuccessDh4096AlgAesForEncryptPromise - * @tc.desc Success dh 4096 alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_28900', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_4096); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_29000 - * @tc.name InvalidPaddingPssPurposeEncryptDecryptAlgAesForEncryptPromise - * @tc.desc Invalid padding pss purpose encrypt decrypt alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_29000', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_PSS); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_29100 - * @tc.name InvalidPaddingPkcs5PurposeEncryptDecryptAlgAesForEncryptPromise - * @tc.desc Invalid padding pkcs5 purpose encrypt decrypt alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_29100', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_PKCS5); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_29200 - * @tc.name InvalidPaddingPkcs7PurposeEncryptDecryptAlgAesForEncryptPromise - * @tc.desc Invalid padding pkcs7 purpose encrypt decrypt alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_29200', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_PKCS7); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_29300 - * @tc.name SuccessDigestMd5AlgAesForEncryptPromise - * @tc.desc Success digest md5 alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_29300', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidDigestOption(hks.HuksKeyDigest.HUKS_DIGEST_MD5); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_29400 - * @tc.name InvalidArgumentIndataLargerThanKeySizeRsaPaddingNoneForEncryptPromise - * @tc.desc Invalid argument indata is larger than key size rsa padding none for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_29400', 0, async function (done) { - var option = generateRSAKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = rsaEncryptOrDecryptInvalidIndataOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_29500 - * @tc.name InvalidArgumentIndataLargerThanKeySizeAesPaddingNoneForEncryptPromise - * @tc.desc Invalid argument indata is larger than key size aes padding none for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_29500', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidIndataOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_29600 - * @tc.name InvalidPurposeDecryptAlgAesForEncryptPromise - * @tc.desc Invalid purpose decrypt alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_29600', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_29700 - * @tc.name InvalidPurposeSignAlgAesForEncryptPromise - * @tc.desc Invalid purpose sign alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_29700', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_29800 - * @tc.name InvalidPurposeVerifyAlgAesForEncryptPromise - * @tc.desc Invalid purpose verify alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_29800', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_29900 - * @tc.name InvalidPurposeDeriveAlgAesForEncryptPromise - * @tc.desc Invalid purpose derive alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_29900', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_30000 - * @tc.name InvalidPurposeWrapAlgAesForEncryptPromise - * @tc.desc Invalid purpose wrap alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_30000', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_WRAP); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_30100 - * @tc.name InvalidPurposeUnwrapAlgAesForEncryptPromise - * @tc.desc Invalid purpose unwrap alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_30100', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_30200 - * @tc.name InvalidPurposeMacAlgAesForEncryptPromise - * @tc.desc Invalid purpose mac alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_30200', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_30300 - * @tc.name InvalidPurposeagreeAlgAesForEncryptPromise - * @tc.desc Invalid purpose agree alg aes for encrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_30300', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_30400 - * @tc.name InvalidAlgorithmEccForDecryptPromise - * @tc.desc Invalid algorithm ecc for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_30400', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ECC); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_30500 - * @tc.name InvalidAlgorithmDsaForDecryptPromise - * @tc.desc Invalid algorithm dsa for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_30500', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_DSA); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_30600 - * @tc.name InvalidAlgorithmHmacForDecryptPromise - * @tc.desc Invalid algorithm hmac for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_30600', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_HMAC); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_30700 - * @tc.name InvalidAlgorithmHkdfForDecryptPromise - * @tc.desc Invalid algorithm hkdf for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_30700', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_HKDF); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_30800 - * @tc.name InvalidAlgorithmPbkdf2ForDecryptPromise - * @tc.desc Invalid algorithm pbkdf2 for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_30800', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_PBKDF2); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_30900 - * @tc.name InvalidAlgorithmEcdhForDecryptPromise - * @tc.desc Invalid algorithm ecdh for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_30900', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ECDH); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_31000 - * @tc.name InvalidAlgorithmX25519ForDecryptPromise - * @tc.desc Invalid algorithm x25519 for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_31000', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_X25519); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_31100 - * @tc.name InvalidAlgorithmEd25519ForDecryptPromise - * @tc.desc Invalid algorithm ed25519 for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_31100', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ED25519); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_31200 - * @tc.name InvalidAlgorithmDhForDecryptPromise - * @tc.desc Invalid algorithm dh for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_31200', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = encryptOrDecryptInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_DH); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_31300 - * @tc.name SuccessEcc224AlgRsaForDecryptPromise - * @tc.desc Success ecc 224 alg rsa for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_31300', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, cipherText); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_31400 - * @tc.name SuccessEcc256AlgRsaForDecryptPromise - * @tc.desc Success ecc 256 alg rsa for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_31400', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, cipherText); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_31500 - * @tc.name SuccessEcc384AlgRsaForDecryptPromise - * @tc.desc Success ecc 384 alg rsa for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_31500', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_384, cipherText); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_31600 - * @tc.name SuccessEcc521AlgRsaForDecryptPromise - * @tc.desc Success ecc 521 alg rsa for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_31600', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_521, cipherText); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_31700 - * @tc.name SuccessAes128AlgRsaForDecryptPromise - * @tc.desc Success aes 128 alg rsa for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_31700', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_128, cipherText); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_31800 - * @tc.name SuccessAes192AlgRsaForDecryptPromise - * @tc.desc Success aes 192 alg rsa for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_31800', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_192, cipherText); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_31900 - * @tc.name SuccessAes256AlgRsaForDecryptPromise - * @tc.desc Success aes 256 alg rsa for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_31900', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_256, cipherText); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_32000 - * @tc.name SuccessAes512AlgRsaForDecryptPromise - * @tc.desc Success aes 512 alg rsa for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_32000', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_AES_KEY_SIZE_512, cipherText); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_32100 - * @tc.name SuccessCurve25519256AlgRsaForDecryptPromise - * @tc.desc Success curve25519 256 alg rsa for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_32100', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256, cipherText); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_32200 - * @tc.name SuccessDh2048AlgRsaForDecryptPromise - * @tc.desc Success dh 2048 alg rsa for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_32200', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_2048, cipherText); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_32300 - * @tc.name SuccessDh3072AlgRsaForDecryptPromise - * @tc.desc Success dh 3072 alg rsa for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_32300', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_3072, cipherText); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_32400 - * @tc.name SuccessDh4096AlgRsaForDecryptPromise - * @tc.desc Success dh 4096 alg rsa for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_32400', 0, async function (done) { - var option = encryptOrDecryptGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var encryptOption = encryptOrDecryptOption(); - var encryptRet = await hks.encrypt(alias, encryptOption); - expect(encryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - cipherText = encryptRet.outData; - var decryptOption = rsaDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_4096, cipherText); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_32500 - * @tc.name SuccessRsa512AlgAesForDecryptPromise - * @tc.desc Success rsa 512 alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_32500', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_32600 - * @tc.name SuccessRsa768AlgAesForDecryptPromise - * @tc.desc Success rsa 768 alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_32600', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_768); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_32700 - * @tc.name SuccessRsa1024AlgAesForDecryptPromise - * @tc.desc Success rsa 1024 alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_32700', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_32800 - * @tc.name SuccessRsa2048AlgAesForDecryptPromise - * @tc.desc Success rsa 2048 alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_32800', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_32900 - * @tc.name SuccessRsa3072AlgAesForDecryptPromise - * @tc.desc Success rsa 3072 alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_32900', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_33000 - * @tc.name SuccessRsa4096AlgAesForDecryptPromise - * @tc.desc Success rsa 4096 alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_33000', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_33100 - * @tc.name SuccessEcc224AlgAesForDecryptPromise - * @tc.desc Success ecc 224 alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_33100', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_224); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_33200 - * @tc.name SuccessEcc256AlgAesForDecryptPromise - * @tc.desc Success ecc 256 alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_33200', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_33300 - * @tc.name SuccessEcc384AlgAesForDecryptPromise - * @tc.desc Success ecc 384 alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_33300', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_384); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_33400 - * @tc.name SuccessEcc521AlgAesForDecryptPromise - * @tc.desc Success ecc 521 alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_33400', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_ECC_KEY_SIZE_521); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_33500 - * @tc.name Successcurve25519256AlgAesForDecryptPromise - * @tc.desc Success curve25519 256 alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_33500', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_33600 - * @tc.name SuccessDh2048AlgAesForDecryptPromise - * @tc.desc Success dh 2048 alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_33600', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_2048); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_33700 - * @tc.name SuccessDh3072AlgAesForDecryptPromise - * @tc.desc Success dh 3072 alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_33700', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_3072); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_33800 - * @tc.name SuccessDh4096AlgAesForDecryptPromise - * @tc.desc Success dh 4096 alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_33800', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidSizeOption(hks.HuksKeySize.HUKS_DH_KEY_SIZE_4096); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_33900 - * @tc.name InvalidPaddingPssPurposeEncryptDecryptAlgAesForDecryptPromise - * @tc.desc Invalid padding pss purpose encrypt decrypt alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_33900', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_PSS); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_34000 - * @tc.name InvalidPaddingPkcs5PurposeEncryptDecryptAlgAesForDecryptPromise - * @tc.desc Invalid padding pkcs5 purpose encrypt decrypt alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_34000', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_PKCS5); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_34100 - * @tc.name InvalidPaddingPkcs7PurposeEncryptDecryptAlgAesForDecryptPromise - * @tc.desc Invalid padding pkcs7 purpose encrypt decrypt alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_34100', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_PKCS7); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_34200 - * @tc.name SuccessDigestMd5AlgAesForDecryptPromise - * @tc.desc Success digest md5 alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_34200', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidDigestOption(hks.HuksKeyDigest.HUKS_DIGEST_MD5); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_34300 - * @tc.name InvalidArgumentIndataLargerThanKeySizeRsaPaddingNoneForDecryptPromise - * @tc.desc Invalid argument indata is larger than key size rsa padding none for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_34300', 0, async function (done) { - var option = generateRSAKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = rsaEncryptOrDecryptInvalidIndataOption(); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_34400 - * @tc.name InvalidArgumentIndataLargerThanKeySizeAesPaddingNoneForDecryptPromise - * @tc.desc Invalid argument indata is larger than key size aes padding none for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_34400', 0, async function (done) { - var option = generateAesCBCKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidIndataOption(); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_34500 - * @tc.name InvalidPurposeEncryptAlgAesForDecryptPromise - * @tc.desc Invalid purpose encrypt alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_34500', 0, async function (done) { - var option = generateAesGCMKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_34600 - * @tc.name InvalidPurposeSignAlgAesForDecryptPromise - * @tc.desc Invalid purpose sign alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_34600', 0, async function (done) { - var option = generateAesGCMKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_34700 - * @tc.name InvalidPurposeVerifyAlgAesForDecryptPromise - * @tc.desc Invalid purpose verify alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_34700', 0, async function (done) { - var option = generateAesGCMKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_34800 - * @tc.name InvalidPurposeDeriveAlgAesForDecryptPromise - * @tc.desc Invalid purpose derive alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_34800', 0, async function (done) { - var option = generateAesGCMKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_34900 - * @tc.name InvalidPurposeWrapAlgAesForDecryptPromise - * @tc.desc Invalid purpose wrap alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_34900', 0, async function (done) { - var option = generateAesGCMKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_WRAP); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_35000 - * @tc.name InvalidPurposeUnwrapAlgAesForDecryptPromise - * @tc.desc Invalid purpose unwrap alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_35000', 0, async function (done) { - var option = generateAesGCMKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_35100 - * @tc.name InvalidPurposeMacAlgAesForDecryptPromise - * @tc.desc Invalid purpose mac alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_35100', 0, async function (done) { - var option = generateAesGCMKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_CALLBACK_35200 - * @tc.name InvalidPurposeAgreeAlgAesForDecryptPromise - * @tc.desc Invalid purpose agree alg aes for decrypt promise. - */ - it('HUKS_ABNORMAL_PROMISE_35200', 0, async function (done) { - var option = generateAesGCMKeyOption; - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = aesEncryptOrDecryptInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE); - var decryptRet = await hks.decrypt(alias, decryptOption); - expect(decryptRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); -}); - diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_promise_part4.test.js b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_promise_part4.test.js deleted file mode 100644 index db3d6ca5a0a021089ecf0a7a2178496977659727..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_promise_part4.test.js +++ /dev/null @@ -1,600 +0,0 @@ -/* - * 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 hks from '@ohos.security.huks' -import { describe, it, expect } from 'deccjsunit/index' -import { - alias, -} from '../../../../../../hks_xts_common.test' -import { - plainTextSize64, - signOrVerifyGenerateKeyOption, - signOrVerifyInvalidAlgOption, - signOrVerifyInvalidPurposeOption, - signOrVerifyInvalidPaddingOption, -} from './hks_abnormal_common.test.js' - -describe('Hks_Abnormal_Promise_Part4', function () { - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_35300 - * @tc.name InvalidAlgorithmAlgAesForSignPromise - * @tc.desc Invalid algorithm alg aes for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_35300', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var signOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_AES); - var signRet = await hks.sign(alias, signOption); - expect(signRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_35400 - * @tc.name InvalidAlgorithmAlghmacForSignPromise - * @tc.desc Invalid algorithm alg hmac for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_35400', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var signOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_HMAC); - var signRet = await hks.sign(alias, signOption); - expect(signRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_35500 - * @tc.name InvalidAlgorithmAlgHkdfForSignPromise - * @tc.desc Invalid algorithm alg hkdf for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_35500', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var signOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_HKDF); - var signRet = await hks.sign(alias, signOption); - expect(signRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_35600 - * @tc.name InvalidAlgorithmAlgPbkdf2ForSignPromise - * @tc.desc Invalid algorithm alg pbkdf2 for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_35600', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var signOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_PBKDF2); - var signRet = await hks.sign(alias, signOption); - expect(signRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_35700 - * @tc.name InvalidAlgorithmAlgEcdhForSignPromise - * @tc.desc Invalid algorithm alg ecdh for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_35700', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var signOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ECDH); - var signRet = await hks.sign(alias, signOption); - expect(signRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_35800 - * @tc.name InvalidAlgorithmAlgX25519ForSignPromise - * @tc.desc Invalid algorithm alg x25519 for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_35800', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var signOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_X25519); - var signRet = await hks.sign(alias, signOption); - expect(signRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_35900 - * @tc.name InvalidAlgorithmAlgDhForSignPromise - * @tc.desc Invalid algorithm alg dh for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_35900', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var signOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_DH); - var signRet = await hks.sign(alias, signOption); - expect(signRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_36000 - * @tc.name InvalidPurposeEncryptForSignPromise - * @tc.desc Invalid purpose encrypt for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_36000', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var signOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT); - var signRet = await hks.sign(alias, signOption); - expect(signRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_36100 - * @tc.name InvalidPurposeDecryptForSignPromise - * @tc.desc Invalid purpose decrypt for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_36100', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var signOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT); - var signRet = await hks.sign(alias, signOption); - expect(signRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_36200 - * @tc.name InvalidPurposeVerifyForSignPromise - * @tc.desc Invalid purpose verify for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_36200', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var signOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY); - var signRet = await hks.sign(alias, signOption); - expect(signRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_36300 - * @tc.name InvalidPurposeDeriveForSignPromise - * @tc.desc Invalid purpose derive for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_36300', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var signOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - var signRet = await hks.sign(alias, signOption); - expect(signRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_36400 - * @tc.name InvalidPurposeWrapForSignPromise - * @tc.desc Invalid purpose wrap for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_36400', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var signOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_WRAP); - var signRet = await hks.sign(alias, signOption); - expect(signRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_36500 - * @tc.name InvalidPurposeUnwrapForSignPromise - * @tc.desc Invalid purpose unwrap for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_36500', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var signOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP); - var signRet = await hks.sign(alias, signOption); - expect(signRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_36600 - * @tc.name InvalidPurposeMacForSignPromise - * @tc.desc Invalid purpose mac for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_36600', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var signOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - var signRet = await hks.sign(alias, signOption); - expect(signRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_36700 - * @tc.name InvalidPurposeAgreeForSignPromise - * @tc.desc Invalid purpose agree for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_36700', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var signOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE); - var signRet = await hks.sign(alias, signOption); - expect(signRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_36800 - * @tc.name InvalidPaddingNoneAlgRsaForSignPromise - * @tc.desc Invalid padding none alg rsa for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_36800', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var signOption = signOrVerifyInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_NONE); - var signRet = await hks.sign(alias, signOption); - expect(signRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_36900 - * @tc.name InvalidPaddingOaepAlgRsaForSignPromise - * @tc.desc Invalid padding oaep alg rsa for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_36900', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var signOption = signOrVerifyInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_OAEP); - var signRet = await hks.sign(alias, signOption); - expect(signRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_37000 - * @tc.name InvalidPaddingPkcs5AlgRsaForSignPromise - * @tc.desc Invalid padding pkcs5 alg rsa for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_37000', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var signOption = signOrVerifyInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_PKCS5); - var signRet = await hks.sign(alias, signOption); - expect(signRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_37100 - * @tc.name InvalidPaddingPkcs7AlgRsaForSignPromise - * @tc.desc Invalid padding pkcs7 alg rsa for sign promise. - */ - it('HUKS_ABNORMAL_PROMISE_37100', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var signOption = signOrVerifyInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_PKCS7); - var signRet = await hks.sign(alias, signOption); - expect(signRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_37200 - * @tc.name InvalidAlgorithmAlgAesForVerifyPromise - * @tc.desc Invalid algorithm alg aes for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_37200', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var verifyOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_AES); - var verifyRet = await hks.verify(alias, verifyOption, plainTextSize64); - expect(verifyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_37300 - * @tc.name InvalidAlgorithmAlgHmacForVerifyPromise - * @tc.desc Invalid algorithm alg hmac for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_37300', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var verifyOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_HMAC); - var verifyRet = await hks.verify(alias, verifyOption, plainTextSize64); - expect(verifyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_37400 - * @tc.name InvalidAlgorithmAlgHkdfForVerifyPromise - * @tc.desc Invalid algorithm alg hkdf for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_37400', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var verifyOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_HKDF); - var verifyRet = await hks.verify(alias, verifyOption, plainTextSize64); - expect(verifyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_37500 - * @tc.name InvalidAlgorithmAlgPbkdf2ForVerifyPromise - * @tc.desc Invalid algorithm alg pbkdf2 for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_37500', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var verifyOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_PBKDF2); - var verifyRet = await hks.verify(alias, verifyOption, plainTextSize64); - expect(verifyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_37600 - * @tc.name InvalidAlgorithmAlgEcdhForVerifyPromise - * @tc.desc Invalid algorithm alg ecdh for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_37600', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var verifyOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ECDH); - var verifyRet = await hks.verify(alias, verifyOption, plainTextSize64); - expect(verifyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_37700 - * @tc.name InvalidAlgorithmAlgX25519ForVerifyPromise - * @tc.desc Invalid algorithm alg x25519 for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_37700', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var verifyOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_X25519); - var verifyRet = await hks.verify(alias, verifyOption, plainTextSize64); - expect(verifyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_37800 - * @tc.name InvalidAlgorithmAlgDhForVerifyPromise - * @tc.desc Invalid algorithm alg dh for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_37800', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var verifyOption = signOrVerifyInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_DH); - var verifyRet = await hks.verify(alias, verifyOption, plainTextSize64); - expect(verifyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_37900 - * @tc.name InvalidAlgorithmEncryptForVerifyPromise - * @tc.desc Invalid purpose encrypt for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_37900', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var verifyOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT); - var verifyRet = await hks.verify(alias, verifyOption, plainTextSize64); - expect(verifyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_38000 - * @tc.name InvalidAlgorithmDecryptForVerifyPromise - * @tc.desc Invalid purpose decrypt for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_38000', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var verifyOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT); - var verifyRet = await hks.verify(alias, verifyOption, plainTextSize64); - expect(verifyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_38100 - * @tc.name InvalidAlgorithmSignForVerifyPromise - * @tc.desc Invalid purpose sign for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_38100', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var verifyOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN); - var verifyRet = await hks.verify(alias, verifyOption, plainTextSize64); - expect(verifyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_38200 - * @tc.name InvalidAlgorithmDeriveForVerifyPromise - * @tc.desc Invalid purpose derive for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_38200', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var verifyOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE); - var verifyRet = await hks.verify(alias, verifyOption, plainTextSize64); - expect(verifyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_38300 - * @tc.name InvalidAlgorithmWrapForVerifyPromise - * @tc.desc Invalid purpose wrap for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_38300', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var verifyOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_WRAP); - var verifyRet = await hks.verify(alias, verifyOption, plainTextSize64); - expect(verifyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_38400 - * @tc.name InvalidAlgorithmUnwrapForVerifyPromise - * @tc.desc Invalid purpose unwrap for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_38400', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var verifyOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP); - var verifyRet = await hks.verify(alias, verifyOption, plainTextSize64); - expect(verifyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_38500 - * @tc.name InvalidAlgorithmMacForVerifyPromise - * @tc.desc Invalid purpose mac for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_38500', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var verifyOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - var verifyRet = await hks.verify(alias, verifyOption, plainTextSize64); - expect(verifyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_38600 - * @tc.name InvalidAlgorithmAgreeForVerifyPromise - * @tc.desc Invalid purpose agree for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_38600', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var verifyOption = signOrVerifyInvalidPurposeOption(hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE); - var verifyRet = await hks.verify(alias, verifyOption, plainTextSize64); - expect(verifyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_38700 - * @tc.name InvalidPaddingNoneAlgRsaForVerifyPromise - * @tc.desc Invalid padding none alg rsa for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_38700', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var verifyOption = signOrVerifyInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_NONE); - var verifyRet = await hks.verify(alias, verifyOption, plainTextSize64); - expect(verifyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_38800 - * @tc.name InvalidPaddingOaepAlgRsaForVerifyPromise - * @tc.desc Invalid padding oaep alg rsa for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_38800', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var verifyOption = signOrVerifyInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_OAEP); - var verifyRet = await hks.verify(alias, verifyOption, plainTextSize64); - expect(verifyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_38900 - * @tc.name InvalidPaddingPksc5AlgRsaForVerifyPromise - * @tc.desc Invalid padding pksc5 alg rsa for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_38900', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var verifyOption = signOrVerifyInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_PKCS5); - var verifyRet = await hks.verify(alias, verifyOption, plainTextSize64); - expect(verifyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_39000 - * @tc.name InvalidPaddingPkcs7AlgRsaForVerifyPromise - * @tc.desc Invalid padding pkcs7 alg rsa for verify promise. - */ - it('HUKS_ABNORMAL_PROMISE_39000', 0, async function (done) { - var option = signOrVerifyGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var verifyOption = signOrVerifyInvalidPaddingOption(hks.HuksKeyPadding.HUKS_PADDING_PKCS7); - var verifyRet = await hks.verify(alias, verifyOption, plainTextSize64); - expect(verifyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); -}); \ No newline at end of file diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_promise_part5.test.js b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_promise_part5.test.js deleted file mode 100644 index cdd7cb4b668e15480b4dc85147d6ee644d7fb918..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_promise_part5.test.js +++ /dev/null @@ -1,345 +0,0 @@ -/* - * 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 hks from '@ohos.security.huks' -import { describe, it, expect } from 'deccjsunit/index' -import { - alias, -} from '../../../../../../hks_xts_common.test' -import { - generateAgreeKeyOption, - hmacGenerateKeyOption, - agreeInvalidAlgOption, - hmacInvalidPurposeOption, -} from './hks_abnormal_common.test.js' - -describe('Hks_Abnormal_Promise_Part5', function () { - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_39100 - * @tc.name InvalidAlgorithmAlgRsaForAgreeKeyPromise - * @tc.desc Invalid algorithm alg rsa for agree key promise. - */ - it('HUKS_ABNORMAL_PROMISE_39100', 0, async function (done) { - var option = generateAgreeKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(alias, option); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var agreeOption = agreeInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_RSA); - agreeOption.inData = exportKeyRet.outData - var agreeRet = await hks.agreeKey(alias, agreeOption); - expect(agreeRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_39200 - * @tc.name InvalidAlgorithmAlgEccForAgreeKeyPromise - * @tc.desc Invalid algorithm alg ecc for agree key promise. - */ - it('HUKS_ABNORMAL_PROMISE_39200', 0, async function (done) { - var option = generateAgreeKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(alias, option); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var agreeOption = agreeInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ECC); - agreeOption.inData = exportKeyRet.outData - var agreeRet = await hks.agreeKey(alias, agreeOption); - expect(agreeRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_39300 - * @tc.name InvalidAlgorithmAlgDsaForAgreeKeyPromise - * @tc.desc Invalid algorithm alg dsa for agree key promise. - */ - it('HUKS_ABNORMAL_PROMISE_39300', 0, async function (done) { - var option = generateAgreeKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(alias, option); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var agreeOption = agreeInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_DSA); - agreeOption.inData = exportKeyRet.outData - var agreeRet = await hks.agreeKey(alias, agreeOption); - expect(agreeRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_39400 - * @tc.name InvalidAlgorithmAlgAesForAgreeKeyPromise - * @tc.desc Invalid algorithm alg aes for agree key promise. - */ - it('HUKS_ABNORMAL_PROMISE_39400', 0, async function (done) { - var option = generateAgreeKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(alias, option); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var agreeOption = agreeInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_AES); - agreeOption.properties[1].value = hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256; - agreeOption.inData = exportKeyRet.outData - var agreeRet = await hks.agreeKey(alias, agreeOption); - expect(agreeRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_INFO); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_39500 - * @tc.name InvalidAlgorithmAlgHmacForAgreeKeyPromise - * @tc.desc Invalid algorithm alg hmac for agree key promise. - */ - it('HUKS_ABNORMAL_PROMISE_39500', 0, async function (done) { - var option = generateAgreeKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(alias, option); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var agreeOption = agreeInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_HMAC); - agreeOption.inData = exportKeyRet.outData - var agreeRet = await hks.agreeKey(alias, agreeOption); - expect(agreeRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_39600 - * @tc.name InvalidAlgorithmAlgHkdfForAgreeKeyPromise - * @tc.desc Invalid algorithm alg hkdf for agree key promise. - */ - it('HUKS_ABNORMAL_PROMISE_39600', 0, async function (done) { - var option = generateAgreeKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(alias, option); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var agreeOption = agreeInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_HKDF); - agreeOption.inData = exportKeyRet.outData - var agreeRet = await hks.agreeKey(alias, agreeOption); - expect(agreeRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_39700 - * @tc.name InvalidAlgorithmAlgPbkdf2ForAgreeKeyPromise - * @tc.desc Invalid algorithm alg pbkdf2 for agree key promise. - */ - it('HUKS_ABNORMAL_PROMISE_39700', 0, async function (done) { - var option = generateAgreeKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(alias, option); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var agreeOption = agreeInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_PBKDF2); - agreeOption.inData = exportKeyRet.outData - var agreeRet = await hks.agreeKey(alias, agreeOption); - expect(agreeRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_39800 - * @tc.name InvalidAlgorithmAlgEd25519ForAgreeKeyPromise - * @tc.desc Invalid algorithm alg ed25519 for agree key promise. - */ - it('HUKS_ABNORMAL_PROMISE_39800', 0, async function (done) { - var option = generateAgreeKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(alias, option); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var agreeOption = agreeInvalidAlgOption(hks.HuksKeyAlg.HUKS_ALG_ED25519); - agreeOption.properties[1].value = hks.HuksKeySize.HUKS_ECC_KEY_SIZE_256; - agreeOption.inData = exportKeyRet.outData - var agreeRet = await hks.agreeKey(alias, agreeOption); - expect(agreeRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_INFO); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_39900 - * @tc.name InvalidPurposeEncryptForMacPromise - * @tc.desc Invalid purpose encrypt for mac promise. - */ - it('HUKS_ABNORMAL_PROMISE_39900', 0, async function (done) { - var option = hmacGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var macOption = hmacInvalidPurposeOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1); - var macRet = await hks.mac(alias, macOption); - expect(macRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_40000 - * @tc.name InvalidPurposeDecryptForMacPromise - * @tc.desc Invalid purpose decrypt for mac promise. - */ - it('HUKS_ABNORMAL_PROMISE_40000', 0, async function (done) { - var option = hmacGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var macOption = hmacInvalidPurposeOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1); - var macRet = await hks.mac(alias, macOption); - expect(macRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_40100 - * @tc.name InvalidPurposeSignForMacPromise - * @tc.desc Invalid purpose sign for mac promise. - */ - it('HUKS_ABNORMAL_PROMISE_40100', 0, async function (done) { - var option = hmacGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var macOption = hmacInvalidPurposeOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1); - var macRet = await hks.mac(alias, macOption); - expect(macRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_40200 - * @tc.name InvalidPurposeVerifyForMacPromise - * @tc.desc Invalid purpose verify for mac promise. - */ - it('HUKS_ABNORMAL_PROMISE_40200', 0, async function (done) { - var option = hmacGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var macOption = hmacInvalidPurposeOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1); - var macRet = await hks.mac(alias, macOption); - expect(macRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_40300 - * @tc.name InvalidPurposeDeriveForMacPromise - * @tc.desc Invalid purpose derive for mac promise. - */ - it('HUKS_ABNORMAL_PROMISE_40300', 0, async function (done) { - var option = hmacGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var macOption = hmacInvalidPurposeOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1); - var macRet = await hks.mac(alias, macOption); - expect(macRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_40400 - * @tc.name InvalidPurposeWrapForMacPromise - * @tc.desc Invalid purpose wrap for mac promise. - */ - it('HUKS_ABNORMAL_PROMISE_40400', 0, async function (done) { - var option = hmacGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var macOption = hmacInvalidPurposeOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_WRAP, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1); - var macRet = await hks.mac(alias, macOption); - expect(macRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_40500 - * @tc.name InvalidPurposeUnwrapForMacPromise - * @tc.desc Invalid purpose unwrap for mac promise. - */ - it('HUKS_ABNORMAL_PROMISE_40500', 0, async function (done) { - var option = hmacGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var macOption = hmacInvalidPurposeOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1); - var macRet = await hks.mac(alias, macOption); - expect(macRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_40600 - * @tc.name InvalidPurposeAgreeForMacPromise - * @tc.desc Invalid purpose agree for mac promise. - */ - it('HUKS_ABNORMAL_PROMISE_40600', 0, async function (done) { - var option = hmacGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var macOption = hmacInvalidPurposeOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, - hks.HuksKeyDigest.HUKS_DIGEST_SHA1); - var macRet = await hks.mac(alias, macOption); - expect(macRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_40700 - * @tc.name InvalidDigestNoneForMacPromise - * @tc.desc Invalid digest none for mac promise. - */ - it('HUKS_ABNORMAL_PROMISE_40700', 0, async function (done) { - var option = hmacGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var macOption = hmacInvalidPurposeOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - hks.HuksKeyDigest.HUKS_DIGEST_NONE); - var macRet = await hks.mac(alias, macOption); - expect(macRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_40800 - * @tc.name InvalidDigestMd5ForMacPromise - * @tc.desc Invalid digest md5 for mac promise. - */ - it('HUKS_ABNORMAL_PROMISE_40800', 0, async function (done) { - var option = hmacGenerateKeyOption(); - var ret = await hks.generateKey(alias, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var macOption = hmacInvalidPurposeOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - hks.HuksKeyDigest.HUKS_DIGEST_MD5); - var macRet = await hks.mac(alias, macOption); - expect(macRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - done(); - }); -}); \ No newline at end of file diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_promise_part6.test.js b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_promise_part6.test.js deleted file mode 100644 index c59e3f6f334c3bb541a2dd995fb337825b309e32..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_promise_part6.test.js +++ /dev/null @@ -1,669 +0,0 @@ -/* - * 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 hks from '@ohos.security.huks' -import { describe, it, expect } from 'deccjsunit/index' -import { - aliasA, - aliasB, -} from '../../../../../../hks_xts_common.test' -import { - generateImportKeyOption, - eccGenerateKeyOption, - importOptionsInvalidAlgOption, - importOptionsInvalidSizeOption, - importOptionsInvalidPurposeOrPaddingOption, -} from './hks_abnormal_common.test.js' - -describe('Hks_Abnormal_Promise_Part6', function () { - var publicKey = []; - - var emptyOption = makeEmptyOptions(); - - function makeEmptyOptions() { - var emptyOptions = { - properties: [] - }; - return emptyOptions; - }; - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_40900 - * @tc.name InvalidPurposeDeriveAlgRsaForImportKeyPromise - * @tc.desc Invalid purpose derive alg rsa for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_40900', 0, async function (done) { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_RSA, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_41000 - * @tc.name InvalidPurposeDeriveAlgEccForImportKeyPromise - * @tc.desc Invalid purpose derive alg ecc for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_41000', 0, async function (done) { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_ECC, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_41100 - * @tc.name InvalidPurposeDeriveAlgDsaForImportKeyPromise - * @tc.desc Invalid purpose derive alg dsa for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_41100', 0, async function (done) { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_DSA, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_41200 - * @tc.name InvalidPurposeDeriveAlgHkdfForImportKeyPromise - * @tc.desc Invalid purpose derive alg hkdf for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_41200', 0, async function (done) { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_HKDF, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_41300 - * @tc.name InvalidPurposeDeriveAlgPbkdf2ForImportKeyPromise - * @tc.desc Invalid purpose derive alg pbkdf2 for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_41300', 0, async function (done) { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_PBKDF2, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_41400 - * @tc.name InvalidPurposeDeriveAlgEcdhForImportKeyPromise - * @tc.desc Invalid purpose derive alg ecdh for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_41400', 0, async function (done) { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_ECDH, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_41500 - * @tc.name InvalidPurposeDeriveAlgX25519ForImportKeyPromise - * @tc.desc Invalid purpose derive alg x25519 for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_41500', 0, async function (done) { - var option = eccGenerateKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_X25519, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_INFO); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_41600 - * @tc.name InvalidPurposeDeriveAlgEd25519ForImportKeyPromise - * @tc.desc Invalid purpose derive alg ed25519 for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_41600', 0, async function (done) { - var option = eccGenerateKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_ED25519, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_INFO); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_41700 - * @tc.name InvalidPurposeDeriveAlgDhForImportKeyPromise - * @tc.desc Invalid purpose derive alg dh for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_41700', 0, async function (done) { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_DH, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_41800 - * @tc.name InvalidPurposeMacAlgRsaForImportKeyPromise - * @tc.desc Invalid purpose mac alg rsa for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_41800', 0, async function (done) { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_RSA, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_41900 - * @tc.name InvalidPurposeMacAlgEccForImportKeyPromise - * @tc.desc Invalid purpose mac alg ecc for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_41900', 0, async function (done) { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_ECC, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_42000 - * @tc.name InvalidPurposeMacAlgDsaForImportKeyPromise - * @tc.desc Invalid purpose mac alg dsa for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_42000', 0, async function (done) { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_DSA, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_42100 - * @tc.name InvalidPurposeMacAlgHkdfForImportKeyPromise - * @tc.desc Invalid purpose mac alg hkdf for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_42100', 0, async function (done) { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_HKDF, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_42200 - * @tc.name InvalidPurposeMacAlgPbkdf2ForImportKeyPromise - * @tc.desc Invalid purpose mac alg pbkdf2 for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_42200', 0, async function (done) { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_PBKDF2, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_42300 - * @tc.name InvalidPurposeMacAlgEcdhForImportKeyPromise - * @tc.desc Invalid purpose mac alg ecdh for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_42300', 0, async function (done) { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_ECDH, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_42400 - * @tc.name InvalidPurposeMacAlgX25519ForImportKeyPromise - * @tc.desc Invalid purpose mac alg x25519 for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_42400', 0, async function (done) { - var option = eccGenerateKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_X25519, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_INFO); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_42500 - * @tc.name InvalidPurposeMacAlgEd25519ForImportKeyPromise - * @tc.desc Invalid purpose mac alg ed25519 for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_42500', 0, async function (done) { - var option = eccGenerateKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_ED25519, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_INFO); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_42600 - * @tc.name InvalidPurposeMacAlgDhForImportKeyPromise - * @tc.desc Invalid purpose mac alg dh for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_42600', 0, async function (done) { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidAlgOption( - hks.HuksKeyAlg.HUKS_ALG_DH, - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_42700 - * @tc.name GenerateAndImportKeySizeDifferentAesForImportKeyPromise - * @tc.desc Generate key and import key have different key size aes for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_42700', 0, async function (done) { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidSizeOption(hks.HuksKeyAlg.HUKS_ALG_AES, publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_INFO); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_42800 - * @tc.name GenerateAndImportKeySizeDifferentRsaForImportKeyPromise - * @tc.desc Generate key and import key have different key size rsa for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_42800', 0, async function (done) { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidSizeOption(hks.HuksKeyAlg.HUKS_ALG_RSA, publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_INFO); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_42900 - * @tc.name GenerateAndImportKeySizeDifferentEccForImportKeyPromise - * @tc.desc Generate key and import key have different key size ecc for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_42900', 0, async function (done) { - var option = eccGenerateKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidSizeOption(hks.HuksKeyAlg.HUKS_ALG_ECC, publicKey); - importOptions.properties[1].value = hks.HuksKeySize.HUKS_ECC_KEY_SIZE_521; - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_INFO); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_43000 - * @tc.name InvalidPurposeDecryptForImportKeyPromise - * @tc.desc Invalid purpose decrypt for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_43000', 0, async function (done) { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidPurposeOrPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_43100 - * @tc.name InvalidPurposeSignForImportKeyPromise - * @tc.desc Invalid purpose sign for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_43100', 0, async function (done) { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidPurposeOrPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN, - hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_43200 - * @tc.name InvalidPaddingNonePurposeEncryptForImportKeyPromise - * @tc.desc Invalid padding none purpose encrypt for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_43200', 0, async function (done) { - var option = generateImportKeyOption(); - var purpose = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT; - option.properties[2].value = purpose; - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidPurposeOrPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - hks.HuksKeyPadding.HUKS_PADDING_PSS, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_43300 - * @tc.name InvalidPaddingPkcs5PurposeEncryptForImportKeyPromise - * @tc.desc Invalid padding pkcs5 purpose encrypt for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_43300', 0, async function (done) { - var option = generateImportKeyOption(); - var purpose = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT; - option.properties[2].value = purpose; - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidPurposeOrPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - hks.HuksKeyPadding.HUKS_PADDING_PKCS5, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_43400 - * @tc.name InvalidPaddingPkcs7PurposeEncryptForImportKeyPromise - * @tc.desc Invalid padding pkcs7 purpose encrypt for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_43400', 0, async function (done) { - var option = generateImportKeyOption(); - var purpose = hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT; - option.properties[2].value = purpose; - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidPurposeOrPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - hks.HuksKeyPadding.HUKS_PADDING_PKCS7, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_43500 - * @tc.name InvalidPaddingNonePurposeVerifyForImportKeyPromise - * @tc.desc Invalid padding none purpose verify for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_43500', 0, async function (done) { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidPurposeOrPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_NONE, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_43600 - * @tc.name InvalidPaddingOaepPurposeVerifyForImportKeyPromise - * @tc.desc Invalid padding oaep purpose verify for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_43600', 0, async function (done) { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidPurposeOrPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_OAEP, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_43700 - * @tc.name InvalidPaddingPkcs5PurposeVerifyForImportKeyPromise - * @tc.desc Invalid padding pkcs5 purpose verify for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_43700', 0, async function (done) { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidPurposeOrPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_PKCS5, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); - - /** - * @tc.number HUKS_ABNORMAL_PROMISE_43800 - * @tc.name InvalidPaddingPkcs7PurposeVerifyForImportKeyPromise - * @tc.desc Invalid padding pkcs7 purpose verify for import key promise. - */ - it('HUKS_ABNORMAL_PROMISE_43800', 0, async function (done) { - var option = generateImportKeyOption(); - var ret = await hks.generateKey(aliasA, option); - expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await hks.exportKey(aliasA, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOptions = importOptionsInvalidPurposeOrPaddingOption( - hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - hks.HuksKeyPadding.HUKS_PADDING_PKCS7, - publicKey); - var importKeyRet = await hks.importKey(aliasB, importOptions); - expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - done(); - }); -}); \ No newline at end of file diff --git a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_testList.test.js b/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_testList.test.js deleted file mode 100644 index be118a2543b409da8c5a92996ad51b888bbcba71..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAbnormalTest/entry/src/main/js/test/hks_abnormal_testList.test.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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. - */ - -require('./hks_abnormal_promise_part1.test.js'); -require('./hks_abnormal_promise_part2.test'); -require('./hks_abnormal_promise_part3.test'); -require('./hks_abnormal_promise_part4.test'); -require('./hks_abnormal_promise_part5.test'); -require('./hks_abnormal_promise_part6.test'); -require('./hks_abnormal_callback_part1.test.js'); -require('./hks_abnormal_callback_part2.test'); -require('./hks_abnormal_callback_part3.test'); -require('./hks_abnormal_callback_part4.test'); -require('./hks_abnormal_callback_part5.test'); -require('./hks_abnormal_callback_part6.test'); diff --git a/security/huks_standard/HuksAbnormalTest/signature/openharmony_sx.p7b b/security/huks_standard/HuksAbnormalTest/signature/openharmony_sx.p7b deleted file mode 100644 index 9be1e98fa4c0c28ca997ed660112fa16b194f0f5..0000000000000000000000000000000000000000 Binary files a/security/huks_standard/HuksAbnormalTest/signature/openharmony_sx.p7b and /dev/null differ diff --git a/security/huks_standard/HuksAlgCompletionTest/BUILD.gn b/security/huks_standard/HuksAlgCompletionTest/BUILD.gn deleted file mode 100644 index a48415ffb3b37bf52962ffd7b4936086827a0997..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAlgCompletionTest/BUILD.gn +++ /dev/null @@ -1,31 +0,0 @@ -# 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("//test/xts/tools/build/suite.gni") - -ohos_js_hap_suite("ActsHuksAlgCompletionTest") { - hap_profile = "./entry/src/main/config.json" - deps = [ - ":hjs_demo_js_assets", - ":hjs_demo_resources", - ] - certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsHuksAlgCompletionTest" -} -ohos_js_assets("hjs_demo_js_assets") { - source_dir = "./entry/src/main/js/default" -} -ohos_resources("hjs_demo_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" -} diff --git a/security/huks_standard/HuksAlgCompletionTest/Test.json b/security/huks_standard/HuksAlgCompletionTest/Test.json deleted file mode 100644 index f7121dd29833e416c14b4a9295e93dd9237539f3..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAlgCompletionTest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for algorithm completion test", - "driver": { - "type": "JSUnitTest", - "test-timeout": "26000000", - "package": "com.example.hksxtstest", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHuksAlgCompletionTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/config.json b/security/huks_standard/HuksAlgCompletionTest/entry/src/main/config.json deleted file mode 100644 index df60f7ebba6718e867102c702f082be69d878251..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/config.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "app": { - "bundleName": "com.example.hksxtstest", - "vendor": "example", - "version": { - "code": 1, - "name": "1.0.0" - }, - "apiVersion": { - "compatible": 4, - "target": 5, - "releaseType": "Beta1" - } - }, - "deviceConfig": {}, - "module": { - "package": "com.example.hksxtstest", - "name": ".MyApplication", - "mainAbility": "com.example.hksxtstest.MainAbility", - "deviceType": [ - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry", - "installationFree": true - }, - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "name": "com.example.hksxtstest.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:entry_MainAbility", - "type": "page", - "launchType": "singleton", - "visible": true, - "isVisible": "true" - } - ], - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": true - } - } - ] - } - } \ No newline at end of file diff --git a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/default/app.js b/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/default/app.js deleted file mode 100644 index 14ca792625c50b934e7bda87ac333d3414dc12bd..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/default/app.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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. - */ - -export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } -}; diff --git a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/default/i18n/en-US.json b/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/default/i18n/en-US.json deleted file mode 100644 index e63c70d978a3a53be988388c87182f81785e170c..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/default/i18n/en-US.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - } -} \ No newline at end of file diff --git a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/default/i18n/zh-CN.json b/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/default/i18n/zh-CN.json deleted file mode 100644 index de6ee5748322f44942c1b003319d8e66c837675f..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/default/i18n/zh-CN.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - } -} \ No newline at end of file diff --git a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/default/pages/index/index.css b/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/default/pages/index/index.css deleted file mode 100644 index f96e198556759fe591de240be0baaaa43dafc110..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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. - */ - -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 40px; - color: #000; - opacity: .9; -} - -.btn { - background-color: dodgerblue; - color: white; - padding: 15px 32px; - text-align: center; - font-size: 12px; - margin-top: 5px; -} - -@media screen and (device-type: tablet) and (orientation: landscape) { - .title { - font-size: 100px; - } -} - -@media screen and (device-type: wearable) { - .title { - font-size: 28px; - color: #FFF; - } -} - -@media screen and (device-type: tv) { - .container { - background-image: url(../../common/images/Wallpaper.png); - background-size: cover; - background-repeat: no-repeat; - } - - .title { - font-size: 100px; - color: #FFF; - } -} - -@media screen and (device-type: phone) and (orientation: landscape) { - .title { - font-size: 60px; - } -} diff --git a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/default/pages/index/index.hml b/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/default/pages/index/index.hml deleted file mode 100644 index 546cd8296b727c1639d551d2301a0bca055c1457..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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. - */ - -
- - {{ $t('strings.hello') }} {{ title }} - -
diff --git a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/default/pages/index/index.js b/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/default/pages/index/index.js deleted file mode 100644 index 97a9962320e534900da6449525c42dcd7b40e65e..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/default/pages/index/index.js +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 file from '@system.file'; -import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index'; - -export default { - data: { - title: '' - }, - onInit() { - this.title = this.$t('strings.world'); - }, - - onShow() { - const core = Core.getInstance(); - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }); - const reportExtend = new ReportExtend(file); - core.addService('expect', expectExtend); - core.addService('report', reportExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 7200000; - configService.setConfig(this); - require('../../../test/hks_xtsTestList_algCompletion.test.js'); - core.execute(); - } -} diff --git a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/resources/base/element/string.json b/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/resources/base/element/string.json deleted file mode 100644 index c0dd3a09e5dcefc69f22b5e00e92296f1c3f55a5..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "entry_MainAbility" - }, - { - "name": "mainability_description", - "value": "JS_Empty Ability" - } - ] -} \ No newline at end of file diff --git a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/resources/base/media/icon.png b/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/resources/base/media/icon.png and /dev/null differ diff --git a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_jsApi_ca.test.js b/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_jsApi_ca.test.js deleted file mode 100644 index a2446e4859560704c55ea537706d98b7aa1f1c8a..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_jsApi_ca.test.js +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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 huks from '@ohos.security.huks' -import {describe, it, expect} from 'deccjsunit/index' -import { - alias, - emptyOption, - inDataOption, - timer, - targetAlias -} from '../../../../../../hks_xts_common.test' - -describe('HuksTest_JSApiTest_CA', function () { - - /** - * @tc.number HuksTest_JSApiTest_CA_00100 - * @tc.name JSAPI_Test_CA - * @tc.desc Test for attestKey. - */ - it('HuksTest_JSApiTest_CA_00100', 0, async function (done) { - var attestKeyRet = await huks.attestKey(alias, emptyOption); - expect(attestKeyRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_NOT_SUPPORTED); - - var getCertificateChainRet = await huks.getCertificateChain(alias, emptyOption); - expect(getCertificateChainRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_NOT_SUPPORTED); - - var wrapKeyRet = await huks.wrapKey(alias, targetAlias, emptyOption); - expect(wrapKeyRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_NOT_SUPPORTED); - - var unwrapKeyRet = await huks.unwrapKey(alias, targetAlias, inDataOption); - expect(unwrapKeyRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_NOT_SUPPORTED); - - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_CA_00200 - * @tc.name JSAPI_Test_attestKey - * @tc.desc Test for attestKey. - */ - it('HuksTest_JSApiTest_CA_00200', 0, async function (done) { - huks.attestKey(alias, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_NOT_SUPPORTED); - done(); - }); - }); - - /** - * @tc.number HuksTest_JSApiTest_CA_00300 - * @tc.name JSAPI_Test_getCertificateChain - * @tc.desc Test for getCertificateChain. - */ - it('HuksTest_JSApiTest_CA_00300', 0, async function (done) { - huks.getCertificateChain(alias, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_NOT_SUPPORTED); - done(); - }); - }); - - /** - * @tc.number HuksTest_JSApiTest_CA_00400 - * @tc.name JSAPI_Test_wrapKey - * @tc.desc Test for wrapKey. - */ - it('HuksTest_JSApiTest_CA_00400', 0, async function (done) { - huks.wrapKey(alias, targetAlias, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_NOT_SUPPORTED); - done(); - }); - }); - - /** - * @tc.number HuksTest_JSApiTest_CA_00500 - * @tc.name JSAPI_Test_unwrapKey - * @tc.desc Test for unwrapKey. - */ - it('HuksTest_JSApiTest_CA_00500', 0, async function (done) { - huks.unwrapKey(alias, targetAlias, inDataOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_NOT_SUPPORTED); - done(); - }); - }); -}); \ No newline at end of file diff --git a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_jsApi_deriveKey.test.js b/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_jsApi_deriveKey.test.js deleted file mode 100644 index 502dc7878c7ecc68b5bf81ad6d84212880eec244..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_jsApi_deriveKey.test.js +++ /dev/null @@ -1,726 +0,0 @@ -/* - * 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 huks from '@ohos.security.huks' -import {describe, it, expect} from 'deccjsunit/index' -import { - emptyOption, - timer, -} from '../../../../../../hks_xts_common.test.js' - -describe('HuksTest_JSApiTest_DeriveKey', function () { - - function makeGenerateKeyOption(digest) { - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128 - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC - }; - properties[4] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: digest - }; - var options = { - properties: properties - }; - return options; - }; - - function makeHKDFDeriveOption(digest) { - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_HKDF - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: digest - }; - var options = { - properties: properties - }; - return options; - }; - - function makePBKDF2DeriveOption(digest, iteration, salt) { - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_PBKDF2 - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: digest - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_ITERATION, - value: iteration - }; - properties[4] = { - tag: huks.HuksTag.HUKS_TAG_SALT, - value: salt - }; - var options = { - properties: properties - }; - return options; - }; - - function deleteKey(done) { - huks.deleteKey('alias1', emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - isKeyExist(done); - }); - }; - - function isKeyExist(done) { - huks.isKeyExist('alias1', emptyOption, function (err, data) { - expect(data).assertEqual(false); - done(); - }); - }; - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_00100 - * @tc.name PromiseGenerateSha256HkdfDeriveNone - * @tc.desc Promise generate key digest sha256 hkdf derive key digest none. - */ - it('HuksTest_JSApiTest_DeriveKey_00100', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_00100 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makeHKDFDeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_NONE); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - var deriveKeyResult = await huks.deriveKey('alias1', deriveKeyOption); - console.log('deriveKeyResult' + JSON.stringify(deriveKeyResult)); - expect(deriveKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - var deleteKeyResult = await huks.deleteKey('alias1', emptyOption); - expect(huks.HuksErrorCode.HUKS_SUCCESS).assertEqual(deleteKeyResult.errorCode); - var isKeyExistResult = await huks.isKeyExist('alias1', emptyOption); - expect(isKeyExistResult).assertEqual(false); - console.log('HuksTest_JSApiTest_DeriveKey_00100 end'); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_00200 - * @tc.name PromiseGenerateSha256HkdfDeriveMd5 - * @tc.desc Promise generate key digest sha256 hkdf derive key digest md5. - */ - it('HuksTest_JSApiTest_DeriveKey_00200', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_00200 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makeHKDFDeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_MD5); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - var deriveKeyResult = await huks.deriveKey('alias1', deriveKeyOption); - console.log('deriveKeyResult' + JSON.stringify(deriveKeyResult)); - expect(deriveKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - var deleteKeyResult = await huks.deleteKey('alias1', emptyOption); - expect(huks.HuksErrorCode.HUKS_SUCCESS).assertEqual(deleteKeyResult.errorCode); - var isKeyExistResult = await huks.isKeyExist('alias1', emptyOption); - expect(isKeyExistResult).assertEqual(false); - console.log('HuksTest_JSApiTest_DeriveKey_00200 end'); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_00300 - * @tc.name PromiseGenerateSha256HkdfDeriveSha1 - * @tc.desc Promise generate key digest sha256 hkdf derive key digest sha1. - */ - it('HuksTest_JSApiTest_DeriveKey_00300', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_00300 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makeHKDFDeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA1); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - var deriveKeyResult = await huks.deriveKey('alias1', deriveKeyOption); - console.log('deriveKeyResult' + JSON.stringify(deriveKeyResult)); - expect(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT).assertEqual(deriveKeyResult.errorCode); - var deleteKeyResult = await huks.deleteKey('alias1', emptyOption); - expect(huks.HuksErrorCode.HUKS_SUCCESS).assertEqual(deleteKeyResult.errorCode); - var isKeyExistResult = await huks.isKeyExist('alias1', emptyOption); - expect(isKeyExistResult).assertEqual(false); - console.log('HuksTest_JSApiTest_DeriveKey_00300 end'); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_00400 - * @tc.name PromiseGenerateSha256HkdfDeriveSha224 - * @tc.desc Promise generate key digest sha256 hkdf derive key digest sha224. - */ - it('HuksTest_JSApiTest_DeriveKey_00400', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_00400 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makeHKDFDeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA224); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - var deriveKeyResult = await huks.deriveKey('alias1', deriveKeyOption); - console.log('deriveKeyResult' + JSON.stringify(deriveKeyResult)); - expect(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT).assertEqual(deriveKeyResult.errorCode); - var deleteKeyResult = await huks.deleteKey('alias1', emptyOption); - expect(huks.HuksErrorCode.HUKS_SUCCESS).assertEqual(deleteKeyResult.errorCode); - var isKeyExistResult = await huks.isKeyExist('alias1', emptyOption); - expect(isKeyExistResult).assertEqual(false); - console.log('HuksTest_JSApiTest_DeriveKey_00400 end'); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_00500 - * @tc.name PromiseGenerateSha256HkdfDeriveSha256 - * @tc.desc Promise generate key digest sha256 hkdf derive key digest sha256. - */ - it('HuksTest_JSApiTest_DeriveKey_00500', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_00500 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makeHKDFDeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - var deriveKeyResult = await huks.deriveKey('alias1', deriveKeyOption); - console.log('deriveKeyResult' + JSON.stringify(deriveKeyResult)); - expect(deriveKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deleteResult = await huks.deleteKey('alias1', emptyOption); - expect(deleteResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var isKeyExistResult = await huks.isKeyExist('alias1', emptyOption); - expect(isKeyExistResult).assertEqual(false); - console.log('HuksTest_JSApiTest_DeriveKey_00500 end'); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_00600 - * @tc.name PromiseGenerateSha384HkdfDeriveSha384 - * @tc.desc Promise generate key digest sha384 hkdf derive key digest sha384. - */ - it('HuksTest_JSApiTest_DeriveKey_00600', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_00500 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA384); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makeHKDFDeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA384); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - var deriveKeyResult = await huks.deriveKey('alias1', deriveKeyOption); - console.log('deriveKeyResult' + JSON.stringify(deriveKeyResult)); - expect(deriveKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deleteResult = await huks.deleteKey('alias1', emptyOption); - expect(deleteResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var isKeyExistResult = await huks.isKeyExist('alias1', emptyOption); - expect(isKeyExistResult).assertEqual(false); - console.log('HuksTest_JSApiTest_DeriveKey_00500 end'); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_00700 - * @tc.name PromiseGenerateSha512HkdfDeriveSha512 - * @tc.desc Promise generate key digest sha512 hkdf derive key digest sha512. - */ - it('HuksTest_JSApiTest_DeriveKey_00700', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_00700 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA512); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makeHKDFDeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA512); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - var deriveKeyResult = await huks.deriveKey('alias1', deriveKeyOption); - console.log('deriveKeyResult' + JSON.stringify(deriveKeyResult)); - expect(deriveKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deleteResult = await huks.deleteKey('alias1', emptyOption); - expect(deleteResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var isKeyExistResult = await huks.isKeyExist('alias1', emptyOption); - expect(isKeyExistResult).assertEqual(false); - console.log('HuksTest_JSApiTest_DeriveKey_00700 end'); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_00800 - * @tc.name CallbackGenerateSha256HkdfDeriveNone - * @tc.desc Callback generate key digest sha256 hkdf derive key digest none. - */ - it('HuksTest_JSApiTest_DeriveKey_00800', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_00800 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makeHKDFDeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_NONE); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - huks.deriveKey('alias1', deriveKeyOption, function (err, data) { - console.log('data' + JSON.stringify(data)); - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - console.log('HuksTest_JSApiTest_DeriveKey_00800 end'); - deleteKey(done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_00900 - * @tc.name CallbackGenerateSha256HkdfDeriveMd5 - * @tc.desc Callback generate key digest sha256 hkdf derive key digest md5. - */ - it('HuksTest_JSApiTest_DeriveKey_00900', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_00900 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makeHKDFDeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_MD5); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - huks.deriveKey('alias1', deriveKeyOption, function (err, data) { - console.log('data' + JSON.stringify(data)); - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - console.log('HuksTest_JSApiTest_DeriveKey_00900 end'); - deleteKey(done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_01000 - * @tc.name CallbackGenerateSha256HkdfDeriveSha1 - * @tc.desc Callback generate key digest sha256 hkdf derive key digest sha1. - */ - it('HuksTest_JSApiTest_DeriveKey_01000', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_01000 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makeHKDFDeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA1); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - huks.deriveKey('alias1', deriveKeyOption, function (err, data) { - console.log('data' + JSON.stringify(data)); - expect(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT).assertEqual(data.errorCode); - console.log('HuksTest_JSApiTest_DeriveKey_01000 end'); - deleteKey(done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_01100 - * @tc.name CallbackGenerateSha256HkdfDeriveSha224 - * @tc.desc Callback generate key digest sha256 hkdf derive key digest sha224. - */ - it('HuksTest_JSApiTest_DeriveKey_01100', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_01100 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makeHKDFDeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA224); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - huks.deriveKey('alias1', deriveKeyOption, function (err, data) { - console.log('data' + JSON.stringify(data)); - expect(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT).assertEqual(data.errorCode); - console.log('HuksTest_JSApiTest_DeriveKey_01100 end'); - deleteKey(done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_01200 - * @tc.name CallbackGenerateSha256HkdfDeriveSha256 - * @tc.desc Callback generate key digest sha256 hkdf derive key digest sha256. - */ - it('HuksTest_JSApiTest_DeriveKey_01200', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_01200 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makeHKDFDeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - huks.deriveKey('alias1', deriveKeyOption, function (err, data) { - console.log('data' + JSON.stringify(data)); - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HuksTest_JSApiTest_DeriveKey_01200 end'); - deleteKey(done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_01300 - * @tc.name CallbackGenerateSha384HkdfDeriveSha384 - * @tc.desc Callback generate key digest sha384 hkdf derive key digest sha384. - */ - it('HuksTest_JSApiTest_DeriveKey_01300', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_01300 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA384); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makeHKDFDeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA384); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - huks.deriveKey('alias1', deriveKeyOption, function (err, data) { - console.log('data' + JSON.stringify(data)); - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HuksTest_JSApiTest_DeriveKey_01300 end'); - deleteKey(done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_01400 - * @tc.name CallbackGenerateSha512HkdfDeriveSha512 - * @tc.desc Callback generate key digest sha512 hkdf derive key digest sha512. - */ - it('HuksTest_JSApiTest_DeriveKey_01400', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_01400 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA512); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makeHKDFDeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA512); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - huks.deriveKey('alias1', deriveKeyOption, function (err, data) { - console.log('data' + JSON.stringify(data)); - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HuksTest_JSApiTest_DeriveKey_01400 end'); - deleteKey(done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_01500 - * @tc.name PromiseGenerateSha256Pbkdf2DeriveSha256 - * @tc.desc Promise generate key digest sha256 pbkdf2 derive key digest sha256. - */ - it('HuksTest_JSApiTest_DeriveKey_01500', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_01500 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makePBKDF2DeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256, 1000, new Uint8Array(16)); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - var deriveKeyResult = await huks.deriveKey('alias1', deriveKeyOption); - console.log('deriveKeyResult' + JSON.stringify(deriveKeyResult)); - expect(deriveKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deleteKeyResult = await huks.deleteKey('alias1', emptyOption); - expect(huks.HuksErrorCode.HUKS_SUCCESS).assertEqual(deleteKeyResult.errorCode); - var isKeyExistResult = await huks.isKeyExist('alias1', emptyOption); - expect(isKeyExistResult).assertEqual(false); - console.log('HuksTest_JSApiTest_DeriveKey_01500 end'); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_01600 - * @tc.name PromiseGenerateSha256Pbkdf2DeriveSha384 - * @tc.desc Promise generate key digest sha256 pbkdf2 derive key digest sha384. - */ - it('HuksTest_JSApiTest_DeriveKey_01600', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_01600 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makePBKDF2DeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA384, 1000, new Uint8Array(16)); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - var deriveKeyResult = await huks.deriveKey('alias1', deriveKeyOption); - console.log('deriveKeyResult' + JSON.stringify(deriveKeyResult)); - expect(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT).assertEqual(deriveKeyResult.errorCode); - var deleteKeyResult = await huks.deleteKey('alias1', emptyOption); - expect(huks.HuksErrorCode.HUKS_SUCCESS).assertEqual(deleteKeyResult.errorCode); - var isKeyExistResult = await huks.isKeyExist('alias1', emptyOption); - expect(isKeyExistResult).assertEqual(false); - console.log('HuksTest_JSApiTest_DeriveKey_01600 end'); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_01700 - * @tc.name PromiseGenerateSha256Pbkdf2DeriveSha512 - * @tc.desc Promise generate key digest sha256 pbkdf2 derive key digest sha512. - */ - it('HuksTest_JSApiTest_DeriveKey_01700', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_01700 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makePBKDF2DeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA512, 1000, new Uint8Array(16)); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - var deriveKeyResult = await huks.deriveKey('alias1', deriveKeyOption); - console.log('deriveKeyResult' + JSON.stringify(deriveKeyResult)); - expect(deriveKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - var deleteKeyResult = await huks.deleteKey('alias1', emptyOption); - expect(huks.HuksErrorCode.HUKS_SUCCESS).assertEqual(deleteKeyResult.errorCode); - var isKeyExistResult = await huks.isKeyExist('alias1', emptyOption); - expect(isKeyExistResult).assertEqual(false); - console.log('HuksTest_JSApiTest_DeriveKey_01700 end'); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_01800 - * @tc.name PromisePbkdf2DeriveIterationAbnormal - * @tc.desc Promise pbkdf2 derive key iteration abnormal. - */ - it('HuksTest_JSApiTest_DeriveKey_01800', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_01800 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makePBKDF2DeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256, 999, new Uint8Array(16)); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - var deriveKeyResult = await huks.deriveKey('alias1', deriveKeyOption); - console.log('deriveKeyResult' + JSON.stringify(deriveKeyResult)); - expect(deriveKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ITERATION); - var deleteKeyResult = await huks.deleteKey('alias1', emptyOption); - expect(huks.HuksErrorCode.HUKS_SUCCESS).assertEqual(deleteKeyResult.errorCode); - var isKeyExistResult = await huks.isKeyExist('alias1', emptyOption); - expect(isKeyExistResult).assertEqual(false); - console.log('HuksTest_JSApiTest_DeriveKey_01800 end'); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_01900 - * @tc.name PromisePbkdf2DeriveSaltAbnormal - * @tc.desc Promise pbkdf2 derive key salt abnormal. - */ - it('HuksTest_JSApiTest_DeriveKey_01900', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_01900 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makePBKDF2DeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256, 1000, new Uint8Array(15)); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - var deriveKeyResult = await huks.deriveKey('alias1', deriveKeyOption); - console.log('deriveKeyResult' + JSON.stringify(deriveKeyResult)); - expect(deriveKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_SALT); - var deleteKeyResult = await huks.deleteKey('alias1', emptyOption); - expect(huks.HuksErrorCode.HUKS_SUCCESS).assertEqual(deleteKeyResult.errorCode); - var isKeyExistResult = await huks.isKeyExist('alias1', emptyOption); - expect(isKeyExistResult).assertEqual(false); - console.log('HuksTest_JSApiTest_DeriveKey_01900 end'); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_02000 - * @tc.name CallbackGenerateSha256Pbkdf2DeriveSha256 - * @tc.desc Callback generate key digest sha256 pbkdf2 derive key digest sha256. - */ - it('HuksTest_JSApiTest_DeriveKey_02000', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_02000 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makePBKDF2DeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256, 1000, new Uint8Array(16)); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - huks.deriveKey('alias1', deriveKeyOption, function (err, data) { - console.log('deriveKeyResult' + JSON.stringify(data)); - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HuksTest_JSApiTest_DeriveKey_02000 end'); - deleteKey(done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_02100 - * @tc.name CallbackGenerateSha256Pbkdf2DeriveSha384 - * @tc.desc Callback generate key digest sha256 pbkdf2 derive key digest sha384. - */ - it('HuksTest_JSApiTest_DeriveKey_02100', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_02100 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makePBKDF2DeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA384, 1000, new Uint8Array(16)); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - huks.deriveKey('alias1', deriveKeyOption, function (err, data) { - console.log('deriveKeyResult' + JSON.stringify(data)); - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - console.log('HuksTest_JSApiTest_DeriveKey_02000 end'); - deleteKey(done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_02200 - * @tc.name CallbackGenerateSha256Pbkdf2DeriveSha512 - * @tc.desc Callback generate key digest sha256 pbkdf2 derive key digest sha512. - */ - it('HuksTest_JSApiTest_DeriveKey_02200', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_02200 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makePBKDF2DeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA512, 1000, new Uint8Array(16)); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - huks.deriveKey('alias1', deriveKeyOption, function (err, data) { - console.log('deriveKeyResult' + JSON.stringify(data)); - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - console.log('HuksTest_JSApiTest_DeriveKey_02000 end'); - deleteKey(done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_02300 - * @tc.name CallbackPbkdf2DeriveIterationAbnormal - * @tc.desc Callback pbkdf2 derive key iteration abnormal. - */ - it('HuksTest_JSApiTest_DeriveKey_02300', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_02300 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makePBKDF2DeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256, 999, new Uint8Array(16)); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - huks.deriveKey('alias1', deriveKeyOption, function (err, data) { - console.log('deriveKeyResult' + JSON.stringify(data)); - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ITERATION); - console.log('HuksTest_JSApiTest_DeriveKey_02300 end'); - deleteKey(done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_DeriveKey_02400 - * @tc.name CallbackPbkdf2DeriveSaltAbnormal - * @tc.desc Callback pbkdf2 derive key salt abnormal. - */ - it('HuksTest_JSApiTest_DeriveKey_02400', 0, async function (done) { - console.log('HuksTest_JSApiTest_DeriveKey_02400 start'); - var generateKeyOption = makeGenerateKeyOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256); - console.log('generateKeyOption' + JSON.stringify(generateKeyOption)); - var generateKeyResult = await huks.generateKey('alias1', generateKeyOption); - console.log('generateKeyResult' + JSON.stringify(generateKeyResult)); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deriveKeyOption = makePBKDF2DeriveOption(huks.HuksKeyDigest.HUKS_DIGEST_SHA256, 1000, new Uint8Array(15)); - console.log('deriveKeyOption' + JSON.stringify(deriveKeyOption)); - huks.deriveKey('alias1', deriveKeyOption, function (err, data) { - console.log('deriveKeyResult' + JSON.stringify(data)); - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_SALT); - console.log('HuksTest_JSApiTest_DeriveKey_02000 end'); - deleteKey(done); - }); - setTimeout(function () { - }, timer); - }); -}); \ No newline at end of file diff --git a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_jsApi_generateKey.test.js b/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_jsApi_generateKey.test.js deleted file mode 100644 index a3ddf48015ddc731c4aa4b573cdddcc2a7b10d03..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_jsApi_generateKey.test.js +++ /dev/null @@ -1,1307 +0,0 @@ -/* - * 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 huks from '@ohos.security.huks' -import {describe, it, expect} from 'deccjsunit/index' -import { - useLib, - timer -} from '../../../../../../hks_xts_common.test.js' - -describe('HuksTest_JSApiTest_GenerateKey', function () { - - var dsaKeySize = 1024; - var defaultAlias = 'defaultAlias'; - - var aes128Option = makeGenerateAESKeyOptions(huks.HuksKeySize.HUKS_AES_KEY_SIZE_128); - var aes192Option = makeGenerateAESKeyOptions(huks.HuksKeySize.HUKS_AES_KEY_SIZE_192); - var aes256Option = makeGenerateAESKeyOptions(huks.HuksKeySize.HUKS_AES_KEY_SIZE_256); - var rsa512Option = makeGenerateRSAKeyOptions(huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512); - var rsa768Option = makeGenerateRSAKeyOptions(huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768); - var rsa1024Option = makeGenerateRSAKeyOptions(huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024); - var rsa2048Option = makeGenerateRSAKeyOptions(huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048); - var rsa3072Option = makeGenerateRSAKeyOptions(huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072); - var rsa4096Option = makeGenerateRSAKeyOptions(huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096); - var ecc224Option = makeGenerateECCKeyOptions(huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224); - var ecc256Option = makeGenerateECCKeyOptions(huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256); - var ecc384Option = makeGenerateECCKeyOptions(huks.HuksKeySize.HUKS_ECC_KEY_SIZE_384); - var ecc521Option = makeGenerateECCKeyOptions(huks.HuksKeySize.HUKS_ECC_KEY_SIZE_521); - var dsaOption = makeGenerateDSAKeyOptions(); - - function makeWrongOption(alg, size, purpose, padding, mode) { - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: alg - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: size - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: purpose - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: padding - }; - properties[4] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: mode - }; - var options = { - properties: properties - }; - return options; - } - - function makeGenerateAESKeyOptions(size) { - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: size - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE - }; - properties[4] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC - }; - var options = { - properties: properties - }; - return options; - }; - - function makeGenerateRSAKeyOptions(size) { - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: size - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE - }; - properties[4] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_ECB - }; - properties[5] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_NONE - }; - properties[6] = { - tag: huks.HuksTag.HUKS_TAG_KEY_GENERATE_TYPE, - value: huks.HuksKeyGenerateType.HUKS_KEY_GENERATE_TYPE_DEFAULT - }; - var options = { - properties: properties - }; - return options; - }; - - function makeGenerateECCKeyOptions(size) { - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_ECC - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: size - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_NONE - }; - var options = { - properties: properties - }; - return options; - }; - - function makeGenerateMACKeyOptions(digest, size) { - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_HMAC - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: digest - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: size - }; - var options = { - properties: properties - }; - return options; - }; - - function makeGenerateDSAKeyOptions() { - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_DSA - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: dsaKeySize - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA1 - }; - var options = { - properties: properties - }; - return options; - }; - - function makeEmptyOptions() { - var emptyOptions = { - properties: [] - }; - return emptyOptions; - } - - function deleteKeyFun(alias, done) { - var option = makeEmptyOptions(); - huks.deleteKey(alias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - done(); - }); - }; - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_00100 - * @tc.name JSAPI_GenerateAESKey_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_00100', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_00100 start'); - var aes128Result = await huks.generateKey(defaultAlias, aes128Option); - expect(aes128Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var aes192Result = await huks.generateKey(defaultAlias, aes192Option); - expect(aes192Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var aes256Result = await huks.generateKey(defaultAlias, aes256Option); - expect(aes256Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deleteKeyOption = makeEmptyOptions(); - var deleteKeyResult = await huks.deleteKey(defaultAlias, deleteKeyOption); - expect(deleteKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - - console.log('HUKS_JSAPI_GenerateKey_Test_00100 end'); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_00200 - * @tc.name JSAPI_GenerateAES128Key_Callback - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_00200', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_00200 start') - huks.generateKey(defaultAlias, aes128Option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - deleteKeyFun(defaultAlias, done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_00300 - * @tc.name JSAPI_GenerateAES192Key_Callback - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_00300', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_00300 start'); - huks.generateKey(defaultAlias, aes192Option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_00300 end'); - deleteKeyFun(defaultAlias, done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_00400 - * @tc.name JSAPI_GenerateAES256Key_Callback - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_00400', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_00400 start'); - huks.generateKey(defaultAlias, aes256Option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_00400 end'); - deleteKeyFun(defaultAlias, done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_00500 - * @tc.name JSAPI_GenerateRSAKey_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_00500', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_00500 start'); - var rsa512Result = await huks.generateKey(defaultAlias, rsa512Option); - expect(rsa512Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var rsa768Result = await huks.generateKey(defaultAlias, rsa768Option); - expect(rsa768Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var rsa1024Result = await huks.generateKey(defaultAlias, rsa1024Option); - expect(rsa1024Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var rsa2048Result = await huks.generateKey(defaultAlias, rsa2048Option); - expect(rsa2048Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var rsa3072Result = await huks.generateKey(defaultAlias, rsa3072Option); - expect(rsa3072Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var rsa4096Result = await huks.generateKey(defaultAlias, rsa4096Option); - expect(rsa4096Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_00500 end'); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_00600 - * @tc.name JSAPI_GenerateRSA512Key_callback - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_00600', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_00600 start'); - huks.generateKey(defaultAlias, rsa512Option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_00600 end'); - deleteKeyFun(defaultAlias, done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_00700 - * @tc.name JSAPI_GenerateRSA768Key_callback - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_00700', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_00700 start'); - huks.generateKey(defaultAlias, rsa768Option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_00700 end'); - deleteKeyFun(defaultAlias, done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_00800 - * @tc.name JSAPI_GenerateRSA1024Key_callback - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_00800', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_00800 start'); - huks.generateKey(defaultAlias, rsa1024Option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_00800 end'); - deleteKeyFun(defaultAlias, done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_00900 - * @tc.name JSAPI_GenerateRSA2048Key_callback - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_00900', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_00900 start'); - huks.generateKey(defaultAlias, rsa2048Option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_00900 end'); - deleteKeyFun(defaultAlias, done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_01000 - * @tc.name JSAPI_GenerateRSA3072Key_callback - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_01000', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_01000 start'); - huks.generateKey(defaultAlias, rsa3072Option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_01000 end'); - deleteKeyFun(defaultAlias, done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_01100 - * @tc.name JSAPI_GenerateRSA4096Key_callback - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_01100', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_01100 start'); - huks.generateKey(defaultAlias, rsa4096Option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_01100 end'); - deleteKeyFun(defaultAlias, done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_01200 - * @tc.name JSAPI_GenerateECCKey_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_01200', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_01200 start'); - var ecc224Result = await huks.generateKey(defaultAlias, ecc224Option); - expect(ecc224Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var ecc256Result = await huks.generateKey(defaultAlias, ecc256Option); - expect(ecc256Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var ecc384Result = await huks.generateKey(defaultAlias, ecc384Option); - expect(ecc384Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var ecc521Result = await huks.generateKey(defaultAlias, ecc521Option); - expect(ecc521Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_01200 end'); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_01300 - * @tc.name JSAPI_GenerateECC224Key_Callback - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_01300', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_01300 start'); - huks.generateKey(defaultAlias, ecc224Option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_01300 end'); - deleteKeyFun(defaultAlias, done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_01400 - * @tc.name JSAPI_GenerateECC256Key_Callback - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_01400', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_01400 start'); - huks.generateKey(defaultAlias, ecc256Option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_01400 end'); - deleteKeyFun(defaultAlias, done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_01500 - * @tc.name JSAPI_GenerateECC384Key_Callback - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_01500', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_01500 start'); - huks.generateKey(defaultAlias, ecc384Option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_01500 end'); - deleteKeyFun(defaultAlias, done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_01600 - * @tc.name JSAPI_GenerateECC521Key_Callback - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_01600', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_01600 start'); - huks.generateKey(defaultAlias, ecc521Option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_01600 end'); - deleteKeyFun(defaultAlias, done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_01700 - * @tc.name JSAPI_GenerateHmacKey_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_01700', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_01700 start'); - var hmacSHA1Option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA1, 160); - var hmacSHA224Option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA224, 224); - var hmacSHA256Option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA256, 256); - var hmacSHA384Option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA384, 384); - var hmacSHA512Option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA512, 512); - var hmacSHA1Result = await huks.generateKey(defaultAlias, hmacSHA1Option); - expect(hmacSHA1Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var hmacSHA224Result = await huks.generateKey(defaultAlias, hmacSHA224Option); - expect(hmacSHA224Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var hmacSHA256Result = await huks.generateKey(defaultAlias, hmacSHA256Option); - expect(hmacSHA256Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var hmacSHA384Result = await huks.generateKey(defaultAlias, hmacSHA384Option); - expect(hmacSHA384Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var hmacSHA512Result = await huks.generateKey(defaultAlias, hmacSHA512Option); - expect(hmacSHA512Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_01700 end'); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_01800 - * @tc.name JSAPI_GenerateHmacSHA1Key - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_01800', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_01800 start'); - var hmacSHA1Option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA1, 160); - huks.generateKey(defaultAlias, hmacSHA1Option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_01800 end'); - deleteKeyFun(defaultAlias, done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_01900 - * @tc.name JSAPI_GenerateHmacSHA224Key - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_01900', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_01900 start'); - var hmacSHA224Option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA224, 224); - huks.generateKey(defaultAlias, hmacSHA224Option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_01900 end'); - deleteKeyFun(defaultAlias, done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_02000 - * @tc.name JSAPI_GenerateHmacSHA256Key - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_02000', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_02000 start'); - var hmacSHA256Option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA256, 256); - huks.generateKey(defaultAlias, hmacSHA256Option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_02000 end'); - deleteKeyFun(defaultAlias, done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_02100 - * @tc.name JSAPI_GenerateHmacSHA384Key - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_02100', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_02100 start'); - var hmacSHA384Option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA384, 384); - huks.generateKey(defaultAlias, hmacSHA384Option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_02100 end'); - deleteKeyFun(defaultAlias, done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_02200 - * @tc.name JSAPI_GenerateHmacSHA512Key - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_02200', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_02200 start'); - var hmacSHA512Option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA512, 512); - huks.generateKey(defaultAlias, hmacSHA512Option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_02200 end'); - deleteKeyFun(defaultAlias, done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_02300 - * @tc.name JSAPI_GenerateDSAKey_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_02300', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_02300 start'); - var dsaResult = await huks.generateKey(defaultAlias, dsaOption); - if (useLib == 'mbedtls') { - expect(dsaResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_NOT_SUPPORTED); - done(); - } else { - expect(dsaResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_02300 end'); - deleteKeyFun(defaultAlias, done); - } - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_02400 - * @tc.name JSAPI_GenerateDSAKey_Callback - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_02400', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_02400 start'); - huks.generateKey(defaultAlias, dsaOption, function (err, data) { - if (useLib == 'mbedtls') { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_NOT_SUPPORTED); - done(); - } else { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_02400 end'); - deleteKeyFun(defaultAlias, done); - } - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_02500 - * @tc.name JSAPI_GenerateKey_Test_GenKey_WrongAlg_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_02500', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_02500 start'); - var notExistAlg = -1; - console.log('HUKS_JSAPI_GenerateKey_Test_02500_01 start'); - var option = makeWrongOption( - notExistAlg, - huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_CBC - ); - - var result = await huks.generateKey(defaultAlias, option); - expect(result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - - console.log('HUKS_JSAPI_GenerateKey_Test_02500 end'); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_02600 - * @tc.name JSAPI_GenerateKey_Test_GenKey_WrongSize_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_02600', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_02600 start'); - var notExistSize = -1; - var option = makeWrongOption( - huks.HuksKeyAlg.HUKS_ALG_AES, - notExistSize, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_CBC - ); - - var result = await huks.generateKey(defaultAlias, option); - expect(result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - - console.log('HUKS_JSAPI_GenerateKey_Test_02600 end'); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_02700 - * @tc.name JSAPI_GenerateKey_Test_GenKey_WrongPurpose_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_02700', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_02700 start'); - var notExistPurpose = -1; - var option = makeWrongOption( - huks.HuksKeyAlg.HUKS_ALG_AES, - huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - notExistPurpose, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_CBC - ); - - var result = await huks.generateKey(defaultAlias, option); - expect(result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - - console.log('HUKS_JSAPI_GenerateKey_Test_02700 end'); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_02800 - * @tc.name JSAPI_GenerateKey_Test_GenKey_WrongPadding_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_02800', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_02800 start'); - var notExistPadding = -1; - var option = makeWrongOption( - huks.HuksKeyAlg.HUKS_ALG_AES, - huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - notExistPadding, - huks.HuksCipherMode.HUKS_MODE_CBC - ); - - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - console.log('HUKS_JSAPI_GenerateKey_Test_02800 end'); - done(); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_02900 - * @tc.name JSAPI_GenerateKey_Test_GenKey_WrongAlg_Callback - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_02900', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_02900 start'); - var notExistAlg = -1; - var option = makeWrongOption( - notExistAlg, - huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_CBC - ); - - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - console.log('HUKS_JSAPI_GenerateKey_Test_02900 end'); - done(); - }); - - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_03000 - * @tc.name JSAPI_GenerateKey_Test_GenKey_WrongSize_Callback - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_03000', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_03000 start'); - var notExistSize = -1; - var option = makeWrongOption( - huks.HuksKeyAlg.HUKS_ALG_AES, - notExistSize, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_CBC - ); - - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - console.log('HUKS_JSAPI_GenerateKey_Test_03000 end'); - done(); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_03100 - * @tc.name JSAPI_GenerateKey_Test_GenKey_WrongPurpose_Callback - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_03100', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_03100 start'); - var notExistPurpose = -1; - var option = makeWrongOption( - huks.HuksKeyAlg.HUKS_ALG_AES, - huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - notExistPurpose, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_CBC - ); - - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - console.log('HUKS_JSAPI_GenerateKey_Test_03100 end'); - done(); - }); - setTimeout(function () { - }, timer); - }); - - /**C - * @tc.number HUKS_JSAPI_GenerateKey_Test_03200 - * @tc.name JSAPI_GenerateKey_Test_GenKey_WrongPadding_Callback - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_03200', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_03200 start'); - var notExistPadding = -1; - var option = makeWrongOption( - huks.HuksKeyAlg.HUKS_ALG_AES, - huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - notExistPadding, - huks.HuksCipherMode.HUKS_MODE_CBC - ); - - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); - console.log('HUKS_JSAPI_GenerateKey_Test_03200 end'); - done(); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_03300 - * @tc.name JSAPI_GenerateKey_Test_GenKey_Hmac_Margin_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_03300', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_03300 start'); - var hmacSHA1OptionSize8 = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA1, 8); - var hmacSHA1ResultSize8 = await huks.generateKey(defaultAlias, hmacSHA1OptionSize8); - expect(hmacSHA1ResultSize8.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - - var hmacSHA1OptionSize1024 = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA1, 1024); - var hmacSHA1ResultSize1024 = await huks.generateKey(defaultAlias, hmacSHA1OptionSize1024); - expect(hmacSHA1ResultSize1024.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - - var hmacSHA224OptionSize8 = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA224, 8); - var hmacSHA224ResultSize8 = await huks.generateKey(defaultAlias, hmacSHA224OptionSize8); - expect(hmacSHA224ResultSize8.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - - var hmacSHA224OptionSize1024 = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA224, 1024); - var hmacSHA224ResultSize1024 = await huks.generateKey(defaultAlias, hmacSHA224OptionSize1024); - expect(hmacSHA224ResultSize1024.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - - var hmacSHA256OptionSize8 = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA256, 8); - var hmacSHA256ResultSize8 = await huks.generateKey(defaultAlias, hmacSHA256OptionSize8); - expect(hmacSHA256ResultSize8.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - - var hmacSHA256OptionSize1024 = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA256, 1024); - var hmacSHA256ResultSize1024 = await huks.generateKey(defaultAlias, hmacSHA256OptionSize1024); - expect(hmacSHA256ResultSize1024.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - - var hmacSHA384OptionSize8 = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA384, 8); - var hmacSHA384ResultSize8 = await huks.generateKey(defaultAlias, hmacSHA384OptionSize8); - expect(hmacSHA384ResultSize8.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - - var hmacSHA384OptionSize1024 = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA384, 1024); - var hmacSHA384ResultSize1024 = await huks.generateKey(defaultAlias, hmacSHA384OptionSize1024); - expect(hmacSHA384ResultSize1024.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - - var hmacSHA512OptionSize8 = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA512, 8); - var hmacSHA512ResultSize8 = await huks.generateKey(defaultAlias, hmacSHA512OptionSize8); - expect(hmacSHA512ResultSize8.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - - var hmacSHA512OptionSize1024 = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA512, 1024); - var hmacSHA512ResultSize1024 = await huks.generateKey(defaultAlias, hmacSHA512OptionSize1024); - expect(hmacSHA512ResultSize1024.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - - console.log('HUKS_JSAPI_GenerateKey_Test_03300 end'); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_03400 - * @tc.name JSAPI_GenerateKey_Test_GenKey_Hmac_Margin_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_03400', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_03400 start'); - var option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA1, 8); - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_03400 end'); - deleteKeyFun(defaultAlias, done); - }); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_03500 - * @tc.name JSAPI_GenerateKey_Test_GenKey_Hmac_Margin_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_03500', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_03500 start'); - var option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA1, 1024); - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_03500 end'); - deleteKeyFun(defaultAlias, done); - }); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_03600 - * @tc.name JSAPI_GenerateKey_Test_GenKey_Hmac_Margin_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_03600', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_03600 start'); - var option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA224, 8); - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_03600 end'); - deleteKeyFun(defaultAlias, done); - }); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_03700 - * @tc.name JSAPI_GenerateKey_Test_GenKey_Hmac_Margin_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_03700', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_03700 start'); - var option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA224, 1024); - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_03700 end'); - deleteKeyFun(defaultAlias, done); - }); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_03800 - * @tc.name JSAPI_GenerateKey_Test_GenKey_Hmac_Margin_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_03800', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_03800 start'); - var option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA256, 8); - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_03800 end'); - deleteKeyFun(defaultAlias, done); - }); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_03900 - * @tc.name JSAPI_GenerateKey_Test_GenKey_Hmac_Margin_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_03900', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_03900 start'); - var option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA256, 1024); - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_03600 end'); - deleteKeyFun(defaultAlias, done); - }); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_04000 - * @tc.name JSAPI_GenerateKey_Test_GenKey_Hmac_Margin_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_04000', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_04000 start'); - var option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA384, 8); - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_04000 end'); - deleteKeyFun(defaultAlias, done); - }); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_04100 - * @tc.name JSAPI_GenerateKey_Test_GenKey_Hmac_Margin_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_04100', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_04100 start'); - var option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA384, 1024); - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_04100 end'); - deleteKeyFun(defaultAlias, done); - }); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_04200 - * @tc.name JSAPI_GenerateKey_Test_GenKey_Hmac_Margin_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_04200', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_04200 start'); - var option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA512, 8); - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_04200 end'); - deleteKeyFun(defaultAlias, done); - }); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_04300 - * @tc.name JSAPI_GenerateKey_Test_GenKey_Hmac_Margin_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_04300', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_04300 start'); - var option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA512, 1024); - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('HUKS_JSAPI_GenerateKey_Test_04300 end'); - deleteKeyFun(defaultAlias, done); - }); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_04400 - * @tc.name JSAPI_GenerateKey_Test_GenKey_Hmac_WrongSize_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_04400', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_04400 start'); - var hmacSHA1Option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA1, 7); - var hmacSHA1Result = await huks.generateKey(defaultAlias, hmacSHA1Option); - expect(hmacSHA1Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - - hmacSHA1Option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA1, 1025); - hmacSHA1Result = await huks.generateKey(defaultAlias, hmacSHA1Option); - expect(hmacSHA1Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - - var hmacSHA224Option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA224, 7); - var hmacSHA224Result = await huks.generateKey(defaultAlias, hmacSHA224Option); - expect(hmacSHA224Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - - hmacSHA224Option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA224, 1025); - hmacSHA224Result = await huks.generateKey(defaultAlias, hmacSHA224Option); - expect(hmacSHA224Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - - var hmacSHA256Option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA256, 7); - var hmacSHA256Result = await huks.generateKey(defaultAlias, hmacSHA256Option); - expect(hmacSHA256Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - - hmacSHA256Option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA256, 1025); - hmacSHA256Result = await huks.generateKey(defaultAlias, hmacSHA256Option); - expect(hmacSHA256Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - - var hmacSHA384Option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA384, 7); - var hmacSHA384Result = await huks.generateKey(defaultAlias, hmacSHA384Option); - expect(hmacSHA384Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - - hmacSHA384Option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA384, 1025); - hmacSHA384Result = await huks.generateKey(defaultAlias, hmacSHA384Option); - expect(hmacSHA384Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - - var hmacSHA512Option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA512, 7); - var hmacSHA512Result = await huks.generateKey(defaultAlias, hmacSHA512Option); - expect(hmacSHA512Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - - hmacSHA512Option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA512, 1025); - hmacSHA512Result = await huks.generateKey(defaultAlias, hmacSHA512Option); - expect(hmacSHA512Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - - console.log('HUKS_JSAPI_GenerateKey_Test_04400 end'); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_04500 - * @tc.name JSAPI_GenerateKey_Test_GenKey_Hmac_Margin_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_04500', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_04500 start'); - var option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA1, 7); - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - console.log('HUKS_JSAPI_GenerateKey_Test_04500 end'); - done(); - }); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_04600 - * @tc.name JSAPI_GenerateKey_Test_GenKey_Hmac_Margin_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_04600', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_04600 start'); - var option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA1, 1025); - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - console.log('HUKS_JSAPI_GenerateKey_Test_04600 end'); - done(); - }); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_04700 - * @tc.name JSAPI_GenerateKey_Test_GenKey_Hmac_Margin_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_04700', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_04700 start'); - var option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA224, 7); - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - console.log('HUKS_JSAPI_GenerateKey_Test_04700 end'); - done(); - }); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_04800 - * @tc.name JSAPI_GenerateKey_Test_GenKey_Hmac_Margin_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_04800', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_04800 start'); - var option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA224, 1025); - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - console.log('HUKS_JSAPI_GenerateKey_Test_04800 end'); - done(); - }); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_04900 - * @tc.name JSAPI_GenerateKey_Test_GenKey_Hmac_Margin_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_04900', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_04900 start'); - var option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA256, 7); - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - console.log('HUKS_JSAPI_GenerateKey_Test_04900 end'); - done(); - }); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_05000 - * @tc.name JSAPI_GenerateKey_Test_GenKey_Hmac_Margin_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_05000', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_05000 start'); - var option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA256, 1025); - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - console.log('HUKS_JSAPI_GenerateKey_Test_05000 end'); - done(); - }); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_05100 - * @tc.name JSAPI_GenerateKey_Test_GenKey_Hmac_Margin_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_05100', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_05100 start'); - var option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA384, 7); - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - console.log('HUKS_JSAPI_GenerateKey_Test_05100 end'); - done(); - }); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_05200 - * @tc.name JSAPI_GenerateKey_Test_GenKey_Hmac_Margin_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_05200', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_05200 start'); - var option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA384, 1025); - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - console.log('HUKS_JSAPI_GenerateKey_Test_05200 end'); - done(); - }); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_05300 - * @tc.name JSAPI_GenerateKey_Test_GenKey_Hmac_Margin_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_05300', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_05300 start'); - var option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA512, 7); - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - console.log('HUKS_JSAPI_GenerateKey_Test_05300 end'); - done(); - }); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_05400 - * @tc.name JSAPI_GenerateKey_Test_GenKey_Hmac_Margin_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_05400', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_05400 start'); - var option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA512, 1025); - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - console.log('HUKS_JSAPI_GenerateKey_Test_05400 end'); - done(); - }); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_05500 - * @tc.name JSAPI_GenerateKey_Test_GenKey_WrongMode_Promise - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_05500', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_05500 start'); - var notExistMode = -1; - var option = makeWrongOption( - huks.HuksKeyAlg.HUKS_ALG_AES, - huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - notExistMode - ); - - var result = await huks.generateKey(defaultAlias, option); - expect(result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_MODE); - - console.log('HUKS_JSAPI_GenerateKey_Test_05500 end'); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_JSAPI_GenerateKey_Test_05600 - * @tc.name JSAPI_GenerateKey_Test_GenKey_WrongAlg_Callback - * @tc.desc Test for APP JSAPI_GenerateKey. - */ - it('HUKS_JSAPI_GenerateKey_Test_05600', 0, async function (done) { - console.log('HUKS_JSAPI_GenerateKey_Test_05600 start'); - var notExistMode = -1; - var option = makeWrongOption( - huks.HuksKeyAlg.HUKS_ALG_AES, - huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - notExistMode - ); - - huks.generateKey(defaultAlias, option, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_MODE); - console.log('HUKS_JSAPI_GenerateKey_Test_05600 end'); - done(); - }); - setTimeout(function () { - }, timer); - }); -}); \ No newline at end of file diff --git a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_jsApi_getKeyProperties.test.js b/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_jsApi_getKeyProperties.test.js deleted file mode 100644 index f0cdc244140b2f8b6350dd7e97b72962f9914779..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_jsApi_getKeyProperties.test.js +++ /dev/null @@ -1,426 +0,0 @@ -/* - * 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 huks from '@ohos.security.huks' -import {describe, it, expect} from 'deccjsunit/index' -import { - useLib, - emptyOption, - timer -} from '../../../../../../hks_xts_common.test.js' - -describe('HuksTest_JSApiTest_GetKeyProperties', function () { - var dsaKeySize = 1024; - var defaultAlias = 'defaultAlias'; - var signAndVerify = huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY; - var encryptAndDecrypt = huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT; - var aes128Option = makeGenerateAESKeyOptions(huks.HuksKeySize.HUKS_AES_KEY_SIZE_128); - var rsa512Option = makeGenerateRSAKeyOptions(huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512); - var ecc224Option = makeGenerateECCKeyOptions(huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224); - var hmacSHA1Option = makeGenerateMACKeyOptions(huks.HuksKeyDigest.HUKS_DIGEST_SHA1, 160); - var dsaOption = makeGenerateDSAKeyOptions(); - - function makeGenerateAESKeyOptions(size) { - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: size - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE - }; - properties[4] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC - }; - var options = { - properties: properties - }; - return options; - }; - - function makeGenerateRSAKeyOptions(size) { - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: size - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE - }; - properties[4] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_ECB - }; - properties[5] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_NONE - }; - properties[6] = { - tag: huks.HuksTag.HUKS_TAG_KEY_GENERATE_TYPE, - value: huks.HuksKeyGenerateType.HUKS_KEY_GENERATE_TYPE_DEFAULT - }; - var options = { - properties: properties - }; - return options; - }; - - function makeGenerateECCKeyOptions(size) { - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_ECC - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: size - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_NONE - }; - var options = { - properties: properties - }; - return options; - }; - - function makeGenerateMACKeyOptions(digest, size) { - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_HMAC - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: digest - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: size - }; - var options = { - properties: properties - }; - return options; - }; - - function makeGenerateDSAKeyOptions() { - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_DSA - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: dsaKeySize - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA1 - }; - var options = { - properties: properties - }; - return options; - }; - - function isKeyExistFun(done) { - huks.isKeyExist(defaultAlias, emptyOption, function (err, data) { - expect(data).assertEqual(false); - done(); - }); - }; - - function deleteKeyFun(done) { - huks.deleteKey(defaultAlias, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - isKeyExistFun(done); - }); - }; - - /** - * @tc.number HuksTest_JSApiTest_getKeyProperties_00100 - * @tc.name JSAPI_Test_getKeyProperties - * @tc.desc Test for get key properties. - */ - it('HuksTest_JSApiTest_getKeyProperties_00100', 0, async function (done) { - var aes128Result = await huks.generateKey(defaultAlias, aes128Option); - expect(aes128Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var getKeyPropertiesRet = await huks.getKeyProperties(defaultAlias, emptyOption); - expect(getKeyPropertiesRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('getKeyPropertiesRet ' + JSON.stringify(getKeyPropertiesRet)); - expect(getKeyPropertiesRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - expect(getKeyPropertiesRet.properties[0].value).assertEqual(huks.HuksKeyAlg.HUKS_ALG_AES); - expect(getKeyPropertiesRet.properties[1].value).assertEqual(huks.HuksKeySize.HUKS_AES_KEY_SIZE_128); - expect(getKeyPropertiesRet.properties[2].value).assertEqual(encryptAndDecrypt); - expect(getKeyPropertiesRet.properties[3].value).assertEqual(huks.HuksKeyPadding.HUKS_PADDING_NONE); - expect(getKeyPropertiesRet.properties[4].value).assertEqual(huks.HuksCipherMode.HUKS_MODE_CBC); - var deleteKeyResult = await huks.deleteKey(defaultAlias, emptyOption); - expect(huks.HuksErrorCode.HUKS_SUCCESS).assertEqual(deleteKeyResult.errorCode); - var isKeyExistResult = await huks.isKeyExist(defaultAlias, emptyOption); - expect(isKeyExistResult).assertEqual(false); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_getKeyProperties_00200 - * @tc.name JSAPI_Test_getKeyProperties - * @tc.desc Test for get key properties. - */ - it('HuksTest_JSApiTest_getKeyProperties_00200', 0, async function (done) { - var aes128Result = await huks.generateKey(defaultAlias, aes128Option); - expect(aes128Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - huks.getKeyProperties(defaultAlias, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('getKeyPropertiesRet ' + JSON.stringify(data)); - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - expect(data.properties[0].value).assertEqual(huks.HuksKeyAlg.HUKS_ALG_AES); - expect(data.properties[1].value).assertEqual(huks.HuksKeySize.HUKS_AES_KEY_SIZE_128); - expect(data.properties[2].value).assertEqual(encryptAndDecrypt); - expect(data.properties[3].value).assertEqual(huks.HuksKeyPadding.HUKS_PADDING_NONE); - expect(data.properties[4].value).assertEqual(huks.HuksCipherMode.HUKS_MODE_CBC); - deleteKeyFun(done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_getKeyProperties_00300 - * @tc.name JSAPI_Test_getKeyProperties - * @tc.desc Test for get key properties. - */ - it('HuksTest_JSApiTest_getKeyProperties_00300', 0, async function (done) { - var rsa512Result = await huks.generateKey(defaultAlias, rsa512Option); - expect(rsa512Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var getKeyPropertiesRet = await huks.getKeyProperties(defaultAlias, emptyOption); - expect(getKeyPropertiesRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('getKeyPropertiesRet ' + JSON.stringify(getKeyPropertiesRet)); - expect(getKeyPropertiesRet.properties[0].value).assertEqual(huks.HuksKeyAlg.HUKS_ALG_RSA); - expect(getKeyPropertiesRet.properties[1].value).assertEqual(huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512); - expect(getKeyPropertiesRet.properties[2].value).assertEqual(encryptAndDecrypt); - expect(getKeyPropertiesRet.properties[3].value).assertEqual(huks.HuksKeyPadding.HUKS_PADDING_NONE); - expect(getKeyPropertiesRet.properties[4].value).assertEqual(huks.HuksCipherMode.HUKS_MODE_ECB); - var deleteKeyResult = await huks.deleteKey(defaultAlias, emptyOption); - expect(huks.HuksErrorCode.HUKS_SUCCESS).assertEqual(deleteKeyResult.errorCode); - var isKeyExistResult = await huks.isKeyExist(defaultAlias, emptyOption); - expect(isKeyExistResult).assertEqual(false); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_getKeyProperties_00400 - * @tc.name JSAPI_Test_getKeyProperties - * @tc.desc Test for get key properties. - */ - it('HuksTest_JSApiTest_getKeyProperties_00400', 0, async function (done) { - var rsa512Result = await huks.generateKey(defaultAlias, rsa512Option); - expect(rsa512Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - huks.getKeyProperties(defaultAlias, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - console.log('getKeyPropertiesRet ' + JSON.stringify(data)); - expect(data.properties[0].value).assertEqual(huks.HuksKeyAlg.HUKS_ALG_RSA); - expect(data.properties[1].value).assertEqual(huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512); - - expect(data.properties[2].value).assertEqual(encryptAndDecrypt); - expect(data.properties[3].value).assertEqual(huks.HuksKeyPadding.HUKS_PADDING_NONE); - expect(data.properties[4].value).assertEqual(huks.HuksCipherMode.HUKS_MODE_ECB); - deleteKeyFun(done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_getKeyProperties_00500 - * @tc.name JSAPI_Test_getKeyProperties - * @tc.desc Test for get key properties. - */ - it('HuksTest_JSApiTest_getKeyProperties_00500', 0, async function (done) { - var ecc224Result = await huks.generateKey(defaultAlias, ecc224Option); - expect(ecc224Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var getKeyPropertiesRet = await huks.getKeyProperties(defaultAlias, emptyOption); - expect(getKeyPropertiesRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - expect(getKeyPropertiesRet.properties[0].value).assertEqual(huks.HuksKeyAlg.HUKS_ALG_ECC); - expect(getKeyPropertiesRet.properties[1].value).assertEqual(huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224); - expect(getKeyPropertiesRet.properties[2].value).assertEqual(signAndVerify); - expect(getKeyPropertiesRet.properties[3].value).assertEqual(huks.HuksKeyDigest.HUKS_DIGEST_NONE); - console.log('getKeyPropertiesRet ' + JSON.stringify(getKeyPropertiesRet)); - var deleteKeyResult = await huks.deleteKey(defaultAlias, emptyOption); - expect(huks.HuksErrorCode.HUKS_SUCCESS).assertEqual(deleteKeyResult.errorCode); - var isKeyExistResult = await huks.isKeyExist(defaultAlias, emptyOption); - expect(isKeyExistResult).assertEqual(false); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_getKeyProperties_00600 - * @tc.name JSAPI_Test_getKeyProperties - * @tc.desc Test for get key properties. - */ - it('HuksTest_JSApiTest_getKeyProperties_00600', 0, async function (done) { - var ecc224Result = await huks.generateKey(defaultAlias, ecc224Option); - expect(ecc224Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - huks.getKeyProperties(defaultAlias, emptyOption, function (err, data) { - console.log('getKeyPropertiesRet ' + JSON.stringify(data)); - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - expect(data.properties[0].value).assertEqual(huks.HuksKeyAlg.HUKS_ALG_ECC); - expect(data.properties[1].value).assertEqual(huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224); - expect(data.properties[2].value).assertEqual(signAndVerify); - expect(data.properties[3].value).assertEqual(huks.HuksKeyDigest.HUKS_DIGEST_NONE); - deleteKeyFun(done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_getKeyProperties_00700 - * @tc.name JSAPI_Test_getKeyProperties - * @tc.desc Test for get key properties. - */ - it('HuksTest_JSApiTest_getKeyProperties_00700', 0, async function (done) { - var hmacSHA1Result = await huks.generateKey(defaultAlias, hmacSHA1Option); - expect(hmacSHA1Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var getKeyPropertiesRet = await huks.getKeyProperties(defaultAlias, emptyOption); - expect(getKeyPropertiesRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - expect(getKeyPropertiesRet.properties[0].value).assertEqual(huks.HuksKeyAlg.HUKS_ALG_HMAC); - expect(getKeyPropertiesRet.properties[1].value).assertEqual(huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - expect(getKeyPropertiesRet.properties[2].value).assertEqual(huks.HuksKeyDigest.HUKS_DIGEST_SHA1); - expect(getKeyPropertiesRet.properties[3].value).assertEqual(160); - console.log('getKeyPropertiesRet ' + JSON.stringify(getKeyPropertiesRet)); - var deleteKeyResult = await huks.deleteKey(defaultAlias, emptyOption); - expect(huks.HuksErrorCode.HUKS_SUCCESS).assertEqual(deleteKeyResult.errorCode); - var isKeyExistResult = await huks.isKeyExist(defaultAlias, emptyOption); - expect(isKeyExistResult).assertEqual(false); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_getKeyProperties_00800 - * @tc.name JSAPI_Test_getKeyProperties - * @tc.desc Test for get key properties. - */ - it('HuksTest_JSApiTest_getKeyProperties_00800', 0, async function (done) { - var hmacSHA1Result = await huks.generateKey(defaultAlias, hmacSHA1Option); - expect(hmacSHA1Result.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - huks.getKeyProperties(defaultAlias, emptyOption, function (err, data) { - console.log('getKeyPropertiesRet ' + JSON.stringify(data)); - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - expect(data.properties[0].value).assertEqual(huks.HuksKeyAlg.HUKS_ALG_HMAC); - expect(data.properties[1].value).assertEqual(huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC); - expect(data.properties[2].value).assertEqual(huks.HuksKeyDigest.HUKS_DIGEST_SHA1); - expect(data.properties[3].value).assertEqual(160); - deleteKeyFun(done); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_getKeyProperties_00900 - * @tc.name JSAPI_Test_getKeyProperties - * @tc.desc Test for get key properties. - */ - it('HuksTest_JSApiTest_getKeyProperties_00900', 0, async function (done) { - var dsaResult = await huks.generateKey(defaultAlias, dsaOption); - if (useLib == 'mbedtls') { - expect(dsaResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_NOT_SUPPORTED); - } else { - expect(dsaResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var getKeyPropertiesRet = await huks.getKeyProperties(defaultAlias, emptyOption); - expect(getKeyPropertiesRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - expect(getKeyPropertiesRet.properties[0].value).assertEqual(huks.HuksKeyAlg.HUKS_ALG_DSA); - - expect(getKeyPropertiesRet.properties[1].value).assertEqual(signAndVerify); - expect(getKeyPropertiesRet.properties[2].value).assertEqual(dsaKeySize); - expect(getKeyPropertiesRet.properties[3].value).assertEqual(huks.HuksKeyDigest.HUKS_DIGEST_SHA1); - console.log('getKeyPropertiesRet ' + JSON.stringify(getKeyPropertiesRet)); - var deleteKeyResult = await huks.deleteKey(defaultAlias, emptyOption); - expect(huks.HuksErrorCode.HUKS_SUCCESS).assertEqual(deleteKeyResult.errorCode); - var isKeyExistResult = await huks.isKeyExist(defaultAlias, emptyOption); - expect(isKeyExistResult).assertEqual(false); - } - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HuksTest_JSApiTest_getKeyProperties_01000 - * @tc.name JSAPI_Test_getKeyProperties - * @tc.desc Test for get key properties. - */ - it('HuksTest_JSApiTest_getKeyProperties_01000', 0, async function (done) { - var dsaResult = await huks.generateKey(defaultAlias, dsaOption); - if (useLib == 'mbedtls') { - expect(dsaResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_NOT_SUPPORTED); - done(); - } else { - expect(dsaResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - huks.getKeyProperties(defaultAlias, emptyOption, function (err, data) { - console.log('getKeyPropertiesRet ' + JSON.stringify(data)); - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - expect(data.properties[0].value).assertEqual(huks.HuksKeyAlg.HUKS_ALG_DSA); - expect(data.properties[1].value).assertEqual(signAndVerify); - expect(data.properties[2].value).assertEqual(dsaKeySize); - expect(data.properties[3].value).assertEqual(huks.HuksKeyDigest.HUKS_DIGEST_SHA1); - deleteKeyFun(done); - }); - } - setTimeout(function () { - }, timer); - }); -}); \ No newline at end of file diff --git a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_jsApi_getSdkVersion.test.js b/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_jsApi_getSdkVersion.test.js deleted file mode 100644 index 80f3c821fc573cfd1279eb51acceb51e66550d13..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_jsApi_getSdkVersion.test.js +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 huks from '@ohos.security.huks' -import {describe, it, expect} from 'deccjsunit/index' -import { - emptyOption, - timer -} from '../../../../../../hks_xts_common.test.js' - -describe('HuksTest_JSApiTest_getSdkVersion', function () { - - /** - * @tc.number HuksTest_JSApiTest_getSdkVersion_00100 - * @tc.name JSAPI_Test_getSdkVersion - * @tc.desc Test for get sdk version. - */ - it('HuksTest_JSApiTest_getSdkVersion_00100', 0, async function (done) { - var sdkVersion = await huks.getSdkVersion(emptyOption); - console.log('sdk version ' + JSON.stringify(sdkVersion)); - var result = false; - if (sdkVersion.length > 0) { - result = true; - } - expect(result).assertEqual(true); - done(); - setTimeout(function () { - }, timer); - }); -}); \ No newline at end of file diff --git a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_xtsTestList_algCompletion.test.js b/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_xtsTestList_algCompletion.test.js deleted file mode 100644 index 45ae2b8ddc03214a1bfd35f8ef0052cfc2c18bd6..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_xtsTestList_algCompletion.test.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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. - */ - -require('./hks_xtsTest_algCompletion_encryptAndDecrypt_aes.test.js'); - -require('./hks_xtsTest_algCompletion_encryptAndDecrypt_rsa.test.js'); - -require ('./hks_xtsTest_algCompletion_signAndVerify_promise.test.js'); - -require ('./hks_xtsTest_algCompletion_signAndVerify_callback.test.js'); - -require('./hks_xtsTest_algCompletion_agree.test.js'); - -require('./hks_xtsTest_algCompletion_mac.test.js'); - -require('./hks_jsApi_ca.test.js'); - -require('./hks_jsApi_deriveKey.test.js'); - -require('./hks_jsApi_generateKey.test.js'); - -require('./hks_jsApi_getKeyProperties.test.js'); - -require('./hks_jsApi_getSdkVersion.test.js'); \ No newline at end of file diff --git a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_xtsTest_algCompletion_agree.test.js b/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_xtsTest_algCompletion_agree.test.js deleted file mode 100644 index 7ce9fa3c1ba4660ca8ca1f61e5fc2f2cd153fa2d..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_xtsTest_algCompletion_agree.test.js +++ /dev/null @@ -1,698 +0,0 @@ -/* - * 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 huks from '@ohos.security.huks' -import {describe, it, expect} from 'deccjsunit/index' -import { - emptyOption, - useLib, - timer, - makeGenerateKeyOption, -} from '../../../../../../hks_xts_common.test.js' - -var defaultAliasA = 'defaultAliasA'; -var defaultAliasB = 'defaultAliasB'; -var publicKeyA = []; -var publicKeyB = []; -var keyA = []; -var keyB = []; - -function makeAgreeOptions(alg, size, publicKey) { - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: alg - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: size - }; - var options = { - properties: properties, - inData: publicKey - }; - return options; -}; - -describe('Hks_XtsTest_AlgCompletion_Agree', function () { - - /** - * @tc.number HUKS_ALG_COMPLETION_37300 - * @tc.name DH2048_DH_Promise - * @tc.desc Test for algorithm completion(agree with DH). - */ - it('HUKS_ALG_COMPLETION_37300', 0, async function (done) { - agreePromise( - huks.HuksKeyAlg.HUKS_ALG_DH, - huks.HuksKeySize.HUKS_DH_KEY_SIZE_2048, - done, - 'HUKS_ALG_COMPLETION_37300' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_37400 - * @tc.name DH3072_DH_Promise - * @tc.desc Test for algorithm completion(agree with DH). - */ - it('HUKS_ALG_COMPLETION_37400', 0, async function (done) { - agreePromise( - huks.HuksKeyAlg.HUKS_ALG_DH, - huks.HuksKeySize.HUKS_DH_KEY_SIZE_3072, - done, - 'HUKS_ALG_COMPLETION_37400' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_37500 - * @tc.name DH4096_DH_Promise - * @tc.desc Test for algorithm completion(agree with DH). - */ - it('HUKS_ALG_COMPLETION_37500', 0, async function (done) { - agreePromise( - huks.HuksKeyAlg.HUKS_ALG_DH, - huks.HuksKeySize.HUKS_DH_KEY_SIZE_4096, - done, - 'HUKS_ALG_COMPLETION_37500' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_37600 - * @tc.name DH2048_DH_AsyncCallback - * @tc.desc Test for algorithm completion(agree with DH). - */ - it('HUKS_ALG_COMPLETION_37600', 0, async function (done) { - agreeCallback( - huks.HuksKeyAlg.HUKS_ALG_DH, - huks.HuksKeySize.HUKS_DH_KEY_SIZE_2048, - done, - 'HUKS_ALG_COMPLETION_37600' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_37700 - * @tc.name DH3072_DH_AsyncCallback - * @tc.desc Test for algorithm completion(agree with DH). - */ - it('HUKS_ALG_COMPLETION_37700', 0, async function (done) { - agreeCallback( - huks.HuksKeyAlg.HUKS_ALG_DH, - huks.HuksKeySize.HUKS_DH_KEY_SIZE_3072, - done, - 'HUKS_ALG_COMPLETION_37700' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_37800 - * @tc.name DH4096_DH_AsyncCallback - * @tc.desc Test for algorithm completion(agree with DH). - */ - it('HUKS_ALG_COMPLETION_37800', 0, async function (done) { - agreeCallback( - huks.HuksKeyAlg.HUKS_ALG_DH, - huks.HuksKeySize.HUKS_DH_KEY_SIZE_4096, - done, - 'HUKS_ALG_COMPLETION_37800' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_37900 - * @tc.name ECDH224_Promise - * @tc.desc Test for algorithm completion(agree with ECDH). - */ - it('HUKS_ALG_COMPLETION_37900', 0, async function (done) { - agreePromise( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - done, - 'HUKS_ALG_COMPLETION_37900' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_38000 - * @tc.name ECDH256_Promise - * @tc.desc Test for algorithm completion(agree with ECDH). - */ - it('HUKS_ALG_COMPLETION_38000', 0, async function (done) { - agreePromise( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - done, - 'HUKS_ALG_COMPLETION_38000' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_38100 - * @tc.name ECDH384_Promise - * @tc.desc Test for algorithm completion(agree with ECDH). - */ - it('HUKS_ALG_COMPLETION_38100', 0, async function (done) { - agreePromise( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_384, - done, - 'HUKS_ALG_COMPLETION_38100' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_38200 - * @tc.name ECDH521_Promise - * @tc.desc Test for algorithm completion(agree with ECDH). - */ - it('HUKS_ALG_COMPLETION_38200', 0, async function (done) { - agreePromise( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_521, - done, - 'HUKS_ALG_COMPLETION_38200' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_38300 - * @tc.name ECDH224_AsyncCallback - * @tc.desc Test for algorithm completion(agree with ECDH). - */ - it('HUKS_ALG_COMPLETION_38300', 0, async function (done) { - agreeCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - done, - 'HUKS_ALG_COMPLETION_38300' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_38400 - * @tc.name ECDH256_AsyncCallback - * @tc.desc Test for algorithm completion(agree with ECDH). - */ - it('HUKS_ALG_COMPLETION_38400', 0, async function (done) { - agreeCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - done, - 'HUKS_ALG_COMPLETION_38400' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_38500 - * @tc.name ECDH384_AsyncCallback - * @tc.desc Test for algorithm completion(agree with ECDH). - */ - it('HUKS_ALG_COMPLETION_38500', 0, async function (done) { - agreeCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_384, - done, - 'HUKS_ALG_COMPLETION_38500' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_38600 - * @tc.name ECDH521_AsyncCallback - * @tc.desc Test for algorithm completion(agree with ECDH). - */ - it('HUKS_ALG_COMPLETION_38600', 0, async function (done) { - agreeCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_521, - done, - 'HUKS_ALG_COMPLETION_38600' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_38700 - * @tc.name X25519_Promise - * @tc.desc Test for X25519 Regression Testing. - */ - it('HUKS_ALG_COMPLETION_38700', 0, async function (done) { - agreePromise( - huks.HuksKeyAlg.HUKS_ALG_X25519, - huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256, - done, - 'HUKS_ALG_COMPLETION_38700' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_38800 - * @tc.name X25519_Promise - * @tc.desc Test for X25519 Regression Testing. - */ - it('HUKS_ALG_COMPLETION_38800', 0, async function (done) { - agreeCallback( - huks.HuksKeyAlg.HUKS_ALG_X25519, - huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256, - done, - 'HUKS_ALG_COMPLETION_38800' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_38900 - * @tc.name AgreeWithError - * @tc.desc Test for algorithm completion(agree with ECDH). - */ - it('HUKS_ALG_COMPLETION_38900', 0, async function (done) { - var generateKeyOptions = makeGenerateKeyOption( - -1, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, - null, - null, - huks.HuksKeyDigest.HUKS_DIGEST_NONE - ); - var generateKeyRet = await huks.generateKey(defaultAliasA, generateKeyOptions); - expect(generateKeyRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_39000 - * @tc.name AgreeWithError - * @tc.desc Test for algorithm completion(agree with ECDH). - */ - it('HUKS_ALG_COMPLETION_39000', 0, async function (done) { - var generateKeyOptions = makeGenerateKeyOption( - -1, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, - null, - null, - huks.HuksKeyDigest.HUKS_DIGEST_NONE - ); - huks.generateKey(defaultAliasA, generateKeyOptions, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_39100 - * @tc.name AgreeWithError - * @tc.desc Test for algorithm completion(agree with ECDH). - */ - it('HUKS_ALG_COMPLETION_39100', 0, async function (done) { - var generateKeyOptions = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_ECC, - -1, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, - null, - null, - huks.HuksKeyDigest.HUKS_DIGEST_NONE - ); - var generateKeyRet = await huks.generateKey(defaultAliasA, generateKeyOptions); - expect(generateKeyRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_39200 - * @tc.name AgreeWithError - * @tc.desc Test for algorithm completion(agree with ECDH). - */ - it('HUKS_ALG_COMPLETION_39200', 0, async function (done) { - var generateKeyOptions = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_ECC, - -1, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, - null, - null, - huks.HuksKeyDigest.HUKS_DIGEST_NONE - ); - huks.generateKey(defaultAliasA, generateKeyOptions, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_SIZE); - done(); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_39300 - * @tc.name AgreeWithError - * @tc.desc Test for algorithm completion(agree with ECDH). - */ - it('HUKS_ALG_COMPLETION_39300', 0, async function (done) { - var generateKeyOptions = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - -1, - null, - null, - huks.HuksKeyDigest.HUKS_DIGEST_NONE - ); - var generateKeyRet = await huks.generateKey(defaultAliasA, generateKeyOptions); - expect(generateKeyRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_39400 - * @tc.name AgreeWithError - * @tc.desc Test for algorithm completion(agree with ECDH). - */ - it('HUKS_ALG_COMPLETION_39400', 0, async function (done) { - var generateKeyOptions = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - -1, - null, - null, - huks.HuksKeyDigest.HUKS_DIGEST_NONE - ); - huks.generateKey(defaultAliasA, generateKeyOptions, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); - done(); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_39500 - * @tc.name AgreeWithError - * @tc.desc Test for algorithm completion(agree with ECDH). - */ - it('HUKS_ALG_COMPLETION_39500', 0, async function (done) { - var generateKeyOptions = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, - null, - null, - -1 - ); - var generateKeyRet = await huks.generateKey(defaultAliasA, generateKeyOptions); - expect(generateKeyRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - done(); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_39600 - * @tc.name AgreeWithError - * @tc.desc Test for algorithm completion(agree with ECDH). - */ - it('HUKS_ALG_COMPLETION_39600', 0, async function (done) { - var generateKeyOptions = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, - null, - null, - -1 - ); - huks.generateKey(defaultAliasA, generateKeyOptions, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - done(); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_39700 - * @tc.name AgreeWithError - * @tc.desc Test for algorithm completion(agree with ECDH). - */ - it('HUKS_ALG_COMPLETION_39700', 0, async function (done) { - var generateKeyOptions = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, - null, - null, - huks.HuksKeyDigest.HUKS_DIGEST_NONE - ); - var generateKeyARet = await huks.generateKey(defaultAliasA, generateKeyOptions); - expect(generateKeyARet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var generateKeyBRet = await huks.generateKey(defaultAliasB, generateKeyOptions); - expect(generateKeyBRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - - var exportKeyARet = await huks.exportKey(defaultAliasA, emptyOption); - publicKeyA = exportKeyARet.outData; - - var exportKeyBRet = await huks.exportKey(defaultAliasB, emptyOption); - publicKeyB = exportKeyBRet.outData; - - var agreeKeyAOption = makeAgreeOptions( - -1, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - publicKeyB - ); - var agreeKeyARet = await huks.agreeKey(defaultAliasB, agreeKeyAOption); - expect(agreeKeyARet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - - huks.agreeKey(defaultAliasA, agreeKeyAOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ALGORITHM); - done(); - }); - - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_39800 - * @tc.name AgreeWithError - * @tc.desc Test for algorithm completion(agree with ECDH). - */ - it('HUKS_ALG_COMPLETION_39800', 0, async function (done) { - var generateKeyOptions = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, - null, - null, - huks.HuksKeyDigest.HUKS_DIGEST_NONE - ); - var generateKeyARet = await huks.generateKey(defaultAliasA, generateKeyOptions); - expect(generateKeyARet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var generateKeyBRet = await huks.generateKey(defaultAliasB, generateKeyOptions); - expect(generateKeyBRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyARet = await huks.exportKey(defaultAliasA, emptyOption); - publicKeyA = exportKeyARet.outData; - var exportKeyBRet = await huks.exportKey(defaultAliasB, emptyOption); - publicKeyB = exportKeyBRet.outData; - var agreeKeyAOption = makeAgreeOptions( - huks.HuksKeyAlg.HUKS_ALG_ECDH, - -1, - publicKeyB - ); - var agreeKeyARet = await huks.agreeKey(defaultAliasB, agreeKeyAOption); - expect(agreeKeyARet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - huks.agreeKey(defaultAliasA, agreeKeyAOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - }); - setTimeout(function () { - }, timer); - }); - - function isKeyBExist(caseId, done) { - huks.isKeyExist(defaultAliasB, emptyOption, function (err, data) { - expect(data).assertEqual(false); - console.info(caseId + ' end'); - done(); - }); - }; - - function isKeyAExist(caseId, done) { - huks.isKeyExist(defaultAliasA, emptyOption, function (err, data) { - expect(data).assertEqual(false); - isKeyBExist(caseId, done); - }); - }; - - function deleteKeyB(caseId, done) { - huks.deleteKey(defaultAliasB, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - isKeyAExist(caseId, done); - }); - }; - - function deleteKeyA(caseId, done) { - huks.deleteKey(defaultAliasA, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - deleteKeyB(caseId, done); - }); - }; - - function agreeKeyB(alg, size, done, caseId) { - var agreeKeyAOption = makeAgreeOptions(alg, size, publicKeyB); - huks.agreeKey(defaultAliasA, agreeKeyAOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - keyB = data.outData; - expect(JSON.stringify(keyB)).assertEqual(JSON.stringify(keyA)); - deleteKeyA(caseId, done); - }); - }; - - function agreeKeyA(alg, size, done, caseId) { - if (alg == huks.HuksKeyAlg.HUKS_ALG_ECC) { - alg = huks.HuksKeyAlg.HUKS_ALG_ECDH - } - var agreeKeyAOption = makeAgreeOptions(alg, size, publicKeyB); - huks.agreeKey(defaultAliasA, agreeKeyAOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - keyA = data.outData; - agreeKeyB(alg, size, done, caseId); - }); - }; - - function exportKeyB(alg, size, done, caseId) { - huks.exportKey(defaultAliasB, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - publicKeyB = data.outData; - agreeKeyA(alg, size, done, caseId); - }); - }; - - function exportKeyA(alg, size, done, caseId) { - huks.exportKey(defaultAliasA, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - publicKeyA = data.outData; - exportKeyB(alg, size, done, caseId); - }); - }; - - function generateKeyB(alg, size, done, caseId) { - var generateKeyBOption = makeGenerateKeyOption( - alg, - size, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, - null, - null, - huks.HuksKeyDigest.HUKS_DIGEST_NONE - ); - huks.generateKey(defaultAliasB, generateKeyBOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - exportKeyA(alg, size, done, caseId); - }); - }; - - function generateKeyA(alg, size, done, caseId) { - var generateKeyAOption = makeGenerateKeyOption( - alg, - size, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, - null, - null, - huks.HuksKeyDigest.HUKS_DIGEST_NONE - ); - huks.generateKey(defaultAliasA, generateKeyAOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - generateKeyB(alg, size, done, caseId); - }); - }; - - function agreeCallback(alg, size, done, caseId) { - generateKeyA(alg, size, done, caseId); - }; - - async function agreePromise(alg, size, done, caseId){ - var generateKeyAOption = makeGenerateKeyOption( - alg, size, huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, null, null, huks.HuksKeyDigest.HUKS_DIGEST_NONE - ); - var generateKeyARet = await huks.generateKey(defaultAliasA, generateKeyAOption); - expect(generateKeyARet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var generateKeyBOption = makeGenerateKeyOption( - alg, size, huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE, null, null, huks.HuksKeyDigest.HUKS_DIGEST_NONE - ); - var generateKeyBRet = await huks.generateKey(defaultAliasB, generateKeyBOption); - expect(generateKeyBRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - - var exportKeyARet = await huks.exportKey(defaultAliasA, emptyOption); - var exportKeyBRet = await huks.exportKey(defaultAliasB, emptyOption); - expect(exportKeyARet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - expect(exportKeyBRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - publicKeyA = exportKeyARet.outData; - publicKeyB = exportKeyBRet.outData; - if (alg == huks.HuksKeyAlg.HUKS_ALG_ECC) { - alg = huks.HuksKeyAlg.HUKS_ALG_ECDH - } - var agreeKeyAOption = makeAgreeOptions(alg, size, publicKeyB); - var agreeKeyARet = await huks.agreeKey(defaultAliasA, agreeKeyAOption); - expect(agreeKeyARet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var agreeKeyBOption = makeAgreeOptions(alg, size, publicKeyA); - var agreeKeyBRet = await huks.agreeKey(defaultAliasB, agreeKeyBOption); - expect(agreeKeyBRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - expect(JSON.stringify(agreeKeyARet.outData)).assertEqual(JSON.stringify(agreeKeyBRet.outData)); - var deleteKeyARet = await huks.deleteKey(defaultAliasA, emptyOption); - expect(deleteKeyARet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deleteKeyBRet = await huks.deleteKey(defaultAliasB, emptyOption); - expect(deleteKeyBRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var isKeyAExist = await huks.isKeyExist(defaultAliasA, emptyOption); - expect(isKeyAExist).assertEqual(false); - var isKeyBExist = await huks.isKeyExist(defaultAliasA, emptyOption); - expect(isKeyBExist).assertEqual(false); - console.info(caseId + ' end'); - done(); - }; -}); \ No newline at end of file diff --git a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_xtsTest_algCompletion_encryptAndDecrypt_aes.test.js b/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_xtsTest_algCompletion_encryptAndDecrypt_aes.test.js deleted file mode 100644 index cd39f08989269855d16d638e8c31e7cf4ba0a759..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_xtsTest_algCompletion_encryptAndDecrypt_aes.test.js +++ /dev/null @@ -1,726 +0,0 @@ -/* - * 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 huks from '@ohos.security.huks' -import {describe, it, expect} from 'deccjsunit/index' -import { - emptyOption, - useLib, - timer, - makeGenerateKeyOption, - makeEncryptAndDecryptOption, - makeRandomArr -} from '../../../../../../hks_xts_common.test.js' - -var plainText = makeRandomArr (64); -var alias = ''; - -function makeAesGenerateKeyOption (size, padding, mode) { - var option = makeGenerateKeyOption ( - huks.HuksKeyAlg.HUKS_ALG_AES, - size, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - padding, - mode - ); - return option; -}; - -function makeAesEncryptOption (padding, mode) { - var option = makeEncryptAndDecryptOption ( - huks.HuksKeyAlg.HUKS_ALG_AES, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - padding, - mode, - null, - null, - plainText - ); - return option; -}; - -function makeAesDecryptOption (padding, mode, ciphertext) { - var option = makeEncryptAndDecryptOption ( - huks.HuksKeyAlg.HUKS_ALG_AES, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - padding, - mode, - null, - null, - ciphertext - ); - return option; -}; - -describe ('Hks_XtsTest_algCompletion_Aes_Encrypt_Decrypt', function () { - - /** - * @tc.number HUKS_ALG_COMPLETION_00100 - * @tc.name AES128_AES_CBC_NoPadding_Promise - * @tc.desc Test for algorithm completion(AES128_AES_CBC_NoPadding). - */ - it ('HUKS_ALG_COMPLETION_00100', 0, async function (done) { - encryptAndDecryptWithPromise ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_CBC, - done, - 'HUKS_ALG_COMPLETION_00100' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_00200 - * @tc.name AES128_AES_CBC_NoPadding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it ('HUKS_ALG_COMPLETION_00200', 0, async function (done) { - encryptAndDecryptWithCallback ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_CBC, - done, - 'HUKS_ALG_COMPLETION_00200' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_00300 - * @tc.name AES192_AES_CBC_NoPadding_Promise - * @tc.desc Test for algorithm completion(AES192_AES_CBC_NoPadding). - */ - it ('HUKS_ALG_COMPLETION_00300', 0, async function (done) { - encryptAndDecryptWithPromise ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_192, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_CBC, - done, - 'HUKS_ALG_COMPLETION_00300' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_00400 - * @tc.name AES192_AES_CBC_NoPadding_AsyncCallback - * @tc.desc Test for algorithm completion(AES192_AES_CBC_NoPadding).. - */ - it ('HUKS_ALG_COMPLETION_00400', 0, async function (done) { - encryptAndDecryptWithCallback ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_192, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_CBC, - done, - 'HUKS_ALG_COMPLETION_00400' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_00500 - * @tc.name AES256_AES_CBC_NoPadding_Promise - * @tc.desc Test for algorithm completion(AES256_AES_CBC_NoPadding). - */ - it ('HUKS_ALG_COMPLETION_00500', 0, async function (done) { - encryptAndDecryptWithPromise ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_CBC, - done, - 'HUKS_ALG_COMPLETION_00500' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_00600 - * @tc.name AES256_AES_CBC_NoPadding_AsyncCallback - * @tc.desc Test for algorithm completion(AES256_AES_CBC_NoPadding). - */ - it ('HUKS_ALG_COMPLETION_00600', 0, async function (done) { - encryptAndDecryptWithCallback ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_CBC, - done, - 'HUKS_ALG_COMPLETION_00600' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_00700 - * @tc.name AES128_AES_CBC_PKCS7Padding_Promise - * @tc.desc Test for algorithm completion(AES128_AES_CBC_PKCS7Padding). - */ - it ('HUKS_ALG_COMPLETION_00700', 0, async function (done) { - encryptAndDecryptWithPromise ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - huks.HuksKeyPadding.HUKS_PADDING_PKCS7, - huks.HuksCipherMode.HUKS_MODE_CBC, - done, - 'HUKS_ALG_COMPLETION_00700' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_00800 - * @tc.name AES128_AES_CBC_PKCS7Padding_Callback - * @tc.desc Test for algorithm completion(AES128_AES_CBC_PKCS7Padding). - */ - it ('HUKS_ALG_COMPLETION_00800', 0, async function (done) { - encryptAndDecryptWithCallback ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - huks.HuksKeyPadding.HUKS_PADDING_PKCS7, - huks.HuksCipherMode.HUKS_MODE_CBC, - done, - 'HUKS_ALG_COMPLETION_00800' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_00900 - * @tc.name AES192_AES_CBC_PKCS7Padding_Promise - * @tc.desc Test for algorithm completion(AES192_AES_CBC_PKCS7Padding). - */ - it ('HUKS_ALG_COMPLETION_00900', 0, async function (done) { - encryptAndDecryptWithPromise ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_192, - huks.HuksKeyPadding.HUKS_PADDING_PKCS7, - huks.HuksCipherMode.HUKS_MODE_CBC, - done, - 'HUKS_ALG_COMPLETION_00900' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_01000 - * @tc.name AES192_AES_CBC_PKCS7Padding_Callback - * @tc.desc Test for algorithm completion(AES192_AES_CBC_PKCS7Padding). - */ - it ('HUKS_ALG_COMPLETION_01000', 0, async function (done) { - encryptAndDecryptWithCallback ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_192, - huks.HuksKeyPadding.HUKS_PADDING_PKCS7, - huks.HuksCipherMode.HUKS_MODE_CBC, - done, - 'HUKS_ALG_COMPLETION_01000' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_01100 - * @tc.name AES256_AES_CBC_PKCS7Padding_Promise - * @tc.desc Test for algorithm completion(AES256_AES_CBC_PKCS7Padding). - */ - it ('HUKS_ALG_COMPLETION_01100', 0, async function (done) { - encryptAndDecryptWithPromise ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_PKCS7, - huks.HuksCipherMode.HUKS_MODE_CBC, - done, - 'HUKS_ALG_COMPLETION_01100' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_01200 - * @tc.name AES256_AES_CBC_PKCS7Padding_Callback - * @tc.desc Test for algorithm completion(AES256_AES_CBC_PKCS7Padding). - */ - it ('HUKS_ALG_COMPLETION_01200', 0, async function (done) { - encryptAndDecryptWithCallback ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_PKCS7, - huks.HuksCipherMode.HUKS_MODE_CBC, - done, - 'HUKS_ALG_COMPLETION_01200' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_01300 - * @tc.name AES128_AES_CTR_NoPadding_Promise - * @tc.desc Test for algorithm completion(AES128_AES_CTR_NoPadding). - */ - it ('HUKS_ALG_COMPLETION_01300', 0, async function (done) { - encryptAndDecryptWithPromise ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_CTR, - done, - 'HUKS_ALG_COMPLETION_01300' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_01400 - * @tc.name AES128_AES_CTR_NoPadding_AsyncCallback - * @tc.desc Test for algorithm completion(AES128_AES_CTR_NoPadding). - */ - it ('HUKS_ALG_COMPLETION_01400', 0, async function (done) { - encryptAndDecryptWithCallback ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_CTR, - done, - 'HUKS_ALG_COMPLETION_01400' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_01500 - * @tc.name AES192_AES_CTR_NoPadding_Promise - * @tc.desc Test for algorithm completion(AES192_AES_CTR_NoPadding). - */ - it ('HUKS_ALG_COMPLETION_01500', 0, async function (done) { - encryptAndDecryptWithPromise ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_192, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_CTR, - done, - 'HUKS_ALG_COMPLETION_01500' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_01600 - * @tc.name AES192_AES_CTR_NoPadding_AsyncCallback - * @tc.desc Test for algorithm completion(AES192_AES_CTR_NoPadding). - */ - it ('HUKS_ALG_COMPLETION_01600', 0, async function (done) { - encryptAndDecryptWithCallback ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_192, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_CTR, - done, - 'HUKS_ALG_COMPLETION_01600' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_01700 - * @tc.name AES256_AES_CTR_NoPadding_Promise - * @tc.desc Test for algorithm completion(AES256_AES_CTR_NoPadding). - */ - it ('HUKS_ALG_COMPLETION_01700', 0, async function (done) { - encryptAndDecryptWithPromise ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_CTR, - done, - 'HUKS_ALG_COMPLETION_01700' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_01800 - * @tc.name AES256_AES_CTR_NoPadding_AsyncCallback - * @tc.desc Test for algorithm completion(AES128_AES_CTR_NoPadding). - */ - it ('HUKS_ALG_COMPLETION_01800', 0, async function (done) { - encryptAndDecryptWithCallback ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_CTR, - done, - 'HUKS_ALG_COMPLETION_01800' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_01900 - * @tc.name AES128_AES_ECB_NoPadding_Promise - * @tc.desc Test for algorithm completion(AES128_AES_ECB_NoPadding). - */ - it ('HUKS_ALG_COMPLETION_01900', 0, async function (done) { - encryptAndDecryptWithPromise ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_ECB, - done, - 'HUKS_ALG_COMPLETION_01900' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_02000 - * @tc.name AES128_AES_ECB_NoPadding_AsyncCallback - * @tc.desc Test for algorithm completion(AES128_AES_ECB_NoPadding). - */ - it ('HUKS_ALG_COMPLETION_02000', 0, async function (done) { - encryptAndDecryptWithCallback ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_ECB, - done, - 'HUKS_ALG_COMPLETION_02000' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_02100 - * @tc.name AES192_AES_ECB_NoPadding_Promise - * @tc.desc Test for algorithm completion(AES192_AES_ECB_NoPadding). - */ - it ('HUKS_ALG_COMPLETION_02100', 0, async function (done) { - encryptAndDecryptWithPromise ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_192, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_ECB, - done, - 'HUKS_ALG_COMPLETION_02100' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_02200 - * @tc.name AES192_AES_ECB_NoPadding_AsyncCallback - * @tc.desc Test for algorithm completion(AES192_AES_ECB_NoPadding). - */ - it ('HUKS_ALG_COMPLETION_02200', 0, async function (done) { - encryptAndDecryptWithCallback ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_192, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_ECB, - done, - 'HUKS_ALG_COMPLETION_02200' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_02300 - * @tc.name AES256_AES_ECB_NoPadding_Promise - * @tc.desc Test for algorithm completion(AES256_AES_ECB_NoPadding). - */ - it ('HUKS_ALG_COMPLETION_02300', 0, async function (done) { - encryptAndDecryptWithPromise ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_ECB, - done, - 'HUKS_ALG_COMPLETION_02300' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_02400 - * @tc.name AES256_AES_ECB_NoPadding_AsyncCallback - * @tc.desc Test for algorithm completion(AES256_AES_ECB_NoPadding). - */ - it ('HUKS_ALG_COMPLETION_02400', 0, async function (done) { - encryptAndDecryptWithCallback ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_ECB, - done, - 'HUKS_ALG_COMPLETION_02400' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_02500 - * @tc.name AES128_AES_ECB_PKCS7Padding_Promise - * @tc.desc Test for algorithm completion(AES128_AES_ECB_PKCS7Padding). - */ - it ('HUKS_ALG_COMPLETION_02500', 0, async function (done) { - encryptAndDecryptWithPromise ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - huks.HuksKeyPadding.HUKS_PADDING_PKCS7, - huks.HuksCipherMode.HUKS_MODE_ECB, - done, - 'HUKS_ALG_COMPLETION_02500' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_02600 - * @tc.name AES128_AES_ECB_PKCS7Padding_AsyncCallback - * @tc.desc Test for algorithm completion(AES128_AES_ECB_PKCS7Padding). - */ - it ('HUKS_ALG_COMPLETION_02600', 0, async function (done) { - encryptAndDecryptWithCallback ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - huks.HuksKeyPadding.HUKS_PADDING_PKCS7, - huks.HuksCipherMode.HUKS_MODE_ECB, - done, - 'HUKS_ALG_COMPLETION_02600' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_02700 - * @tc.name Test AES192_AES_ECB_PKCS7Padding_Promise - * @tc.desc Test for algorithm completion(AES192_AES_ECB_PKCS7Padding). - */ - it ('HUKS_ALG_COMPLETION_02700', 0, async function (done) { - encryptAndDecryptWithPromise ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_192, - huks.HuksKeyPadding.HUKS_PADDING_PKCS7, - huks.HuksCipherMode.HUKS_MODE_ECB, - done, - 'HUKS_ALG_COMPLETION_02700' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_02800 - * @tc.name AES192_AES_ECB_PKCS7Padding_AsyncCallback - * @tc.desc Test for algorithm completion(AES192_AES_ECB_PKCS7Padding). - */ - it ('HUKS_ALG_COMPLETION_02800', 0, async function (done) { - encryptAndDecryptWithCallback ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_192, - huks.HuksKeyPadding.HUKS_PADDING_PKCS7, - huks.HuksCipherMode.HUKS_MODE_ECB, - done, - 'HUKS_ALG_COMPLETION_02800' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_02900 - * @tc.name AES256_AES_ECB_PKCS7Padding_Promise - * @tc.desc Test for algorithm completion(AES256_AES_ECB_PKCS7Padding). - */ - it ('HUKS_ALG_COMPLETION_02900', 0, async function (done) { - encryptAndDecryptWithPromise ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_PKCS7, - huks.HuksCipherMode.HUKS_MODE_ECB, - done, - 'HUKS_ALG_COMPLETION_02900' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_03000 - * @tc.name AES256_AES_ECB_PKCS7Padding_AsyncCallback - * @tc.desc Test for algorithm completion(AES256_AES_ECB_PKCS7Padding). - */ - it ('HUKS_ALG_COMPLETION_03000', 0, async function (done) { - encryptAndDecryptWithCallback ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_PKCS7, - huks.HuksCipherMode.HUKS_MODE_ECB, - done, - 'HUKS_ALG_COMPLETION_03000' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_03100 - * @tc.name AES128_AES_GCM_NoPadding_Promise - * @tc.desc Test for algorithm completion(AES128_AES_GCM_NoPadding). - */ - it ('HUKS_ALG_COMPLETION_03100', 0, async function (done) { - encryptAndDecryptWithPromise ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_GCM, - done, - 'HUKS_ALG_COMPLETION_03100' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_03200 - * @tc.name AES28_AES_GCM_NoPadding_AsyncCallback - * @tc.desc Test for algorithm completion(AES128_AES_GCM_NoPadding). - */ - it ('HUKS_ALG_COMPLETION_03200', 0, async function (done) { - encryptAndDecryptWithCallback ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_128, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_GCM, - done, - 'HUKS_ALG_COMPLETION_03200' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_03300 - * @tc.name AES192_AES_GCM_NoPadding_Promise - * @tc.desc Test for algorithm completion(AES192_AES_GCM_NoPadding. - */ - it ('HUKS_ALG_COMPLETION_03300', 0, async function (done) { - encryptAndDecryptWithPromise ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_192, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_GCM, - done, - 'HUKS_ALG_COMPLETION_03300' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_03400 - * @tc.name AES192_AES_GCM_NoPadding_AsyncCallback - * @tc.desc Test for algorithm completion(AES192_AES_GCM_NoPadding. - */ - it ('HUKS_ALG_COMPLETION_03400', 0, async function (done) { - encryptAndDecryptWithCallback ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_192, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_GCM, - done, - 'HUKS_ALG_COMPLETION_03400' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_03500 - * @tc.name AES256_AES_GCM_NoPadding_Promise - * @tc.desc Test for algorithm completion(AES256_AES_GCM_NoPadding). - */ - it ('HUKS_ALG_COMPLETION_03500', 0, async function (done) { - encryptAndDecryptWithPromise ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_GCM, - done, - 'HUKS_ALG_COMPLETION_03500' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_03600 - * @tc.name AES256_AES_GCM_NoPadding_AsyncCallback - * @tc.desc Test for algorithm completion(AES256_AES_GCM_NoPadding). - */ - it ('HUKS_ALG_COMPLETION_03600', 0, async function (done) { - encryptAndDecryptWithCallback ( - huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_GCM, - done, - 'HUKS_ALG_COMPLETION_03600' - ); - }); - - async function encryptAndDecryptWithPromise (size, padding, mode, done, caseId) { - var generateKeyOption = makeAesGenerateKeyOption (size, padding, mode); - var generateKeyResult = await huks.generateKey (caseId, generateKeyOption); - expect (generateKeyResult.errorCode).assertEqual (huks.HuksErrorCode.HUKS_SUCCESS); - var isKeyExist = await huks.isKeyExist (caseId, emptyOption); - expect (isKeyExist).assertEqual (true); - var encryptOption = makeAesEncryptOption (padding, mode); - var encryptResult = await huks.encrypt (caseId, encryptOption); - if (useLib == 'openssl') { - expect (encryptResult.errorCode).assertEqual (huks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = makeAesDecryptOption (padding, mode, encryptResult.outData); - var decryptResult = await huks.decrypt (caseId, decryptOption); - expect (decryptResult.errorCode).assertEqual (huks.HuksErrorCode.HUKS_SUCCESS); - expect (JSON.stringify (plainText)).assertEqual (JSON.stringify (decryptResult.outData)); - var deleteKeyResult = await huks.deleteKey (caseId, emptyOption); - expect (deleteKeyResult.errorCode).assertEqual (huks.HuksErrorCode.HUKS_SUCCESS); - var isKeyExist = await huks.isKeyExist (caseId, emptyOption); - expect (isKeyExist).assertEqual (false); - } else { - if (mode == huks.HuksCipherMode.HUKS_MODE_CBC - || mode == huks.HuksCipherMode.HUKS_MODE_CTR - || mode == huks.HuksCipherMode.HUKS_MODE_GCM) { - expect (encryptResult.errorCode).assertEqual (huks.HuksErrorCode.HUKS_SUCCESS); - var decryptOption = makeAesDecryptOption (padding, mode, encryptResult.outData); - var decryptResult = await huks.decrypt (caseId, decryptOption); - expect (decryptResult.errorCode).assertEqual (huks.HuksErrorCode.HUKS_SUCCESS); - expect (JSON.stringify (plainText)).assertEqual (JSON.stringify (decryptResult.outData)); - var deleteKeyResult = await huks.deleteKey (caseId, emptyOption); - expect (deleteKeyResult.errorCode).assertEqual (huks.HuksErrorCode.HUKS_SUCCESS); - var isKeyExist = await huks.isKeyExist (caseId, emptyOption); - expect (isKeyExist).assertEqual (false); - } else if (huks.HuksCipherMode.HUKS_MODE_ECB) { - if (padding == huks.HuksKeyPadding.HUKS_PADDING_PKCS7) { - expect (encryptResult.errorCode).assertEqual (huks.HuksErrorCode.HUKS_ERROR_NOT_SUPPORTED); - } else { - expect (encryptResult.errorCode).assertEqual (huks.HuksErrorCode.HUKS_ERROR_CRYPTO_ENGINE_ERROR); - } - } else { - expect (encryptResult.errorCode).assertEqual (huks.HuksErrorCode.HUKS_ERROR_CRYPTO_ENGINE_ERROR); - } - } - console.log (caseId + ' end'); - done (); - setTimeout (function () { - }, timer); - }; - - function checkKeyIsExistAfterDeleteKey (done, caseId) { - huks.isKeyExist (caseId, emptyOption, function (err, data) { - expect (data).assertEqual (false); - console.log (caseId + ' end'); - done (); - setTimeout (function () { - }, timer); - }); - }; - - function deleteKeyWithCallback (done, caseId) { - huks.deleteKey (caseId, emptyOption, function (err, data) { - expect (data.errorCode).assertEqual (huks.HuksErrorCode.HUKS_SUCCESS); - checkKeyIsExistAfterDeleteKey (done, caseId); - }); - }; - - function decryptWithCallback (size, padding, mode, ciphertext, done, caseId) { - var decryptOption = makeAesDecryptOption (padding, mode, ciphertext); - huks.decrypt (caseId, decryptOption, function (err, data) { - expect (data.errorCode).assertEqual (huks.HuksErrorCode.HUKS_SUCCESS); - expect (JSON.stringify (plainText)).assertEqual (JSON.stringify (data.outData)); - deleteKeyWithCallback (done, caseId); - }); - }; - - function encryptWithCallback (size, padding, mode, done, caseId) { - var encryptOption = makeAesEncryptOption (padding, mode); - huks.encrypt (caseId, encryptOption, function (err, data) { - if (useLib == 'openssl') { - decryptWithCallback (size, padding, mode, data.outData, done, caseId); - } else { - switch (mode) { - case huks.HuksCipherMode.HUKS_MODE_CBC: - case huks.HuksCipherMode.HUKS_MODE_CTR: - case huks.HuksCipherMode.HUKS_MODE_GCM: - expect (data.errorCode).assertEqual (huks.HuksErrorCode.HUKS_SUCCESS); - decryptWithCallback (size, padding, mode, data.outData, done, caseId); - break; - case huks.HuksCipherMode.HUKS_MODE_ECB: - if (padding == huks.HuksKeyPadding.HUKS_PADDING_PKCS7) { - expect (data.errorCode).assertEqual (huks.HuksErrorCode.HUKS_ERROR_NOT_SUPPORTED); - done (); - } else { - expect (data.errorCode).assertEqual (huks.HuksErrorCode.HUKS_ERROR_CRYPTO_ENGINE_ERROR); - done (); - } - break; - default: - expect (data.errorCode).assertEqual (huks.HuksErrorCode.HUKS_ERROR_CRYPTO_ENGINE_ERROR); - done (); - } - } - }); - }; - - function checkKeyIsExistAfterGenerateKey (size, padding, mode, done, caseId) { - huks.isKeyExist (caseId, emptyOption, function (err, data) { - expect (data).assertEqual (true); - encryptWithCallback (size, padding, mode, done, caseId); - }); - }; - - function encryptAndDecryptWithCallback (size, padding, mode, done, caseId) { - var generateKeyOption = makeAesGenerateKeyOption (size, padding, mode); - huks.generateKey (caseId, generateKeyOption, function (err, data) { - expect (data.errorCode).assertEqual (huks.HuksErrorCode.HUKS_SUCCESS); - checkKeyIsExistAfterGenerateKey (size, padding, mode, done, caseId); - }); - }; -}); \ No newline at end of file diff --git a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_xtsTest_algCompletion_encryptAndDecrypt_rsa.test.js b/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_xtsTest_algCompletion_encryptAndDecrypt_rsa.test.js deleted file mode 100644 index d7755d4254eca9591b5d862430ba3cb5d4257394..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_xtsTest_algCompletion_encryptAndDecrypt_rsa.test.js +++ /dev/null @@ -1,1905 +0,0 @@ -/* - * 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 huks from '@ohos.security.huks' -import {describe, it, expect} from 'deccjsunit/index' -import { - makeGenerateKeyOption, - makeEncryptAndDecryptOption, - makeRandomArr, - emptyOption, - makeImportOption, - useLib, - timer -} from '../../../../../../hks_xts_common.test.js' - -describe('Hks_XtsTest_ALGCOMPLETION_RSA_ENCRYPT_DECRYPT', function () { - var aliasForRSAEncrypt = 'aliasForRSAEncrypt'; - var aliasForRSADecrypt = 'aliasForRSADecrypt'; - var publicKey = []; - var ciphertext = []; - - function makePlainTextSize(size,padding,digest){ - var plainTextSize = 0; - if (padding == huks.HuksKeyPadding.HUKS_PADDING_OAEP) { - if (digest == huks.HuksKeyDigest.HUKS_DIGEST_SHA224 && size == huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512) { - plainTextSize = 4; - } else { - plainTextSize = 16; - } - } else if (padding == huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5) { - plainTextSize = 8; - } else { - switch (size) { - case huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512: - plainTextSize = 64; - break; - case huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768: - plainTextSize = 96; - break; - case huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024: - plainTextSize = 128; - break; - case huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048: - plainTextSize = 256; - break; - case huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072: - plainTextSize = 384; - break; - case huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096: - plainTextSize = 512; - break; - default: - plainTextSize = 512; - } - } - return plainTextSize; - }; - - async function encryptAndDecryptWithPromise (size, padding, mode, digest, done, caseId){ - var plainTextSize = makePlainTextSize(size, padding,digest); - var plainText = makeRandomArr(plainTextSize); - var genKeyOpt = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_RSA,size, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT,padding,mode,digest - ); - var genKeyRet = await huks.generateKey(aliasForRSADecrypt, genKeyOpt); - expect(genKeyRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var exportKeyRet = await huks.exportKey(aliasForRSADecrypt, emptyOption); - expect(exportKeyRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importKeyOpt = makeImportOption( - huks.HuksKeyAlg.HUKS_ALG_RSA,size,huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT,padding,mode,digest,publicKey - ); - var importRet = await huks.importKey(aliasForRSAEncrypt, importKeyOpt); - expect(importRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var isEncryptKeyExist = await huks.isKeyExist(aliasForRSAEncrypt, emptyOption); - expect(isEncryptKeyExist).assertEqual(true); - var isDecryptKeyExist = await huks.isKeyExist(aliasForRSADecrypt, emptyOption); - expect(isDecryptKeyExist).assertEqual(true); - var encryptOpt = makeEncryptAndDecryptOption( - huks.HuksKeyAlg.HUKS_ALG_RSA,huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT,padding,mode,size,digest,plainText - ); - var encryptRet = await huks.encrypt(aliasForRSAEncrypt, encryptOpt); - if (useLib == 'mbedtls' - && mode == huks.HuksCipherMode.HUKS_MODE_ECB - && padding == huks.HuksKeyPadding.HUKS_PADDING_NONE){ - expect(encryptRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_NOT_SUPPORTED); - } else { - expect(encryptRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - ciphertext = encryptRet.outData; - var decryptOpt = makeEncryptAndDecryptOption( - huks.HuksKeyAlg.HUKS_ALG_RSA,huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT,padding,mode,size,digest,ciphertext - ); - var decryptRet = await huks.decrypt(aliasForRSADecrypt, decryptOpt); - expect(decryptRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - expect(JSON.stringify(plainText)).assertEqual(JSON.stringify(decryptRet.outData)); - var deleteEncryptKeyRet = await huks.deleteKey(aliasForRSAEncrypt, emptyOption); - expect(deleteEncryptKeyRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var deleteDecryptKeyRet = await huks.deleteKey(aliasForRSADecrypt, emptyOption); - expect(deleteDecryptKeyRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - isEncryptKeyExist = await huks.isKeyExist(aliasForRSAEncrypt, emptyOption); - expect(isEncryptKeyExist).assertEqual(false); - isDecryptKeyExist = await huks.isKeyExist(aliasForRSADecrypt, emptyOption); - expect(isDecryptKeyExist).assertEqual(false); - } - console.log(caseId + ' end'); - done(); - }; - - function checkDecryptKeyDeletedWithCallback(done, caseId) { - huks.isKeyExist(aliasForRSADecrypt, emptyOption, function (err, data) { - expect(data).assertEqual(false); - console.log(caseId + ' end'); - done(); - }); - }; - - function checkEncryptKeyDeletedWithCallback(done, caseId) { - huks.isKeyExist(aliasForRSAEncrypt, emptyOption, function (err, data) { - expect(data).assertEqual(false); - checkDecryptKeyDeletedWithCallback(done, caseId); - }); - }; - - function deleteDecryptKeyWithCallback(done, caseId) { - huks.deleteKey(aliasForRSADecrypt, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - checkEncryptKeyDeletedWithCallback(done, caseId); - }); - }; - - function deleteEncryptKeyWithCallback(done, caseId) { - huks.deleteKey(aliasForRSAEncrypt, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - deleteDecryptKeyWithCallback(done, caseId); - }); - }; - - function decryptWithCallback(size, padding, mode, digest, plainText, ciphertext, done, caseId) { - var decryptOpt = makeEncryptAndDecryptOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - padding, - mode, - size, - digest, - ciphertext - ); - huks.decrypt(aliasForRSADecrypt, decryptOpt, function (err, data) { - expect(JSON.stringify(plainText)).assertEqual(JSON.stringify(data.outData)); - deleteEncryptKeyWithCallback(done, caseId); - }); - }; - - function encryptWithCallback(size, padding, mode, digest, done, caseId) { - var plainTextSize = makePlainTextSize(size, padding,digest); - var plainText = makeRandomArr(plainTextSize); - var encryptOpt = makeEncryptAndDecryptOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - padding, - mode, - size, - digest, - plainText - ); - huks.encrypt(aliasForRSAEncrypt, encryptOpt, function (err, data) { - if (useLib == 'mbedtls' - && mode == huks.HuksCipherMode.HUKS_MODE_ECB - && padding == huks.HuksKeyPadding.HUKS_PADDING_NONE){ - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_NOT_SUPPORTED); - done(); - } else { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - decryptWithCallback(size, padding, mode, digest, plainText, data.outData, done, caseId); - } - }); - }; - - function checkDecryptKeyExistWithCallback(size, padding, mode, digest, done, caseId) { - huks.isKeyExist(aliasForRSADecrypt, emptyOption, function (err, data) { - expect(data).assertEqual(true); - encryptWithCallback(size, padding, mode, digest, done, caseId); - }); - }; - - function checkEncryptKeyExistWithCallback(size, padding, mode, digest, done, caseId) { - huks.isKeyExist(aliasForRSAEncrypt, emptyOption, function (err, data) { - expect(data).assertEqual(true); - checkDecryptKeyExistWithCallback(size, padding, mode, digest, done, caseId); - }); - }; - - function importWithCallback(size, padding, mode, digest, done, caseId) { - var importKeyOpt = makeImportOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - size, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - padding, - mode, - digest, - publicKey - ); - huks.importKey(aliasForRSAEncrypt, importKeyOpt, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - checkEncryptKeyExistWithCallback(size, padding, mode, digest, done, caseId); - }); - }; - - function exportWithCallback(size, padding, mode, digest, done, caseId) { - huks.exportKey(aliasForRSADecrypt, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - publicKey = data.outData; - importWithCallback(size, padding, mode, digest, done, caseId); - }); - }; - - function encryptAndDecryptWithCallback(size, padding, mode, digest, done, caseId) { - var genKeyOpt = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - size, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - padding, - mode, - digest - ); - huks.generateKey(aliasForRSADecrypt, genKeyOpt, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - exportWithCallback(size, padding, mode, digest, done, caseId); - }); - }; - - /** - * @tc.number HUKS_ALG_COMPLETION_03700 - * @tc.name RSA512_RSA_ECB_NoPadding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_03700', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_03700' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_03800 - * @tc.name RSA512_RSA_ECB_NoPadding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_03800', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_03800' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_03900 - * @tc.name RSA768_RSA_ECB_NoPadding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_03900', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_03900' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_04000 - * @tc.name RSA768_RSA_ECB_NoPadding_Callback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_04000', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_04000' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_04100 - * @tc.name RSA1024_RSA_ECB_NoPadding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_04100', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_04100' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_04200 - * @tc.name RSA1024_RSA_ECB_NoPadding_Callback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_04200', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_04200' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_04300 - * @tc.name RSA2048_RSA_ECB_NoPadding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_04300', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_04300' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_04400 - * @tc.name RSA2048_RSA_ECB_NoPadding_Callback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_04400', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_04400' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_04500 - * @tc.name RSA3072_RSA_ECB_NoPadding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_04500', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_04500' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_04600 - * @tc.name RSA3072_RSA_ECB_NoPadding_Callback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_04600', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_04600' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_04700 - * @tc.name RSA4096_RSA_ECB_NoPadding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_04700', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_04700' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_04800 - * @tc.name RSA4096_RSA_ECB_NoPadding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_04800', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_04800' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_04900 - * @tc.name RSA512_RSA_ECB_PKCS1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_04900', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_04900' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_05000 - * @tc.name RSA512_RSA_ECB_PKCS1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_05000', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_05000' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_05100 - * @tc.name RSA768_RSA_ECB_PKCS1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_05100', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_05100' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_05200 - * @tc.name RSA768_RSA_ECB_PKCS1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_05200', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_05200' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_05300 - * @tc.name RSA1024_RSA_ECB_PKCS1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_05300', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_05300' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_05400 - * @tc.name RSA1024_RSA_ECB_PKCS1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_05400', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_05400' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_05500 - * @tc.name RSA2048_RSA_ECB_PKCS1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_05500', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_05500' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_05600 - * @tc.name RSA2048_RSA_ECB_PKCS1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_05600', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_05600' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_05700 - * @tc.name RSA3072_RSA_ECB_PKCS1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_05700', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_05700' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_05800 - * @tc.name RSA3072_RSA_ECB_PKCS1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_05800', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_05800' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_05900 - * @tc.name RSA4096_RSA_ECB_PKCS1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_05900', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_05900' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_06000 - * @tc.name RSA4096_RSA_ECB_PKCS1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_06000', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_06000' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_06100 - * @tc.name RSA512_RSA_ECB_OAEPWithSHA-1AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_06100', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_06100' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_06200 - * @tc.name RSA512_RSA_ECB_OAEPWithSHA-1AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_06200', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_06200' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_06300 - * @tc.name RSA768_RSA_ECB_OAEPWithSHA-1AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_06300', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_06300' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_06400 - * @tc.name RSA768_RSA_ECB_OAEPWithSHA-1AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_06400', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_06400' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_06500 - * @tc.name RSA1024_RSA_ECB_OAEPWithSHA-1AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_06500', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_06500' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_06600 - * @tc.name RSA1024_RSA_ECB_OAEPWithSHA-1AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_06600', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_06600' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_06700 - * @tc.name RSA2048_RSA_ECB_OAEPWithSHA-1AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_06700', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_06700' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_06800 - * @tc.name RSA2048_RSA_ECB_OAEPWithSHA-1AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_06800', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_06800' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_06900 - * @tc.name RSA3072_RSA_ECB_OAEPWithSHA-1AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_06900', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_06900' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_07000 - * @tc.name RSA3072_RSA_ECB_OAEPWithSHA-1AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_07000', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_07000' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_07100 - * @tc.name RSA4096_RSA_ECB_OAEPWithSHA-1AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_07100', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_07100' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_07200 - * @tc.name RSA4096_RSA_ECB_OAEPWithSHA-1AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_07200', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_07200' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_07300 - * @tc.name RSA512_RSA_ECB_OAEPWithSHA-224AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_07300', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_07300' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_07400 - * @tc.name RSA512_RSA_ECB_OAEPWithSHA-224AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_07400', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_07400' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_07500 - * @tc.name RSA768_RSA_ECB_OAEPWithSHA-224AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_07500', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_07500' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_07600 - * @tc.name RSA768_RSA_ECB_OAEPWithSHA-224AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_07600', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_07600' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_07700 - * @tc.name RSA1024_RSA_ECB_OAEPWithSHA-224AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_07700', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_07700' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_07800 - * @tc.name RSA1024_RSA_ECB_OAEPWithSHA-224AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_07800', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_07800' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_07900 - * @tc.name RSA2048_RSA_ECB_OAEPWithSHA-224AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_07900', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_07900' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_08000 - * @tc.name RSA2048_RSA_ECB_OAEPWithSHA-224AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_08000', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_08000' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_08100 - * @tc.name RSA3072_RSA_ECB_OAEPWithSHA-224AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_08100', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_08100' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_08200 - * @tc.name RSA3072_RSA_ECB_OAEPWithSHA-224AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_08200', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_08200' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_08300 - * @tc.name RSA4096_RSA_ECB_OAEPWithSHA-224AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_08300', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_08300' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_08400 - * @tc.name RSA4096_RSA_ECB_OAEPWithSHA-224AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_08400', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_08400' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_08700 - * @tc.name RSA768_RSA_ECB_OAEPWithSHA-256AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_08700', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_08700' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_08800 - * @tc.name RSA768_RSA_ECB_OAEPWithSHA-256AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_08800', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_08800' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_08900 - * @tc.name RSA1024_RSA_ECB_OAEPWithSHA-256AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_08900', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_08900' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_09000 - * @tc.name RSA1024_RSA_ECB_OAEPWithSHA-256AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_09000', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_09000' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_09100 - * @tc.name RSA2048_RSA_ECB_OAEPWithSHA-256AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_09100', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_09100' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_09200 - * @tc.name RSA2048_RSA_ECB_OAEPWithSHA-256AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_09200', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_09200' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_09300 - * @tc.name RSA3072_RSA_ECB_OAEPWithSHA-256AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_09300', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_09300' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_09400 - * @tc.name RSA3072_RSA_ECB_OAEPWithSHA-256AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_09400', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_09400' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_09500 - * @tc.name RSA4096_RSA_ECB_OAEPWithSHA-256AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_09500', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_09500' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_09600 - * @tc.name RSA4096_RSA_ECB_OAEPWithSHA-256AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_09600', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_09600' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_09700 - * @tc.name RSA512_RSA_ECB_OAEPWithSHA-384AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_09700', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - ); - var generateKeyResult = await huks.generateKey('alias',generateKeyOption); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var text = makeRandomArr(256); - var encryptOption = makeEncryptAndDecryptOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - text - ); - var encryptResult = await huks.encrypt('alias',encryptOption); - expect(encryptResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_FILE); - done(); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_09800 - * @tc.name RSA512_RSA_ECB_OAEPWithSHA-384AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_09800', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - ); - var generateKeyResult = await huks.generateKey('alias',generateKeyOption); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var text = makeRandomArr(256); - var encryptOption = makeEncryptAndDecryptOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - text - ); - huks.encrypt('alias',encryptOption,function(err,data){ - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_FILE); - done(); - }); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_09900 - * @tc.name RSA768_RSA_ECB_OAEPWithSHA-384AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_09900', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - ); - var generateKeyResult = await huks.generateKey('alias',generateKeyOption); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var text = makeRandomArr(256); - var encryptOption = makeEncryptAndDecryptOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - text - ); - var encryptResult = await huks.encrypt('alias',encryptOption); - expect(encryptResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_FILE); - done(); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_10000 - * @tc.name RSA768_RSA_ECB_OAEPWithSHA-384AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_10000', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - ); - var generateKeyResult = await huks.generateKey('alias',generateKeyOption); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var text = makeRandomArr(256); - var encryptOption = makeEncryptAndDecryptOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - text - ); - huks.encrypt('alias',encryptOption,function(err,data){ - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_FILE); - done(); - }); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_10100 - * @tc.name RSA1024_RSA_ECB_OAEPWithSHA-384AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_10100', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_10100' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_10200 - * @tc.name RSA1024_RSA_ECB_OAEPWithSHA-384AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_10200', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_10200' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_10300 - * @tc.name RSA2048_RSA_ECB_OAEPWithSHA-384AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_10300', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_10300' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_10400 - * @tc.name RSA2048_RSA_ECB_OAEPWithSHA-384AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_10400', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_10400' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_10500 - * @tc.name RSA3072_RSA_ECB_OAEPWithSHA-384AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_10500', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_10500' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_10600 - * @tc.name RSA3072_RSA_ECB_OAEPWithSHA-384AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_10600', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_10600' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_10700 - * @tc.name RSA4096_RSA_ECB_OAEPWithSHA-384AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_10700', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_10700' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_10800 - * @tc.name RSA4096_RSA_ECB_OAEPWithSHA-384AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_10800', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_10800' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_10900 - * @tc.name RSA512_RSA_ECB_OAEPWithSHA-512AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_10900', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - ); - var generateKeyResult = await huks.generateKey('alias',generateKeyOption); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var text = makeRandomArr(256); - var encryptOption = makeEncryptAndDecryptOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - text - ); - var encryptResult = await huks.encrypt('alias',encryptOption); - expect(encryptResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_FILE); - done(); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_11000 - * @tc.name RSA512_RSA_ECB_OAEPWithSHA-512AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_11000', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - ); - var generateKeyResult = await huks.generateKey('alias',generateKeyOption); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var text = makeRandomArr(256); - var encryptOption = makeEncryptAndDecryptOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - text - ); - huks.encrypt('alias',encryptOption,function(err,data){ - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_FILE); - done(); - }); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_11100 - * @tc.name RSA768_RSA_ECB_OAEPWithSHA-512AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_11100', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - ); - var generateKeyResult = await huks.generateKey('alias',generateKeyOption); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var text = makeRandomArr(256); - var encryptOption = makeEncryptAndDecryptOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - text - ); - var encryptResult = await huks.encrypt('alias',encryptOption); - expect(encryptResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_FILE); - done(); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_11200 - * @tc.name RSA768_RSA_ECB_OAEPWithSHA-384AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_11200', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - ); - var generateKeyResult = await huks.generateKey('alias',generateKeyOption); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var text = makeRandomArr(256); - var encryptOption = makeEncryptAndDecryptOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - text - ); - huks.encrypt('alias',encryptOption,function(err,data){ - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_FILE); - done(); - }); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_11300 - * @tc.name RSA1024_RSA_ECB_OAEPWithSHA-512AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_11300', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - ); - var generateKeyResult = await huks.generateKey('alias',generateKeyOption); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var text = makeRandomArr(256); - var encryptOption = makeEncryptAndDecryptOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - text - ); - var encryptResult = await huks.encrypt('alias',encryptOption); - expect(encryptResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_FILE); - done(); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_11400 - * @tc.name RSA1024_RSA_ECB_OAEPWithSHA-512AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_11400', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - ); - var generateKeyResult = await huks.generateKey('alias',generateKeyOption); - expect(generateKeyResult.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - var text = makeRandomArr(256); - var encryptOption = makeEncryptAndDecryptOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - text - ); - huks.encrypt('alias',encryptOption,function(err,data){ - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_KEY_FILE); - done(); - }); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_11500 - * @tc.name RSA2048_RSA_ECB_OAEPWithSHA-512AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_11500', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_11500' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_11600 - * @tc.name RSA2048_RSA_ECB_OAEPWithSHA-512AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_11600', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_11600' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_11700 - * @tc.name RSA3072_RSA_ECB_OAEPWithSHA-512AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_11700', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_11700' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_11800 - * @tc.name RSA3072_RSA_ECB_OAEPWithSHA-512AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_11800', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_11800' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_11900 - * @tc.name RSA4096_RSA_ECB_OAEPWithSHA-512AndMGF1Padding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_11900', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_11900' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_12000 - * @tc.name RSA4096_RSA_ECB_OAEPWithSHA-512AndMGF1Padding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_12000', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_12000' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_12100 - * @tc.name RSA512_RSA_ECB_OAEPPadding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_12100', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_12100' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_12200 - * @tc.name RSA512_RSA_ECB_OAEPPadding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_12200', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_12200' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_12300 - * @tc.name RSA768_RSA_ECB_OAEPPadding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_12300', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_12300' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_12400 - * @tc.name RSA768_RSA_ECB_OAEPPadding_AsyncCallback - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_12400', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_12400' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_12500 - * @tc.name RSA1024_RSA_ECB_OAEPPadding_Promise - * @tc.desc Test for algorithm completion. - */ - it('HUKS_ALG_COMPLETION_12500', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_12500' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_12600 - * @tc.name RSA1024_RSA_ECB_OAEPPadding_AsyncCallback - * @tc.desc Test for algorithm completion - */ - it('HUKS_ALG_COMPLETION_12600', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_12600' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_12700 - * @tc.name RSA2048_RSA_ECB_OAEPPadding_Promise - * @tc.desc Test for algorithm completion - */ - it('HUKS_ALG_COMPLETION_12700', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_12700' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_12800 - * @tc.name RSA2048_RSA_ECB_OAEPPadding_AsyncCallback - * @tc.desc Test for algorithm completion - */ - it('HUKS_ALG_COMPLETION_12800', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_12800' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_12900 - * @tc.name RSA3072_RSA_ECB_OAEPPadding_Promise - * @tc.desc Test for algorithm completion - */ - it('HUKS_ALG_COMPLETION_12900', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_12900' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_13000 - * @tc.name RSA3072_RSA_ECB_OAEPPadding_AsyncCallback - * @tc.desc Test for algorithm completion - */ - it('HUKS_ALG_COMPLETION_13000', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_13000' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_13100 - * @tc.name RSA4096_RSA_ECB_OAEPPadding_Promise - * @tc.desc Test for algorithm completion - */ - it('HUKS_ALG_COMPLETION_13100', 0, async function (done) { - encryptAndDecryptWithPromise( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_13100' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_13200 - * @tc.name RSA4096_RSA_ECB_OAEPPadding_AsyncCallback - * @tc.desc Test for algorithm completion - */ - it('HUKS_ALG_COMPLETION_13200', 0, async function (done) { - encryptAndDecryptWithCallback( - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_OAEP, - huks.HuksCipherMode.HUKS_MODE_ECB, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_13200' - ); - }); -}); \ No newline at end of file diff --git a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_xtsTest_algCompletion_mac.test.js b/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_xtsTest_algCompletion_mac.test.js deleted file mode 100644 index d21bb7aced252deee38996e6044b255a82389715..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_xtsTest_algCompletion_mac.test.js +++ /dev/null @@ -1,255 +0,0 @@ -/* - * 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 huks from '@ohos.security.huks' -import {describe, it, expect} from 'deccjsunit/index' -import { - emptyOption, - makeGenerateKeyOption, - makeRandomArr, - timer -} from '../../../../../../hks_xts_common.test.js' - -var defaultAlias = 'defaultAlias'; -var plaintText = makeRandomArr(64); - -describe('Hks_XtsTest_AlgCompletion_Mac', function () { - - /** - * @tc.number HUKS_ALG_COMPLETION_39900 - * @tc.name HmacSHA1_Promise - * @tc.desc Test for algorithm completion(HmacSHA1). - */ - it('HUKS_ALG_COMPLETION_39900', 0, async function (done) { - macPromise( - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - 160, - done, - 'HUKS_ALG_COMPLETION_39900' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_40000 - * @tc.name HmacSHA224_Promise - * @tc.desc Test for algorithm completion(HmacSHA224). - */ - it('HUKS_ALG_COMPLETION_40000', 0, async function (done) { - macPromise( - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - 224, - done, - 'HUKS_ALG_COMPLETION_40000' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_40100 - * @tc.name HmacSHA256_Promise - * @tc.desc Test for algorithm completion(HmacSHA256). - */ - it('HUKS_ALG_COMPLETION_40100', 0, async function (done) { - macPromise( - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - 256, - done, - 'HUKS_ALG_COMPLETION_40100' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_40200 - * @tc.name HmacSHA384_Promise - * @tc.desc Test for algorithm completion(HmacSHA384). - */ - it('HUKS_ALG_COMPLETION_40200', 0, async function (done) { - macPromise( - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - 384, - done, - 'HUKS_ALG_COMPLETION_40200' - ); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_40300 - * @tc.name HmacSHA512_Promise - * @tc.desc Test for algorithm completion(HmacSHA512). - */ - it('HUKS_ALG_COMPLETION_40300', 0, async function (done) { - macPromise( - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - 512, - done, - 'HUKS_ALG_COMPLETION_40300' - ); - }); - - function isKeyExist(done,caseId){ - huks.isKeyExist(defaultAlias, emptyOption,function(err,data){ - expect(data).assertEqual(false); - console.log(caseId + ' end'); - done(); - }); - }; - - function deleteKey(done, caseId){ - huks.deleteKey(defaultAlias, emptyOption, function(err,data){ - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - isKeyExist(done, caseId); - }); - }; - - function doMac(digest, size, done, caseId){ - var macOption = makeMacOption(size, digest); - huks.mac(defaultAlias, macOption,function(err,data){ - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - deleteKey(done,caseId); - }); - }; - - function macCallback(digest, size, done, caseId) { - var generateKeyOption = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_HMAC, size, huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, null, null, digest - ); - huks.generateKey(defaultAlias, generateKeyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - doMac(digest, size, done, caseId); - }); - }; - - /** - * @tc.number HUKS_ALG_COMPLETION_40400 - * @tc.name HmacSHA1_AsyncCallback - * @tc.desc Test for algorithm completion(HmacSHA512). - */ - it('HUKS_ALG_COMPLETION_40400', 0, async function (done) { - macCallback( - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - 160, - done, - 'HUKS_ALG_COMPLETION_40400' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_40500 - * @tc.name HmacSHA224_AsyncCallback - * @tc.desc Test for algorithm completion(HmacSHA512). - */ - it('HUKS_ALG_COMPLETION_40500', 0, async function (done) { - macCallback( - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - 224, - done, - 'HUKS_ALG_COMPLETION_40500' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_40600 - * @tc.name HmacSHA256_AsyncCallback - * @tc.desc Test for algorithm completion(HmacSHA512). - */ - it('HUKS_ALG_COMPLETION_40600', 0, async function (done) { - macCallback( - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - 256, - done, - 'HUKS_ALG_COMPLETION_40600' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_40700 - * @tc.name HmacSHA384_AsyncCallback - * @tc.desc Test for algorithm completion(HmacSHA512). - */ - it('HUKS_ALG_COMPLETION_40700', 0, async function (done) { - macCallback( - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - 384, - done, - 'HUKS_ALG_COMPLETION_40700' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_40800 - * @tc.name HmacSHA512_AsyncCallback - * @tc.desc Test for algorithm completion(HmacSHA512). - */ - it('HUKS_ALG_COMPLETION_40800', 0, async function (done) { - macCallback( - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - 512, - done, - 'HUKS_ALG_COMPLETION_40800' - ); - setTimeout(function () { - }, timer); - }); - - function makeMacOption(size, digest) { - var properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_HMAC - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: digest - }; - var options = { - properties: properties, - inData: plaintText - }; - return options; - }; - - async function macPromise(digest, size, done, caseId) { - var generateKeyOption = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_HMAC, size, huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC, null, null, digest - ); - var generateKeyRet = await huks.generateKey(defaultAlias, generateKeyOption); - expect(generateKeyRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - - var macOption = makeMacOption(size, digest); - var macRet = await huks.mac(defaultAlias, macOption); - expect(macRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - - var deleteKeyRet = await huks.deleteKey(defaultAlias, emptyOption); - expect(deleteKeyRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - - var isKeyExist = await huks.isKeyExist(defaultAlias, emptyOption); - expect(isKeyExist).assertEqual(false); - console.log(caseId + ' end'); - done(); - setTimeout(function () { - }, timer); - } -}); \ No newline at end of file diff --git a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_xtsTest_algCompletion_signAndVerify_callback.test.js b/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_xtsTest_algCompletion_signAndVerify_callback.test.js deleted file mode 100644 index f076c880f8207dceb2aba2bc1428bca2762d1fc5..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_xtsTest_algCompletion_signAndVerify_callback.test.js +++ /dev/null @@ -1,2398 +0,0 @@ -/* - * 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 huks from '@ohos.security.huks'; -import {describe, it, expect} from 'deccjsunit/index'; -import { - aliasA, - aliasB, - useLib, - makeGenerateKeyOption, - makeImportOption, - makeSignAndVerifyOption, - makeRandomArr, - timer, - emptyOption -} from '../../../../../../hks_xts_common.test.js' - -var signedText = []; -var publicKey = []; - -describe('Hks_XtsTest_AlgCompletion_Sign_Verify', function () { - - /** - * @tc.number HUKS_ALG_COMPLETION_17500 - * @tc.name RSA512_MD5withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_17500', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_17500' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_17600 - * @tc.name RSA768_MD5withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_17600', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_17600' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_17700 - * @tc.name RSA1024_MD5withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_17700', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_17700' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_17800 - * @tc.name RSA2048_MD5withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_17800', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_17800' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_17900 - * @tc.name RSA3072_MD5withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_17900', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_17900' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_18000 - * @tc.name RSA4096_MD5withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_18000', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_18000' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_18100 - * @tc.name RSA512_NONEwithRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_18100', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_18100' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_18200 - * @tc.name RSA768_NONEwithRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_18200', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_18200' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_18300 - * @tc.name RSA1024_NONEwithRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_18300', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_18300' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_18400 - * @tc.name RSA2048_NONEwithRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_18400', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_18400' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_18500 - * @tc.name RSA3072_NONEwithRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_18500', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_18500' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_18600 - * @tc.name RSA4096_NONEwithRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_18600', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_18600' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_18700 - * @tc.name RSA512_SHA1withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_18700', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_18700' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_18800 - * @tc.name RSA768_SHA1withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_18800', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_18800' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_18900 - * @tc.name RSA1024_SHA1withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_18900', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_18900' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_19000 - * @tc.name RSA2048_SHA1withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_19000', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_19000' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_19100 - * @tc.name RSA3072_SHA1withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_19100', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_19100' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_19200 - * @tc.name RSA4096_SHA1withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_19200', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_19200' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_19300 - * @tc.name RSA512_SHA224withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_19300', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_19300' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_19400 - * @tc.name RSA768_SHA224withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_19400', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_19400' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_19500 - * @tc.name RSA1024_SHA224withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_19500', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_19500' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_19600 - * @tc.name RSA2048_SHA224withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_19600', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_19600' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_19700 - * @tc.name RSA3072_SHA224withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_19700', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_19700' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_19800 - * @tc.name RSA4096_SHA224withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_19800', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_19800' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_19900 - * @tc.name RSA512_SHA256withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_19900', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_19900' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_20000 - * @tc.name RSA768_SHA256withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_20000', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_20000' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_20100 - * @tc.name RSA1024_SHA256withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_20100', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_20100' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_20200 - * @tc.name RSA2048_SHA256withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_20200', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_20200' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_20300 - * @tc.name RSA3072_SHA256withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_20300', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_20300' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_20400 - * @tc.name RSA4096_SHA256withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_20400', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_20400' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_20500 - * @tc.name RSA512_SHA384withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_20500', 0, async function (done) { - var plainText = makeRandomArr(16); - var generateKeyOption = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - null, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384 - ); - var generateKeyRet = await huks.generateKey(aliasA, generateKeyOption); - expect(generateKeyRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - - var signOption = makeSignAndVerifyOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - plainText - ); - huks.sign(aliasA, signOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_CRYPTO_ENGINE_ERROR); - console.log('HUKS_ALG_COMPLETION_20500 end'); - done(); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_20600 - * @tc.name RSA768_SHA384withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_20600', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_20600' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_20700 - * @tc.name RSA1024_SHA384withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_20700', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_20700' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_20800 - * @tc.name RSA2048_SHA384withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_20800', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_20800' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_20900 - * @tc.name RSA3072_SHA384withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_20900', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_20900' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_21000 - * @tc.name RSA4096_SHA384withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_21000', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_21000' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_21100 - * @tc.name RSA512_SHA512withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_21100', 0, async function (done) { - var plainText = makeRandomArr(16); - var generateKeyOption = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - null, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512 - ); - var generateKeyRet = await huks.generateKey(aliasA, generateKeyOption); - expect(generateKeyRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - - var signOption = makeSignAndVerifyOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - plainText - ); - huks.sign(aliasA, signOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_CRYPTO_ENGINE_ERROR); - console.log('HUKS_ALG_COMPLETION_21100 end'); - done(); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_21200 - * @tc.name RSA768_SHA512withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_21200', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_21200' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_21300 - * @tc.name RSA1024_SHA512withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_21300', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_21300' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number zHUKS_ALG_COMPLETION_21400 - * @tc.name RSA2048_SHA512withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_21400', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_21400' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_21500 - * @tc.name RSA3072_SHA512withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_21500', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_21500' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_21600 - * @tc.name RSA4096_SHA512withRSA_Callback - * @tc.desc Test for sign and verify with rsa. - */ - it('HUKS_ALG_COMPLETION_21600', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_21600' - ); - setTimeout(function () { - }, timer); - }); - - - - /** - * @tc.number HUKS_ALG_COMPLETION_25900 - * @tc.name RSA512_MD5withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_25900', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_25900' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_26000 - * @tc.name RSA768_MD5withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_26000', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_26000' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_26100 - * @tc.name RSA1024_MD5withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_26100', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_26100' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_26200 - * @tc.name RSA2048_MD5withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_26200', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_26200' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_26300 - * @tc.name RSA3072_MD5withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_26300', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_26300' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_26400 - * @tc.name RSA4096_MD5withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_26400', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_26400' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_26500 - * @tc.name RSA512_NONEwithRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_26500', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_26500' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_26600 - * @tc.name RSA768_NONEwithRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_26600', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_26600' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_26700 - * @tc.name RSA1024_NONEwithRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_26700', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_26700' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_26800 - * @tc.name RSA2048_NONEwithRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_26800', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_26800' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_26900 - * @tc.name RSA3072_NONEwithRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_26900', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_26900' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_27000 - * @tc.name RSA4096_NONEwithRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_27000', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_27000' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_27100 - * @tc.name RSA512_SHA1withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_27100', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_27100' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_27200 - * @tc.name RSA768_SHA1withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_27200', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_27200' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_27300 - * @tc.name RSA1024_SHA1withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_27300', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_27300' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_27400 - * @tc.name RSA2048_SHA1withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_27400', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_27400' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_27500 - * @tc.name RSA3072_SHA1withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_27500', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_27500' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_27600 - * @tc.name RSA4096_SHA1withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_27600', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_27600' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_27700 - * @tc.name RSA512_SHA224withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_27700', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_27700' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_27800 - * @tc.name RSA768_SHA224withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_27800', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_27800' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_27900 - * @tc.name RSA1024_SHA224withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_27900', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_27900' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_28000 - * @tc.name RSA2048_SHA224withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_28000', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_28000' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_28100 - * @tc.name RSA3072_SHA224withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_28100', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_28100' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_28200 - * @tc.name RSA4096_SHA224withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_28200', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_28200' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_28300 - * @tc.name RSA512_SHA256withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_28300', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_28300' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_28400 - * @tc.name RSA768_SHA256withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_28400', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_28400' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_28500 - * @tc.name RSA1024_SHA256withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_28500', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_28500' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_28600 - * @tc.name RSA2048_SHA256withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_28600', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_28600' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_28700 - * @tc.name RSA3072_SHA256withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_28700', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_28700' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_28800 - * @tc.name RSA4096_SHA256withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_28800', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_28800' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_28900 - * @tc.name RSA512_SHA384withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_28900', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_28900' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_29000 - * @tc.name RSA768_SHA384withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_29000', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_29000' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_29100 - * @tc.name RSA1024_SHA384withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_29100', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_29100' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_29200 - * @tc.name RSA2048_SHA384withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_29200', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_29200' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_29300 - * @tc.name RSA3072_SHA384withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_29300', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_29300' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_29400 - * @tc.name RSA4096_SHA384withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_29400', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_29400' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_29500 - * @tc.name RSA512_SHA512withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_29500', 0, async function (done) { - var plainText = makeRandomArr(16); - var generateKeyOption = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - null, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512 - ); - var generateKeyRet = await huks.generateKey(aliasA, generateKeyOption); - expect(generateKeyRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - - var signOption = makeSignAndVerifyOption( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - plainText - ); - huks.sign(aliasA, signOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_CRYPTO_ENGINE_ERROR); - console.log('HUKS_ALG_COMPLETION_29500 end'); - done(); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_29600 - * @tc.name RSA768_SHA512withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_29600', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_29600' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_29700 - * @tc.name RSA1024_SHA512withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_29700', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_29700' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_29800 - * @tc.name RSA2048_SHA512withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_29800', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_29800' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_29900 - * @tc.name RSA3072_SHA512withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_29900', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_29900' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_30000 - * @tc.name RSA4096_SHA512withRSA_Pss_AsyncCallback - * @tc.desc Test for sign and verify with rsa/pss. - */ - it('HUKS_ALG_COMPLETION_30000', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_30000' - ); - setTimeout(function () { - }, timer); - }); - - - - /** - * @tc.number HUKS_ALG_COMPLETION_30800 - * @tc.name DSA_MD5withDSA_AsyncCallback - * @tc.desc Test for sign and verify with dsa. - */ - it('HUKS_ALG_COMPLETION_30800', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_DSA, - 1024, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - null, - huks.HuksKeyDigest.HUKS_DIGEST_MD5 - ); - huks.generateKey(aliasA, generateKeyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - console.log('HUKS_ALG_COMPLETION_30800 end'); - done(); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_30900 - * @tc.name DSA_NONEwithDSA_AsyncCallback - * @tc.desc Test for sign and verify with dsa. - */ - it('HUKS_ALG_COMPLETION_30900', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_DSA, - 1024, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - null, - huks.HuksKeyDigest.HUKS_DIGEST_NONE - ); - huks.generateKey(aliasA, generateKeyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - console.log('HUKS_ALG_COMPLETION_30900 end'); - done(); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_31000 - * @tc.name DSA_SHA1withDSA_AsyncCallback - * @tc.desc Test for sign and verify with dsa. - */ - it('HUKS_ALG_COMPLETION_31000', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_DSA, - 1024, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_31000' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_31100 - * @tc.name DSA_SHA224withDSA_AsyncCallback - * @tc.desc Test for sign and verify with dsa. - */ - it('HUKS_ALG_COMPLETION_31100', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_DSA, - 1024, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_31100' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_31200 - * @tc.name DSA_SHA256withDSA_AsyncCallback - * @tc.desc Test for sign and verify with dsa. - */ - it('HUKS_ALG_COMPLETION_31200', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_DSA, - 1024, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_31200' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_31300 - * @tc.name DSA_SHA384withDSA_AsyncCallback - * @tc.desc Test for sign and verify with dsa. - */ - it('HUKS_ALG_COMPLETION_31300', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_DSA, - 1024, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_31300' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_31400 - * @tc.name DSA_SHA512withDSA_AsyncCallback - * @tc.desc Test for sign and verify with dsa. - */ - it('HUKS_ALG_COMPLETION_31400', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_DSA, - 1024, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_31400' - ); - setTimeout(function () { - }, timer); - }); - - - - /** - * @tc.number HUKS_ALG_COMPLETION_32200 - * @tc.name ECDSA224_MD5withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_32200', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - null, - huks.HuksKeyDigest.HUKS_DIGEST_MD5 - ); - huks.generateKey(aliasA, generateKeyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - console.log('HUKS_ALG_COMPLETION_32200 end'); - done(); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_32300 - * @tc.name ECDSA224_NONEwithECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_32300', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_32300' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_32400 - * @tc.name ECDSA224_SHA1withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_32400', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_32400' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_32500 - * @tc.name ECDSA224_SHA224withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_32500', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_32500' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_32600 - * @tc.name ECDSA224_SHA256withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_32600', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_32600' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_32700 - * @tc.name ECDSA224_SHA384withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_32700', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_32700' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_32800 - * @tc.name ECDSA224_SHA512withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_32800', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_32800' - ); - setTimeout(function () { - }, timer); - }); - - - - /** - * @tc.number HUKS_ALG_COMPLETION_33600 - * @tc.name ECDSA256_MD5withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_33600', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - null, - huks.HuksKeyDigest.HUKS_DIGEST_MD5 - ); - huks.generateKey(aliasA, generateKeyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - console.log('HUKS_ALG_COMPLETION_33600 end'); - done(); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_33700 - * @tc.name ECDSA256_NONEwithECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_33700', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_33700' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_33800 - * @tc.name ECDSA256_SHA1withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_33800', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_33800' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_33900 - * @tc.name ECDSA256_SHA224withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_33900', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_33900' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_34000 - * @tc.name ECDSA256_SHA256withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_34000', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_34000' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_34100 - * @tc.name ECDSA256_SHA384withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_34100', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_34100' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_34200 - * @tc.name ECDSA256_SHA512withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_34200', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_34200' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_35000 - * @tc.name ECDSA384_MD5withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_35000', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_384, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - null, - huks.HuksKeyDigest.HUKS_DIGEST_MD5 - ); - huks.generateKey(aliasA, generateKeyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - console.log('HUKS_ALG_COMPLETION_35000 end'); - done(); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_35100 - * @tc.name ECDSA384_NONEwithECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_35100', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_384, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_35100' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_35200 - * @tc.name ECDSA384_SHA1withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_35200', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_384, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_35200' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_35300 - * @tc.name ECDSA384_SHA224withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_35300', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_384, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_35300' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_35400 - * @tc.name ECDSA384_SHA256withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_35400', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_384, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_35400' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_35500 - * @tc.name ECDSA384_SHA384withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_35500', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_384, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_35500' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_35600 - * @tc.name ECDSA384_SHA512withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_35600', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_384, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_35600' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_36400 - * @tc.name ECDSA521_MD5withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_36400', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_521, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - null, - huks.HuksKeyDigest.HUKS_DIGEST_MD5 - ); - huks.generateKey(aliasA, generateKeyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - console.log('HUKS_ALG_COMPLETION_36400 end'); - done(); - }); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_36500 - * @tc.name ECDSA521_NONEwithECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_36500', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_521, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_36500' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_36600 - * @tc.name ECDSA521_SHA1withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_36600', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_521, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_36600' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_36700 - * @tc.name ECDSA521_SHA224withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_36700', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_521, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_36700' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_36800 - * @tc.name ECDSA521_SHA256withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_36800', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_521, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_36800' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_36900 - * @tc.name ECDSA521_SHA384withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_36900', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_521, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_36900' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_37000 - * @tc.name ECDSA521_SHA512withECDSA_AsyncCallback - * @tc.desc Test for sign and verify with ECDSA. - */ - it('HUKS_ALG_COMPLETION_37000', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_521, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_37000' - ); - setTimeout(function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_37200 - * @tc.name Regression_Testing_ED25519_CallBack - * @tc.desc Test for ED25519 Regression Testing. - */ - it('HUKS_ALG_COMPLETION_37200', 0, async function (done) { - signAndVerifyCallback( - huks.HuksKeyAlg.HUKS_ALG_ED25519, - huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_37200' - ); - setTimeout(function () { - }, timer); - }); - - function isAliasBExist(done, caseId) { - huks.isKeyExist(aliasB, emptyOption, function (err, data) { - expect(data).assertEqual(false); - console.log(caseId + ' end'); - done(); - }) - }; - - function isAliasAExist(done, caseId) { - huks.isKeyExist(aliasA, emptyOption, function (err, data) { - expect(data).assertEqual(false); - isAliasBExist(done, caseId); - }) - }; - - function deleteAliasB(done, caseId) { - huks.deleteKey(aliasB, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - isAliasAExist(done, caseId); - }) - }; - - function deleteAliasA(done, caseId) { - huks.deleteKey(aliasA, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - deleteAliasB(done, caseId); - }) - }; - - function verifyWithCallback(alg, size, padding, digest, plainText, done, caseId) { - var verifyOptions = makeSignAndVerifyOption( - alg, - size, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - padding, - digest, - plainText - ); - huks.verify(aliasB, verifyOptions, signedText, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - deleteAliasA(done, caseId); - }); - }; - - function importWithCallback(alg, size, padding, digest, plainText, done, caseId) { - var importOption = makeImportOption( - alg, - size, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - padding, - null, - digest, - publicKey - ); - huks.importKey(aliasB, importOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - verifyWithCallback(alg, size, padding, digest, plainText, done, caseId); - }); - }; - - function exportWithCallback(alg, size, padding, digest, plainText, done, caseId) { - huks.exportKey(aliasA, emptyOption, function (err, data) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - publicKey = data.outData; - importWithCallback(alg, size, padding, digest, plainText, done, caseId); - }); - }; - - function signWithCallback(alg, size, padding, digest, done, caseId) { - var plainText = makeRandomArr(16); - var signOption = makeSignAndVerifyOption( - alg, - size, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN, - padding, - digest, - plainText - ); - huks.sign(aliasA, signOption, function (err, data) { - if (useLib == 'mbedtls' && ( - caseId == 'HUKS_ALG_COMPLETION_28900' || - caseId == 'HUKS_ALG_COMPLETION_29500' || - caseId == 'HUKS_ALG_COMPLETION_29600')) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_CRYPTO_ENGINE_ERROR); - done(); - } else { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - signedText = data.outData; - console.log('signedText ' + JSON.stringify(signedText)); - exportWithCallback(alg, size, padding, digest, plainText, done, caseId); - } - }); - }; - - function signAndVerifyCallback(alg, size, padding, digest, done, caseId) { - var generateKeyOption = makeGenerateKeyOption( - alg, - size, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - padding, - null, - digest - ); - huks.generateKey(aliasA, generateKeyOption, function (err, data) { - if (useLib == 'mbedtls' && alg == huks.HuksKeyAlg.HUKS_ALG_DSA) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_NOT_SUPPORTED); - console.log(caseId + ' end'); - done(); - } else { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - signWithCallback(alg, size, padding, digest, done, caseId); - } - }); - }; -}); \ No newline at end of file diff --git a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_xtsTest_algCompletion_signAndVerify_promise.test.js b/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_xtsTest_algCompletion_signAndVerify_promise.test.js deleted file mode 100644 index 9825112ebf12f5687a451264224941084418eea5..0000000000000000000000000000000000000000 --- a/security/huks_standard/HuksAlgCompletionTest/entry/src/main/js/test/hks_xtsTest_algCompletion_signAndVerify_promise.test.js +++ /dev/null @@ -1,2355 +0,0 @@ -/* - * 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 huks from '@ohos.security.huks'; -import {describe, it, expect} from 'deccjsunit/index'; -import { - aliasA, - aliasB, - useLib, - makeGenerateKeyOption, - makeImportOption, - makeSignAndVerifyOption, - makeRandomArr, - timer, - emptyOption -} from '../../../../../../hks_xts_common.test.js' - -var signedText = new Uint8Array( 0); -var publicKey = new Uint8Array( 0); -var plainText = makeRandomArr (16); - -function makeSignGenerateKeyOption (alg, size, padding, digest) { - var option = makeGenerateKeyOption ( - alg, - size, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - padding, - null, - digest - ); - return option; -}; - -function makeSignOption (alg, size, padding, digest) { - var option = makeSignAndVerifyOption ( - alg, - size, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN, - padding, - digest, - plainText, - ); - return option; -}; - -function makeVerifyOption (alg, size, padding, digest) { - var option = makeSignAndVerifyOption ( - alg, - size, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - padding, - digest, - plainText, - ); - return option; -}; - -function makeImportKeyOption (alg, size, padding, digest) { - var option = makeImportOption ( - alg, - size, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - padding, - null, - digest, - publicKey - ); - return option; -}; - -describe ('Hks_XtsTest_AlgCompletion_Rsa_Sign_Verify_Promise', function () { - - /** - * @tc.number HUKS_ALG_COMPLETION_13300 - * @tc.name RSA512_MD5withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_13300', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_13300' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_13400 - * @tc.name RSA768_MD5withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_13400', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_13400' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_13500 - * @tc.name RSA1024_MD5withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_13500', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_13500' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_13600 - * @tc.name RSA2048_MD5withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_13600', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_13600' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_13700 - * @tc.name RSA3072_MD5withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_13700', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_13700' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_13800 - * @tc.name RSA4096_MD5withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_13800', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_13800' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_13900 - * @tc.name RSA512_NONEwithRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_13900', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_13900' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_14000 - * @tc.name RSA768_NONEwithRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_14000', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_14000' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_14100 - * @tc.name RSA1024_NONEwithRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_14100', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_14100' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_14200 - * @tc.name RSA2048_NONEwithRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_14200', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_14200' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_14300 - * @tc.name RSA3072_NONEwithRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_14300', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_14300' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_14400 - * @tc.name RSA4096_NONEwithRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_14400', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_14400' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_14500 - * @tc.name RSA512_SHA1withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_14500', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_14500' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_14600 - * @tc.name RSA768_SHA1withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_14600', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_14600' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_14700 - * @tc.name RSA1024_SHA1withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_14700', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_14700' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_14800 - * @tc.name RSA2048_SHA1withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_14800', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_14800' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_14900 - * @tc.name RSA3072_SHA1withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_14900', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_14900' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_15000 - * @tc.name RSA4096_SHA1withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_15000', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_15000' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_15100 - * @tc.name RSA512_SHA224withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_15100', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_15100' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_15200 - * @tc.name RSA768_SHA224withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_15200', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_15200' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_15300 - * @tc.name RSA1024_SHA224withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_15300', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_15300' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_15400 - * @tc.name RSA2048_SHA224withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_15400', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_15400' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_15500 - * @tc.name RSA3072_SHA224withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_15500', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_15500' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_15600 - * @tc.name RSA4096_SHA224withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_15600', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_15600' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_15700 - * @tc.name RSA512_SHA256withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_15700', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_15700' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_15800 - * @tc.name RSA768_SHA256withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_15800', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_15800' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_15900 - * @tc.name RSA1024_SHA256withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_15900', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_15900' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_16000 - * @tc.name RSA2048_SHA256withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_16000', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_16000' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_16100 - * @tc.name RSA3072_SHA256withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_16100', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_16100' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_16200 - * @tc.name RSA4096_SHA256withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_16200', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_16200' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_16300 - * @tc.name RSA512_SHA384withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_16300', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - null, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384 - ); - var generateKeyRet = await huks.generateKey (aliasA, generateKeyOption); - expect (generateKeyRet.errorCode).assertEqual (huks.HuksErrorCode.HUKS_SUCCESS); - - var signOption = makeSignAndVerifyOption ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - plainText - ); - var signRet = await huks.sign (aliasA, signOption); - expect (signRet.errorCode).assertEqual (huks.HuksErrorCode.HUKS_ERROR_CRYPTO_ENGINE_ERROR); - console.log ('HUKS_ALG_COMPLETION_16300 end'); - done (); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_16400 - * @tc.name RSA768_SHA384withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_16400', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_16400' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_16500 - * @tc.name RSA1024_SHA384withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_16500', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_16500' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_16600 - * @tc.name RSA2048_SHA384withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_16600', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_16600' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_16700 - * @tc.name RSA3072_SHA384withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_16700', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_16700' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_16800 - * @tc.name RSA4096_SHA384withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_16800', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_16800' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_16900 - * @tc.name RSA512_SHA512withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_16900', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - null, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512 - ); - var generateKeyRet = await huks.generateKey (aliasA, generateKeyOption); - expect (generateKeyRet.errorCode).assertEqual (huks.HuksErrorCode.HUKS_SUCCESS); - - var signOption = makeSignAndVerifyOption ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - plainText - ); - var signRet = await huks.sign (aliasA, signOption); - expect (signRet.errorCode).assertEqual (huks.HuksErrorCode.HUKS_ERROR_CRYPTO_ENGINE_ERROR); - console.log ('HUKS_ALG_COMPLETION_16900 end'); - done (); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_17000 - * @tc.name RSA768_SHA512withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_17000', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_17000' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_17100 - * @tc.name RSA1024_SHA512withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_17100', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_17100' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_17200 - * @tc.name RSA2048_SHA512withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_17200', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_17200' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_17300 - * @tc.name RSA3072_SHA512withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_17300', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_17300' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_17400 - * @tc.name RSA4096_SHA512withRSA_Promise - * @tc.desc Test for sign and verify with rsa. - */ - it ('HUKS_ALG_COMPLETION_17400', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_17400' - ); - setTimeout (function () { - }, timer); - }); - - - /** - * @tc.number HUKS_ALG_COMPLETION_21700 - * @tc.name RSA512_MD5withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_21700', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_21700' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_21800 - * @tc.name RSA768_MD5withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_21800', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_21800' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_21900 - * @tc.name RSA1024_MD5withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_21900', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_21900' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_22000 - * @tc.name RSA2048_MD5withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_22000', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_22000' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_22100 - * @tc.name RSA3072_MD5withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_22100', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_22100' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_22200 - * @tc.name RSA4096_MD5withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_22200', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_MD5, - done, - 'HUKS_ALG_COMPLETION_22200' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_22300 - * @tc.name RSA512_NONEwithRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_22300', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_22300' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_22400 - * @tc.name RSA768_NONEwithRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_22400', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_22400' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_22500 - * @tc.name RSA1024_NONEwithRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_22500', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_22500' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_22600 - * @tc.name RSA2048_NONEwithRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_22600', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_22600' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_22700 - * @tc.name RSA3072_NONEwithRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_22700', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_22700' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_22800 - * @tc.name RSA4096_NONEwithRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_22800', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_22800' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_22900 - * @tc.name RSA512_SHA1withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_22900', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_22900' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_23000 - * @tc.name RSA768_SHA1withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_23000', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_23000' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_23100 - * @tc.name RSA1024_SHA1withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_23100', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_23100' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_23200 - * @tc.name RSA2048_SHA1withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_23200', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_23200' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_23300 - * @tc.name RSA3072_SHA1withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_23300', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_23300' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_23400 - * @tc.name RSA4096_SHA1withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_23400', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_23400' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_23500 - * @tc.name RSA512_SHA224withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_23500', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_23500' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_23600 - * @tc.name RSA768_SHA224withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_23600', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_23600' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_23700 - * @tc.name RSA1024_SHA224withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_23700', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_23700' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_23800 - * @tc.name RSA2048_SHA224withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_23800', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_23800' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_23900 - * @tc.name RSA3072_SHA224withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_23900', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_23900' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_24000 - * @tc.name RSA4096_SHA224withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_24000', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_24000' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_24100 - * @tc.name RSA512_SHA256withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_24100', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_24100' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_24200 - * @tc.name RSA768_SHA256withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_24200', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_24200' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_24300 - * @tc.name RSA1024_SHA256withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_24300', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_24300' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_24400 - * @tc.name RSA2048_SHA256withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_24400', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_24400' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_24500 - * @tc.name RSA3072_SHA256withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_24500', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_24500' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_24600 - * @tc.name RSA4096_SHA256withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_24600', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_24600' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_24700 - * @tc.name RSA512_SHA384withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_24700', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_24700' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_24800 - * @tc.name RSA768_SHA384withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_24800', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_24800' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_24900 - * @tc.name RSA1024_SHA384withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_24900', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_24900' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_25000 - * @tc.name RSA2048_SHA384withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_25000', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_25000' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_25100 - * @tc.name RSA3072_SHA384withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_25100', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_25100' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_25200 - * @tc.name RSA4096_SHA384withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_25200', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_25200' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_25300 - * @tc.name RSA512_SHA512withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_25300', 0, async function (done) { - var plainText = makeRandomArr (16); - var generateKeyOption = makeGenerateKeyOption ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - null, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512 - ); - var generateKeyRet = await huks.generateKey (aliasA, generateKeyOption); - expect (generateKeyRet.errorCode).assertEqual (huks.HuksErrorCode.HUKS_SUCCESS); - - var signOption = makeSignAndVerifyOption ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_512, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - plainText - ); - var signRet = await huks.sign (aliasA, signOption); - expect (signRet.errorCode).assertEqual (huks.HuksErrorCode.HUKS_ERROR_CRYPTO_ENGINE_ERROR); - console.log ('HUKS_ALG_COMPLETION_25300 end'); - done (); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_25400 - * @tc.name RSA768_SHA512withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_25400', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_768, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_25400' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_25500 - * @tc.name RSA1024_SHA512withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_25500', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_25500' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_25600 - * @tc.name RSA2048_SHA512withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_25600', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_25600' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_25700 - * @tc.name RSA3072_SHA512withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_25700', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_25700' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_25800 - * @tc.name RSA4096_SHA512withRSA_Pss_Promise - * @tc.desc Test for sign and verify with rsa/pss. - */ - it ('HUKS_ALG_COMPLETION_25800', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_RSA, - huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, - huks.HuksKeyPadding.HUKS_PADDING_PSS, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_25800' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_30100 - * @tc.name DSA_MD5withDSA_Promise - * @tc.desc Test for sign and verify with dsa. - */ - it ('HUKS_ALG_COMPLETION_30100', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption ( - huks.HuksKeyAlg.HUKS_ALG_DSA, - 1024, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - null, - huks.HuksKeyDigest.HUKS_DIGEST_MD5 - ); - var generateKeyRet = await huks.generateKey (aliasA, generateKeyOption); - expect (generateKeyRet.errorCode).assertEqual (huks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - console.log ('HUKS_ALG_COMPLETION_30100 end'); - done (); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_30200 - * @tc.name DSA_NONEwithDSA_Promise - * @tc.desc Test for sign and verify with dsa. - */ - it ('HUKS_ALG_COMPLETION_30200', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption ( - huks.HuksKeyAlg.HUKS_ALG_DSA, - 1024, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - null, - huks.HuksKeyDigest.HUKS_DIGEST_NONE - ); - var generateKeyRet = await huks.generateKey (aliasA, generateKeyOption); - expect (generateKeyRet.errorCode).assertEqual (huks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - console.log ('HUKS_ALG_COMPLETION_30200 end'); - done (); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_30300 - * @tc.name DSA_SHA1withDSA_Promise - * @tc.desc Test for sign and verify with dsa. - */ - it ('HUKS_ALG_COMPLETION_30300', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_DSA, - 1024, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_30300' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_30400 - * @tc.name DSA_SHA224withDSA_Promise - * @tc.desc Test for sign and verify with dsa. - */ - it ('HUKS_ALG_COMPLETION_30400', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_DSA, - 1024, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_30400' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_30500 - * @tc.name DSA_SHA256withDSA_Promise - * @tc.desc Test for sign and verify with dsa. - */ - it ('HUKS_ALG_COMPLETION_30500', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_DSA, - 1024, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_30500' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_30600 - * @tc.name DSA_SHA384withDSA_Promise - * @tc.desc Test for sign and verify with dsa. - */ - it ('HUKS_ALG_COMPLETION_30600', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_DSA, - 1024, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_30600' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_30700 - * @tc.name DSA_SHA512withDSA_Promise - * @tc.desc Test for sign and verify with dsa. - */ - it ('HUKS_ALG_COMPLETION_30700', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_DSA, - 1024, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_30700' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_31500 - * @tc.name ECDSA224_MD5withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_31500', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - null, - huks.HuksKeyDigest.HUKS_DIGEST_MD5 - ); - var genKeyRet = await huks.generateKey (aliasA, generateKeyOption); - expect (genKeyRet.errorCode).assertEqual (huks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - console.log ('HUKS_ALG_COMPLETION_31500 end'); - done (); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_31600 - * @tc.name ECDSA224_NONEwithECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_31600', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_31600' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_31700 - * @tc.name ECDSA224_SHA1withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_31700', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_31700' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_31800 - * @tc.name ECDSA224_SHA224withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_31800', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_31800' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_31900 - * @tc.name ECDSA224_SHA256withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_31900', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_31900' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_32000 - * @tc.name ECDSA224_SHA384withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_32000', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_32000' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_32100 - * @tc.name ECDSA224_SHA512withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_32100', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_224, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_32100' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_32900 - * @tc.name ECDSA256_MD5withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_32900', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - null, - huks.HuksKeyDigest.HUKS_DIGEST_MD5 - ); - var genKeyRet = await huks.generateKey (aliasA, generateKeyOption); - expect (genKeyRet.errorCode).assertEqual (huks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - console.log ('HUKS_ALG_COMPLETION_32900 end'); - done (); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_33000 - * @tc.name ECDSA256_NONEwithECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_33000', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_33000' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_33100 - * @tc.name ECDSA256_SHA1withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_33100', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_33100' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_33200 - * @tc.name ECDSA256_SHA224withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_33200', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_33200' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_33300 - * @tc.name ECDSA256_SHA256withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_33300', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_33300' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_33400 - * @tc.name ECDSA256_SHA384withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_33400', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_33400' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_33500 - * @tc.name ECDSA256_SHA512withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_33500', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_33500' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_34300 - * @tc.name ECDSA384_MD5withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_34300', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_384, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - null, - huks.HuksKeyDigest.HUKS_DIGEST_MD5 - ); - var genKeyRet = await huks.generateKey (aliasA, generateKeyOption); - expect (genKeyRet.errorCode).assertEqual (huks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - console.log ('HUKS_ALG_COMPLETION_34300 end'); - done (); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_34400 - * @tc.name ECDSA384_NONEwithECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_34400', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_384, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_34400' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_34500 - * @tc.name ECDSA384_SHA1withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_34500', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_384, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_34500' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_34600 - * @tc.name ECDSA384_SHA224withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_34600', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_384, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_34600' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_34700 - * @tc.name ECDSA384_SHA256withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_34700', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_384, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_34700' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_34800 - * @tc.name ECDSA384_SHA384withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_34800', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_384, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_34800' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_34900 - * @tc.name ECDSA384_SHA512withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_34900', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_384, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_34900' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_35700 - * @tc.name ECDSA521_MD5withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_35700', 0, async function (done) { - var generateKeyOption = makeGenerateKeyOption ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_521, - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - null, - huks.HuksKeyDigest.HUKS_DIGEST_MD5 - ); - var genKeyRet = await huks.generateKey (aliasA, generateKeyOption); - expect (genKeyRet.errorCode).assertEqual (huks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); - console.log ('HUKS_ALG_COMPLETION_35700 end'); - done (); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_35800 - * @tc.name ECDSA521_NONEwithECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_35800', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_521, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_35800' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_35900 - * @tc.name ECDSA521_SHA1withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_35900', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_521, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA1, - done, - 'HUKS_ALG_COMPLETION_35900' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_36000 - * @tc.name ECDSA521_SHA224withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_36000', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_521, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA224, - done, - 'HUKS_ALG_COMPLETION_36000' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_36100 - * @tc.name ECDSA521_SHA256withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_36100', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_521, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - done, - 'HUKS_ALG_COMPLETION_36100' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_36200 - * @tc.name ECDSA521_SHA384withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_36200', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_521, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA384, - done, - 'HUKS_ALG_COMPLETION_36200' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_36300 - * @tc.name ECDSA521_SHA512withECDSA_Promise - * @tc.desc Test for sign and verify with ECDSA. - */ - it ('HUKS_ALG_COMPLETION_36300', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ECC, - huks.HuksKeySize.HUKS_ECC_KEY_SIZE_521, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_SHA512, - done, - 'HUKS_ALG_COMPLETION_36300' - ); - setTimeout (function () { - }, timer); - }); - - /** - * @tc.number HUKS_ALG_COMPLETION_37100 - * @tc.name Regression_Testing_ED25519_Promise - * @tc.desc Test for ED25519 Regression Testing. - */ - it ('HUKS_ALG_COMPLETION_37100', 0, async function (done) { - signAndVerifyPromise ( - huks.HuksKeyAlg.HUKS_ALG_ED25519, - huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256, - huks.HuksKeyPadding.HUKS_PADDING_NONE, - huks.HuksKeyDigest.HUKS_DIGEST_NONE, - done, - 'HUKS_ALG_COMPLETION_37100' - ); - setTimeout (function () { - }, timer); - }); - - async function signAndVerifyPromise (alg, size, padding, digest, done, caseId) { - var generateKeyOption = makeSignGenerateKeyOption (alg, size, padding, digest); - var generateKeyResult = await huks.generateKey (aliasA, generateKeyOption); - if (useLib == 'mbedtls' && alg == huks.HuksKeyAlg.HUKS_ALG_DSA) { - expect (generateKeyResult.errorCode).assertEqual (huks.HuksErrorCode.HUKS_ERROR_NOT_SUPPORTED); - } else { - expect (generateKeyResult.errorCode).assertEqual (huks.HuksErrorCode.HUKS_SUCCESS); - var signOption = makeSignOption (alg, size, padding, digest); - var signResult = await huks.sign (aliasA, signOption); - if (useLib == 'mbedtls' && ( - caseId == 'HUKS_ALG_COMPLETION_24700' || - caseId == 'HUKS_ALG_COMPLETION_25300' || - caseId == 'HUKS_ALG_COMPLETION_25400')) { - expect (signResult.errorCode).assertEqual (huks.HuksErrorCode.HUKS_ERROR_CRYPTO_ENGINE_ERROR); - } else { - expect (signResult.errorCode).assertEqual (huks.HuksErrorCode.HUKS_SUCCESS); - signedText = signResult.outData; - var exportKeyRet = await huks.exportKey (aliasA, emptyOption); - expect (exportKeyRet.errorCode).assertEqual (huks.HuksErrorCode.HUKS_SUCCESS); - publicKey = exportKeyRet.outData; - var importOption = makeImportKeyOption (alg, size, padding, digest); - var importKeyResult = await huks.importKey (aliasB, importOption); - expect (importKeyResult.errorCode).assertEqual (huks.HuksErrorCode.HUKS_SUCCESS); - var verifyOption = makeVerifyOption (alg, size, padding, digest); - var verifyRet = await huks.verify (aliasB, verifyOption, signedText); - expect (verifyRet.errorCode).assertEqual (huks.HuksErrorCode.HUKS_SUCCESS); - var deleteKeyAliasA = await huks.deleteKey (aliasA, emptyOption); - var deleteKeyAliasB = await huks.deleteKey (aliasB, emptyOption); - expect (deleteKeyAliasA.errorCode).assertEqual (huks.HuksErrorCode.HUKS_SUCCESS); - expect (deleteKeyAliasB.errorCode).assertEqual (huks.HuksErrorCode.HUKS_SUCCESS); - var isKeyAExist = await huks.isKeyExist (aliasA, emptyOption); - expect (isKeyAExist).assertEqual (false); - var isKeyBExist = await huks.isKeyExist (aliasB, emptyOption); - expect (isKeyBExist).assertEqual (false); - } - } - console.log (caseId + ' end'); - done (); - }; -}); \ No newline at end of file diff --git a/security/huks_standard/HuksAlgCompletionTest/signature/openharmony_sx.p7b b/security/huks_standard/HuksAlgCompletionTest/signature/openharmony_sx.p7b deleted file mode 100644 index 9be1e98fa4c0c28ca997ed660112fa16b194f0f5..0000000000000000000000000000000000000000 Binary files a/security/huks_standard/HuksAlgCompletionTest/signature/openharmony_sx.p7b and /dev/null differ diff --git a/security/huks_standard/hks_xts_common.test.js b/security/huks_standard/hks_xts_common.test.js deleted file mode 100644 index 5f81fdc77adbade187cae777ff7b1d4000c2ed5c..0000000000000000000000000000000000000000 --- a/security/huks_standard/hks_xts_common.test.js +++ /dev/null @@ -1,305 +0,0 @@ -/* - * 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 hks from '@ohos.security.huks' - -export const alias = 'alias'; -export const aliasA = 'aliasA'; -export var aliasB = 'aliasB'; -export var targetAlias = 'targetAlias'; - -export var useLib = 'openssl'; /** openssl or mbedtls */ - -export var successStr = 'SUCCESS'; -export var failStr = 'FAIL'; - -export var loop = 200; -export var timer = 1000; - -export var emptyOption = makeEmptyOption(); -export var inDataOption = makeInDataOption(); - -export function makeGenerateKeyOption(alg, size, purpose, padding, mode, digest) { - var properties = new Array(); - properties[0] = makeAlgTagProperty(alg); - properties[1] = makeSizeProperty(size); - properties[2] = makePurposeProperty(purpose); - if (purpose == (hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT)) { - properties[3] = makePaddingProperty(padding); - properties[4] = makeModeProperty(mode); - if (alg == hks.HuksKeyAlg.HUKS_ALG_RSA) { - properties[5] = makeDigestProperty(digest); - properties[6] = makeKeyGenerateType(); - } - } else if (purpose == (hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY)) { - properties[3] = makePaddingProperty(padding); - properties[4] = makeDigestProperty(digest); - } else if (purpose == hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC) { - properties[3] = makeDigestProperty(digest); - } else { - properties[3] = makeDigestProperty(digest); - } - var option = { - properties: properties - }; - return option; -}; - -export function makeEncryptAndDecryptOption(alg, purpose, padding, mode, size, digest, text) { - var properties = new Array(); - properties[0] = makeAlgTagProperty(alg); - properties[1] = makePurposeProperty(purpose); - properties[2] = makePaddingProperty(padding); - properties[3] = makeModeProperty(mode); - if (alg == hks.HuksKeyAlg.HUKS_ALG_AES) { - properties[4] = makeIV(); - if (mode == hks.HuksCipherMode.HUKS_MODE_GCM) { - properties[5] = makeAAD(); - properties[6] = makeNonce(); - } - } else { - properties[4] = makeIsKeyAlias(); - properties[5] = makeSizeProperty(size); - properties[6] = makeDigestProperty(digest); - } - var option = { - properties: properties, - inData: text - }; - return option; -}; - -export function makeSignAndVerifyOption(alg, size, purpose, padding, digest, text) { - var properties = new Array(); - properties[0] = makeAlgTagProperty(alg); - properties[1] = makeSizeProperty(size); - properties[2] = makePurposeProperty(purpose); - properties[3] = makePaddingProperty(padding); - properties[4] = makeDigestProperty(digest); - var option = { - properties: properties, - inData: text - }; - return option; -}; - -export function makeRandomArr(size) { - var arr = new Uint8Array(size); - for (var i = 0; i < size; i++) { - arr[i] = Math.floor(Math.random() * 10); - } - return arr; -}; - -export function makePlainTextSize(size,padding,digest){ - var plainTextSize = 0; - if (padding == hks.HuksKeyPadding.HUKS_PADDING_OAEP) { - if (digest == hks.HuksKeyDigest.HUKS_DIGEST_SHA224 && size == hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512) { - plainTextSize = 4; - } else { - plainTextSize = 16; - } - } else if (padding == hks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5) { - plainTextSize = 8; - } else { - switch (size) { - case hks.HuksKeySize.HUKS_RSA_KEY_SIZE_512: - plainTextSize = 64; - break; - case hks.HuksKeySize.HUKS_RSA_KEY_SIZE_768: - plainTextSize = 96; - break; - case hks.HuksKeySize.HUKS_RSA_KEY_SIZE_1024: - plainTextSize = 128; - break; - case hks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048: - plainTextSize = 256; - break; - case hks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072: - plainTextSize = 384; - break; - case hks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096: - plainTextSize = 512; - break; - default: - plainTextSize = 512; - } - } - return plainTextSize; -}; - -export function makeImportOption(alg, size, purpose, padding, mode, digest, publicKey) { - var properties = new Array(); - properties[0] = makeAlgTagProperty(alg); - properties[1] = makeSizeProperty(size); - properties[2] = makePurposeProperty(purpose); - properties[3] = makePaddingProperty(padding); - if (alg == hks.HuksKeyAlg.HUKS_ALG_RSA || alg == hks.HuksKeyAlg.HUKS_ALG_DSA || alg == hks.HuksKeyAlg.HUKS_ALG_ECC) { - if (purpose == (hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT)) { - properties[4] = makeModeProperty(mode); - properties[5] = makeDigestProperty(digest); - properties[6] = makeKeyGenerateType(); - } else { - properties[4] = makeDigestProperty(digest); - } - } - var options = { - properties: properties, - inData: publicKey - }; - return options; -}; - - -function makeAlgTagProperty(alg) { - var property = { - tag: hks.HuksTag.HUKS_TAG_ALGORITHM, - value: alg - } - return property; -}; - -function makeSizeProperty(size) { - var property = { - tag: hks.HuksTag.HUKS_TAG_KEY_SIZE, - value: size - }; - return property; -}; - -function makePurposeProperty(purpose) { - var property = { - tag: hks.HuksTag.HUKS_TAG_PURPOSE, - value: purpose - }; - return property; -}; - -function makePaddingProperty(padding) { - var property = { - tag: hks.HuksTag.HUKS_TAG_PADDING, - value: padding - }; - return property; -}; - -function makeModeProperty(mode) { - var property = { - tag: hks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: mode - }; - return property; -}; - -function makeDigestProperty(digest) { - var property = { - tag: hks.HuksTag.HUKS_TAG_DIGEST, - value: digest - }; - return property; -}; - -function makeKeyGenerateType() { - var property = { - tag: hks.HuksTag.HUKS_TAG_KEY_GENERATE_TYPE, - value: hks.HuksKeyGenerateType.HUKS_KEY_GENERATE_TYPE_DEFAULT - }; - return property; -}; - -function makeIV() { - var property = { - tag: hks.HuksTag.HUKS_TAG_IV, - value: new Uint8Array(16) - }; - return property; -}; - -function makeAAD() { - var property = { - tag: hks.HuksTag.HUKS_TAG_ASSOCIATED_DATA, - value: new Uint8Array(16) - }; - return property; -}; - -function makeNonce() { - var property = { - tag: hks.HuksTag.HUKS_TAG_NONCE, - value: new Uint8Array(16) - }; - return property; -}; - -function makeIsKeyAlias() { - var property = { - tag: hks.HuksTag.HUKS_TAG_IS_KEY_ALIAS, - value: true - }; - return property; -}; - -function makeEmptyOption() { - var emptyOption = { - properties: [] - }; - return emptyOption; -}; - -function makeInDataOption() { - var option = { - properties: [], - inData: new Uint8Array(16) - }; - return option; -}; - -export function makeMacOption(plaintText) { - var properties = new Array(); - properties[0] = { - tag: hks.HuksTag.HUKS_TAG_ALGORITHM, - value: hks.HuksKeyAlg.HUKS_ALG_HMAC - }; - properties[1] = { - tag: hks.HuksTag.HUKS_TAG_PURPOSE, - value: hks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC - }; - properties[2] = { - tag: hks.HuksTag.HUKS_TAG_DIGEST, - value: hks.HuksKeyDigest.HUKS_DIGEST_SHA1 - }; - var options = { - properties: properties, - inData: plaintText - }; - return options; -}; - -export function makeAgreeOptions(publicKey) { - var properties = new Array(); - properties[0] = { - tag: hks.HuksTag.HUKS_TAG_ALGORITHM, - value: hks.HuksKeyAlg.HUKS_ALG_ECDH - }; - properties[1] = { - tag: hks.HuksTag.HUKS_TAG_KEY_SIZE, - value: hks.HuksKeySize.HUKS_ECC_KEY_SIZE_224 - }; - var options = { - properties: properties, - inData: publicKey - }; - return options; -}; \ No newline at end of file diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/config.json index 2d0216365a0d597a7e17f02a152e912b6904c85c..991cde8116710d4d5580deccf588102a3a08b119 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/config.json +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/config.json @@ -53,7 +53,7 @@ "pages": [ "pages/index/index" ], - "name": "default", + "name": "MainAbility", "window": { "designWidth": 720, "autoDesignWidth": true diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/config.json index fd880f26c1ac24320c33397934cb3c1f4c13d985..3365ab51b76fa9b892f797eb3ed90380ce4998bc 100644 --- a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/config.json +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/config.json @@ -53,7 +53,7 @@ "pages": [ "pages/index/index" ], - "name": "default", + "name": "MainAbility", "window": { "designWidth": 720, "autoDesignWidth": true diff --git a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/config.json index ffa0f8813140f35ded57fc00d16a85d22debd743..d8027b5827aa41fe4fc8aa1439a4a577f2fe0526 100644 --- a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/config.json +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/config.json @@ -53,7 +53,7 @@ "pages": [ "pages/index/index" ], - "name": "default", + "name": "MainAbility", "window": { "designWidth": 720, "autoDesignWidth": true diff --git a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/config.json index 42f14065cd713eff25d4373e413c2cacc9dc5c9b..a9bfcd22a3e127356ec90ceff224f42630b216d9 100644 --- a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/config.json +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/config.json @@ -53,7 +53,7 @@ "pages": [ "pages/index/index" ], - "name": "default", + "name": "MainAbility", "window": { "designWidth": 720, "autoDesignWidth": true diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/config.json index 3b1804e59202865b632e84c5a1c861fb6fc866d6..0b8daa5d2a013058b9498187f8c3222771cd0eb8 100644 --- a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/config.json +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/config.json @@ -53,7 +53,7 @@ "pages": [ "pages/index/index" ], - "name": "default", + "name": "MainAbility", "window": { "designWidth": 720, "autoDesignWidth": true diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/config.json index e7ee3e8f36030d4771ec7f68eab5962ab429777e..0bb91698e2c371ac05bc39c6f63e342302500aa3 100644 --- a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/config.json +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/config.json @@ -53,7 +53,7 @@ "pages": [ "pages/index/index" ], - "name": "default", + "name": "MainAbility", "window": { "designWidth": 720, "autoDesignWidth": true diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/config.json index 5eff4b7f57a66f3778aed81108e0ec0fefc3c8d7..109810e27401bd15a23ac106264961e0049bf04f 100644 --- a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/config.json +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/config.json @@ -53,7 +53,7 @@ "pages": [ "pages/index/index" ], - "name": "default", + "name": "MainAbility", "window": { "designWidth": 720, "autoDesignWidth": true diff --git a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/config.json index 4a442a046f6a38794625d35972b54dc519256f31..c34446000d323e376b70e3634f890a9ee245417c 100644 --- a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/config.json +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/config.json @@ -53,7 +53,7 @@ "pages": [ "pages/index/index" ], - "name": "default", + "name": "MainAbility", "window": { "designWidth": 720, "autoDesignWidth": true diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/config.json index 43adac6f31ad96cb52b69cf81ad678657eeb2440..9278691c2a6eb9e43c30dfad398361ab6084f941 100644 --- a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/config.json +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/config.json @@ -53,7 +53,7 @@ "pages": [ "pages/index/index" ], - "name": "default", + "name": "MainAbility", "window": { "designWidth": 720, "autoDesignWidth": true diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/config.json index f0674418eb36e508bd3cdea30d6872d157f00f0a..63e8462f51c9b0cfa57c43e7b8e3621e028043d6 100644 --- a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/config.json +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/config.json @@ -53,7 +53,7 @@ "pages": [ "pages/index/index" ], - "name": "default", + "name": "MainAbility", "window": { "designWidth": 720, "autoDesignWidth": true