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 index 1acf62041cff19dafc03a2eb9f0c05729b78b9ae..7ce9fa3c1ba4660ca8ca1f61e5fc2f2cd153fa2d 100644 --- 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 @@ -608,26 +608,17 @@ describe('Hks_XtsTest_AlgCompletion_Agree', function () { function exportKeyB(alg, size, done, caseId) { huks.exportKey(defaultAliasB, emptyOption, function (err, data) { - if (useLib == 'openssl' && alg == huks.HuksKeyAlg.HUKS_ALG_X25519) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - } else { 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) { - if (useLib == 'openssl' && alg == huks.HuksKeyAlg.HUKS_ALG_X25519) { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - } else { - expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); - publicKeyA = data.outData; - } - exportKeyB(alg, size, done, caseId); + expect(data.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); + publicKeyA = data.outData; + exportKeyB(alg, size, done, caseId); }); }; @@ -679,11 +670,6 @@ describe('Hks_XtsTest_AlgCompletion_Agree', function () { var exportKeyARet = await huks.exportKey(defaultAliasA, emptyOption); var exportKeyBRet = await huks.exportKey(defaultAliasB, emptyOption); - if (useLib == 'openssl' && alg == huks.HuksKeyAlg.HUKS_ALG_X25519) { - expect(exportKeyARet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - expect(exportKeyBRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); - done(); - } else { expect(exportKeyARet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); expect(exportKeyBRet.errorCode).assertEqual(huks.HuksErrorCode.HUKS_SUCCESS); publicKeyA = exportKeyARet.outData; @@ -708,6 +694,5 @@ describe('Hks_XtsTest_AlgCompletion_Agree', function () { expect(isKeyBExist).assertEqual(false); console.info(caseId + ' end'); done(); - } }; }); \ No newline at end of file diff --git a/security/security_huks_basic/BUILD.gn b/security/security_huks_basic/BUILD.gn index e6b366c893317007cca166d979da6270c59ef1de..7649501dff1e55f80ffb4a2654203248c793e701 100644 --- a/security/security_huks_basic/BUILD.gn +++ b/security/security_huks_basic/BUILD.gn @@ -1,31 +1,31 @@ -# 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") - -group("security_huks_basic") { - testonly = true - if (is_standard_system) { - deps = [ - "huks_agree_callback_BasicTest:huksagree_callback_basic_js_test", - "huks_agree_promise_BasicTest:huksagree_promise_basic_js_test", - "huks_cipher_callback_BasicTest:hukscipher_callback_basic_js_test", - "huks_cipher_promise_BasicTest:hukscipher_promise_basic_js_test", - "huks_derive_callback_BasicTest:huksderive_callback_basic_js_test", - "huks_derive_promise_BasicTest:huksderive_promise_basic_js_test", - "huks_hmac_callback_BasicTest:hukshmac_callback_basic_js_test", - "huks_hmac_promise_BasicTest:hukshmac_promise_basic_js_test", - "huks_signverify_callback_BasicTest:hukssignverify_callback_basic_js_test", - "huks_signverify_promise_BasicTest:hukssignverify_promise_basic_js_test", - ] - } -} +# 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") + +group("security_huks_basic") { + testonly = true + if (is_standard_system) { + deps = [ + "huks_agree_promise_BasicTest:huksagree_promise_basic_js_test", + "huks_cipher_promise_BasicTest:hukscipher_promise_basic_js_test", + "huks_derive_promise_BasicTest:huksderive_promise_basic_js_test", + "huks_hmac_promise_BasicTest:hukshmac_promise_basic_js_test", + "huks_signverify_promise_BasicTest:hukssignverify_promise_basic_js_test", + "huks_agree_callback_BasicTest:huksagree_callback_basic_js_test", + "huks_cipher_callback_BasicTest:hukscipher_callback_basic_js_test", + "huks_derive_callback_BasicTest:huksderive_callback_basic_js_test", + "huks_hmac_callback_BasicTest:hukshmac_callback_basic_js_test", + "huks_signverify_callback_BasicTest:hukssignverify_callback_basic_js_test" + ] + } +} diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/BUILD.gn b/security/security_huks_basic/huks_agree_callback_BasicTest/BUILD.gn index 206be2a3fa9695cb2e06e197cba8a2a97ddb7329..2b879e90196a675133847c5badc350da84ab0adf 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/BUILD.gn +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/BUILD.gn @@ -1,30 +1,30 @@ -# 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("huksagree_callback_basic_js_test") { - hap_profile = "./entry/src/main/config.json" - deps = [ - ":huks_js_assets", - ":huks_js_resources", - ] - certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsHuksAgreeBasicCallbackJSApiTest" -} -ohos_js_assets("huks_js_assets") { - source_dir = "./entry/src/main/js/MainAbility" -} -ohos_resources("huks_js_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" -} +# 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("huksagree_callback_basic_js_test") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":huks_js_assets", + ":huks_js_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsHuksAgreeBasicCallbackJSApiTest" +} +ohos_js_assets("huks_js_assets") { + source_dir = "./entry/src/main/js/MainAbility" +} +ohos_resources("huks_js_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/app.js index 03bdca4c355a186eb638028322e8a94a7d424a17..bd5ae64a246945132c418cb72c795d5ba12c8f8a 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/app.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/app.js @@ -1,23 +1,23 @@ -/* - * 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'); - }, -}; +/* + * 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/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json index 5d2837c22d1a98e26f7e3035532d8b1fc4d9114d..7f21065f105c8ff8fabc971f5e5161ab30c73d2d 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json @@ -1,7 +1,7 @@ -{ - "strings": { - "hello": "Hello", - "world": "world", - "start": "test start" - } +{ + "strings": { + "hello": "Hello", + "world": "world", + "start": "test start" + } } \ No newline at end of file diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json index cce34b494cb907700edc55dbb56a827497be2859..29bea0fd91faa67602a08572d6feea8b79a0067b 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json @@ -1,7 +1,7 @@ -{ - "strings": { - "hello": "您好", - "world": "世界", - "start": "测试开始" - } +{ + "strings": { + "hello": "您好", + "world": "世界", + "start": "测试开始" + } } \ No newline at end of file diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css index f42c43b7cced3e43b1af3bbebb744df6c21f8d4f..50637f89ac7ae3d1ce45a4ad565eb4eab743709e 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -1,46 +1,46 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.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; - } -} +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.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/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml index fa09baa7ed8e1d6578b809d8188db603074dd208..201249a906e694fc042d0e967049a3eff15edfe2 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml @@ -1,5 +1,5 @@ -
- - {{ $t('strings.hello') }} {{ title }} - +
+ + {{ $t('strings.hello') }} {{ title }} +
\ No newline at end of file diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js index c50c0bca16e770bd158b0b3a5314c14a3afeebde..764001cef986c1922056a382084c79e9017ca814 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -1,40 +1,40 @@ -/* - * 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 { Core, ExpectExtend } 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', - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000; - configService.setConfig(this); - console.log('test start'); - require('../../../test/List.test'); - core.execute(); - }, - onReady() {}, -}; +/* + * 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 { Core, ExpectExtend } 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', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js index d537f07565f54a1f4461b5b4484930d53c054f57..75924499c3b9994ae6258cbc8f59642e0ac59a32 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js @@ -32,7 +32,7 @@ let HuksOptions63kb = { }; describe('SecurityHuksAgreeDHCallbackJsunit', function () { - it('testAgreeDHAbort63KB001', 0, async function (done) { + it('testAgreeDH102', 0, async function (done) { const srcKeyAliesFirst = 'testAgreeDHSize2048Abort63KBAgreeKeyAlias_01_001'; const srcKeyAliesSecond = 'testAgreeDHSize2048Abort63KBAgreeKeyAlias_02_001'; diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js index 0f6e3beb8c227faaa8ad9fa3f1fde033ddc7561c..86daf43fe5a3eaaa7bbf57c5abb5aea863942550 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js @@ -32,7 +32,7 @@ let HuksOptions65kb = { }; describe('SecurityHuksAgreeDHCallbackJsunit', function () { - it('testAgreeDHAbort65KB001', 0, async function (done) { + it('testAgreeDH004', 0, async function (done) { const srcKeyAliesFirst = 'testAgreeDHSize2048Abort65KBAgreeKeyAlias_01_001'; const srcKeyAliesSecond = 'testAgreeDHSize2048Abort65KBAgreeKeyAlias_02_001'; diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js index ed856cd8a5cb98e3da4e8376d2342e7a8f444181..70fb1e0de7bd46d5a62b69d333df33299ffce0d9 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js @@ -32,7 +32,7 @@ let HuksOptions63kb = { }; describe('SecurityHuksAgreeDHCallbackJsunit', function () { - it('testAgreeDHFinish63KB001', 0, async function (done) { + it('testAgreeDH101', 0, async function (done) { const srcKeyAliesFirst = 'testAgreeDHSize2048Finish63KBAgreeKeyAlias_01_001'; const srcKeyAliesSecond = diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js index 38b37a112453666d40d5b938d930b9dcd7b0c7ac..356ed9664a79fbe44840210ecc6c1a6d5338c28d 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js @@ -32,7 +32,7 @@ let HuksOptions65kb = { }; describe('SecurityHuksAgreeDHCallbackJsunit', function () { - it('testAgreeDHFinish65KB001', 0, async function (done) { + it('testAgreeDH003', 0, async function (done) { const srcKeyAliesFirst = 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_01_001'; const srcKeyAliesSecond = diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js index 06ce05f18db9c0d993ec32150b3534cb577d57ff..53f3c9ac24b6c756e0ff83ef2210b99438fa1e36 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js @@ -35,7 +35,7 @@ let HuksOptions63kb = { }; describe('SecurityHuksAgreeECDHCallbackJsunit', function () { - it('testAgreeECDHAbort63KB001', 0, async function (done) { + it('testAgreeEDCH102', 0, async function (done) { const srcKeyAliesFirst = 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_01_001'; const srcKeyAliesSecond = diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js index 887cd2ab05be3c5c35801e3827db8b0786f357df..7244b476b38f9945dc5811d460564512ae7be2d4 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js @@ -35,7 +35,7 @@ let HuksOptions65kb = { }; describe('SecurityHuksAgreeECDHCallbackJsunit', function () { - it('testAgreeECDHAbort65KB001', 0, async function (done) { + it('testAgreeEDCH104', 0, async function (done) { const srcKeyAliesFirst = 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_01_001'; const srcKeyAliesSecond = diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js index ff5749455d6375d5bbda7a342f6a9c2dad7f7280..be603de603a36720cf11b22991033438bb22acf4 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js @@ -35,7 +35,7 @@ let HuksOptions63kb = { }; describe('SecurityHuksAgreeECDHCallbackJsunit', function () { - it('testAgreeECDHFinish63KB001', 0, async function (done) { + it('testAgreeEDCH101', 0, async function (done) { const srcKeyAliesFirst = 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_01_001'; const srcKeyAliesSecond = diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js index 7a38031c3f001e9ef30214883424f09f96d403ae..8090ead916d2defed12bfe4cccb3c27b301fc6c8 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js @@ -35,7 +35,7 @@ let HuksOptions65kb = { }; describe('SecurityHuksAgreeECDHCallbackJsunit', function () { - it('testAgreeECDHFinish65KB001', 0, async function (done) { + it('testAgreeEDCH103', 0, async function (done) { const srcKeyAliesFirst = 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_01_001'; const srcKeyAliesSecond = diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js index 7e8c2d57e977efd070685c51a192d320020a6966..e3dbe5cebeca9d87f2f3e85b1395234b8465a109 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js @@ -35,7 +35,7 @@ let HuksOptions63kb = { }; describe('SecurityHuksAgreeX25519CallbackJsunit', function () { - it('testAgreeX25519Abort63KB001', 0, async function (done) { + it('testAgreeX25519102', 0, async function (done) { const srcKeyAliesFirst = 'testAgreeX25519Size256Abort63KBAgreeKeyAlias_01_001'; const srcKeyAliesSecond = diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js index e8957771327a1594de789181c02d786559f1bb1c..d1b11f3cd77bc57294090bcf6243ae69722b4b32 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js @@ -35,7 +35,7 @@ let HuksOptions65kb = { }; describe('SecurityHuksAgreeX25519CallbackJsunit', function () { - it('testAgreeX25519Abort65KB001', 0, async function (done) { + it('testAgreeX25519004', 0, async function (done) { const srcKeyAliesFirst = 'testAgreeX25519Size256Abort65KBAgreeKeyAlias_01_001'; const srcKeyAliesSecond = diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js index 3537c2786271f47d87663f079fd0bcccfe0662b4..6e5e538cec56449141b841b775da95ef8901d22f 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js @@ -35,7 +35,7 @@ let HuksOptions63kb = { }; describe('SecurityHuksAgreeX25519CallbackJsunit', function () { - it('testAgreeX25519Finish63KB001', 0, async function (done) { + it('testAgreeX25519001', 0, async function (done) { const srcKeyAliesFirst = 'testAgreeX25519Size256Finish63KBAgreeKeyAlias_01_001'; const srcKeyAliesSecond = diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js index 42cb711cd86a50e589b9bbc3e8f05fb67464a66a..9eed987822b1d211ac78db434ca5278f98b446ea 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js @@ -35,7 +35,7 @@ let HuksOptions65kb = { }; describe('SecurityHuksAgreeX25519CallbackJsunit', function () { - it('testAgreeX25519Finish65KB001', 0, async function (done) { + it('testAgreeX25519003', 0, async function (done) { const srcKeyAliesFirst = 'testAgreeX25519Size256Finish65KBAgreeKeyAlias_01_001'; const srcKeyAliesSecond = diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/BUILD.gn b/security/security_huks_basic/huks_agree_promise_BasicTest/BUILD.gn index 092ba9199d5f4e9d761754e68767b6b9721b471c..e46fc41a05e9a7003c78eed50760ab911ffe76e3 100644 --- a/security/security_huks_basic/huks_agree_promise_BasicTest/BUILD.gn +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/BUILD.gn @@ -1,30 +1,30 @@ -# 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("huksagree_promise_basic_js_test") { - hap_profile = "./entry/src/main/config.json" - deps = [ - ":huks_js_assets", - ":huks_js_resources", - ] - certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsHuksAgreeBasicPromiseJSApiTest" -} -ohos_js_assets("huks_js_assets") { - source_dir = "./entry/src/main/js/MainAbility" -} -ohos_resources("huks_js_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" -} +# 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("huksagree_promise_basic_js_test") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":huks_js_assets", + ":huks_js_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsHuksAgreeBasicPromiseJSApiTest" +} +ohos_js_assets("huks_js_assets") { + source_dir = "./entry/src/main/js/MainAbility" +} +ohos_resources("huks_js_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/app.js index 5a5f568dfc0d7be0d64e09123ae920f1116557f6..83c43385acf60c088e550062c781ee53efc97779 100644 --- a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/app.js +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/app.js @@ -1,23 +1,23 @@ -/* - * 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'); - }, -}; +/* + * 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/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json index 5d2837c22d1a98e26f7e3035532d8b1fc4d9114d..7f21065f105c8ff8fabc971f5e5161ab30c73d2d 100644 --- a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json @@ -1,7 +1,7 @@ -{ - "strings": { - "hello": "Hello", - "world": "world", - "start": "test start" - } +{ + "strings": { + "hello": "Hello", + "world": "world", + "start": "test start" + } } \ No newline at end of file diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json index cce34b494cb907700edc55dbb56a827497be2859..29bea0fd91faa67602a08572d6feea8b79a0067b 100644 --- a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json @@ -1,7 +1,7 @@ -{ - "strings": { - "hello": "您好", - "world": "世界", - "start": "测试开始" - } +{ + "strings": { + "hello": "您好", + "world": "世界", + "start": "测试开始" + } } \ No newline at end of file diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css index f42c43b7cced3e43b1af3bbebb744df6c21f8d4f..50637f89ac7ae3d1ce45a4ad565eb4eab743709e 100644 --- a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -1,46 +1,46 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.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; - } -} +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.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/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml index fa09baa7ed8e1d6578b809d8188db603074dd208..201249a906e694fc042d0e967049a3eff15edfe2 100644 --- a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml @@ -1,5 +1,5 @@ -
- - {{ $t('strings.hello') }} {{ title }} - +
+ + {{ $t('strings.hello') }} {{ title }} +
\ No newline at end of file diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js index b73c0cda6eb1bf1c44a794156fd2f4a0dffc94e7..52df3aae59591efbb0be43c86b24af6d78652323 100644 --- a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -1,40 +1,40 @@ -/* - * 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 { Core, ExpectExtend } 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', - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000; - configService.setConfig(this); - console.log('test start'); - require('../../../test/List.test'); - core.execute(); - }, - onReady() {}, -}; +/* + * 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 { Core, ExpectExtend } 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', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort65KBPromiseJsunit.test.js index ebc03048afe3f7a383c9c34d8beed9d3a50948c1..1d4fc7c475cb6e2cb42b19fc799ccbbbaa0a12a3 100644 --- a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort65KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort65KBPromiseJsunit.test.js @@ -32,7 +32,7 @@ let HuksOptions65kb = { }; describe('SecurityHuksAgreeDHPromiseJsunit', function () { - it('testAgreeDHSize2048Abort65KBAgree101', 0, async function (done) { + it('testAgreeDH104', 0, async function (done) { const srcKeyAliesFirst = 'testAgreeDHSize2048Abort65KBAgreeKeyAlias_01_101'; const srcKeyAliesSecond = 'testAgreeDHSize2048Abort65KBAgreeKeyAlias_02_101'; diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js index a5a9f8a15a5897d66c59eb7d4fe357640a17d5f9..408eb7a2a7beff0857ed4d852f7c1b8fb325a6ef 100644 --- a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js @@ -32,7 +32,7 @@ let HuksOptions65kb = { }; describe('SecurityHuksAgreeDHPromiseJsunit', function () { - it('testAgreeDHSize2048Finish65KBAgree101', 0, async function (done) { + it('testAgreeDH103', 0, async function (done) { const srcKeyAliesFirst = 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_01_101'; const srcKeyAliesSecond = diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js index 4cbafaef032c8467ad9b3fb2ea0433abc0e2f7a8..08c79594fc2f06e024c501acc4ff3e52c025ebe7 100644 --- a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js @@ -39,7 +39,7 @@ describe('SecurityHuksAgreeECDHPromiseJsunit', function () { }; console.info('test beforeEach called'); }); - it('testAgreeECDHAbort63KBAgree101', 0, async function (done) { + it('testAgreeECDH102', 0, async function (done) { const srcKeyAliesFirst = 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_01_101'; const srcKeyAliesSecond = diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js index d84c7ee11e73461657c28626577159fd6763a105..9b0131fd6b54644cb9410f33a40b9a8c76725508 100644 --- a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js @@ -40,7 +40,7 @@ describe('SecurityHuksAgreeECDHPromiseJsunit', function () { console.info('test beforeEach called'); }); - it('testAgreeECDHAbort65KBAgree101', 0, async function (done) { + it('testAgreeECDH104', 0, async function (done) { const srcKeyAliesFirst = 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_01_101'; const srcKeyAliesSecond = diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js index 014451133a4df9bb7552238dc7d544235e77516a..e3d13159ba76b345fca7bff90ad84bccf7e2d693 100644 --- a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js @@ -51,7 +51,7 @@ describe('SecurityHuksAgreeECDHPromiseJsunit', function () { console.info('test beforeEach called'); }); - it('testAgreeECDHFinish63KBAgree101', 0, async function (done) { + it('testAgreeECDH101', 0, async function (done) { const srcKeyAliesFirst = 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_01_101'; const srcKeyAliesSecond = diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js index aa0ac398ccc91eab54b6cb88275307ff15d5c0c9..36f6cf18d7d3709f3b0fc4e17373c893f69c0621 100644 --- a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js @@ -40,7 +40,7 @@ describe('SecurityHuksAgreeECDHPromiseJsunit', function () { console.info('test beforeEach called'); }); - it('testAgreeECDHFinish65KBAgree101', 0, async function (done) { + it('testAgreeECDH103', 0, async function (done) { const srcKeyAliesFirst = 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_01_101'; const srcKeyAliesSecond = diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort65KBPromiseJsunit.test.js index 66db29bb8dc3bfb3555e4fc40581063c9dd8d69c..ff4d5fc1a3217104409584cf1a6c82a4c97685b8 100644 --- a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort65KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort65KBPromiseJsunit.test.js @@ -35,7 +35,7 @@ let HuksOptions65kb = { }; describe('SecurityHuksAgreeX25519PromiseJsunit', function () { - it('testAgreeX25519Abort65KBAgree101', 0, async function (done) { + it('testAgreeX25519104', 0, async function (done) { const srcKeyAliesFirst = 'testAgreeX25519Size256Abort65KBAgreeKeyAlias_01_101'; const srcKeyAliesSecond = diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish63KBPromiseJsunit.test.js index ee096574f4f8b35f124763cc33be7ff53804a353..f296b922dd2fa21c77f43a4bbcce3c293db4e56e 100644 --- a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish63KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish63KBPromiseJsunit.test.js @@ -35,7 +35,7 @@ let HuksOptions63kb = { inData: srcData63Kb, }; describe('SecurityHuksAgreeX25519PromiseJsunit', function () { - it('testAgreeX25519Finish63KBAgree101', 0, async function (done) { + it('testAgreeX25519101', 0, async function (done) { const srcKeyAliesFirst = 'testAgreeX25519Size256Finish63KBAgreeKeyAlias_01_101'; const srcKeyAliesSecond = diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish65KBPromiseJsunit.test.js index 2200d3718e8a314203a5b3956c4d5c717bb7c4b9..f670c97f188de394c62b4ab0c564de4a55455109 100644 --- a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish65KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish65KBPromiseJsunit.test.js @@ -35,7 +35,7 @@ let HuksOptions65kb = { }; describe('SecurityHuksAgreeX25519PromiseJsunit', function () { - it('testAgreeX25519Finish65KBAgree101', 0, async function (done) { + it('testAgreeX25519103', 0, async function (done) { const srcKeyAliesFirst = 'testAgreeX25519Size256Finish65KBAgreeKeyAlias_01_101'; const srcKeyAliesSecond = diff --git a/security/security_huks_basic/huks_cipher_callback_BasicTest/BUILD.gn b/security/security_huks_basic/huks_cipher_callback_BasicTest/BUILD.gn index 12730c2d9d832c6854f57643ecdcd6e9b0233546..7881a921fc6ad6639be5520008c94da3dd1701fa 100644 --- a/security/security_huks_basic/huks_cipher_callback_BasicTest/BUILD.gn +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/BUILD.gn @@ -1,30 +1,30 @@ -# 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("hukscipher_callback_basic_js_test") { - hap_profile = "./entry/src/main/config.json" - deps = [ - ":huks_js_assets", - ":huks_js_resources", - ] - certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsHuksCipherBasicCallbackJSApiTest" -} -ohos_js_assets("huks_js_assets") { - source_dir = "./entry/src/main/js/MainAbility" -} -ohos_resources("huks_js_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" -} +# 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("hukscipher_callback_basic_js_test") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":huks_js_assets", + ":huks_js_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsHuksCipherBasicCallbackJSApiTest" +} +ohos_js_assets("huks_js_assets") { + source_dir = "./entry/src/main/js/MainAbility" +} +ohos_resources("huks_js_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/app.js index 5a5f568dfc0d7be0d64e09123ae920f1116557f6..83c43385acf60c088e550062c781ee53efc97779 100644 --- a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/app.js +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/app.js @@ -1,23 +1,23 @@ -/* - * 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'); - }, -}; +/* + * 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/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json index 5d2837c22d1a98e26f7e3035532d8b1fc4d9114d..7f21065f105c8ff8fabc971f5e5161ab30c73d2d 100644 --- a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json @@ -1,7 +1,7 @@ -{ - "strings": { - "hello": "Hello", - "world": "world", - "start": "test start" - } +{ + "strings": { + "hello": "Hello", + "world": "world", + "start": "test start" + } } \ No newline at end of file diff --git a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json index cce34b494cb907700edc55dbb56a827497be2859..29bea0fd91faa67602a08572d6feea8b79a0067b 100644 --- a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json @@ -1,7 +1,7 @@ -{ - "strings": { - "hello": "您好", - "world": "世界", - "start": "测试开始" - } +{ + "strings": { + "hello": "您好", + "world": "世界", + "start": "测试开始" + } } \ No newline at end of file diff --git a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css index f42c43b7cced3e43b1af3bbebb744df6c21f8d4f..50637f89ac7ae3d1ce45a4ad565eb4eab743709e 100644 --- a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -1,46 +1,46 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.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; - } -} +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.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/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml index fa09baa7ed8e1d6578b809d8188db603074dd208..201249a906e694fc042d0e967049a3eff15edfe2 100644 --- a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml @@ -1,5 +1,5 @@ -
- - {{ $t('strings.hello') }} {{ title }} - +
+ + {{ $t('strings.hello') }} {{ title }} +
\ No newline at end of file diff --git a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js index b73c0cda6eb1bf1c44a794156fd2f4a0dffc94e7..52df3aae59591efbb0be43c86b24af6d78652323 100644 --- a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -1,40 +1,40 @@ -/* - * 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 { Core, ExpectExtend } 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', - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000; - configService.setConfig(this); - console.log('test start'); - require('../../../test/List.test'); - core.execute(); - }, - onReady() {}, -}; +/* + * 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 { Core, ExpectExtend } 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', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksAESBasicCallbackJsunit.test.js b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksAESBasicCallbackJsunit.test.js index 3803e093e3eff7b9be0656b8f20b117f18e9ceb5..c44b4173aa977b57b125498f8977678001b7d08f 100644 --- a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksAESBasicCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksAESBasicCallbackJsunit.test.js @@ -39,9 +39,6 @@ let genHuksOptions = { }; async function publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) { - console.log( - `test GenerateHuksOptions: ${JSON.stringify(genHuksOptionsNONECBC)}` - ); await generateKey(srcKeyAlies, genHuksOptionsNONECBC) .then((data) => { console.log(`test generateKey data: ${JSON.stringify(data)}`); @@ -68,7 +65,6 @@ function generateKey(srcKeyAlies, HuksOptions) { } async function publicInitFunc(srcKeyAlies, HuksOptions) { - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`); await init(srcKeyAlies, HuksOptions) .then((data) => { console.log(`test init data: ${JSON.stringify(data)}`); @@ -95,17 +91,9 @@ function init(srcKeyAlies, HuksOptions) { } async function publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt) { - console.log( - `test update before handle: ${JSON.stringify( - handle - )} HuksOptions: ${JSON.stringify(HuksOptions)}` - ); let dateSize = 64; let huksOptionsInData = HuksOptions.inData; let inDataArray = HuksOptions.inData; - console.log( - 'test update finish HuksOptions inData: ' + Array.from(inDataArray).length - ); if (Array.from(inDataArray).length < dateSize) { await update(handle, HuksOptions); // HuksOptions.inData = new Uint8Array(new Array()); @@ -113,22 +101,10 @@ async function publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt) { } else { let count = Math.floor(Array.from(inDataArray).length / dateSize); let remainder = Array.from(inDataArray).length % dateSize; - console.log('test count ' + count + 'remainder ' + remainder); for (let i = 0; i < count; i++) { HuksOptions.inData = new Uint8Array( Array.from(huksOptionsInData).slice(dateSize * i, dateSize * (i + 1)) ); - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - ) - ); await update(handle, HuksOptions); } HuksOptions.inData = huksOptionsInData; @@ -139,17 +115,6 @@ async function publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt) { uint8ArrayToString(inDataArray).length ) ); - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - ) - ); } await publicFinishAbortFunc( HuksOptions, @@ -197,11 +162,8 @@ async function publicFinishAbortFunc( remainder ) { if (thirdInderfaceName == 'finish') { - HuksOptions.outData = new Uint8Array(new Array(encryptedData.length * 2)); - console.log(`test remainder ${remainder}`); await finish(HuksOptions, isEncrypt); } else if (thirdInderfaceName == 'abort') { - HuksOptions.outData = new Uint8Array(new Array(encryptedData.length * 2)); await abort(HuksOptions); } } @@ -221,20 +183,8 @@ async function finish(HuksOptions, isEncrypt) { } if (isEncrypt) { if (finishData === uint8ArrayToString(encryptedData)) { - console.log( - `test finish Encrypt fail ${uint8ArrayToString(encryptedData)}` - ); - console.log( - `test finish Encrypt fail ${uint8ArrayToString(finishData)}` - ); expect(null).assertFail(); } else { - console.log( - `test finish Encrypt success ${uint8ArrayToString(encryptedData)}` - ); - console.log( - `test finish Encrypt success ${uint8ArrayToString(finishData)}` - ); expect(data.errorCode == 0).assertTrue(); } } @@ -355,7 +305,6 @@ describe('SecurityHuksCipherAESCallbackJsunit', function () { { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } ), inData: srcData63Kb, - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, @@ -375,7 +324,6 @@ describe('SecurityHuksCipherAESCallbackJsunit', function () { { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } ), inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, @@ -400,7 +348,6 @@ describe('SecurityHuksCipherAESCallbackJsunit', function () { { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } ), inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, @@ -425,7 +372,6 @@ describe('SecurityHuksCipherAESCallbackJsunit', function () { { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } ), inData: srcData63Kb, - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, @@ -445,7 +391,6 @@ describe('SecurityHuksCipherAESCallbackJsunit', function () { { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } ), inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, @@ -470,7 +415,6 @@ describe('SecurityHuksCipherAESCallbackJsunit', function () { { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } ), inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, diff --git a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js index a4d564c3b5685a9387bfeb71c0848a7f5bbebc3a..022ca6b5251f8ba61800e0d951443059249437a3 100644 --- a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js @@ -40,9 +40,6 @@ let genHuksOptions = { }; async function publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONC) { - console.log( - `test Generate HuksOptions: ${JSON.stringify(genHuksOptionsNONC)}` - ); await generateKey(srcKeyAlies, genHuksOptionsNONC) .then((data) => { console.log(`test generateKey data: ${JSON.stringify(data)}`); @@ -69,9 +66,6 @@ function generateKey(srcKeyAlies, HuksOptions) { } async function publicExportKeyFunc(srcKeyAlies, genHuksOptionsNONC) { - console.log( - `test ExportKey HuksOptions: ${JSON.stringify(genHuksOptionsNONC)}` - ); await exportkey(srcKeyAlies, genHuksOptionsNONC) .then((data) => { console.log(`test ExportKey data: ${JSON.stringify(data)}`); @@ -100,7 +94,6 @@ function exportkey(srcKeyAlies, HuksOptions) { async function publicImportKeyFunc(srcKeyAlies, HuksOptions) { HuksOptions.inData = exportKey; - console.log(`test importKey HuksOptions: ${JSON.stringify(HuksOptions)}`); await importkey(srcKeyAlies, HuksOptions) .then((data) => { console.log(`test ImportKey data: ${JSON.stringify(data)}`); @@ -127,7 +120,6 @@ function importkey(srcKeyAlies, HuksOptions) { } async function publicInitFunc(srcKeyAlies, HuksOptions) { - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`); await init(srcKeyAlies, HuksOptions) .then((data) => { console.log(`test init data: ${JSON.stringify(data)}`); @@ -154,17 +146,9 @@ function init(srcKeyAlies, HuksOptions) { } async function publicUpdateFunc(HuksOptions) { - console.log( - `test update before handle: ${JSON.stringify( - handle - )} HuksOptions: ${JSON.stringify(HuksOptions)}` - ); let dateSize = 64; let huksOptionsInData = HuksOptions.inData; let inDataArray = HuksOptions.inData; - console.log( - 'test update finish HuksOptions inData: ' + Array.from(inDataArray).length - ); if (Array.from(inDataArray).length < dateSize) { await update(handle, HuksOptions); HuksOptions.inData = stringToUint8Array('0'); @@ -175,17 +159,6 @@ async function publicUpdateFunc(HuksOptions) { HuksOptions.inData = new Uint8Array( Array.from(huksOptionsInData).slice(dateSize * i, dateSize * (i + 1)) ); - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - ) - ); await update(handle, HuksOptions); HuksOptions.inData = huksOptionsInData; } @@ -197,23 +170,11 @@ async function publicUpdateFunc(HuksOptions) { ) ); await update(handle, HuksOptions); - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - ) - ); } } } async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`); await updateCallback(handle, HuksOptions) .then(async (data) => { console.log(`test update data ${JSON.stringify(data)}`); @@ -244,7 +205,6 @@ async function publicFinishAbortFunc( isEncrypt ) { if (thirdInderfaceName == 'finish') { - HuksOptions.outData = new Uint8Array(new Array(1024)); HuksOptions.inData = new Uint8Array(new Array()); await finish(HuksOptions, isEncrypt); } else if (thirdInderfaceName == 'abort') { @@ -403,7 +363,6 @@ describe('SecurityHuksCipherRSACallbackJsunit', function () { HuksCipherRSA.HuksKeyRSADIGESTSHA256 ), inData: gInData64Array, - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, @@ -423,7 +382,6 @@ describe('SecurityHuksCipherRSACallbackJsunit', function () { HuksCipherRSA.HuksKeyRSADIGESTSHA256 ), inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, @@ -450,7 +408,6 @@ describe('SecurityHuksCipherRSACallbackJsunit', function () { HuksCipherRSA.HuksKeyRSADIGESTSHA256 ), inData: gInData64Array, - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, @@ -477,7 +434,6 @@ describe('SecurityHuksCipherRSACallbackJsunit', function () { HuksCipherRSA.HuksKeyRSADIGESTSHA256 ), inData: gInData64Array, - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, @@ -497,7 +453,6 @@ describe('SecurityHuksCipherRSACallbackJsunit', function () { HuksCipherRSA.HuksKeyRSADIGESTSHA256 ), inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, @@ -524,7 +479,6 @@ describe('SecurityHuksCipherRSACallbackJsunit', function () { HuksCipherRSA.HuksKeyRSADIGESTSHA256 ), inData: gInData64Array, - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, diff --git a/security/security_huks_basic/huks_cipher_promise_BasicTest/BUILD.gn b/security/security_huks_basic/huks_cipher_promise_BasicTest/BUILD.gn index bd1a2820fd4067551ce8d2af33d400cf4f3dee7a..604e518bd6c92d68e0a485139df5d91dede269b5 100644 --- a/security/security_huks_basic/huks_cipher_promise_BasicTest/BUILD.gn +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/BUILD.gn @@ -1,30 +1,30 @@ -# 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("hukscipher_promise_basic_js_test") { - hap_profile = "./entry/src/main/config.json" - deps = [ - ":huks_js_assets", - ":huks_js_resources", - ] - certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsHuksCipherBasicPromiseJSApiTest" -} -ohos_js_assets("huks_js_assets") { - source_dir = "./entry/src/main/js/MainAbility" -} -ohos_resources("huks_js_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" -} +# 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("hukscipher_promise_basic_js_test") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":huks_js_assets", + ":huks_js_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsHuksCipherBasicPromiseJSApiTest" +} +ohos_js_assets("huks_js_assets") { + source_dir = "./entry/src/main/js/MainAbility" +} +ohos_resources("huks_js_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/app.js index 5a5f568dfc0d7be0d64e09123ae920f1116557f6..83c43385acf60c088e550062c781ee53efc97779 100644 --- a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/app.js +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/app.js @@ -1,23 +1,23 @@ -/* - * 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'); - }, -}; +/* + * 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/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json index 5d2837c22d1a98e26f7e3035532d8b1fc4d9114d..7f21065f105c8ff8fabc971f5e5161ab30c73d2d 100644 --- a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json @@ -1,7 +1,7 @@ -{ - "strings": { - "hello": "Hello", - "world": "world", - "start": "test start" - } +{ + "strings": { + "hello": "Hello", + "world": "world", + "start": "test start" + } } \ No newline at end of file diff --git a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json index cce34b494cb907700edc55dbb56a827497be2859..29bea0fd91faa67602a08572d6feea8b79a0067b 100644 --- a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json @@ -1,7 +1,7 @@ -{ - "strings": { - "hello": "您好", - "world": "世界", - "start": "测试开始" - } +{ + "strings": { + "hello": "您好", + "world": "世界", + "start": "测试开始" + } } \ No newline at end of file diff --git a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css index f42c43b7cced3e43b1af3bbebb744df6c21f8d4f..50637f89ac7ae3d1ce45a4ad565eb4eab743709e 100644 --- a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -1,46 +1,46 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.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; - } -} +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.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/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml index fa09baa7ed8e1d6578b809d8188db603074dd208..201249a906e694fc042d0e967049a3eff15edfe2 100644 --- a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml @@ -1,5 +1,5 @@ -
- - {{ $t('strings.hello') }} {{ title }} - +
+ + {{ $t('strings.hello') }} {{ title }} +
\ No newline at end of file diff --git a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js index b73c0cda6eb1bf1c44a794156fd2f4a0dffc94e7..52df3aae59591efbb0be43c86b24af6d78652323 100644 --- a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -1,40 +1,40 @@ -/* - * 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 { Core, ExpectExtend } 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', - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000; - configService.setConfig(this); - console.log('test start'); - require('../../../test/List.test'); - core.execute(); - }, - onReady() {}, -}; +/* + * 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 { Core, ExpectExtend } 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', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js index 218270015f09a446106bea96727cca6bf1cecb80..bbf5c1e3ecda89a8503942a7195c8438e97ae7a1 100644 --- a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js @@ -38,9 +38,6 @@ let genHuksOptions = { }; async function publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) { - console.log( - `test GenerateHuksOptions: ${JSON.stringify(genHuksOptionsNONECBC)}` - ); await huks .generateKey(srcKeyAlies, genHuksOptionsNONECBC) .then((data) => { @@ -54,7 +51,6 @@ async function publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) { } async function publicInitFunc(srcKeyAlies, HuksOptions) { - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`); await huks .init(srcKeyAlies, HuksOptions) .then((data) => { @@ -69,17 +65,9 @@ async function publicInitFunc(srcKeyAlies, HuksOptions) { } async function publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt) { - console.log( - `test update before handle: ${JSON.stringify( - handle - )} HuksOptions: ${JSON.stringify(HuksOptions)}` - ); let dateSize = 64; let huksOptionsInData = HuksOptions.inData; let inDataArray = HuksOptions.inData; - console.log( - 'test update finish HuksOptions inData: ' + Array.from(inDataArray).length - ); if (Array.from(inDataArray).length < dateSize) { await update(handle, HuksOptions); HuksOptions.inData = new Uint8Array(new Array()); @@ -87,22 +75,10 @@ async function publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt) { } else { let count = Math.floor(Array.from(inDataArray).length / dateSize); let remainder = Array.from(inDataArray).length % dateSize; - console.log('test count ' + count + 'remainder ' + remainder); for (let i = 0; i < count; i++) { HuksOptions.inData = new Uint8Array( Array.from(huksOptionsInData).slice(dateSize * i, dateSize * (i + 1)) ); - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - ) - ); await update(handle, HuksOptions); } HuksOptions.inData = huksOptionsInData; @@ -113,17 +89,6 @@ async function publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt) { uint8ArrayToString(inDataArray).length ) ); - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - ) - ); } else { HuksOptions.inData = new Uint8Array(new Array()); } @@ -137,8 +102,6 @@ async function publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt) { } async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`); - console.log(`test update data ${JSON.stringify(HuksOptions.inData.length)}`); await huks .update(handle, HuksOptions) .then(async (data) => { @@ -146,11 +109,9 @@ async function update(handle, HuksOptions) { if (updateResult.length !== 0) { console.log(`test update outDatalength ${updateResult.length}`); updateResult = updateResult.concat(Array.from(data.outData)); - console.log(`test update outDatalength ${updateResult.length}`); } else { console.log(`test update outDatalength ${updateResult.length}`); updateResult = Array.from(data.outData); - console.log(`test update outDatalength ${updateResult.length}`); } expect(data.errorCode == 0).assertTrue(); }) @@ -167,11 +128,8 @@ async function publicFinishAbortFunc( remainder ) { if (thirdInderfaceName == 'finish') { - HuksOptions.outData = new Uint8Array(new Array(encryptedData.length * 2)); - console.log(`test remainder ${remainder}`); await finish(HuksOptions, isEncrypt); } else if (thirdInderfaceName == 'abort') { - HuksOptions.outData = new Uint8Array(new Array(encryptedData.length * 2)); await abort(HuksOptions); } } @@ -192,39 +150,15 @@ async function finish(HuksOptions, isEncrypt) { } if (isEncrypt) { if (finishData === uint8ArrayToString(encryptedData)) { - console.log( - `test finish Encrypt fail ${uint8ArrayToString(encryptedData)}` - ); - console.log( - `test finish Encrypt fail ${uint8ArrayToString(finishData)}` - ); expect(null).assertFail(); } else { - console.log( - `test finish Encrypt success ${uint8ArrayToString(encryptedData)}` - ); - console.log( - `test finish Encrypt success ${uint8ArrayToString(finishData)}` - ); expect(data.errorCode == 0).assertTrue(); } } if (!isEncrypt) { if (finishData === uint8ArrayToString(encryptedData)) { - console.log( - `test finish Decrypt success ${uint8ArrayToString(encryptedData)}` - ); - console.log( - `test finish Decrypt success ${uint8ArrayToString(finishData)}` - ); expect(data.errorCode == 0).assertTrue(); } else { - console.log( - `test finish Decrypt fail ${uint8ArrayToString(encryptedData)}` - ); - console.log( - `test finish Decrypt fail ${uint8ArrayToString(finishData)}` - ); expect(null).assertFail(); } } @@ -301,7 +235,6 @@ describe('SecurityHuksCipherAESPromiseJsunit', function () { { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } ), inData: srcData63Kb, - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, @@ -321,7 +254,6 @@ describe('SecurityHuksCipherAESPromiseJsunit', function () { { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } ), inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, @@ -346,7 +278,6 @@ describe('SecurityHuksCipherAESPromiseJsunit', function () { { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } ), inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, @@ -371,7 +302,6 @@ describe('SecurityHuksCipherAESPromiseJsunit', function () { { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } ), inData: srcData63Kb, - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, @@ -391,7 +321,6 @@ describe('SecurityHuksCipherAESPromiseJsunit', function () { { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } ), inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, @@ -416,7 +345,6 @@ describe('SecurityHuksCipherAESPromiseJsunit', function () { { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } ), inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, diff --git a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js index 085596fdde3fba370767886548e3b0ab54e53af7..7a3ed915301fafa6e8a1470700ef9915738fd3a2 100644 --- a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js @@ -43,9 +43,6 @@ let genHuksOptions = { }; async function publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONC) { - console.log( - `test Generate HuksOptions: ${JSON.stringify(genHuksOptionsNONC)}` - ); await huks .generateKey(srcKeyAlies, genHuksOptionsNONC) .then((data) => { @@ -59,9 +56,6 @@ async function publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONC) { } async function publicExportKeyFunc(srcKeyAlies, genHuksOptionsNONC) { - console.log( - `test ExportKey HuksOptions: ${JSON.stringify(genHuksOptionsNONC)}` - ); await huks .exportKey(srcKeyAlies, genHuksOptionsNONC) .then((data) => { @@ -77,7 +71,6 @@ async function publicExportKeyFunc(srcKeyAlies, genHuksOptionsNONC) { async function publicImportKeyFunc(srcKeyAlies, HuksOptions) { HuksOptions.inData = exportKey; - console.log(`test importKey HuksOptions: ${JSON.stringify(HuksOptions)}`); await huks .importKey(srcKeyAlies, HuksOptions) .then((data) => { @@ -106,17 +99,9 @@ async function publicInitFunc(srcKeyAlies, HuksOptions) { } async function publicUpdateFunc(HuksOptions) { - console.log( - `test update before handle: ${JSON.stringify( - handle - )} HuksOptions: ${JSON.stringify(HuksOptions)}` - ); let dateSize = 64; let huksOptionsInData = HuksOptions.inData; let inDataArray = HuksOptions.inData; - console.log( - 'test update finish HuksOptions inData: ' + Array.from(inDataArray).length - ); if (Array.from(inDataArray).length < dateSize) { await update(handle, HuksOptions); HuksOptions.inData = stringToUint8Array('0'); @@ -127,17 +112,6 @@ async function publicUpdateFunc(HuksOptions) { HuksOptions.inData = new Uint8Array( Array.from(huksOptionsInData).slice(dateSize * i, dateSize * (i + 1)) ); - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - ) - ); await update(handle, HuksOptions); HuksOptions.inData = huksOptionsInData; } @@ -149,23 +123,11 @@ async function publicUpdateFunc(HuksOptions) { ) ); await update(handle, HuksOptions); - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - ) - ); } } } async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`); await huks .update(handle, HuksOptions) .then(async (data) => { @@ -184,7 +146,6 @@ async function publicFinishAbortFunc( isEncrypt ) { if (thirdInderfaceName == 'finish') { - HuksOptions.outData = new Uint8Array(new Array(1024)); HuksOptions.inData = new Uint8Array(new Array()); await finish(HuksOptions, isEncrypt); } else if (thirdInderfaceName == 'abort') { @@ -193,16 +154,6 @@ async function publicFinishAbortFunc( } async function finish(HuksOptions, isEncrypt) { - console.log('test before finish HuksOptions inData: ' + HuksOptions.inData); - console.log('test before finish HuksOptions outData: ' + HuksOptions.outData); - console.log( - 'test before finish HuksOptions outData: ' + HuksOptions.outData.length - ); - console.log( - 'test before finish HuksOptions properties: ' + - JSON.stringify(HuksOptions.properties) - ); - await huks .finish(handle, HuksOptions) .then((data) => { @@ -212,20 +163,8 @@ async function finish(HuksOptions, isEncrypt) { if ( uint8ArrayToString(data.outData) === uint8ArrayToString(encryptedData) ) { - console.log( - `test finish Encrypt fail ${uint8ArrayToString(encryptedData)}` - ); - console.log( - `test finish Encrypt fail ${uint8ArrayToString(data.outData)}` - ); expect(null).assertFail(); } else { - console.log( - `test finish Encrypt success ${uint8ArrayToString(encryptedData)}` - ); - console.log( - `test finish Encrypt success ${uint8ArrayToString(data.outData)}` - ); expect(data.errorCode == 0).assertTrue(); } } @@ -233,20 +172,8 @@ async function finish(HuksOptions, isEncrypt) { if ( uint8ArrayToString(data.outData) === uint8ArrayToString(encryptedData) ) { - console.log( - `test finish Decrypt success ${uint8ArrayToString(encryptedData)}` - ); - console.log( - `test finish Decrypt success ${uint8ArrayToString(data.outData)}` - ); expect(data.errorCode == 0).assertTrue(); } else { - console.log( - `test finish Encrypt fail ${uint8ArrayToString(encryptedData)}` - ); - console.log( - `test finish Encrypt fail ${uint8ArrayToString(data.outData)}` - ); expect(null).assertFail(); } } @@ -342,7 +269,6 @@ describe('SecurityHuksCipherRSAPromiseJsunit', function () { HuksCipherRSA.HuksKeyRSADIGESTSHA256 ), inData: gInData64Array, - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, @@ -362,7 +288,6 @@ describe('SecurityHuksCipherRSAPromiseJsunit', function () { HuksCipherRSA.HuksKeyRSADIGESTSHA256 ), inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, @@ -389,7 +314,6 @@ describe('SecurityHuksCipherRSAPromiseJsunit', function () { HuksCipherRSA.HuksKeyRSADIGESTSHA256 ), inData: gInData64Array, - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, @@ -416,7 +340,6 @@ describe('SecurityHuksCipherRSAPromiseJsunit', function () { HuksCipherRSA.HuksKeyRSADIGESTSHA256 ), inData: gInData64Array, - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, @@ -436,7 +359,6 @@ describe('SecurityHuksCipherRSAPromiseJsunit', function () { HuksCipherRSA.HuksKeyRSADIGESTSHA256 ), inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, @@ -463,7 +385,6 @@ describe('SecurityHuksCipherRSAPromiseJsunit', function () { HuksCipherRSA.HuksKeyRSADIGESTSHA256 ), inData: gInData64Array, - outData: stringToUint8Array('0'), }; await publicCipherFunc( srcKeyAlies, diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/BUILD.gn b/security/security_huks_basic/huks_derive_callback_BasicTest/BUILD.gn index 730187b2350f39a6963de2342b6b7c288778a80d..197ef9dc8465e35984c4322f8cd1af794658a936 100644 --- a/security/security_huks_basic/huks_derive_callback_BasicTest/BUILD.gn +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/BUILD.gn @@ -1,30 +1,30 @@ -# 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("huksderive_callback_basic_js_test") { - hap_profile = "./entry/src/main/config.json" - deps = [ - ":huks_js_assets", - ":huks_js_resources", - ] - certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsHuksDeriveBasicCallbackJSApiTest" -} -ohos_js_assets("huks_js_assets") { - source_dir = "./entry/src/main/js/MainAbility" -} -ohos_resources("huks_js_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" -} +# 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("huksderive_callback_basic_js_test") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":huks_js_assets", + ":huks_js_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsHuksDeriveBasicCallbackJSApiTest" +} +ohos_js_assets("huks_js_assets") { + source_dir = "./entry/src/main/js/MainAbility" +} +ohos_resources("huks_js_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/app.js index 5a5f568dfc0d7be0d64e09123ae920f1116557f6..83c43385acf60c088e550062c781ee53efc97779 100644 --- a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/app.js +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/app.js @@ -1,23 +1,23 @@ -/* - * 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'); - }, -}; +/* + * 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/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json index 5d2837c22d1a98e26f7e3035532d8b1fc4d9114d..7f21065f105c8ff8fabc971f5e5161ab30c73d2d 100644 --- a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json @@ -1,7 +1,7 @@ -{ - "strings": { - "hello": "Hello", - "world": "world", - "start": "test start" - } +{ + "strings": { + "hello": "Hello", + "world": "world", + "start": "test start" + } } \ No newline at end of file diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json index cce34b494cb907700edc55dbb56a827497be2859..29bea0fd91faa67602a08572d6feea8b79a0067b 100644 --- a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json @@ -1,7 +1,7 @@ -{ - "strings": { - "hello": "您好", - "world": "世界", - "start": "测试开始" - } +{ + "strings": { + "hello": "您好", + "world": "世界", + "start": "测试开始" + } } \ No newline at end of file diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css index f42c43b7cced3e43b1af3bbebb744df6c21f8d4f..50637f89ac7ae3d1ce45a4ad565eb4eab743709e 100644 --- a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -1,46 +1,46 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.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; - } -} +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.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/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml index fa09baa7ed8e1d6578b809d8188db603074dd208..201249a906e694fc042d0e967049a3eff15edfe2 100644 --- a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml @@ -1,5 +1,5 @@ -
- - {{ $t('strings.hello') }} {{ title }} - +
+ + {{ $t('strings.hello') }} {{ title }} +
\ No newline at end of file diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js index b73c0cda6eb1bf1c44a794156fd2f4a0dffc94e7..52df3aae59591efbb0be43c86b24af6d78652323 100644 --- a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -1,40 +1,40 @@ -/* - * 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 { Core, ExpectExtend } 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', - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000; - configService.setConfig(this); - console.log('test start'); - require('../../../test/List.test'); - core.execute(); - }, - onReady() {}, -}; +/* + * 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 { Core, ExpectExtend } 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', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js index 49ceea6b5276f6c8d87626b3ea0b6b0f91f50491..d8d528ba56cf7f0f5737d5aff34a2c47fe0a453f 100644 --- a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js @@ -33,7 +33,7 @@ let HuksOptions63kb = { }; describe('SecurityHuksDeriveHKDFCallbackJsunit', function () { - it('testDeriveHKDFAbort63KB001', 0, async function (done) { + it('testDeriveHKDF002', 0, async function (done) { const srcKeyAliesFirst = 'testDeriveHKDFSize128SHA256Abort63KBDeriveKeyAlias_01_001'; let huksOptionsFinish = { diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js index 248e202e7072867089fe42d21c0f3d5f264d528b..350a89588a20293ae28845182a624388358e9ef0 100644 --- a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js @@ -33,7 +33,7 @@ let HuksOptions63kb = { }; describe('SecurityHuksDeriveHKDFCallbackJsunit', function () { - it('testDeriveHKDFFinish63KB001', 0, async function (done) { + it('testDeriveHKDF001', 0, async function (done) { const srcKeyAliesFirst = 'testDeriveHKDFSize128SHA256Finish63KBDeriveKeyAlias_01_001'; let huksOptionsFinish = { diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js index eaa617a588f1b3fa44f148b76bab14a8ed841944..3691dd9a0b14711c22720b7cc436050929cd5ec2 100644 --- a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js @@ -33,7 +33,7 @@ let HuksOptions63kb = { }; describe('SecurityHuksDerivePBKDF2CallbackJsunit', function () { - it('testDerivePBKDF2Abort63KB001', 0, async function (done) { + it('testDerivePBKDF2002', 0, async function (done) { const srcKeyAliesFirst = 'testDerivePBKDF2Size128SHA256Abort63KBDeriveKeyAlias_01_001'; let huksOptionsFinish = { diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js index d28f8b73540b9586ab0bebd51a519c9897702bba..c5b411f57c052a01fb52521ec0298d44e4a0d522 100644 --- a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js @@ -33,7 +33,7 @@ let HuksOptions63kb = { }; describe('SecurityHuksDerivePBKDF2CallbackJsunit', function () { - it('testDerivePBKDF2Finish63KB001', 0, async function (done) { + it('testDerivePBKDF2001', 0, async function (done) { const srcKeyAliesFirst = 'testDerivePBKDF2Size128SHA256Finish63KBDeriveKeyAlias_01_001'; let huksOptionsFinish = { diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/BUILD.gn b/security/security_huks_basic/huks_derive_promise_BasicTest/BUILD.gn index c1212c5cc110a6bf23c1646e3a559eb4f78e11b6..c14d5b1881274f91d3d7f91df48cf0aa2c9e713e 100644 --- a/security/security_huks_basic/huks_derive_promise_BasicTest/BUILD.gn +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/BUILD.gn @@ -1,30 +1,30 @@ -# 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("huksderive_promise_basic_js_test") { - hap_profile = "./entry/src/main/config.json" - deps = [ - ":huks_js_assets", - ":huks_js_resources", - ] - certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsHuksDeriveBasicPromiseJSApiTest" -} -ohos_js_assets("huks_js_assets") { - source_dir = "./entry/src/main/js/MainAbility" -} -ohos_resources("huks_js_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" -} +# 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("huksderive_promise_basic_js_test") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":huks_js_assets", + ":huks_js_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsHuksDeriveBasicPromiseJSApiTest" +} +ohos_js_assets("huks_js_assets") { + source_dir = "./entry/src/main/js/MainAbility" +} +ohos_resources("huks_js_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/app.js index 5a5f568dfc0d7be0d64e09123ae920f1116557f6..83c43385acf60c088e550062c781ee53efc97779 100644 --- a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/app.js +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/app.js @@ -1,23 +1,23 @@ -/* - * 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'); - }, -}; +/* + * 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/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json index 5d2837c22d1a98e26f7e3035532d8b1fc4d9114d..7f21065f105c8ff8fabc971f5e5161ab30c73d2d 100644 --- a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json @@ -1,7 +1,7 @@ -{ - "strings": { - "hello": "Hello", - "world": "world", - "start": "test start" - } +{ + "strings": { + "hello": "Hello", + "world": "world", + "start": "test start" + } } \ No newline at end of file diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json index cce34b494cb907700edc55dbb56a827497be2859..29bea0fd91faa67602a08572d6feea8b79a0067b 100644 --- a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json @@ -1,7 +1,7 @@ -{ - "strings": { - "hello": "您好", - "world": "世界", - "start": "测试开始" - } +{ + "strings": { + "hello": "您好", + "world": "世界", + "start": "测试开始" + } } \ No newline at end of file diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css index f42c43b7cced3e43b1af3bbebb744df6c21f8d4f..50637f89ac7ae3d1ce45a4ad565eb4eab743709e 100644 --- a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -1,46 +1,46 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.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; - } -} +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.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/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml index fa09baa7ed8e1d6578b809d8188db603074dd208..201249a906e694fc042d0e967049a3eff15edfe2 100644 --- a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml @@ -1,5 +1,5 @@ -
- - {{ $t('strings.hello') }} {{ title }} - +
+ + {{ $t('strings.hello') }} {{ title }} +
\ No newline at end of file diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js index b73c0cda6eb1bf1c44a794156fd2f4a0dffc94e7..52df3aae59591efbb0be43c86b24af6d78652323 100644 --- a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -1,40 +1,40 @@ -/* - * 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 { Core, ExpectExtend } 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', - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000; - configService.setConfig(this); - console.log('test start'); - require('../../../test/List.test'); - core.execute(); - }, - onReady() {}, -}; +/* + * 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 { Core, ExpectExtend } 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', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js index b02bb8d19551f35cc01c173407dd6d47c9aed88d..09d8f352e4aacb4666501bef814d27e67e8e5824 100644 --- a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js @@ -34,7 +34,7 @@ let HuksOptions63kb = { }; describe('SecurityHuksDeriveHKDFPromiseJsunit', function () { - it('testDeriveHKDFAbort63KBDerive101', 0, async function (done) { + it('testDeriveHKDF102', 0, async function (done) { const srcKeyAliesFirst = 'testDeriveHKDFSize128SHA256Abort63KBDeriveKeyAlias_01_101'; let huksOptionsFinish = { diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js index bcb9b2123022e6cdea65b029e5b17531855a2db8..5e6d487d69a17824053ff6acac8f5656e6724ef0 100644 --- a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js @@ -33,7 +33,7 @@ let HuksOptions63kb = { }; describe('SecurityHuksDeriveHKDFPromiseJsunit', function () { - it('testDeriveHKDFFinish63KBDerive101', 0, async function (done) { + it('testDeriveHKDF101', 0, async function (done) { const srcKeyAliesFirst = 'testDeriveHKDFSize128SHA256Finish63KBDeriveKeyAlias_01_101'; let huksOptionsFinish = { diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js index f788979f28e23d9090d54a68a6cc777bf2975688..44d89c650f74a43b04d140a5b7999bc4373d127e 100644 --- a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js @@ -33,7 +33,7 @@ let HuksOptions63kb = { inData: srcData63Kb, }; describe('SecurityHuksDerivePBKDF2PromiseJsunit', function () { - it('testDerivePBKDF2Abort63KBDerive101', 0, async function (done) { + it('testDerivePBKDF2102', 0, async function (done) { const srcKeyAliesFirst = 'testDerivePBKDF2Size128SHA256Abort63KBDeriveKeyAlias_01_101'; let huksOptionsFinish = { diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js index 77f71810a6f968ad6046aeb3cf43b3da4945e2fa..f2e9908e449779420f0a9f0c89c9e1be56440214 100644 --- a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js @@ -34,7 +34,7 @@ let HuksOptions63kb = { }; describe('SecurityHuksDerivePBKDF2PromiseJsunit', function () { - it('testDerivePBKDF2Finish63KBDerive101', 0, async function (done) { + it('testDerivePBKDF2101', 0, async function (done) { const srcKeyAliesFirst = 'testDerivePBKDF2Size128SHA256Finish63KBDeriveKeyAlias_01_101'; let huksOptionsFinish = { diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/BUILD.gn b/security/security_huks_basic/huks_hmac_callback_BasicTest/BUILD.gn index 27a317886e976732b199126fe7761c2c864dc510..856daedad37ceb490cde5adf046ca724c79a166a 100644 --- a/security/security_huks_basic/huks_hmac_callback_BasicTest/BUILD.gn +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/BUILD.gn @@ -1,30 +1,30 @@ -# 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("hukshmac_callback_basic_js_test") { - hap_profile = "./entry/src/main/config.json" - deps = [ - ":huks_js_assets", - ":huks_js_resources", - ] - certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsHuksHmacBasicCallbackJSApiTest" -} -ohos_js_assets("huks_js_assets") { - source_dir = "./entry/src/main/js/MainAbility" -} -ohos_resources("huks_js_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" -} +# 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("hukshmac_callback_basic_js_test") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":huks_js_assets", + ":huks_js_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsHuksHmacBasicCallbackJSApiTest" +} +ohos_js_assets("huks_js_assets") { + source_dir = "./entry/src/main/js/MainAbility" +} +ohos_resources("huks_js_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/app.js index 5a5f568dfc0d7be0d64e09123ae920f1116557f6..83c43385acf60c088e550062c781ee53efc97779 100644 --- a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/app.js +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/app.js @@ -1,23 +1,23 @@ -/* - * 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'); - }, -}; +/* + * 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/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json index 5d2837c22d1a98e26f7e3035532d8b1fc4d9114d..7f21065f105c8ff8fabc971f5e5161ab30c73d2d 100644 --- a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json @@ -1,7 +1,7 @@ -{ - "strings": { - "hello": "Hello", - "world": "world", - "start": "test start" - } +{ + "strings": { + "hello": "Hello", + "world": "world", + "start": "test start" + } } \ No newline at end of file diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json index cce34b494cb907700edc55dbb56a827497be2859..29bea0fd91faa67602a08572d6feea8b79a0067b 100644 --- a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json @@ -1,7 +1,7 @@ -{ - "strings": { - "hello": "您好", - "world": "世界", - "start": "测试开始" - } +{ + "strings": { + "hello": "您好", + "world": "世界", + "start": "测试开始" + } } \ No newline at end of file diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css index f42c43b7cced3e43b1af3bbebb744df6c21f8d4f..50637f89ac7ae3d1ce45a4ad565eb4eab743709e 100644 --- a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -1,46 +1,46 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.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; - } -} +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.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/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml index fa09baa7ed8e1d6578b809d8188db603074dd208..201249a906e694fc042d0e967049a3eff15edfe2 100644 --- a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml @@ -1,5 +1,5 @@ -
- - {{ $t('strings.hello') }} {{ title }} - +
+ + {{ $t('strings.hello') }} {{ title }} +
\ No newline at end of file diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js index b73c0cda6eb1bf1c44a794156fd2f4a0dffc94e7..52df3aae59591efbb0be43c86b24af6d78652323 100644 --- a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -1,40 +1,40 @@ -/* - * 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 { Core, ExpectExtend } 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', - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000; - configService.setConfig(this); - console.log('test start'); - require('../../../test/List.test'); - core.execute(); - }, - onReady() {}, -}; +/* + * 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 { Core, ExpectExtend } 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', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js index 8bfe363a9afb8417a8d06c743d9d792285e26923..472dc6bef50e073ac5d42f28a3ef7028b4aa95d4 100644 --- a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js @@ -188,9 +188,6 @@ async function publicHmacUpdate(HuksOptions) { async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) { HuksOptions.properties.splice(1, 0, HuksHmac.HuksKeySIZE); - console.log( - 'test before generateKey HuksOptions = ' + JSON.stringify(HuksOptions) - ); await generateKey(srcKeyAlies, HuksOptions) .then((data) => { console.log('test generateKey data = ' + JSON.stringify(data)); @@ -201,7 +198,6 @@ async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) { }); HuksOptions.properties.splice(1, 1); - console.log('test before init HuksOptions = ' + JSON.stringify(HuksOptions)); await init(srcKeyAlies, HuksOptions) .then((data) => { console.log(`test init data: ${JSON.stringify(data)}`); @@ -210,16 +206,10 @@ async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) { console.log(`test init err: " + ${JSON.stringify(err)}`); expect(null).assertFail(); }); - console.log( - 'test before Update HuksOptions = ' + JSON.stringify(HuksOptions) - ); await publicHmacUpdate(HuksOptions); if (thirdInderfaceName == 'finish') { HuksOptions.inData = new Uint8Array(stringToArray('0')); - console.log( - 'test before finish HuksOptions = ' + JSON.stringify(HuksOptions) - ); await finish(handle, HuksOptions) .then((data) => { console.log(`test update data: ${data}`); @@ -229,9 +219,6 @@ async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) { expect(null).assertFail(); }); } else { - console.log( - 'test before abort HuksOptions = ' + JSON.stringify(HuksOptions) - ); await abort(handle, HuksOptions) .then((data) => { console.log(`test abort data: ${data}`); @@ -242,9 +229,6 @@ async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) { }); } HuksOptions.properties.splice(1, 0, HuksHmac.HuksKeySIZE); - console.log( - 'test before deleteKey HuksOptions = ' + JSON.stringify(HuksOptions) - ); await deleteKey(srcKeyAlies, HuksOptions) .then((data) => { console.log(`test deleteKey data: ${data}`); diff --git a/security/security_huks_basic/huks_hmac_promise_BasicTest/BUILD.gn b/security/security_huks_basic/huks_hmac_promise_BasicTest/BUILD.gn index 6b5f3b70c4f491dbaabc9ce165c42e6e927e1096..de6c66e0f2384bd6dbeaabd392c3bb33f3db2149 100644 --- a/security/security_huks_basic/huks_hmac_promise_BasicTest/BUILD.gn +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/BUILD.gn @@ -1,30 +1,30 @@ -# 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("hukshmac_promise_basic_js_test") { - hap_profile = "./entry/src/main/config.json" - deps = [ - ":huks_js_assets", - ":huks_js_resources", - ] - certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsHuksHmacBasicPromiseJSApiTest" -} -ohos_js_assets("huks_js_assets") { - source_dir = "./entry/src/main/js/MainAbility" -} -ohos_resources("huks_js_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" -} +# 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("hukshmac_promise_basic_js_test") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":huks_js_assets", + ":huks_js_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsHuksHmacBasicPromiseJSApiTest" +} +ohos_js_assets("huks_js_assets") { + source_dir = "./entry/src/main/js/MainAbility" +} +ohos_resources("huks_js_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/app.js index 5a5f568dfc0d7be0d64e09123ae920f1116557f6..83c43385acf60c088e550062c781ee53efc97779 100644 --- a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/app.js +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/app.js @@ -1,23 +1,23 @@ -/* - * 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'); - }, -}; +/* + * 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/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json index 5d2837c22d1a98e26f7e3035532d8b1fc4d9114d..7f21065f105c8ff8fabc971f5e5161ab30c73d2d 100644 --- a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json @@ -1,7 +1,7 @@ -{ - "strings": { - "hello": "Hello", - "world": "world", - "start": "test start" - } +{ + "strings": { + "hello": "Hello", + "world": "world", + "start": "test start" + } } \ No newline at end of file diff --git a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json index cce34b494cb907700edc55dbb56a827497be2859..29bea0fd91faa67602a08572d6feea8b79a0067b 100644 --- a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json @@ -1,7 +1,7 @@ -{ - "strings": { - "hello": "您好", - "world": "世界", - "start": "测试开始" - } +{ + "strings": { + "hello": "您好", + "world": "世界", + "start": "测试开始" + } } \ No newline at end of file diff --git a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css index f42c43b7cced3e43b1af3bbebb744df6c21f8d4f..50637f89ac7ae3d1ce45a4ad565eb4eab743709e 100644 --- a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -1,46 +1,46 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.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; - } -} +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.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/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml index fa09baa7ed8e1d6578b809d8188db603074dd208..201249a906e694fc042d0e967049a3eff15edfe2 100644 --- a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml @@ -1,5 +1,5 @@ -
- - {{ $t('strings.hello') }} {{ title }} - +
+ + {{ $t('strings.hello') }} {{ title }} +
\ No newline at end of file diff --git a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js index b73c0cda6eb1bf1c44a794156fd2f4a0dffc94e7..52df3aae59591efbb0be43c86b24af6d78652323 100644 --- a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -1,40 +1,40 @@ -/* - * 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 { Core, ExpectExtend } 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', - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000; - configService.setConfig(this); - console.log('test start'); - require('../../../test/List.test'); - core.execute(); - }, - onReady() {}, -}; +/* + * 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 { Core, ExpectExtend } 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', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js index dc07a64217be0fb8a2f5ae988e2fd88cf28368d3..64ecab027206cf868e994b5e3b5f0fe4391c860e 100644 --- a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js @@ -134,7 +134,6 @@ async function publicHmacFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) { } async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`); await huks .update(handle, HuksOptions) .then(async (data) => { diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/BUILD.gn b/security/security_huks_basic/huks_signverify_callback_BasicTest/BUILD.gn index 6563049b7e1183d172acfd4045a7b09ec2246dcc..79f36505acd2d90e8e00241aa77ceb37472ca101 100644 --- a/security/security_huks_basic/huks_signverify_callback_BasicTest/BUILD.gn +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/BUILD.gn @@ -1,30 +1,30 @@ -# 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("hukssignverify_callback_basic_js_test") { - hap_profile = "./entry/src/main/config.json" - deps = [ - ":huks_js_assets", - ":huks_js_resources", - ] - certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsHuksSignVerifyBasicCallbackJSApiTest" -} -ohos_js_assets("huks_js_assets") { - source_dir = "./entry/src/main/js/MainAbility" -} -ohos_resources("huks_js_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" -} +# 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("hukssignverify_callback_basic_js_test") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":huks_js_assets", + ":huks_js_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsHuksSignVerifyBasicCallbackJSApiTest" +} +ohos_js_assets("huks_js_assets") { + source_dir = "./entry/src/main/js/MainAbility" +} +ohos_resources("huks_js_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/app.js index 5a5f568dfc0d7be0d64e09123ae920f1116557f6..83c43385acf60c088e550062c781ee53efc97779 100644 --- a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/app.js +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/app.js @@ -1,23 +1,23 @@ -/* - * 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'); - }, -}; +/* + * 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/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json index 5d2837c22d1a98e26f7e3035532d8b1fc4d9114d..7f21065f105c8ff8fabc971f5e5161ab30c73d2d 100644 --- a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json @@ -1,7 +1,7 @@ -{ - "strings": { - "hello": "Hello", - "world": "world", - "start": "test start" - } +{ + "strings": { + "hello": "Hello", + "world": "world", + "start": "test start" + } } \ No newline at end of file diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json index cce34b494cb907700edc55dbb56a827497be2859..29bea0fd91faa67602a08572d6feea8b79a0067b 100644 --- a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json @@ -1,7 +1,7 @@ -{ - "strings": { - "hello": "您好", - "world": "世界", - "start": "测试开始" - } +{ + "strings": { + "hello": "您好", + "world": "世界", + "start": "测试开始" + } } \ No newline at end of file diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css index f42c43b7cced3e43b1af3bbebb744df6c21f8d4f..50637f89ac7ae3d1ce45a4ad565eb4eab743709e 100644 --- a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -1,46 +1,46 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.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; - } -} +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.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/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml index fa09baa7ed8e1d6578b809d8188db603074dd208..201249a906e694fc042d0e967049a3eff15edfe2 100644 --- a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml @@ -1,5 +1,5 @@ -
- - {{ $t('strings.hello') }} {{ title }} - +
+ + {{ $t('strings.hello') }} {{ title }} +
\ No newline at end of file diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js index b73c0cda6eb1bf1c44a794156fd2f4a0dffc94e7..52df3aae59591efbb0be43c86b24af6d78652323 100644 --- a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -1,40 +1,40 @@ -/* - * 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 { Core, ExpectExtend } 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', - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000; - configService.setConfig(this); - console.log('test start'); - require('../../../test/List.test'); - core.execute(); - }, - onReady() {}, -}; +/* + * 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 { Core, ExpectExtend } 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', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/BUILD.gn b/security/security_huks_basic/huks_signverify_promise_BasicTest/BUILD.gn index e4ae8d77e8936ebf243d42b9b68cf5bdb53669fa..4a51caf359190d605d01457d72f2141ffcae7108 100644 --- a/security/security_huks_basic/huks_signverify_promise_BasicTest/BUILD.gn +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/BUILD.gn @@ -1,30 +1,30 @@ -# 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("hukssignverify_promise_basic_js_test") { - hap_profile = "./entry/src/main/config.json" - deps = [ - ":huks_js_assets", - ":huks_js_resources", - ] - certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsHuksSignVerifyBasicPromiseJSApiTest" -} -ohos_js_assets("huks_js_assets") { - source_dir = "./entry/src/main/js/MainAbility" -} -ohos_resources("huks_js_resources") { - sources = [ "./entry/src/main/js/resources" ] - hap_profile = "./entry/src/main/config.json" -} +# 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("hukssignverify_promise_basic_js_test") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":huks_js_assets", + ":huks_js_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsHuksSignVerifyBasicPromiseJSApiTest" +} +ohos_js_assets("huks_js_assets") { + source_dir = "./entry/src/main/js/MainAbility" +} +ohos_resources("huks_js_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/app.js index 5a5f568dfc0d7be0d64e09123ae920f1116557f6..83c43385acf60c088e550062c781ee53efc97779 100644 --- a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/app.js +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/app.js @@ -1,23 +1,23 @@ -/* - * 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'); - }, -}; +/* + * 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/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json index 5d2837c22d1a98e26f7e3035532d8b1fc4d9114d..7f21065f105c8ff8fabc971f5e5161ab30c73d2d 100644 --- a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json @@ -1,7 +1,7 @@ -{ - "strings": { - "hello": "Hello", - "world": "world", - "start": "test start" - } +{ + "strings": { + "hello": "Hello", + "world": "world", + "start": "test start" + } } \ No newline at end of file diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json index cce34b494cb907700edc55dbb56a827497be2859..29bea0fd91faa67602a08572d6feea8b79a0067b 100644 --- a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json @@ -1,7 +1,7 @@ -{ - "strings": { - "hello": "您好", - "world": "世界", - "start": "测试开始" - } +{ + "strings": { + "hello": "您好", + "world": "世界", + "start": "测试开始" + } } \ No newline at end of file diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css index f42c43b7cced3e43b1af3bbebb744df6c21f8d4f..50637f89ac7ae3d1ce45a4ad565eb4eab743709e 100644 --- a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -1,46 +1,46 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.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; - } -} +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.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/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml index fa09baa7ed8e1d6578b809d8188db603074dd208..201249a906e694fc042d0e967049a3eff15edfe2 100644 --- a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml @@ -1,5 +1,5 @@ -
- - {{ $t('strings.hello') }} {{ title }} - +
+ + {{ $t('strings.hello') }} {{ title }} +
\ No newline at end of file diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js index b73c0cda6eb1bf1c44a794156fd2f4a0dffc94e7..52df3aae59591efbb0be43c86b24af6d78652323 100644 --- a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -1,40 +1,40 @@ -/* - * 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 { Core, ExpectExtend } 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', - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000; - configService.setConfig(this); - console.log('test start'); - require('../../../test/List.test'); - core.execute(); - }, - onReady() {}, -}; +/* + * 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 { Core, ExpectExtend } 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', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks_basic/utils/param/agree/publicAgreeCallback.js b/security/security_huks_basic/utils/param/agree/publicAgreeCallback.js index 5281c557595d7910502ef4687f9ccd4eb013a577..8c4931b2d2d1469bd1722e87c3a802f80f42180e 100644 --- a/security/security_huks_basic/utils/param/agree/publicAgreeCallback.js +++ b/security/security_huks_basic/utils/param/agree/publicAgreeCallback.js @@ -140,9 +140,6 @@ async function publicAgreeFinishAbortFunc( thirdInderfaceName ) { if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish HuksOptionsFinish ${JSON.stringify(HuksOptionsFinish)}` - ); await finish(handle, HuksOptionsFinish) .then((data) => { console.log(`test finish data ${JSON.stringify(data)}`); diff --git a/security/security_huks_basic/utils/param/agree/publicAgreePromise.js b/security/security_huks_basic/utils/param/agree/publicAgreePromise.js index 30361c3e60f6f1d3434e26d2e83abb900d583be4..bd8e04cae79f63ba1e3faee8ddd6281f9b69ddfc 100644 --- a/security/security_huks_basic/utils/param/agree/publicAgreePromise.js +++ b/security/security_huks_basic/utils/param/agree/publicAgreePromise.js @@ -90,9 +90,6 @@ async function publicAgreeFinishAbortFunc( thirdInderfaceName ) { if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish HuksOptionsFinish ${JSON.stringify(HuksOptionsFinish)}` - ); await huks .finish(handle, HuksOptionsFinish) .then((data) => { diff --git a/security/security_huks_basic/utils/param/derive/publicDeriveCallback.js b/security/security_huks_basic/utils/param/derive/publicDeriveCallback.js index f2946776ecce96ada8c01e6a84a2a4990b8061b9..67874818f2764d0e9b8c27465306838061c032a8 100644 --- a/security/security_huks_basic/utils/param/derive/publicDeriveCallback.js +++ b/security/security_huks_basic/utils/param/derive/publicDeriveCallback.js @@ -101,9 +101,6 @@ async function publicDeriveFinishAbortFunc( thirdInderfaceName ) { if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify(huksOptionsFinish)}` - ); await finish(handle, huksOptionsFinish) .then((data) => { console.log(`test finish data ${JSON.stringify(data)}`); @@ -157,9 +154,6 @@ function finish(handle, huksOptionsFinish) { } async function publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) { - console.log( - 'test before deleteKey HuksOptions: ' + JSON.stringify(HuksOptions) - ); await deleteKey(srcKeyAlies, HuksOptions) .then((data) => { console.log(`test deleteKey data ${JSON.stringify(data)}`); diff --git a/security/security_huks_basic/utils/param/derive/publicDerivePromise.js b/security/security_huks_basic/utils/param/derive/publicDerivePromise.js index b23ab18614fcb1d80084b493c8ac23a5bf906fd6..2db56f097690f642639ddac7d6599f7947332879 100644 --- a/security/security_huks_basic/utils/param/derive/publicDerivePromise.js +++ b/security/security_huks_basic/utils/param/derive/publicDerivePromise.js @@ -62,9 +62,6 @@ async function publicDeriveFinishAbortFunc( thirdInderfaceName ) { if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify(huksOptionsFinish)}` - ); await huks .finish(handle, huksOptionsFinish) .then((data) => { @@ -94,9 +91,6 @@ async function publicDeriveFinishAbortFunc( } async function publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) { - console.log( - 'test before deleteKey HuksOptions: ' + JSON.stringify(HuksOptions) - ); await huks .deleteKey(srcKeyAlies, HuksOptions) .then((data) => { diff --git a/security/security_huks_basic/utils/param/signverify/publicSignverifyCallback.js b/security/security_huks_basic/utils/param/signverify/publicSignverifyCallback.js index bd489c6b02b0f71d8cf7e1fb1ab4e71ec23247c2..1568eeca624259d6c8b8440b94a6a0c784fdb9d6 100644 --- a/security/security_huks_basic/utils/param/signverify/publicSignverifyCallback.js +++ b/security/security_huks_basic/utils/param/signverify/publicSignverifyCallback.js @@ -50,7 +50,6 @@ function generateKey(srcKeyAlies, HuksOptions) { async function publicImportKey(keyAlias, HuksOptions) { let _InData = HuksOptions.inData; HuksOptions.inData = finishOutData; - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`); await importKey(keyAlias, HuksOptions) .then((data) => { console.log(`test ImportKey data: ${JSON.stringify(data)}`); @@ -143,11 +142,6 @@ async function publicUpdateFunc(HuksOptions, isBigData) { } else { let count = Math.floor(uint8ArrayToString(inDataArray).length / dateSize); let remainder = uint8ArrayToString(inDataArray).length % dateSize; - console.log( - `test before update length: ${uint8ArrayToString(inDataArray).length}` - ); - console.log(`test before update count: ${count}`); - console.log(`test before update remainder: ${remainder}`); for (let i = 0; i < count; i++) { HuksOptions.inData = stringToUint8Array( uint8ArrayToString(tempHuksOptionsInData).slice( @@ -172,7 +166,6 @@ async function publicUpdateFunc(HuksOptions, isBigData) { } async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`); await updateCallback(handle, HuksOptions) .then(async (data) => { console.log(`test update data ${JSON.stringify(data)}`); @@ -305,7 +298,6 @@ async function publicSignVerifyFunc( keyAlias = newSrcKeyAlies; await publicImportKey(keyAlias, HuksOptions); } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`); await publicInitFunc(keyAlias, HuksOptions); await publicUpdateFunc(HuksOptions, isBigData); if (thirdInderfaceName == 'finish') { @@ -317,11 +309,6 @@ async function publicSignVerifyFunc( 1, HuksSignVerifyDSA.HuksKeyRSAPurposeSINGVERIFY ); - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ); await publicExportKey(keyAlias, HuksOptions); } else { HuksOptions.outData = exportKey; diff --git a/security/security_huks_basic/utils/param/signverify/publicSignverifyPromise.js b/security/security_huks_basic/utils/param/signverify/publicSignverifyPromise.js index cb88c852b22a069b6f99f127f153c1b6230b2767..2f3f8ec5342dff43a50dd0d93a02235697b8120c 100644 --- a/security/security_huks_basic/utils/param/signverify/publicSignverifyPromise.js +++ b/security/security_huks_basic/utils/param/signverify/publicSignverifyPromise.js @@ -37,8 +37,6 @@ async function publicGenerateKeyFunc(keyAlias, HuksOptions) { async function publicImportKey(keyAlias, HuksOptions) { let _InData = HuksOptions.inData; HuksOptions.inData = finishOutData; - console.log(`test ImportKey keyAlias: ${keyAlias}`); - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`); await huks .importKey(keyAlias, HuksOptions) .then((data) => { @@ -93,11 +91,6 @@ async function publicUpdateFunc(HuksOptions, isBigData) { } else { let count = Math.floor(uint8ArrayToString(inDataArray).length / dateSize); let remainder = uint8ArrayToString(inDataArray).length % dateSize; - console.log( - `test before update length: ${uint8ArrayToString(inDataArray).length}` - ); - console.log(`test before update count: ${count}`); - console.log(`test before update remainder: ${remainder}`); for (let i = 0; i < count; i++) { HuksOptions.inData = stringToUint8Array( uint8ArrayToString(tempHuksOptionsInData).slice( @@ -122,7 +115,6 @@ async function publicUpdateFunc(HuksOptions, isBigData) { } async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`); await huks .update(handle, HuksOptions) .then(async (data) => { @@ -207,30 +199,20 @@ async function publicSignVerifyFunc( keyAlias = newSrcKeyAlies; await publicImportKey(keyAlias, HuksOptions); } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`); await publicInitFunc(keyAlias, HuksOptions); await publicUpdateFunc(HuksOptions, isBigData); if (thirdInderfaceName == 'finish') { if (isSING) { HuksOptions.outData = new Uint8Array(new Array(1024).fill('')); - console.log(`test before finish HuksOptions: ${HuksOptions.inData}`); - console.log(`test before finish HuksOptions: ${HuksOptions.outData}`); await publicFinishFunc(HuksOptions); HuksOptions.properties.splice( 1, 1, HuksSignVerifyDSA.HuksKeyRSAPurposeSINGVERIFY ); - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ); await publicExportKey(keyAlias, HuksOptions); } else { HuksOptions.outData = exportKey; - console.log(`test before finish HuksOptions: ${HuksOptions.inData}`); - console.log(`test before finish HuksOptions: ${HuksOptions.outData}`); await publicFinishFunc(HuksOptions); } } else { diff --git a/security_lite/huks_hal/BUILD.gn b/security_lite/huks_hal/BUILD.gn deleted file mode 100755 index 2c56dff03f7924411c5af29e209477f0b5b701d9..0000000000000000000000000000000000000000 --- a/security_lite/huks_hal/BUILD.gn +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (c) 2020-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("//base/security/huks/build/config.gni") -import("//test/xts/tools/lite/build/suite_lite.gni") - -hctest_suite("ActsSecurityDataTest") { - suite_name = "acts" - sources = [ - "src/security_data_huks_dec_test.c", - "src/security_data_huks_enc_test.c", - "src/security_data_huks_export_hash_random_test.c", - "src/security_data_huks_gen_del_test.c", - "src/security_data_huks_sign_verify_test.c", - ] - if (disable_authenticate == true) { - defines = [ "_CUT_AUTHENTICATE_" ] - } - include_dirs = [ - "src", - "//base/security/huks/interfaces/innerkits/huks_lite/", - ] - cflags = [ "-Wno-error" ] -} diff --git a/security_lite/huks_hal/Test.tmpl b/security_lite/huks_hal/Test.tmpl deleted file mode 100755 index be8407e1286041a5af2bdc75a15633337376eb9d..0000000000000000000000000000000000000000 --- a/security_lite/huks_hal/Test.tmpl +++ /dev/null @@ -1,19 +0,0 @@ -{ - "description": "Config for $module test cases", - "environment": [ - { - "type": "device", - "label": "wifiiot" - } - ], - "kits": [ - { - "type": "DeployKit", - "timeout": "20000", - "burn_file": "$subsystem/$module.bin" - } - ], - "driver": { - "type": "CTestLite" - } -} \ No newline at end of file diff --git a/security_lite/huks_hal/src/security_data_huks.h b/security_lite/huks_hal/src/security_data_huks.h deleted file mode 100755 index 48563919ac018c4625d41f51c3b4a769b61c1296..0000000000000000000000000000000000000000 --- a/security_lite/huks_hal/src/security_data_huks.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2020 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. - */ - -#ifndef TEST_XTS_ACTS_SECURITY_LITE_DATAHUKS_HAL_SRC_SECURITY_DATA_HUKS_H -#define TEST_XTS_ACTS_SECURITY_LITE_DATAHUKS_HAL_SRC_SECURITY_DATA_HUKS_H - -#include "hctest.h" -#include "hks_client.h" -#include "hks_types.h" -#include "securec.h" -#include -#include -#include -#include -#include - -#define NUM1 1 -#define NUM2 2 -#define NUM3 3 -#define NUM4 4 -#define NUM5 5 -#define NUM6 6 -#define NUM10 10 -#define NUM11 11 -#define NUM12 12 -#define NUM15 15 -#define NUM16 16 -#define NUM20 20 -#define NUM21 21 -#define NUM24 24 -#define NUM25 25 -#define NUM30 30 -#define NUM31 31 -#define NUM32 32 -#define NUM33 33 -#define NUM60 60 -#define NUM63 63 -#define NUM64 64 -#define NUM65 65 -#define NUM88 88 -#define NUM100 100 -#define NUM111 111 -#define NUM128 128 -#define NUM192 192 -#define NUM256 256 -#define NUM1025 1025 -#define NUM134 (-134) -#define NUM135 (-135) -#define NUM138 (-138) -#define NUM142 (-142) -#define NUM1000 (-1000) -#define NUM1004 (-1004) -#define NUM1005 (-1005) -#define NUM1006 (-1006) -#define NUM1007 (-1007) -#define NUM1010 (-1010) -#define MAX_INT 2147483647 -#define HKS_FREE_PTR1(p) { if ((p) != NULL) { free(p); (p) = NULL; }} - -void HksStBlobInit1(struct hks_blob *blob, size_t nmemb, size_t size, uint8_t type); - -void HksBlobDestroyT1(struct hks_blob *blob); - -int TestSecShuksGenerateKeyNormal(void); - -int TestSecShuksDeleteKeyNormal(void); - -int TestSecShuksExportPublicNormal(struct hks_blob *keyAlias, struct hks_blob *publicKey1); - -void BuildBlobData(struct hks_blob *param, const char *str, uint8_t type, uint32_t size, uint8_t isDataNull); - -void HexStringToByte(const char *str, int nLen, unsigned char *pHex); - -void TestInitKeyParam1(struct hks_key_param *keyParam, uint32_t keyType, uint32_t keyLen, uint32_t keyMode, - uint32_t keyUsage); - -int TestSecShuksImportPublicNormal(void); - -#endif diff --git a/security_lite/huks_hal/src/security_data_huks_dec_test.c b/security_lite/huks_hal/src/security_data_huks_dec_test.c deleted file mode 100755 index f1a783d1e813aa8677ea6a94b2fbc137cae1af8e..0000000000000000000000000000000000000000 --- a/security_lite/huks_hal/src/security_data_huks_dec_test.c +++ /dev/null @@ -1,1314 +0,0 @@ -/* Copyright (c) 2020-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. -*/ -#include "security_data_huks.h" -#include "hctest.h" -#include "hks_client.h" -#include "hks_types.h" -#include -#include -#include -#include -#include - -/* * - * @tc.desc : register a test suite, this suite is used to test basic flow and interface dependency - * @param : subsystem name is security - * @param : module name is securityData - * @param : test suit name is SecurityDataHuksDecTestSuite - */ -LITE_TEST_SUIT(security, securityData, SecurityDataHuksDecTestSuite); - -/* * - * @tc.setup : setup for all testcases - * @return : setup result, TRUE is success, FALSE is fail - */ -static BOOL SecurityDataHuksDecTestSuiteSetUp(void) -{ - int32_t status; - status = hks_init(); - if (status != 0) { - status = hks_refresh_key_info(); - } - TEST_ASSERT_EQUAL_INT(0, status); - return TRUE; -} - -/* * - * @tc.teardown : teardown for all testcases - * @return : teardown result, TRUE is success, FALSE is fail - */ -static BOOL SecurityDataHuksDecTestSuiteTearDown(void) -{ - printf("-++++++++++++++++++++++++++++++++++++++++++++-\n"); - return TRUE; -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Decrypt key -// begin++++++++++++++++++++++++++++++++++++++++++++++++++++0760-0990 - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0760 - * @tc.name : Aead Decrypt, normal input parameters key, keyParam.ken_len is 128, cryptParam, plaintext, ciphertext - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0760, Function | MediumTest | Level1) -{ - char alias[] = "test_hks_aead_encrypt"; - int32_t statusEncrypt; - int32_t statusDecrypt; - - struct hks_blob key; - HksStBlobInit1(&key, 1, NUM16, HKS_BLOB_TYPE_KEY); - hks_generate_random(&key); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - struct hks_blob nonce = {0}; - HksStBlobInit1(&nonce, 1, NUM16, HKS_BLOB_TYPE_IV); - hks_generate_random(&nonce); - - struct hks_blob aad = {0}; - HksStBlobInit1(&aad, 1, NUM16, HKS_BLOB_TYPE_AAD); - hks_generate_random(&aad); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - HksStBlobInit1(&plaintext, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - hks_generate_random(&plaintext); - - struct hks_blob ciphertext; - HksStBlobInit1(&ciphertext, 1, NUM64 + HKS_SALT_MAX_SIZE, HKS_BLOB_TYPE_CIPHER_TEXT); - statusEncrypt = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(0, statusEncrypt); - - struct hks_blob decrypted; - HksStBlobInit1(&decrypted, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - statusDecrypt = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(0, statusDecrypt); - - size_t k; - for (k = 0; k < decrypted.size; k++) { - TEST_ASSERT_EQUAL_INT(plaintext.data[k], decrypted.data[k]); - } - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&nonce); - HksBlobDestroyT1(&aad); - HksBlobDestroyT1(&plaintext); - HksBlobDestroyT1(&ciphertext); - HksBlobDestroyT1(&decrypted); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0770 - * @tc.name : Aead Decrypt, normal input parameters key, keyParam.ken_len is 192, cryptParam, plaintext, ciphertext - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0770, Function | MediumTest | Level1) -{ - char alias[] = "test_hks_aead_encrypt"; - int32_t statusEncrypt; - int32_t statusDecrypt; - - struct hks_blob key; - HksStBlobInit1(&key, 1, NUM24, HKS_BLOB_TYPE_KEY); - hks_generate_random(&key); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM192; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - struct hks_blob nonce = {0}; - HksStBlobInit1(&nonce, 1, NUM16, HKS_BLOB_TYPE_IV); - hks_generate_random(&nonce); - - struct hks_blob aad = {0}; - HksStBlobInit1(&aad, 1, NUM16, HKS_BLOB_TYPE_AAD); - hks_generate_random(&aad); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - HksStBlobInit1(&plaintext, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - hks_generate_random(&plaintext); - - struct hks_blob ciphertext; - HksStBlobInit1(&ciphertext, 1, NUM64 + HKS_SALT_MAX_SIZE, HKS_BLOB_TYPE_CIPHER_TEXT); - statusEncrypt = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(0, statusEncrypt); - - struct hks_blob decrypted; - HksStBlobInit1(&decrypted, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - statusDecrypt = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(0, statusDecrypt); - - size_t k; - for (k = 0; k < decrypted.size; k++) { - TEST_ASSERT_EQUAL_INT(plaintext.data[k], decrypted.data[k]); - } - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&nonce); - HksBlobDestroyT1(&aad); - HksBlobDestroyT1(&plaintext); - HksBlobDestroyT1(&ciphertext); - HksBlobDestroyT1(&decrypted); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0780 - * @tc.name : Aead Decrypt, normal input parameters key, keyParam.ken_len is 256, cryptParam, plaintext, ciphertext - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0780, Function | MediumTest | Level1) -{ - char alias[] = "test_hks_aead_encrypt"; - int32_t statusEncrypt; - int32_t statusDecrypt; - struct hks_blob key; - HksStBlobInit1(&key, 1, NUM32, HKS_BLOB_TYPE_KEY); - hks_generate_random(&key); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM256; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - struct hks_blob nonce = {0}; - HksStBlobInit1(&nonce, 1, NUM16, HKS_BLOB_TYPE_IV); - hks_generate_random(&nonce); - - struct hks_blob aad = {0}; - HksStBlobInit1(&aad, 1, NUM16, HKS_BLOB_TYPE_AAD); - hks_generate_random(&aad); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - HksStBlobInit1(&plaintext, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - hks_generate_random(&plaintext); - - struct hks_blob ciphertext; - HksStBlobInit1(&ciphertext, 1, NUM64 + HKS_SALT_MAX_SIZE, HKS_BLOB_TYPE_CIPHER_TEXT); - statusEncrypt = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(0, statusEncrypt); - - struct hks_blob decrypted; - HksStBlobInit1(&decrypted, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - statusDecrypt = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(0, statusDecrypt); - - size_t k; - for (k = 0; k < decrypted.size; k++) { - TEST_ASSERT_EQUAL_INT(plaintext.data[k], decrypted.data[k]); - } - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&nonce); - HksBlobDestroyT1(&aad); - HksBlobDestroyT1(&plaintext); - HksBlobDestroyT1(&ciphertext); - HksBlobDestroyT1(&decrypted); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0790 - * @tc.name : Aead Decrypt, abnormal input parameters key is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0790, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob *key = NULL; - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0800 - * @tc.name : Aead Decrypt, abnormal input parameters key.size is not equal to keyParam.key_len divided by 8 - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0800, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = NUM32; - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM1006, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0810 - * @tc.name : Aead Decrypt, abnormal input parameters key.data is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0810, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = NULL; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM1006, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0820 - * @tc.name : Aead Decrypt, abnormal input parameters key.type is not equal to HKS_KEY_TYPE_AES - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0820, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = 0; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM1006, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0830 - * @tc.name : Aead Decrypt, abnormal input parameters keyParam is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0830, Function | MediumTest | Level2) -{ - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param *keyParam = NULL; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0840 - * @tc.name : Aead Decrypt, abnormal input parameters keyParam.key_mode is not equal to HKS_ALG_GCM - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0840, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = 0; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0850 - * @tc.name : Aead Decrypt, abnormal input parameters keyParam.key_len is not equal to 128, 192, 256 - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0850, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM12; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0860 - * @tc.name : Aead Decrypt, abnormal input parameters keyParam.key_type is not equal to HKS_KEY_TYPE_AES - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0860, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = 0; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0870 - * @tc.name : Aead Decrypt, abnormal input parameters keyParam.key_pad is not equal to HKS_PADDING_NONE - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0870, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = NUM88; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0880 - * @tc.name : Aead Decrypt, abnormal input parameters keyParam.key_usage - is not equal to HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0880, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = 0; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0890 - * @tc.name : Aead Decrypt, abnormal input parameters cryptParam is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0890, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param *cryptParam = NULL; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0900 - * @tc.name : Aead Decrypt, abnormal input parameters nonce.size is 0 - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0900, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = 0; - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0910 - * @tc.name : Aead Decrypt, abnormal input parameters nonce.data is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0910, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = NULL; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0920 - * @tc.name : Aead Decrypt, abnormal input parameters aad.size is 0 - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0920, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = 0; - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0930 - * @tc.name : Aead Decrypt, abnormal input parameters aad.data is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0930, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = NULL; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0940 - * @tc.name : Aead Decrypt, abnormal input decrypted plaintext is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0940, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob *decrypted = NULL; - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0950 - * @tc.name : Aead Decrypt, abnormal input decrypted plaintext.data is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0950, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = NULL; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0960 - * @tc.name : Aead Decrypt, abnormal input parameters decrypted.size is less than ciphertext.size minus 16 - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0960, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = NUM15; - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0970 - * @tc.name : Aead Decrypt, abnormal input parameters ciphertext.size is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0970, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob *ciphertext = NULL; - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, ciphertext); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0980 - * @tc.name : Aead Decrypt, abnormal input parameters ciphertext.data is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0980, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = NULL; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0990 - * @tc.name : Aead Decrypt, abnormal input parameters ciphertext.size is less than 16 - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0990, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = NUM10; - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Decrypt key -// begin++++++++++++++++++++++++++++++++++++++++++++++++++++0760-0990 - -RUN_TEST_SUITE(SecurityDataHuksDecTestSuite); diff --git a/security_lite/huks_hal/src/security_data_huks_enc_test.c b/security_lite/huks_hal/src/security_data_huks_enc_test.c deleted file mode 100755 index 37e289b306efefd03b1b535bb7692ea2c01ce12d..0000000000000000000000000000000000000000 --- a/security_lite/huks_hal/src/security_data_huks_enc_test.c +++ /dev/null @@ -1,1337 +0,0 @@ -/* Copyright (c) 2020-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. -*/ -#include "security_data_huks.h" -#include "hctest.h" -#include "hks_client.h" -#include "hks_types.h" -#include -#include -#include -#include -#include - -/* * - * @tc.desc : register a test suite, this suite is used to test basic flow and interface dependency - * @param : subsystem name is security - * @param : module name is securityData - * @param : test suit name is securityDataHuksEncTestSuite - */ -LITE_TEST_SUIT(security, securityData, SecurityDataHuksEncTestSuite); - -/* * - * @tc.setup : setup for all testcases - * @return : setup result, TRUE is success, FALSE is fail - */ -static BOOL SecurityDataHuksEncTestSuiteSetUp(void) -{ - int32_t status; - status = hks_init(); - if (status != 0) { - status = hks_refresh_key_info(); - } - TEST_ASSERT_EQUAL_INT(0, status); - return TRUE; -} - -/* * - * @tc.teardown : teardown for all testcases - * @return : teardown result, TRUE is success, FALSE is fail - */ -static BOOL SecurityDataHuksEncTestSuiteTearDown(void) -{ - printf("-++++++++++++++++++++++++++++++++++++++++++++-\n"); - return TRUE; -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Encrypt key -// begin++++++++++++++++++++++++++++++++++++++++++++++++++++0520-0750 - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0520 - * @tc.name : Aead Encrypt, normal input parameters key, keyParam.ken_len is 128, cryptParam, plaintext, ciphertext - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0520, Function | MediumTest | Level1) -{ - char alias[] = "test_hks_aead_encrypt"; - int32_t statusEncrypt; - int32_t statusDecrypt; - - struct hks_blob key; - HksStBlobInit1(&key, 1, NUM16, HKS_BLOB_TYPE_KEY); - hks_generate_random(&key); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - struct hks_blob nonce = {0}; - HksStBlobInit1(&nonce, 1, NUM16, HKS_BLOB_TYPE_IV); - hks_generate_random(&nonce); - - struct hks_blob aad = {0}; - HksStBlobInit1(&aad, 1, NUM16, HKS_BLOB_TYPE_AAD); - hks_generate_random(&aad); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - HksStBlobInit1(&plaintext, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - hks_generate_random(&plaintext); - - struct hks_blob ciphertext; - HksStBlobInit1(&ciphertext, 1, NUM64 + HKS_SALT_MAX_SIZE, HKS_BLOB_TYPE_CIPHER_TEXT); - statusEncrypt = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(0, statusEncrypt); - - struct hks_blob decrypted; - HksStBlobInit1(&decrypted, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - statusDecrypt = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(0, statusDecrypt); - - size_t k; - for (k = 0; k < decrypted.size; k++) { - TEST_ASSERT_EQUAL_INT(plaintext.data[k], decrypted.data[k]); - } - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&nonce); - HksBlobDestroyT1(&aad); - HksBlobDestroyT1(&plaintext); - HksBlobDestroyT1(&ciphertext); - HksBlobDestroyT1(&decrypted); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0530 - * @tc.name : Aead Encrypt, normal input parameters key, keyParam.ken_len is 192, cryptParam, plaintext, ciphertext - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0530, Function | MediumTest | Level1) -{ - char alias[] = "test_hks_aead_encrypt"; - int32_t statusEncrypt; - int32_t statusDecrypt; - - struct hks_blob key; - HksStBlobInit1(&key, 1, NUM24, HKS_BLOB_TYPE_KEY); - hks_generate_random(&key); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM192; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - struct hks_blob nonce = {0}; - HksStBlobInit1(&nonce, 1, NUM16, HKS_BLOB_TYPE_IV); - hks_generate_random(&nonce); - - struct hks_blob aad = {0}; - HksStBlobInit1(&aad, 1, NUM16, HKS_BLOB_TYPE_AAD); - hks_generate_random(&aad); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - HksStBlobInit1(&plaintext, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - hks_generate_random(&plaintext); - - struct hks_blob ciphertext; - HksStBlobInit1(&ciphertext, 1, NUM64 + HKS_SALT_MAX_SIZE, HKS_BLOB_TYPE_CIPHER_TEXT); - statusEncrypt = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(0, statusEncrypt); - - struct hks_blob decrypted; - HksStBlobInit1(&decrypted, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - statusDecrypt = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(0, statusDecrypt); - - size_t k; - for (k = 0; k < decrypted.size; k++) { - TEST_ASSERT_EQUAL_INT(plaintext.data[k], decrypted.data[k]); - } - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&nonce); - HksBlobDestroyT1(&aad); - HksBlobDestroyT1(&plaintext); - HksBlobDestroyT1(&ciphertext); - HksBlobDestroyT1(&decrypted); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0540 - * @tc.name : Aead Encrypt, normal input parameters key, keyParam.ken_len is 256, cryptParam, plaintext, ciphertext - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0540, Function | MediumTest | Level1) -{ - char alias[] = "test_hks_aead_encrypt"; - int32_t statusEncrypt; - int32_t statusDecrypt; - - struct hks_blob key; - HksStBlobInit1(&key, 1, NUM32, HKS_BLOB_TYPE_KEY); - hks_generate_random(&key); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM256; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - struct hks_blob nonce = {0}; - HksStBlobInit1(&nonce, 1, NUM16, HKS_BLOB_TYPE_IV); - hks_generate_random(&nonce); - - struct hks_blob aad = {0}; - HksStBlobInit1(&aad, 1, NUM16, HKS_BLOB_TYPE_AAD); - hks_generate_random(&aad); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - HksStBlobInit1(&plaintext, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - hks_generate_random(&plaintext); - - struct hks_blob ciphertext; - HksStBlobInit1(&ciphertext, 1, NUM64 + HKS_SALT_MAX_SIZE, HKS_BLOB_TYPE_CIPHER_TEXT); - statusEncrypt = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(0, statusEncrypt); - - struct hks_blob decrypted; - HksStBlobInit1(&decrypted, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - statusDecrypt = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - TEST_ASSERT_EQUAL_INT(0, statusDecrypt); - - size_t k; - for (k = 0; k < decrypted.size; k++) { - TEST_ASSERT_EQUAL_INT(plaintext.data[k], decrypted.data[k]); - } - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&nonce); - HksBlobDestroyT1(&aad); - HksBlobDestroyT1(&plaintext); - HksBlobDestroyT1(&ciphertext); - HksBlobDestroyT1(&decrypted); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0550 - * @tc.name : Aead Encrypt, abnormal input parameters key is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0550, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob *key = NULL; - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0560 - * @tc.name : Aead Encrypt, abnormal input parameters key.size is not equal to keyParam.key_len divided by 8 - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0560, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = NUM32; - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM1006, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0570 - * @tc.name : Aead Encrypt, abnormal input parameters key.data is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0570, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = NULL; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM1006, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0580 - * @tc.name : Aead Encrypt, abnormal input parameters key.type is not equal to HKS_BLOB_TYPE_KEY - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0580, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = 0; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM1006, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0590 - * @tc.name : Aead Encrypt, abnormal input parameters keyParam is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0590, Function | MediumTest | Level2) -{ - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param *keyParam = NULL; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0600 - * @tc.name : Aead Encrypt, abnormal input parameters keyParam.key_mode is not equal to HKS_ALG_GCM - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0600, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = 0; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0610 - * @tc.name : Aead Encrypt, abnormal input parameters keyParam.key_len is not equal to 128, 192, 256 - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0610, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM11; // != 128 192 256 - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0620 - * @tc.name : Aead Encrypt, abnormal input parameters keyParam.key_type is not equal to HKS_KEY_TYPE_AES - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0620, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = 0; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0630 - * @tc.name : Aead Encrypt, abnormal input parameters keyParam.key_pad is not equal to HKS_PADDING_NONE - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0630, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = NUM88; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0640 - * @tc.name : Aead Encrypt, abnormal input parameters keyParam.key_usage - is not equal to HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0640, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = 0; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0650 - * @tc.name : Aead Encrypt, abnormal input parameters cryptParam is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0650, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param *cryptParam = NULL; - - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0660 - * @tc.name : Aead Encrypt, abnormal input parameters nonce.size is less than 12 - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0660, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = NUM10; - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0670 - * @tc.name : Aead Encrypt, abnormal input parameters nonce.data is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0670, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = NULL; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0680 - * @tc.name : Aead Encrypt, abnormal input parameters aad.size is 0 - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0680, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = 0; - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0690 - * @tc.name : Aead Encrypt, abnormal input parameters aad.data is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0690, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = NULL; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0700 - * @tc.name : Aead Encrypt, abnormal input parameters plaintext is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0700, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob *plaintext = NULL; - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0710 - * @tc.name : Aead Encrypt, abnormal input parameters plaintext.data is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0710, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = NULL; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0720 - * @tc.name : Aead Encrypt, abnormal input parameters plaintext.size is 0 - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0720, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = 0; - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0730 - * @tc.name : Aead Encrypt, abnormal input parameters ciphertext is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0730, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob *ciphertext = NULL; - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, ciphertext); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0740 - * @tc.name : Aead Encrypt, abnormal input parameters ciphertext.data is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0740, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = NULL; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0750 - * @tc.name : Aead Encrypt, abnormal input parameters ciphertext.size is less than plaintext.size minus 16 - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0750, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = NUM10; // < +16 - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Encrypt key -// end==++++++++++++++++++++++++++++++++++++++++++++++++++++0520-0750 - -RUN_TEST_SUITE(SecurityDataHuksEncTestSuite); diff --git a/security_lite/huks_hal/src/security_data_huks_export_hash_random_test.c b/security_lite/huks_hal/src/security_data_huks_export_hash_random_test.c deleted file mode 100755 index daf7db6787ec53a8e9432674f0cd0983f06b506d..0000000000000000000000000000000000000000 --- a/security_lite/huks_hal/src/security_data_huks_export_hash_random_test.c +++ /dev/null @@ -1,644 +0,0 @@ -/* Copyright (c) 2020-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. -*/ -#include "security_data_huks.h" -#include "hctest.h" -#include "hks_client.h" -#include "hks_types.h" -#include -#include -#include -#include -#include - -/* * - * @tc.desc : register a test suite, this suite is used to test basic flow and interface dependency - * @param : subsystem name is security - * @param : module name is securityData - * @param : test suit name is SecurityDataHuksExportHashRandomHmacTestSuite - */ -LITE_TEST_SUIT(security, securityData, SecurityDataHuksExportHashRandomHmacTestSuite); - -/* * - * @tc.setup : setup for all testcases - * @return : setup result, TRUE is success, FALSE is fail - */ -static BOOL SecurityDataHuksExportHashRandomHmacTestSuiteSetUp(void) -{ - int32_t status; - status = hks_init(); - if (status != 0) { - status = hks_refresh_key_info(); - } - TEST_ASSERT_EQUAL_INT(0, status); - return TRUE; -} - -/* * - * @tc.teardown : teardown for all testcases - * @return : teardown result, TRUE is success, FALSE is fail - */ -static BOOL SecurityDataHuksExportHashRandomHmacTestSuiteTearDown(void) -{ - printf("-++++++++++++++++++++++++++++++++++++++++++++-\n"); - return TRUE; -} -#ifndef _CUT_AUTHENTICATE_ -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Export Public key -// begin++++++++++++++++++++++++++++++++++++++++++++++1000-1090 - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1000 - * @tc.name : Export Public Key, normal input parameters keyAlias and publicKey - * @tc.desc : [C- SECURITY -1800] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, -securityDataExportPublicKey1000, Function | MediumTest | Level1) -{ - int32_t status; - char testFileName[] = "keyalias1"; - struct hks_blob keyAlias = { 0 }; - - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - (void)TestSecShuksGenerateKeyNormal(); - - struct hks_blob publicKey1 = { 0 }; - HksStBlobInit1(&publicKey1, 1, NUM32, HKS_BLOB_TYPE_KEY); - status = hks_export_public_key(&keyAlias, &publicKey1); - TEST_ASSERT_EQUAL_INT(0, status); - HksBlobDestroyT1(&publicKey1); - (void)TestSecShuksDeleteKeyNormal(); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1010 - * @tc.name : Export Public Key, abnormal input parameters keyAlias is null - * @tc.desc : [C- SECURITY -1800] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, -securityDataExportPublicKey1010, Function | MediumTest | Level2) -{ - int32_t status; - struct hks_blob *keyAlias = NULL; - struct hks_blob publicKey1 = { 0 }; - - publicKey1.data = (uint8_t *)malloc(NUM32); - if (publicKey1.data == NULL) { - return; - } - publicKey1.size = NUM32; - publicKey1.type = HKS_BLOB_TYPE_KEY; - - status = hks_export_public_key(keyAlias, &publicKey1); - TEST_ASSERT_EQUAL_INT(NUM1000, status); - HksBlobDestroyT1(&publicKey1); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1020 - * @tc.name : Export Public Key, abnormal input parameters keyAlias.data is null - * @tc.desc : [C- SECURITY -1800] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, -securityDataExportPublicKey1020, Function | MediumTest | Level2) -{ - int32_t status; - char testFileName[] = "Test_file_north_interfaces"; - struct hks_blob keyAlias = { 0 }; - struct hks_blob publicKey1 = { 0 }; - keyAlias.data = NULL; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - publicKey1.data = (uint8_t *)malloc(NUM32); - if (publicKey1.data == NULL) { - return; - } - publicKey1.size = NUM32; - publicKey1.type = HKS_BLOB_TYPE_KEY; - - status = hks_export_public_key(&keyAlias, &publicKey1); - TEST_ASSERT_EQUAL_INT(NUM135, status); - HksBlobDestroyT1(&publicKey1); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1030 - * @tc.name : Export Public Key, abnormal input parameters keyAlias.type is not equal to HKS_BLOB_TYPE_ALIAS - * @tc.desc : [C- SECURITY -1800] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, -securityDataExportPublicKey1030, Function | MediumTest | Level2) -{ - int32_t status; - char testFileName[] = "Test_file_north_interfaces"; - struct hks_blob keyAlias = { 0 }; - struct hks_blob publicKey1 = { 0 }; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = 0; - - publicKey1.data = (uint8_t *)malloc(NUM32); - if (publicKey1.data == NULL) { - return; - } - publicKey1.size = NUM32; - publicKey1.type = HKS_BLOB_TYPE_KEY; - - status = hks_export_public_key(&keyAlias, &publicKey1); - TEST_ASSERT_EQUAL_INT(NUM135, status); - HksBlobDestroyT1(&publicKey1); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1040 - * @tc.name : Export Public Key, abnormal input parameters keyAlias.size is 0 - * @tc.desc : [C- SECURITY -1800] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, -securityDataExportPublicKey1040, Function | MediumTest | Level2) -{ - int32_t status; - char testFileName[] = "Test_file_north_interfaces"; - struct hks_blob keyAlias = { 0 }; - struct hks_blob publicKey1 = { 0 }; - - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = 0; - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - publicKey1.data = (uint8_t *)malloc(NUM32); - if (publicKey1.data == NULL) { - return; - } - publicKey1.size = NUM32; - publicKey1.type = HKS_BLOB_TYPE_KEY; - - status = hks_export_public_key(&keyAlias, &publicKey1); - TEST_ASSERT_EQUAL_INT(NUM135, status); - HksBlobDestroyT1(&publicKey1); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1050 - * @tc.name : Export Public Key, abnormal input parameters keyAlias.size is more than 64 - * @tc.desc : [C- SECURITY -1800] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, -securityDataExportPublicKey1050, Function | MediumTest | Level2) -{ - int32_t status; - char testFileName[] = "Test_file_north_interfaces"; - struct hks_blob keyAlias = { 0 }; - struct hks_blob publicKey1 = { 0 }; - - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = NUM65; - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - publicKey1.data = (uint8_t *)malloc(NUM32); - if (publicKey1.data == NULL) { - return; - } - publicKey1.size = NUM32; - publicKey1.type = HKS_BLOB_TYPE_KEY; - - status = hks_export_public_key(&keyAlias, &publicKey1); - TEST_ASSERT_EQUAL_INT(NUM135, status); - HksBlobDestroyT1(&publicKey1); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1060 - * @tc.name : Export Public Key, abnormal input parameters publicKey is null - * @tc.desc : [C- SECURITY -1800] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, -securityDataExportPublicKey1060, Function | MediumTest | Level2) -{ - int32_t status; - char testFileName[] = "Test_file_north_interfaces"; - struct hks_blob keyAlias = { 0 }; - struct hks_blob *publicKey1 = NULL; - - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - status = hks_export_public_key(&keyAlias, publicKey1); - TEST_ASSERT_EQUAL_INT(NUM1000, status); - HksBlobDestroyT1(&keyAlias); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1070 - * @tc.name : Export Public Key, abnormal input parameters publicKey.size is less than 32 - * @tc.desc : [C- SECURITY -1800] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, -securityDataExportPublicKey1070, Function | MediumTest | Level2) -{ - int32_t status; - char testFileName[] = "Test_file_north_interfaces"; - struct hks_blob keyAlias = { 0 }; - struct hks_blob publicKey1 = { 0 }; - - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - publicKey1.data = (uint8_t *)malloc(NUM31); - if (publicKey1.data == NULL) { - return; - } - publicKey1.size = NUM31; - publicKey1.type = HKS_BLOB_TYPE_KEY; - - status = hks_export_public_key(&keyAlias, &publicKey1); - TEST_ASSERT_EQUAL_INT(NUM1007, status); - HksBlobDestroyT1(&publicKey1); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1080 - * @tc.name : Export Public Key, abnormal input parameters publicKey.data is null - * @tc.desc : [C- SECURITY -1800] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, -securityDataExportPublicKey1080, Function | MediumTest | Level2) -{ - int32_t status; - char testFileName[] = "Test_file_north_interfaces"; - struct hks_blob keyAlias = { 0 }; - struct hks_blob publicKey1 = { 0 }; - - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - publicKey1.data = NULL; - publicKey1.size = NUM32; - publicKey1.type = HKS_BLOB_TYPE_KEY; - - status = hks_export_public_key(&keyAlias, &publicKey1); - TEST_ASSERT_EQUAL_INT(NUM1007, status); - HksBlobDestroyT1(&publicKey1); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1090 - * @tc.name : Export Public Key, the key does not exist - * @tc.desc : [C- SECURITY -1800] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, -securityDataExportPublicKey1090, Function | MediumTest | Level2) -{ - int32_t status; - char testFileName[] = "Test_file_north_interfaces"; - struct hks_blob keyAlias = { 0 }; - struct hks_blob publicKey1 = { 0 }; - - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - publicKey1.data = (uint8_t *)malloc(NUM32); - if (publicKey1.data == NULL) { - return; - } - publicKey1.size = NUM32; - publicKey1.type = HKS_BLOB_TYPE_KEY; - - status = hks_export_public_key(&keyAlias, &publicKey1); - TEST_ASSERT_EQUAL_INT(NUM1010, status); - HksBlobDestroyT1(&publicKey1); -} -#endif - -#ifndef _CUT_AUTHENTICATE_ -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Export Public key -// end++++++++++++++++++++++++++++++++++++++++++++++++1000-1090 - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Hash -// begin+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++1100-1190 - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1100 - * @tc.name : Hash, normal input parameters SHA256, src, dst - * @tc.desc : [C- SOFTWARE -0200] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, securityDataHash1100, Function | MediumTest | Level1) -{ - struct hks_blob src, dst; - src.data = (uint8_t *)"123456"; - src.size = NUM6; - dst.data = (uint8_t *)malloc(NUM65); - if (dst.data == NULL) { - return; - } - dst.size = NUM65; - - int32_t res = hks_hash(HKS_ALG_HASH_SHA_256, &src, &dst); - TEST_ASSERT_EQUAL_INT(0, res); - free(dst.data); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1110 - * @tc.name : Hash, normal input parameters SHA512, src, dst - * @tc.desc : [C- SOFTWARE -0200] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, securityDataHash1110, Function | MediumTest | Level1) -{ - struct hks_blob src, dst; - src.data = (uint8_t *)"123456"; - src.size = NUM6; - dst.data = (uint8_t *)malloc(NUM65); - if (dst.data == NULL) { - return; - } - dst.size = NUM65; - - int32_t res = hks_hash(HKS_ALG_HASH_SHA_512, &src, &dst); - TEST_ASSERT_EQUAL_INT(0, res); - free(dst.data); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1120 - * @tc.name : Hash, normal input parameters alg is not equal to HKS_ALG_HASH_SHA_256 or HKS_ALG_HASH_SHA_512 - * @tc.desc : [C- SOFTWARE -0200] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, securityDataHash1120, Function | MediumTest | Level2) -{ - struct hks_blob srcData = { 0 }; - const char tmpData6[] = "30313233343536373839616263646566"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM16, 0); - - struct hks_blob hash = { 0 }; - const char tmpData7[] = "3031323334353637383961626364656630313233343536373839616263646566"; - BuildBlobData(&hash, tmpData7, HKS_BLOB_TYPE_RAW, NUM32, 0); - - uint32_t alg = HKS_ALG_HASH_SHA_1; - int32_t status = hks_hash(alg, &srcData, &hash); - HksBlobDestroyT1(&srcData); - HksBlobDestroyT1(&hash); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1130 - * @tc.name : Hash, normal input parameters srcData is null - * @tc.desc : [C- SOFTWARE -0200] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, securityDataHash1130, Function | MediumTest | Level2) -{ - struct hks_blob *srcData = NULL; - - struct hks_blob hash = { 0 }; - const char tmpData7[] = "3031323334353637383961626364656630313233343536373839616263646566"; - BuildBlobData(&hash, tmpData7, HKS_BLOB_TYPE_RAW, NUM32, 0); - - uint32_t alg = HKS_ALG_HASH_SHA_256; - int32_t status = hks_hash(alg, srcData, &hash); - HksBlobDestroyT1(&hash); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1140 - * @tc.name : Hash, normal input parameters srcData.data is null - * @tc.desc : [C- SOFTWARE -0200] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, securityDataHash1140, Function | MediumTest | Level2) -{ - struct hks_blob srcData = { 0 }; - const char tmpData6[] = "30313233343536373839616263646566"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM16, 1); - - struct hks_blob hash = { 0 }; - const char tmpData7[] = "3031323334353637383961626364656630313233343536373839616263646566"; - BuildBlobData(&hash, tmpData7, HKS_BLOB_TYPE_RAW, NUM32, 0); - - uint32_t alg = HKS_ALG_HASH_SHA_256; - int32_t status = hks_hash(alg, &srcData, &hash); - HksBlobDestroyT1(&srcData); - HksBlobDestroyT1(&hash); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1150 - * @tc.name : Hash, normal input parameters srcData.size is 0 - * @tc.desc : [C- SOFTWARE -0200] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, securityDataHash1150, Function | MediumTest | Level2) -{ - struct hks_blob srcData = { 0 }; - srcData.data = (uint8_t *)"1234567890abcdefghigkl0123456789"; - srcData.size = 0; - srcData.type = HKS_BLOB_TYPE_RAW; - - struct hks_blob hash = { 0 }; - const char tmpData7[] = "3031323334353637383961626364656630313233343536373839616263646566"; - BuildBlobData(&hash, tmpData7, HKS_BLOB_TYPE_RAW, NUM32, 0); - - uint32_t alg = HKS_ALG_HASH_SHA_256; - int32_t status = hks_hash(alg, &srcData, &hash); - HksBlobDestroyT1(&hash); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1160 - * @tc.name : Hash, normal input parameters hash is null - * @tc.desc : [C- SOFTWARE -0200] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, securityDataHash1160, Function | MediumTest | Level2) -{ - struct hks_blob srcData = { 0 }; - const char tmpData6[] = "30313233343536373839616263646566"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM16, 0); - - struct hks_blob *hash = NULL; - - uint32_t alg = HKS_ALG_HASH_SHA_256; - int32_t status = hks_hash(alg, &srcData, hash); - HksBlobDestroyT1(&srcData); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1170 - * @tc.name : Hash, normal input parameters hash.data is null - * @tc.desc : [C- SOFTWARE -0200] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, securityDataHash1170, Function | MediumTest | Level2) -{ - struct hks_blob srcData = { 0 }; - const char tmpData6[] = "30313233343536373839616263646566"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM16, 0); - - struct hks_blob hash = { 0 }; - const char tmpData7[] = "3031323334353637383961626364656630313233343536373839616263646566"; - BuildBlobData(&hash, tmpData7, HKS_BLOB_TYPE_RAW, NUM32, 1); - - uint32_t alg = HKS_ALG_HASH_SHA_256; - int32_t status = hks_hash(alg, &srcData, &hash); - HksBlobDestroyT1(&srcData); - HksBlobDestroyT1(&hash); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1180 - * @tc.name : Hash, normal input parameters hash.size is less than 32 - * @tc.desc : [C- SOFTWARE -0200] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, securityDataHash1180, Function | MediumTest | Level2) -{ - struct hks_blob srcData = { 0 }; - const char tmpData6[] = "30313233343536373839616263646566"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM16, 0); - - struct hks_blob hash = { 0 }; - const char tmpData7[] = "303132333435363738396162636465663031323334353637383961626361"; - BuildBlobData(&hash, tmpData7, HKS_BLOB_TYPE_RAW, NUM30, 0); - - uint32_t alg = HKS_ALG_HASH_SHA_256; - int32_t status = hks_hash(alg, &srcData, &hash); - HksBlobDestroyT1(&srcData); - HksBlobDestroyT1(&hash); - TEST_ASSERT_EQUAL_INT(NUM1007, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1190 - * @tc.name : Hash, normal input parameters hash.size is less than 64 - * @tc.desc : [C- SOFTWARE -0200] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, securityDataHash1190, Function | MediumTest | Level2) -{ - struct hks_blob srcData = { 0 }; - const char tmpData6[] = "30313233343536373839616263646566"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM16, 0); - - struct hks_blob hash = { 0 }; - const char tmpData7[] = "3031323334353637383961626364656630313233343536373839616263613031323334353637383961626" - "36465663031323334353637383961626361"; - BuildBlobData(&hash, tmpData7, HKS_BLOB_TYPE_RAW, NUM60, 0); - - uint32_t alg = HKS_ALG_HASH_SHA_512; - int32_t status = hks_hash(alg, &srcData, &hash); - HksBlobDestroyT1(&srcData); - HksBlobDestroyT1(&hash); - TEST_ASSERT_EQUAL_INT(NUM1007, status); -} -#endif -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Hash -// end+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++1100-1190 - - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Generate random -// beign++++++++++++++++++++++++++++++++++++++++++++++++1200-1230 - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1200 - * @tc.name : Generate Random, normal input parameters random - * @tc.desc : [C- SECURITY -1700] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, -securityDataGenerateRandom1200, Function | MediumTest | Level1) -{ - int32_t statusFirst; - int32_t statusSecond; - struct hks_blob randomFirst = { 0 }; - struct hks_blob randomSecond = { 0 }; - - HksStBlobInit1(&randomFirst, 1, NUM64, 0); - HksStBlobInit1(&randomSecond, 1, NUM64, 0); - statusFirst = hks_generate_random(&randomFirst); - statusSecond = hks_generate_random(&randomSecond); - TEST_ASSERT_EQUAL_INT(0, statusFirst); - TEST_ASSERT_EQUAL_INT(0, statusSecond); - TEST_ASSERT_NOT_EQUAL(randomFirst.data, randomSecond.data); - - HksBlobDestroyT1(&randomFirst); - HksBlobDestroyT1(&randomSecond); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1210 - * @tc.name : Generate Random, normal input parameters random is null - * @tc.desc : [C- SECURITY -1700] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, -securityDataGenerateRandom1210, Function | MediumTest | Level2) -{ - int32_t status; - struct hks_blob *random = NULL; - - status = hks_generate_random(random); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1220 - * @tc.name : Generate Random, normal input parameters random.data is null - * @tc.desc : [C- SECURITY -1700] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, -securityDataGenerateRandom1220, Function | MediumTest | Level2) -{ - int32_t status; - struct hks_blob random = { 0 }; - - random.data = NULL; - random.size = NUM32; - random.type = HKS_BLOB_TYPE_KEY; - - status = hks_generate_random(&random); - TEST_ASSERT_EQUAL_INT(NUM1000, status); - HksBlobDestroyT1(&random); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_1230 - * @tc.name : Generate Random, normal input parameters random.size is more than 1024 - * @tc.desc : [C- SECURITY -1700] - */ -LITE_TEST_CASE(SecurityDataHuksExportHashRandomHmacTestSuite, -securityDataGenerateRandom1230, Function | MediumTest | Level2) -{ - int32_t status; - struct hks_blob random = { 0 }; - - random.data = (uint8_t *)malloc(NUM1025); - if (random.data == NULL) { - return; - } - random.size = NUM1025; - random.type = HKS_BLOB_TYPE_KEY; - - status = hks_generate_random(&random); - TEST_ASSERT_EQUAL_INT(NUM135, status); - HksBlobDestroyT1(&random); -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Generate random -// end++++++++++++++++++++++++++++++++++++++++++++++++++1200-1230 - -RUN_TEST_SUITE(SecurityDataHuksExportHashRandomHmacTestSuite); diff --git a/security_lite/huks_hal/src/security_data_huks_gen_del_test.c b/security_lite/huks_hal/src/security_data_huks_gen_del_test.c deleted file mode 100755 index e5563540cbe216490aa7ef680f206596e6adbf3d..0000000000000000000000000000000000000000 --- a/security_lite/huks_hal/src/security_data_huks_gen_del_test.c +++ /dev/null @@ -1,844 +0,0 @@ -/* Copyright (c) 2020-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. -*/ -#include "security_data_huks.h" -#include "hctest.h" -#include "hks_client.h" -#include "hks_types.h" -#include "securec.h" -#include -#include -#include -#include -#include - -void HksStBlobInit1(struct hks_blob *blob, size_t nmemb, size_t size, uint8_t type) -{ - if (blob == NULL || nmemb == 0 || size == 0) { - TEST_ASSERT_EQUAL_INT(0, 1); - return; - } - blob->data = (uint8_t *)calloc(nmemb, size); - if (blob->data == NULL) { - TEST_ASSERT_EQUAL_INT(0, 1); - return; - } - if (memset_s(blob->data, size, 0, size) != EOK) { - TEST_ASSERT_EQUAL_INT(0, 1); - } - blob->size = size; - blob->type = type; -} -void HksBlobDestroyT1(struct hks_blob *blob) -{ - if (blob == NULL) { - return; - } - if (blob && blob->data) { - memset_s(blob->data, blob->size, 0, blob->size); - HKS_FREE_PTR1(blob->data); - } - blob->data = NULL; - blob->size = 0; - blob->type = HKS_BLOB_TYPE_RAW; -} -int TestSecShuksGenerateKeyNormal(void) -{ -#ifndef _CUT_AUTHENTICATE_ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - struct hks_blob keyAlias; - - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - int32_t status = hks_generate_key(&keyAlias, &keyParam); - TEST_ASSERT_EQUAL_INT(0, status); -#endif - return 0; -} -int TestSecShuksDeleteKeyNormal(void) -{ -#ifndef _CUT_AUTHENTICATE_ - char testFileName[] = "keyalias1"; - struct hks_blob keyAlias = { 0 }; - - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - int32_t status = hks_delete_key(&keyAlias); - TEST_ASSERT_EQUAL_INT(0, status); -#endif - return 0; -} -int TestSecShuksExportPublicNormal(struct hks_blob *keyAlias, struct hks_blob *publicKey1) -{ -#ifndef _CUT_AUTHENTICATE_ - int32_t status = hks_export_public_key(keyAlias, publicKey1); - TEST_ASSERT_EQUAL_INT(0, status); -#endif - return 0; -} -void BuildBlobData(struct hks_blob *param, const char *str, uint8_t type, uint32_t size, uint8_t isDataNull) -{ - if (param == NULL) { - TEST_ASSERT_EQUAL_INT(0, 1); - return; - } - param->type = type; - param->size = size; - if (isDataNull == NUM1) { - param->data = NULL; - } else { - if (size == 0) { - return; - } - unsigned char *buff = (unsigned char *)malloc(size + NUM2); - if (buff == NULL) { - return; - } - memset_s(buff, size + NUM2, 0, size + NUM2); - HexStringToByte(str, size * NUM2, buff); - param->data = (uint8_t *)buff; - } -} -void HexStringToByte(const char *str, int nLen, unsigned char *pHex) -{ - unsigned int number = 4; - if (pHex == NULL) { - TEST_ASSERT_EQUAL_INT(0, 1); - return; - } - if (nLen % NUM2) { - TEST_ASSERT_EQUAL_INT(0, 1); - } - int nHexLen = nLen / NUM2; - unsigned char nibble[2]; - if (nHexLen >= MAX_INT) { - TEST_ASSERT_EQUAL_INT(0, 1); - return; - } - for (int i = 0; i < nHexLen; i++) { - nibble[0] = str[i * NUM2]; - nibble[1] = str[i * NUM2 + NUM1]; - for (int j = 0; j < NUM2; j++) { - if (nibble[j] <= 'F' && nibble[j] >= 'A') { - nibble[j] = nibble[j] - 'A' + NUM10; - } else if (nibble[j] <= 'f' && nibble[j] >= 'a') { - nibble[j] = nibble[j] - 'a' + NUM10; - } else if (nibble[j] >= '0' && nibble[j] <= '9') { - nibble[j] = nibble[j] - '0'; - } else { - TEST_ASSERT_EQUAL_INT(0, 1); - } - } - pHex[i] = nibble[0] << number; - pHex[i] |= nibble[1]; - } -} - -void TestInitKeyParam1(struct hks_key_param *keyParam, uint32_t keyType, uint32_t keyLen, uint32_t keyMode, - uint32_t keyUsage) -{ - if (keyParam == NULL) { - TEST_ASSERT_EQUAL_INT(0, 1); - return; - } - keyParam->key_type = keyType; - keyParam->key_len = keyLen; - keyParam->key_pad = HKS_PADDING_NONE; - keyParam->key_mode = keyMode; - keyParam->key_domain = HKS_ECC_CURVE_ED25519; - keyParam->key_usage = keyUsage; - - const char tmpData1[] = "111111"; - BuildBlobData(&keyParam->key_auth_id, tmpData1, HKS_BLOB_TYPE_AUTH_ID, NUM3, 0); -} - -int TestSecShuksImportPublicNormal(void) -{ -#ifndef _CUT_AUTHENTICATE_ - char testFileName[] = "keyalias1"; - struct hks_key_param keyParam1 = { 0 }; - - keyParam1.key_type = HKS_KEY_TYPE_EDDSA_PUBLIC_KEY_ED25519; - keyParam1.key_len = NUM256; - keyParam1.key_usage = NUM3; - keyParam1.key_pad = NUM4; - keyParam1.key_mode = NUM5; - keyParam1.key_role = NUM6; - keyParam1.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam1.key_auth_id.data = (uint8_t *)testFileName; - keyParam1.key_auth_id.size = sizeof(testFileName); - - struct hks_blob publicKey1 = { 0 }; - HksStBlobInit1(&publicKey1, NUM1, NUM32, HKS_BLOB_TYPE_KEY); - - struct hks_blob keyAlias; - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - - int32_t status = hks_import_public_key(&keyAlias, &keyParam1, &publicKey1); - TEST_ASSERT_EQUAL_INT(0, status); - - HksBlobDestroyT1(&publicKey1); -#endif - return 0; -} - -/* * - * @tc.desc : register a test suite, this suite is used to test basic flow and interface dependency - * @param : subsystem name is security - * @param : module name is securityData - * @param : test suit name is SecurityDataHuksGenDelTestSuite - */ -LITE_TEST_SUIT(security, securityData, SecurityDataHuksGenDelTestSuite); - -/* * - * @tc.setup : setup for all testcases - * @return : setup result, TRUE is success, FALSE is fail - */ -static BOOL SecurityDataHuksGenDelTestSuiteSetUp(void) -{ - int32_t status; - status = hks_init(); - if (status != 0) { - status = hks_refresh_key_info(); - } - TEST_ASSERT_EQUAL_INT(0, status); - return TRUE; -} - -/* * - * @tc.teardown : teardown for all testcases - * @return : teardown result, TRUE is success, FALSE is fail - */ -static BOOL SecurityDataHuksGenDelTestSuiteTearDown(void) -{ - printf("-++++++++++++++++++++++++++++++++++++++++++++-\n"); - return TRUE; -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++generate key -// begin+++++++++++++++++++++++++++++++++++++++++++++++++++0000-0120 - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL0_0000 - * @tc.name : Generate key, normal input parameters keyAlias and keyParam - * @tc.desc : [C- SECURITY -1400] - */ -#ifndef _CUT_AUTHENTICATE_ -LITE_TEST_CASE(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0000, Function | MediumTest | Level1) -{ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - int32_t statusGenerate; - int32_t statusDelete; - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - struct hks_blob keyAliasGenerate; - HksStBlobInit1(&keyAliasGenerate, sizeof(uint8_t), sizeof(testFileName) + NUM3, HKS_BLOB_TYPE_ALIAS); - if (memcpy_s(keyAliasGenerate.data, sizeof(testFileName), testFileName, sizeof(testFileName)) != EOK) { - HksBlobDestroyT1(&keyAliasGenerate); - TEST_FAIL(); - return; - } - char tmpGenerate[3] = { 0 }; - if (strcat_s((char *)keyAliasGenerate.data, - strlen((char *)keyAliasGenerate.data) + strlen(tmpGenerate) + 1, - tmpGenerate) != EOK) { - HksBlobDestroyT1(&keyAliasGenerate); - TEST_FAIL(); - return; - } - keyAliasGenerate.size = strlen((char *)keyAliasGenerate.data); - statusGenerate = hks_generate_key(&keyAliasGenerate, &keyParam); - TEST_ASSERT_EQUAL_INT(0, statusGenerate); - HksBlobDestroyT1(&keyAliasGenerate); - struct hks_blob keyAliasDelete; - HksStBlobInit1(&keyAliasDelete, sizeof(uint8_t), sizeof(testFileName) + NUM3, HKS_BLOB_TYPE_ALIAS); - if (memcpy_s(keyAliasDelete.data, sizeof(testFileName), testFileName, sizeof(testFileName)) != EOK) { - HksBlobDestroyT1(&keyAliasDelete); - TEST_FAIL(); - return; - } - char tmpDelete[3] = { 0 }; - if (strcat_s((char *)keyAliasDelete.data, - strlen((char *)keyAliasDelete.data) + strlen(tmpDelete) + 1, - tmpDelete) != EOK) { - HksBlobDestroyT1(&keyAliasDelete); - TEST_FAIL(); - return; - } - keyAliasDelete.size = strlen((char *)keyAliasDelete.data); - statusDelete = hks_delete_key(&keyAliasDelete); - TEST_ASSERT_EQUAL_INT(0, statusDelete); - HksBlobDestroyT1(&keyAliasDelete); -}; - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL0_0010 - * @tc.name : Generate key, abnormal input parameters keyAlias is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0010, Function | MediumTest | Level2) -{ - char testFileName1[] = "key_auth_id1"; - struct hks_blob *keyAlias = NULL; - int32_t status; - - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - - status = hks_generate_key(keyAlias, &keyParam); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL0_0020 - * @tc.name : Generate key, abnormal input parameters keyAlias.size is 0 - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0020, Function | MediumTest | Level2) -{ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - struct hks_blob keyAlias; - int32_t status; - - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = 0; - - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - - status = hks_generate_key(&keyAlias, &keyParam); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL0_0030 - * @tc.name : Generate key, abnormal input parameters keyAlias.size is more than 64 - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0030, Function | MediumTest | Level2) -{ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - struct hks_blob keyAlias; - int32_t status; - - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = NUM65; - - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - - status = hks_generate_key(&keyAlias, &keyParam); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL0_0040 - * @tc.name : Generate key, abnormal input parameters keyAlias.type is not equal to HKS_BLOB_TYPE_ALIAS - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0040, Function | MediumTest | Level2) -{ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - struct hks_blob keyAlias; - int32_t status; - - keyAlias.type = 0; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - - status = hks_generate_key(&keyAlias, &keyParam); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL0_0050 - * @tc.name : Generate key, abnormal input parameters keyAlias.data is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0050, Function | MediumTest | Level2) -{ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - struct hks_blob keyAlias; - int32_t status; - - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - keyAlias.data = NULL; - keyAlias.size = sizeof(testFileName); - - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - - status = hks_generate_key(&keyAlias, &keyParam); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL0_0060 - * @tc.name : Generate key, abnormal input parameters keyParam is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0060, Function | MediumTest | Level2) -{ - char testFileName[] = "keyalias1"; - struct hks_blob keyAlias; - int32_t status; - - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - - struct hks_key_param *keyParam = NULL; - - status = hks_generate_key(&keyAlias, keyParam); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL0_0070 - * @tc.name : Generate key, abnormal input parameters keyParam.key_type - is not equal to HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519 - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0070, Function | MediumTest | Level2) -{ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - struct hks_blob keyAlias; - int32_t status; - - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = NUM1; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - - status = hks_generate_key(&keyAlias, &keyParam); - TEST_ASSERT_EQUAL_INT(NUM134, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL0_0080 - * @tc.name : Generate key, abnormal input parameters keyParam.key_auth_id.size is 0 - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0080, Function | MediumTest | Level2) -{ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - struct hks_blob keyAlias; - int32_t status; - - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = 0; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - - status = hks_generate_key(&keyAlias, &keyParam); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL0_0090 - * @tc.name : Generate key, abnormal input parameters keyParam.key_auth_id.size is more than 64 - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0090, Function | MediumTest | Level2) -{ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - struct hks_blob keyAlias; - int32_t status; - - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = NUM65; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - - status = hks_generate_key(&keyAlias, &keyParam); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL0_0100 - * @tc.name : Generate key, abnormal input parameters keyParam.key_auth_id.type - is not equal to HKS_BLOB_TYPE_AUTHID - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0100, Function | MediumTest | Level2) -{ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - struct hks_blob keyAlias; - int32_t status; - - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = 0; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - - status = hks_generate_key(&keyAlias, &keyParam); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL0_0110 - * @tc.name : Generate key, abnormal input parameters keyParam.key_auth_id.data is null - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0110, Function | MediumTest | Level2) -{ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - struct hks_blob keyAlias; - int32_t status; - - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - - struct hks_key_param keyParam; - keyParam.key_auth_id.data = NULL; - keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - - status = hks_generate_key(&keyAlias, &keyParam); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL0_0120 - * @tc.name : Generate key, the number of stored keys is more than 20 - * @tc.desc : [C- SECURITY -1400] - */ -LITE_TEST_CASE(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0120, Function | MediumTest | Level2) -{ - int status; - char testFileName[] = "keyalias1", testFileName1[] = "key_auth_id1"; - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t*)testFileName1; keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; keyParam.key_usage = 0; keyParam.key_pad = 0; - for (int j = 0; j < NUM21; j++) { - struct hks_blob keyAlias; - HksStBlobInit1(&keyAlias, sizeof(uint8_t), sizeof(testFileName) + NUM3, HKS_BLOB_TYPE_ALIAS); - if (memcpy_s(keyAlias.data, sizeof(testFileName), testFileName, sizeof(testFileName)) != EOK) { - HksBlobDestroyT1(&keyAlias); TEST_FAIL(); - return; - } - char tmp[3] = { 0 }; - sprintf_s(tmp, sizeof(tmp), "%d", j); - if (strcat_s((char*)keyAlias.data, strlen((char*)keyAlias.data) + strlen(tmp) + 1, tmp) != EOK){ - HksBlobDestroyT1(&keyAlias); TEST_FAIL(); - return; - } - keyAlias.size = strlen((char*)keyAlias.data); - status = hks_generate_key(&keyAlias, &keyParam); - if (j < NUM20){ - TEST_ASSERT_EQUAL_INT(0, status); - } - else { - TEST_ASSERT_EQUAL_INT(NUM142, status); - } - HksBlobDestroyT1(&keyAlias); - } - for (int j = 0; j < NUM20; j++) { - struct hks_blob keyAlias; - HksStBlobInit1(&keyAlias, sizeof(uint8_t), sizeof(testFileName) + NUM3, HKS_BLOB_TYPE_ALIAS); - if (memcpy_s(keyAlias.data, sizeof(testFileName), testFileName, sizeof(testFileName)) != EOK) { - HksBlobDestroyT1(&keyAlias); TEST_FAIL(); - return; - } - char tmp[3] = { 0 }; - sprintf_s(tmp, sizeof(tmp), "%d", j); - if (strcat_s((char*)keyAlias.data, strlen((char*)keyAlias.data) + strlen(tmp) + 1, tmp) != EOK) { - HksBlobDestroyT1(&keyAlias); TEST_FAIL(); - return; - } - keyAlias.size = strlen((char*)keyAlias.data); - status = hks_delete_key(&keyAlias); - TEST_ASSERT_EQUAL_INT(0, status); - HksBlobDestroyT1(&keyAlias); - } -} - - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++generate key -// end+++++++++++++++++++++++++++++++++++++++++++++++++++++0000-0120 - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Delete key -// begin+++++++++++++++++++++++++++++++++++++++++++++++++++++0130-0190 -/* * - * @tc.number : SUB_SEC_DataPro_HuksL0_0130 - * @tc.name : Delete key, normal input parameters keyAlias and keyParam - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksGenDelTestSuite, securityDataDeleteKey0130, Function | MediumTest | Level1) -{ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - int32_t statusGenerate; - int32_t statusDelete; - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - struct hks_blob keyAliasGenerate; - HksStBlobInit1(&keyAliasGenerate, sizeof(uint8_t), sizeof(testFileName) + NUM3, HKS_BLOB_TYPE_ALIAS); - if (memcpy_s(keyAliasGenerate.data, sizeof(testFileName), testFileName, sizeof(testFileName)) != EOK) { - HksBlobDestroyT1(&keyAliasGenerate); - TEST_FAIL(); - return; - } - char tmpGenerate[3] = { 0 }; - if (strcat_s((char *)keyAliasGenerate.data, - strlen((char *)keyAliasGenerate.data) + strlen(tmpGenerate) + 1, - tmpGenerate) != EOK) { - HksBlobDestroyT1(&keyAliasGenerate); - TEST_FAIL(); - return; - } - keyAliasGenerate.size = strlen((char *)keyAliasGenerate.data); - statusGenerate = hks_generate_key(&keyAliasGenerate, &keyParam); - TEST_ASSERT_EQUAL_INT(0, statusGenerate); - HksBlobDestroyT1(&keyAliasGenerate); - struct hks_blob keyAliasDelete; - HksStBlobInit1(&keyAliasDelete, sizeof(uint8_t), sizeof(testFileName) + NUM3, HKS_BLOB_TYPE_ALIAS); - if (memcpy_s(keyAliasDelete.data, sizeof(testFileName), testFileName, sizeof(testFileName)) != EOK) { - HksBlobDestroyT1(&keyAliasDelete); - TEST_FAIL(); - return; - } - char tmpDelete[3] = { 0 }; - if (strcat_s((char *)keyAliasDelete.data, - strlen((char *)keyAliasDelete.data) + strlen(tmpDelete) + 1, - tmpDelete) != EOK) { - HksBlobDestroyT1(&keyAliasDelete); - TEST_FAIL(); - return; - } - keyAliasDelete.size = strlen((char *)keyAliasDelete.data); - statusDelete = hks_delete_key(&keyAliasDelete); - TEST_ASSERT_EQUAL_INT(0, statusDelete); - HksBlobDestroyT1(&keyAliasDelete); -}; - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL0_0140 - * @tc.name : Delete key, abnormal input parameters keyAlias is null - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksGenDelTestSuite, securityDataDeleteKey0140, Function | MediumTest | Level2) -{ - int32_t status; - struct hks_blob *keyAlias = NULL; - - status = hks_delete_key(keyAlias); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL0_0150 - * @tc.name : Delete key, abnormal input parameters keyAlias.data is null - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksGenDelTestSuite, securityDataDeleteKey0150, Function | MediumTest | Level2) -{ - int32_t status; - char testFileName[] = "Test_file_north_interfaces"; - struct hks_blob keyAlias = { 0 }; - - keyAlias.data = NULL; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - status = hks_delete_key(&keyAlias); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL0_0160 - * @tc.name : Delete key, abnormal input parameters keyAlias.type is not equal to HKS_BLOB_TYPE_ALIAS - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksGenDelTestSuite, securityDataDeleteKey0160, Function | MediumTest | Level2) -{ - int32_t status; - char testFileName[] = "Test_file_north_interfaces"; - struct hks_blob keyAlias = { 0 }; - - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = 0; - - status = hks_delete_key(&keyAlias); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} -/* * - * @tc.number : SUB_SEC_DataPro_HuksL0_0170 - * @tc.name : Delete key, abnormal input parameters keyAlias.size is 0 - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksGenDelTestSuite, securityDataDeleteKey0170, Function | MediumTest | Level2) -{ - int32_t status; - char testFileName[] = "Test_file_north_interfaces"; - struct hks_blob keyAlias = { 0 }; - - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = 0; - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - status = hks_delete_key(&keyAlias); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} -/* * - * @tc.number : SUB_SEC_DataPro_HuksL0_0180 - * @tc.name : Delete key, abnormal input parameters keyAlias.size is more than 64 - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksGenDelTestSuite, securityDataDeleteKey0180, Function | MediumTest | Level2) -{ - int32_t status; - char testFileName[] = "Test_file_north_interfaces"; - struct hks_blob keyAlias = { 0 }; - - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = NUM65; - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - status = hks_delete_key(&keyAlias); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL0_0190 - * @tc.name : Delete key, the key does not exist - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksGenDelTestSuite, securityDataDeleteKey0190, Function | MediumTest | Level2) -{ - int32_t status; - char testFileName[] = "Test_file_north_interfaces"; - struct hks_blob keyAlias = { 0 }; - - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - status = hks_delete_key(&keyAlias); - TEST_ASSERT_EQUAL_INT(NUM1010, status); -} -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Delete key -// end+++++++++++++++++++++++++++++++++++++++++++++++++++++++0130-0190 -#endif -RUN_TEST_SUITE(SecurityDataHuksGenDelTestSuite); diff --git a/security_lite/huks_hal/src/security_data_huks_sign_verify_test.c b/security_lite/huks_hal/src/security_data_huks_sign_verify_test.c deleted file mode 100755 index aedc6983fe99eae8362a7fedce20e30005ba82f3..0000000000000000000000000000000000000000 --- a/security_lite/huks_hal/src/security_data_huks_sign_verify_test.c +++ /dev/null @@ -1,1274 +0,0 @@ -/* Copyright (c) 2020-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. -*/ -#include "security_data_huks.h" -#include "hctest.h" -#include "hks_client.h" -#include "hks_types.h" -#include -#include -#include -#include -#include - -/* * - * @tc.desc : register a test suite, this suite is used to test basic flow and interface dependency - * @param : subsystem name is security - * @param : module name is securityData - * @param : test suit name is SecurityDataHuksSignVerifyTestSuite - */ -LITE_TEST_SUIT(security, securityData, SecurityDataHuksSignVerifyTestSuite); - -/* * - * @tc.setup : setup for all testcases - * @return : setup result, TRUE is success, FALSE is fail - */ -static BOOL SecurityDataHuksSignVerifyTestSuiteSetUp(void) -{ - int32_t status; - status = hks_init(); - if (status != 0) { - status = hks_refresh_key_info(); - } - TEST_ASSERT_EQUAL_INT(0, status); - return TRUE; -} - -/* * - * @tc.teardown : teardown for all testcases - * @return : teardown result, TRUE is success, FALSE is fail - */ -static BOOL SecurityDataHuksSignVerifyTestSuiteTearDown(void) -{ - printf("-++++++++++++++++++++++++++++++++++++++++++++-\n"); - return TRUE; -} -#ifndef _CUT_AUTHENTICATE_ -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Sign key -// begin+++++++++++++++++++++++++++++++++++++++++++++++++++++++0200-0340 - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0200 - * @tc.name : Asymmetric Sign, normal input parameters keyAlias, keyParam, hash, signature - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricSign0200, Function | MediumTest | Level2) -{ - int32_t statusAsymmetricSign; - int32_t statusAsymmetricVerify; - unsigned char testFileName[] = "keyalias1"; - struct hks_blob keyAlias = { 0 }; - - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32]; - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - uint32_t alg = HKS_ALG_HASH_SHA_256; - struct hks_blob src; - src.data = (uint8_t *)"123456"; - src.size = NUM6; - int32_t status = hks_hash(alg, &src, &hash); - TEST_ASSERT_EQUAL_INT(0, status); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - (void)TestSecShuksGenerateKeyNormal(); - struct hks_blob signature = { 0 }; - HksStBlobInit1(&signature, 1, NUM64, 0); - statusAsymmetricSign = hks_asymmetric_sign(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(0, statusAsymmetricSign); - - statusAsymmetricVerify = hks_asymmetric_verify(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(0, statusAsymmetricVerify); - - HksBlobDestroyT1(&signature); - (void)TestSecShuksDeleteKeyNormal(); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0210 - * @tc.name : Asymmetric Sign, abnormal input parameters keyAlias is null - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricSign0210, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[] = "test_ed25519_6"; - struct hks_blob *keyAlias = NULL; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - - status = hks_asymmetric_sign(keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0220 - * @tc.name : Asymmetric Sign, abnormal input parameters keyAlias.data is null - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricSign0220, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[] = "test_ed25519_6"; - struct hks_blob keyAlias; - keyAlias.data = NULL; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_sign(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0230 - * @tc.name : Asymmetric Sign, abnormal input parameters keyAlias.size is 0 - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricSign0230, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[] = "test_ed25519_6"; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = 0; - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_sign(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0240 - * @tc.name : Asymmetric Sign, abnormal input parameters keyAlias.size is more than 64 - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricSign0240, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[] = "test_ed25519_6"; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = NUM65; - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_sign(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0250 - * @tc.name : Asymmetric Sign, abnormal input parameters keyAlias.type is not equal to HKS_BLOB_TYPE_ALIAS - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricSign0250, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[] = "test_ed25519_6"; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = 0; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_sign(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0260 - * @tc.name : Asymmetric Sign, abnormal input parameters keyParam is null - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricSign0260, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[] = "test_ed25519_6"; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param *keyParam = NULL; - - status = hks_asymmetric_sign(&keyAlias, keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0270 - * @tc.name : Asymmetric Sign, abnormal input parameters keyParam.key_usage - is not equal to HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricSign0270, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[] = "test_ed25519_6"; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = 0; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - - status = hks_asymmetric_sign(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0280 - * @tc.name : Asymmetric Sign, abnormal input parameters keyParam.type - is not equal to HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519 - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricSign0280, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[] = "test_ed25519_6"; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = 0; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_sign(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0290 - * @tc.name : Asymmetric Sign, abnormal input parameters hash is null - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricSign0290, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[] = "test_ed25519_6"; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t sig[NUM64]; - - struct hks_blob *hash = NULL; - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_sign(&keyAlias, &keyParam, hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0300 - * @tc.name : Asymmetric Sign, abnormal input parameters hash.data is null - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricSign0300, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[] = "test_ed25519_6"; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = NULL; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_sign(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0310 - * @tc.name : Asymmetric Sign, abnormal input parameters hash.size is 0 - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricSign0310, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[] = "test_ed25519_6"; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = 0; - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_sign(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0320 - * @tc.name : Asymmetric Sign, abnormal input parameters signature is null - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricSign0320, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[] = "test_ed25519_6"; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob *signature = NULL; - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - - status = hks_asymmetric_sign(&keyAlias, &keyParam, &hash, signature); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0330 - * @tc.name : Asymmetric Sign, abnormal input parameters signature.data is null - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricSign0330, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[] = "test_ed25519_6"; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = NULL; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_sign(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM138, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0340 - * @tc.name : Asymmetric Sign, abnormal input parameters signature.size is less than 64 - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricSign0340, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[] = "test_ed25519_6"; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = sig; - signature.size = NUM63; - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_sign(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM138, status); -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Sign key -// end+++++++++++++++++++++++++++++++++++++++++++++++++++++++++0200-0340 - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Verify key -// begin+++++++++++++++++++++++++++++++++++++++++++++++++++++0350-0510 - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0350 - * @tc.name : Asymmetric Verify, normal input parameters keyAlias, keyParam, hash, signature - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricVerify0350, Function | MediumTest | Level2) -{ - int32_t statusAsymmetricSign; - int32_t statusAsymmetricVerify; - - unsigned char testFileName[] = "keyalias1"; - struct hks_blob keyAlias = { 0 }; - - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32]; - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - uint32_t alg = HKS_ALG_HASH_SHA_256; - struct hks_blob src; - src.data = (uint8_t *)"123456"; - src.size = NUM6; - int32_t status = hks_hash(alg, &src, &hash); - TEST_ASSERT_EQUAL_INT(0, status); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - struct hks_key_param keyParam2 = { 0 }; - keyParam2.key_type = HKS_KEY_TYPE_EDDSA_PUBLIC_KEY_ED25519; - keyParam2.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam2.key_mode = HKS_ALG_GCM; - keyParam2.key_len = NUM32; - keyParam2.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam2.key_auth_id.data = (uint8_t *)testFileName; - keyParam2.key_auth_id.size = sizeof(testFileName); - - (void)TestSecShuksGenerateKeyNormal(); - struct hks_blob pubKey = { 0 }; - HksStBlobInit1(&pubKey, 1, NUM32, HKS_BLOB_TYPE_KEY); - - (void)TestSecShuksExportPublicNormal(&keyAlias, &pubKey); - struct hks_blob signature = { 0 }; - HksStBlobInit1(&signature, 1, NUM64, 0); - statusAsymmetricSign = hks_asymmetric_sign(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(0, statusAsymmetricSign); - - statusAsymmetricVerify = hks_asymmetric_verify(&pubKey, &keyParam2, &hash, &signature); - TEST_ASSERT_EQUAL_INT(0, statusAsymmetricVerify); - - HksBlobDestroyT1(&signature); - (void)TestSecShuksDeleteKeyNormal(); - HksBlobDestroyT1(&pubKey); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0360 - * @tc.name : Asymmetric Verify, abnormal input parameters keyAlias is null - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricVerify0360, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[NUM32]; - struct hks_blob *keyAlias = NULL; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_verify(keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0370 - * @tc.name : Asymmetric Verify, abnormal input parameters keyAlias.type - is HKS_BLOB_TYPE_ALIAS and keyAlias.data is null - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricVerify0370, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[NUM32]; - struct hks_blob keyAlias; - keyAlias.data = NULL; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_verify(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0380 - * @tc.name : Asymmetric Verify, abnormal input parameters keyAlias.size is 0 - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricVerify0380, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[NUM32]; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = 0; - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_verify(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0390 - * @tc.name : Asymmetric Verify, abnormal input parameters keyAlias.size is more than 64 - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricVerify0390, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[NUM32]; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = NUM65; - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_verify(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0400 - * @tc.name : Asymmetric Verify, abnormal input parameters keyAlias.type - is HKS_BLOB_TYPE_KEY and keyAlias.data is null - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricVerify0400, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[NUM32]; - struct hks_blob keyAlias; - keyAlias.data = NULL; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_KEY; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_PUBLIC_KEY_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_verify(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM1006, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0410 - * @tc.name : Asymmetric Verify, abnormal input parameters keyAlias.size is not equal to 32 - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricVerify0410, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[NUM32]; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = NUM25; - keyAlias.type = HKS_BLOB_TYPE_KEY; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_PUBLIC_KEY_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_verify(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM1006, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0420 - * @tc.name : Asymmetric Verify, abnormal input parameters keyAlias.type is not equal to HKS_BLOB_TYPE_KEY - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricVerify0420, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[NUM32]; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = 0; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_verify(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM1006, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0430 - * @tc.name : Asymmetric Verify, abnormal input parameters keyParam is null - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricVerify0430, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[NUM32]; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param *keyParam = NULL; - - status = hks_asymmetric_verify(&keyAlias, keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0440 - * @tc.name : Asymmetric Verify, abnormal input parameters keyParam.key_usage - is not equal to HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricVerify0440, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[NUM32]; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = 0; // = 0 - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_verify(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0450 - * @tc.name : Asymmetric Verify, abnormal input parameters keyParam.key_type is not equal to HKS_ALG_GCM - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricVerify0450, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[NUM32]; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_KEY; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = 0; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_verify(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0460 - * @tc.name : Asymmetric Verify, abnormal input parameters hash is null - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricVerify0460, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[NUM32]; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t sig[NUM64]; - - struct hks_blob *hash = NULL; - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_verify(&keyAlias, &keyParam, hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0470 - * @tc.name : Asymmetric Verify, abnormal input parameters hash.data is null - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricVerify0470, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[NUM32]; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = NULL; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_verify(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0480 - * @tc.name : Asymmetric Verify, abnormal input parameters hash.size is 0 - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricVerify0480, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[NUM32]; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = 0; - - struct hks_blob signature; - signature.data = sig; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_verify(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0490 - * @tc.name : Asymmetric Verify, abnormal input parameters signature is null - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricVerify0490, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[NUM32]; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob *signature = NULL; - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_verify(&keyAlias, &keyParam, &hash, signature); - TEST_ASSERT_EQUAL_INT(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0500 - * @tc.name : Asymmetric Verify, abnormal input parameters signature.data is null - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricVerify0500, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[NUM32]; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = NULL; - signature.size = sizeof(sig); - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_verify(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL0_0510 - * @tc.name : Asymmetric Verify, abnormal input parameters signature.size is less than 64 - * @tc.desc : [C- SECURITY -1900] - */ -LITE_TEST_CASE(SecurityDataHuksSignVerifyTestSuite, securityDataAsymmetricVerify0510, Function | MediumTest | Level2) -{ - int32_t status; - unsigned char testFileName[NUM32]; - struct hks_blob keyAlias; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - uint8_t hash1[NUM32], sig[NUM64]; - - struct hks_blob hash; - hash.data = (uint8_t *)hash1; - hash.size = sizeof(hash1); - - struct hks_blob signature; - signature.data = sig; - signature.size = NUM63; - - struct hks_key_param keyParam = { 0 }; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_usage = HKS_KEY_USAGE_SIGN | HKS_KEY_USAGE_VERIFY; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_len = NUM32; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_auth_id.data = (uint8_t *)testFileName; - keyParam.key_auth_id.size = sizeof(testFileName); - - status = hks_asymmetric_verify(&keyAlias, &keyParam, &hash, &signature); - TEST_ASSERT_EQUAL_INT(NUM135, status); -} -#endif -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Verify key -// end+++++++++++++++++++++++++++++++++++++++++++++++++++++++0350-0510 - -RUN_TEST_SUITE(SecurityDataHuksSignVerifyTestSuite); diff --git a/security_lite/huks_posix/BUILD.gn b/security_lite/huks_posix/BUILD.gn deleted file mode 100755 index b58ea40fab06fc9dd5bc6c11ea9f73f4484c928b..0000000000000000000000000000000000000000 --- a/security_lite/huks_posix/BUILD.gn +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (c) 2020-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/lite/build/suite_lite.gni") - -hcpptest_suite("ActsSecurityDataTest") { - suite_name = "acts" - sources = [ - "src/SecurityDataHuksDecTest.cpp", - "src/SecurityDataHuksEncTest.cpp", - "src/SecurityDataHuksGenDelTest.cpp", - "src/SecurityDataHuksHashRandomHmacTest.cpp", - ] - - include_dirs = [ - "src", - "//base/security/huks/interfaces/innerkits/huks_lite/", - ] - deps = [ "//base/security/huks/frameworks/huks_lite/source:huks" ] - cflags = [ "-Wno-error" ] - - ldflags = [ - "-lstdc++", - "-lm", - "-lpthread", - ] -} diff --git a/security_lite/huks_posix/Test.json b/security_lite/huks_posix/Test.json deleted file mode 100755 index d57a10afca56a7793d759c0cd3736ad4a19a14eb..0000000000000000000000000000000000000000 --- a/security_lite/huks_posix/Test.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "description": "Config for hcpptest demo test cases", - "environment": [ - { - "type": "device", - "label": "ipcamera" - } - ], - "kits": [ - { - "type": "MountKit", - "server": "NfsServer", - "mount": [ - { - "source": "testcases/security", - "target": "/test_root/security" - } - ] - } - ], - "driver": { - "type": "CppTestLite", - "execute": "/test_root/security/ActsSecurityDataTest.bin" - } -} \ No newline at end of file diff --git a/security_lite/huks_posix/src/SecurityDataHuks.h b/security_lite/huks_posix/src/SecurityDataHuks.h deleted file mode 100755 index 7624cb9303b81bc952ca2e6b8d3586adb49f72c4..0000000000000000000000000000000000000000 --- a/security_lite/huks_posix/src/SecurityDataHuks.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2020-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. - */ - -#ifndef TEST_XTS_ACTS_SECURITY_LITE_DATAHUKS_POSIX_SRC_SECURITYDATAHUKS_H -#define TEST_XTS_ACTS_SECURITY_LITE_DATAHUKS_POSIX_SRC_SECURITYDATAHUKS_H -#include "hks_client.h" -#include "hks_types.h" -#include -#include -#include -#include -#include -#include -#include "gtest/gtest.h" -#include -#include -#include -#include "hks_errno.h" -#include -#include - -#define DOUBLE_INT(x) ((x) * 2) -#define DOUBLE_STR_LEN(x) ((x) * 2 + 1) -#define FILE_ERROR -1 -#define HICHAIN_FILEPATH "/storage/" -#define HKS_FREE_PTR1(p) { if ((p) != NULL) { free(p); (p) = NULL; }} - -constexpr int NUM1 = 1; -constexpr int NUM2 = 2; -constexpr int NUM3 = 3; -constexpr int NUM4 = 4; -constexpr int NUM5 = 5; -constexpr int NUM6 = 6; -constexpr int NUM8 = 8; -constexpr int NUM9 = 9; -constexpr int NUM10 = 10; -constexpr int NUM11 = 11; -constexpr int NUM12 = 12; -constexpr int NUM15 = 15; -constexpr int NUM16 = 16; -constexpr int NUM20 = 20; -constexpr int NUM30 = 30; -constexpr int NUM21 = 21; -constexpr int NUM24 = 24; -constexpr int NUM32 = 32; -constexpr int NUM60 = 60; -constexpr int NUM62 = 62; -constexpr int NUM64 = 64; -constexpr int NUM65 = 65; -constexpr int NUM88 = 88; -constexpr int NUM100 = 100; -constexpr int NUM128 = 128; -constexpr int NUM192 = 192; -constexpr int NUM256 = 256; -constexpr int NUM1025 = 1025; -constexpr unsigned NUM2048 = 2048; -constexpr int NUM1234567 = 1234567; -constexpr int NUM1000000 = 1000000; -constexpr int NUM134 = -134; -constexpr int NUM135 = -135; -constexpr int NUM142 = -142; -constexpr int NUM1000 = -1000; -constexpr int NUM1006 = -1006; -constexpr int NUM1007 = -1007; -constexpr int NUM1010 = -1010; -constexpr int G_COUNT_MEM = 10000; -constexpr int MAX_INT = 2147483647; -constexpr int FILE_PATH_LENGTH = 256; - -using namespace std; -using namespace testing::ext; -using errno_t = int32_t; - -errno_t FopenS(FILE **fp, const char *filename, const char *modes); - -int32_t FileSize(const char *filename); - -int32_t FileWrite(const char *filename, uint32_t offset, const uint8_t *buf, uint32_t len); - -int32_t FileRead(const char *filename, uint32_t offset, uint8_t *buf, uint32_t len); - -uint64_t GetTimeMs(); - -void AddLog(const char* logType, const char *tag, const char *func, const char *format, const va_list* ap); - -void Logi(const char *tag, const char *func, const char *format, ...); - -void Logw(const char *tag, const char *func, const char *format, ...); - -void Loge(const char *tag, const char *func, const char *format, ...); - -void Logd(const char *tag, const char *func, const char *format, ...); - -int32_t HksTestGetHardwareUdid(uint8_t* udid, uint32_t udidLen); - -void HksStBlobInit1(struct hks_blob *blob, size_t nmemb, size_t size, uint8_t type); - -void HksBlobDestroyT1(struct hks_blob *blob); - -void HexStringToByte(const char *str, int nLen, unsigned char *pHex); - -void BuildBlobData(struct hks_blob *param, const char *str, uint8_t type, uint32_t size, uint8_t isDataNull); - -#endif diff --git a/security_lite/huks_posix/src/SecurityDataHuksDecTest.cpp b/security_lite/huks_posix/src/SecurityDataHuksDecTest.cpp deleted file mode 100755 index 3b63a9621e0fd781f3c89ae4570f8421c7feb7ef..0000000000000000000000000000000000000000 --- a/security_lite/huks_posix/src/SecurityDataHuksDecTest.cpp +++ /dev/null @@ -1,1325 +0,0 @@ -/* Copyright (c) 2020-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. -*/ -#include "SecurityDataHuks.h" -#include "hks_client.h" -#include "hks_types.h" -#include -#include -#include -#include -#include -#include "gtest/gtest.h" -using namespace std; -using namespace testing::ext; - -class SecurityDataHuksDecTestSuite : public testing::Test { -protected: - // SetUpTestCase: Testsuit setup, run before 1st testcase - static void SetUpTestCase(void) {} - // TearDownTestCase: Testsuit teardown, run after last testcase - static void TearDownTestCase(void) {} - // Testcase setup - virtual void SetUp() - { - int32_t status; - struct hks_file_callbacks fileCallbacks; - - fileCallbacks.read = FileRead; - fileCallbacks.write = FileWrite; - fileCallbacks.file_size = FileSize; - - status = hks_register_file_callbacks(&fileCallbacks); - EXPECT_EQ(0, status); - - struct hks_log_f_group logFunc; - logFunc.log_info = Logi; - logFunc.log_warn = Logw; - logFunc.log_error = Loge; - logFunc.log_debug = Logd; - - status = hks_register_log_interface(&logFunc); - EXPECT_EQ(0, status); - - status = hks_register_get_hardware_udid_callback(HksTestGetHardwareUdid); - - EXPECT_EQ(0, status); - - status = hks_init(); - if (status != 0) { - status = hks_refresh_key_info(); - } - EXPECT_EQ(0, status); -} - // Testcase teardown - virtual void TearDown() {} -}; - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Decrypt key -// begin++++++++++++++++++++++++++++++++++++++++++++++++++++0760-0990 - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0760 - * @tc.name : Aead Decrypt, normal input parameters key, keyParam.ken_len is 128, cryptParam, plaintext, ciphertext - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0760, Function | MediumTest | Level1) -{ - char alias[] = "test_hks_aead_encrypt"; - int32_t statusEncrypt; - int32_t statusDecrypt; - - struct hks_blob key; - HksStBlobInit1(&key, 1, NUM16, HKS_BLOB_TYPE_KEY); - hks_generate_random(&key); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - struct hks_blob nonce = {0}; - HksStBlobInit1(&nonce, 1, NUM16, HKS_BLOB_TYPE_IV); - hks_generate_random(&nonce); - - struct hks_blob aad = {0}; - HksStBlobInit1(&aad, 1, NUM16, HKS_BLOB_TYPE_AAD); - hks_generate_random(&aad); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - HksStBlobInit1(&plaintext, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - hks_generate_random(&plaintext); - - struct hks_blob ciphertext; - HksStBlobInit1(&ciphertext, 1, NUM64 + HKS_SALT_MAX_SIZE, HKS_BLOB_TYPE_CIPHER_TEXT); - statusEncrypt = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(0, statusEncrypt); - - struct hks_blob decrypted; - HksStBlobInit1(&decrypted, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - statusDecrypt = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(0, statusDecrypt); - - size_t k; - for (k = 0; k < decrypted.size; k++) { - EXPECT_EQ(plaintext.data[k], decrypted.data[k]); - } - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&nonce); - HksBlobDestroyT1(&aad); - HksBlobDestroyT1(&plaintext); - HksBlobDestroyT1(&ciphertext); - HksBlobDestroyT1(&decrypted); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0770 - * @tc.name : Aead Decrypt, normal input parameters key, keyParam.ken_len is 192, cryptParam, plaintext, ciphertext - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0770, Function | MediumTest | Level1) -{ - char alias[] = "test_hks_aead_encrypt"; - int32_t statusEncrypt; - int32_t statusDecrypt; - - struct hks_blob key; - HksStBlobInit1(&key, 1, NUM24, HKS_BLOB_TYPE_KEY); - hks_generate_random(&key); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM192; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - struct hks_blob nonce = {0}; - HksStBlobInit1(&nonce, 1, NUM16, HKS_BLOB_TYPE_IV); - hks_generate_random(&nonce); - - struct hks_blob aad = {0}; - HksStBlobInit1(&aad, 1, NUM16, HKS_BLOB_TYPE_AAD); - hks_generate_random(&aad); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - HksStBlobInit1(&plaintext, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - hks_generate_random(&plaintext); - - struct hks_blob ciphertext; - HksStBlobInit1(&ciphertext, 1, NUM64 + HKS_SALT_MAX_SIZE, HKS_BLOB_TYPE_CIPHER_TEXT); - statusEncrypt = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(0, statusEncrypt); - - struct hks_blob decrypted; - HksStBlobInit1(&decrypted, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - statusDecrypt = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(0, statusDecrypt); - - size_t k; - for (k = 0; k < decrypted.size; k++) { - EXPECT_EQ(plaintext.data[k], decrypted.data[k]); - } - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&nonce); - HksBlobDestroyT1(&aad); - HksBlobDestroyT1(&plaintext); - HksBlobDestroyT1(&ciphertext); - HksBlobDestroyT1(&decrypted); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0780 - * @tc.name : Aead Decrypt, normal input parameters key, keyParam.ken_len is 256, cryptParam, plaintext, ciphertext - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0780, Function | MediumTest | Level1) -{ - char alias[] = "test_hks_aead_encrypt"; - int32_t statusEncrypt; - int32_t statusDecrypt; - - struct hks_blob key; - HksStBlobInit1(&key, 1, NUM32, HKS_BLOB_TYPE_KEY); - hks_generate_random(&key); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM256; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - struct hks_blob nonce = {0}; - HksStBlobInit1(&nonce, 1, NUM16, HKS_BLOB_TYPE_IV); - hks_generate_random(&nonce); - - struct hks_blob aad = {0}; - HksStBlobInit1(&aad, 1, NUM16, HKS_BLOB_TYPE_AAD); - hks_generate_random(&aad); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - HksStBlobInit1(&plaintext, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - hks_generate_random(&plaintext); - - struct hks_blob ciphertext; - HksStBlobInit1(&ciphertext, 1, NUM64 + HKS_SALT_MAX_SIZE, HKS_BLOB_TYPE_CIPHER_TEXT); - statusEncrypt = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(0, statusEncrypt); - - struct hks_blob decrypted; - HksStBlobInit1(&decrypted, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - statusDecrypt = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(0, statusDecrypt); - - size_t k; - for (k = 0; k < decrypted.size; k++) { - EXPECT_EQ(plaintext.data[k], decrypted.data[k]); - } - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&nonce); - HksBlobDestroyT1(&aad); - HksBlobDestroyT1(&plaintext); - HksBlobDestroyT1(&ciphertext); - HksBlobDestroyT1(&decrypted); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0790 - * @tc.name : Aead Decrypt, abnormal input parameters key is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0790, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob *key = nullptr; - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0800 - * @tc.name : Aead Decrypt, abnormal input parameters key.size is not equal to keyParam.key_len divided by 8 - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0800, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = NUM32; - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(NUM1006, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0810 - * @tc.name : Aead Decrypt, abnormal input parameters key.data is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0810, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = NULL; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(NUM1006, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0820 - * @tc.name : Aead Decrypt, abnormal input parameters key.type is not equal to HKS_KEY_TYPE_AES - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0820, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = 0; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(NUM1006, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0830 - * @tc.name : Aead Decrypt, abnormal input parameters keyParam is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0830, Function | MediumTest | Level2) -{ - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param *keyParam = nullptr; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0840 - * @tc.name : Aead Decrypt, abnormal input parameters keyParam.key_mode is not equal to HKS_ALG_GCM - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0840, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = 0; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0850 - * @tc.name : Aead Decrypt, abnormal input parameters keyParam.key_len is not equal to 128, 192, 256 - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0850, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM12; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0860 - * @tc.name : Aead Decrypt, abnormal input parameters keyParam.key_type is not equal to HKS_KEY_TYPE_AES - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0860, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = 0; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0870 - * @tc.name : Aead Decrypt, abnormal input parameters keyParam.key_pad is not equal to HKS_PADDING_NONE - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0870, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = NUM88; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0880 - * @tc.name : Aead Decrypt, abnormal input parameters keyParam.key_usage - is not equal to HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0880, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = 0; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0890 - * @tc.name : Aead Decrypt, abnormal input parameters cryptParam is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0890, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - uint8_t key1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param *cryptParam = nullptr; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0900 - * @tc.name : Aead Decrypt, abnormal input parameters nonce.size is 0 - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0900, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = 0; - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0910 - * @tc.name : Aead Decrypt, abnormal input parameters nonce.data is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0910, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = NULL; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0920 - * @tc.name : Aead Decrypt, abnormal input parameters aad.size is 0 - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0920, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = 0; - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0930 - * @tc.name : Aead Decrypt, abnormal input parameters aad.data is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0930, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = NULL; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0940 - * @tc.name : Aead Decrypt, abnormal input decrypted plaintext is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0940, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob *decrypted = nullptr; - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, decrypted, &ciphertext); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0950 - * @tc.name : Aead Decrypt, abnormal input decrypted plaintext.data is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0950, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = NULL; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0960 - * @tc.name : Aead Decrypt, abnormal input parameters decrypted.size is less than ciphertext.size minus 16 - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0960, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = NUM15; - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0970 - * @tc.name : Aead Decrypt, abnormal input parameters ciphertext.size is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0970, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob *ciphertext = nullptr; - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, ciphertext); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0980 - * @tc.name : Aead Decrypt, abnormal input parameters ciphertext.data is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0980, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = NULL; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0990 - * @tc.name : Aead Decrypt, abnormal input parameters ciphertext.size is less than 16 - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksDecTestSuite, securityDataAeadDecrypt0990, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_decrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], decrypted1[NUM100], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob decrypted; - decrypted.data = (uint8_t *)decrypted1; - decrypted.size = sizeof(decrypted1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = NUM10; - - status = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(NUM135, status); -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Decrypt key -// begin++++++++++++++++++++++++++++++++++++++++++++++++++++0760-0990 - diff --git a/security_lite/huks_posix/src/SecurityDataHuksEncTest.cpp b/security_lite/huks_posix/src/SecurityDataHuksEncTest.cpp deleted file mode 100755 index b355b50bc545a036f48fb387ad1ea8c913d78820..0000000000000000000000000000000000000000 --- a/security_lite/huks_posix/src/SecurityDataHuksEncTest.cpp +++ /dev/null @@ -1,1346 +0,0 @@ -/* Copyright (c) 2020-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. -*/ -#include "SecurityDataHuks.h" -#include "hks_client.h" -#include "hks_types.h" -#include -#include -#include -#include -#include -#include "gtest/gtest.h" -using namespace std; -using namespace testing::ext; - -class SecurityDataHuksEncTestSuite : public testing::Test { -protected: - // SetUpTestCase: Testsuit setup, run before 1st testcase - static void SetUpTestCase(void) {} - // TearDownTestCase: Testsuit teardown, run after last testcase - static void TearDownTestCase(void) {} - // Testcase setup - virtual void SetUp() - { - int32_t status; - struct hks_file_callbacks fileCallbacks; - - fileCallbacks.read = FileRead; - fileCallbacks.write = FileWrite; - fileCallbacks.file_size = FileSize; - - status = hks_register_file_callbacks(&fileCallbacks); - EXPECT_EQ(0, status); - - struct hks_log_f_group logFunc; - logFunc.log_info = Logi; - logFunc.log_warn = Logw; - logFunc.log_error = Loge; - logFunc.log_debug = Logd; - - status = hks_register_log_interface(&logFunc); - EXPECT_EQ(0, status); - - status = hks_register_get_hardware_udid_callback(HksTestGetHardwareUdid); - - EXPECT_EQ(0, status); - - status = hks_init(); - if (status != 0) { - status = hks_refresh_key_info(); - } - EXPECT_EQ(0, status); - } - // Testcase teardown - virtual void TearDown() {} -}; - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Encrypt key -// begin++++++++++++++++++++++++++++++++++++++++++++++++++++0520-0750 - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0520 - * @tc.name : Aead Encrypt, normal input parameters key, keyParam.ken_len is 128, cryptParam, plaintext, ciphertext - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0520, Function | MediumTest | Level1) -{ - char alias[] = "test_hks_aead_encrypt"; - int32_t statusEncrypt; - int32_t statusDecrypt; - - struct hks_blob key; - HksStBlobInit1(&key, 1, NUM16, HKS_BLOB_TYPE_KEY); - hks_generate_random(&key); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - struct hks_blob nonce = {0}; - HksStBlobInit1(&nonce, 1, NUM16, HKS_BLOB_TYPE_IV); - hks_generate_random(&nonce); - - struct hks_blob aad = {0}; - HksStBlobInit1(&aad, 1, NUM16, HKS_BLOB_TYPE_AAD); - hks_generate_random(&aad); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - HksStBlobInit1(&plaintext, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - hks_generate_random(&plaintext); - - struct hks_blob ciphertext; - HksStBlobInit1(&ciphertext, 1, NUM64 + HKS_SALT_MAX_SIZE, HKS_BLOB_TYPE_CIPHER_TEXT); - statusEncrypt = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(0, statusEncrypt); - - struct hks_blob decrypted; - HksStBlobInit1(&decrypted, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - statusDecrypt = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(0, statusDecrypt); - - size_t k; - for (k = 0; k < decrypted.size; k++) { - EXPECT_EQ(plaintext.data[k], decrypted.data[k]); - } - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&nonce); - HksBlobDestroyT1(&aad); - HksBlobDestroyT1(&plaintext); - HksBlobDestroyT1(&ciphertext); - HksBlobDestroyT1(&decrypted); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0530 - * @tc.name : Aead Encrypt, normal input parameters key, keyParam.ken_len is 192, cryptParam, plaintext, ciphertext - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0530, Function | MediumTest | Level1) -{ - char alias[] = "test_hks_aead_encrypt"; - int32_t statusEncrypt; - int32_t statusDecrypt; - - struct hks_blob key; - HksStBlobInit1(&key, 1, NUM24, HKS_BLOB_TYPE_KEY); - hks_generate_random(&key); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM192; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - struct hks_blob nonce = {0}; - HksStBlobInit1(&nonce, 1, NUM16, HKS_BLOB_TYPE_IV); - hks_generate_random(&nonce); - - struct hks_blob aad = {0}; - HksStBlobInit1(&aad, 1, NUM16, HKS_BLOB_TYPE_AAD); - hks_generate_random(&aad); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - HksStBlobInit1(&plaintext, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - hks_generate_random(&plaintext); - - struct hks_blob ciphertext; - HksStBlobInit1(&ciphertext, 1, NUM64 + HKS_SALT_MAX_SIZE, HKS_BLOB_TYPE_CIPHER_TEXT); - statusEncrypt = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(0, statusEncrypt); - - struct hks_blob decrypted; - HksStBlobInit1(&decrypted, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - statusDecrypt = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(0, statusDecrypt); - - size_t k; - for (k = 0; k < decrypted.size; k++) { - EXPECT_EQ(plaintext.data[k], decrypted.data[k]); - } - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&nonce); - HksBlobDestroyT1(&aad); - HksBlobDestroyT1(&plaintext); - HksBlobDestroyT1(&ciphertext); - HksBlobDestroyT1(&decrypted); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0540 - * @tc.name : Aead Encrypt, normal input parameters key, keyParam.ken_len is 256, cryptParam, plaintext, ciphertext - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0540, Function | MediumTest | Level1) -{ - char alias[] = "test_hks_aead_encrypt"; - int32_t statusEncrypt; - int32_t statusDecrypt; - - struct hks_blob key; - HksStBlobInit1(&key, 1, NUM32, HKS_BLOB_TYPE_KEY); - hks_generate_random(&key); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM256; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - struct hks_blob nonce = {0}; - HksStBlobInit1(&nonce, 1, NUM16, HKS_BLOB_TYPE_IV); - hks_generate_random(&nonce); - - struct hks_blob aad = {0}; - HksStBlobInit1(&aad, 1, NUM16, HKS_BLOB_TYPE_AAD); - hks_generate_random(&aad); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - HksStBlobInit1(&plaintext, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - hks_generate_random(&plaintext); - - struct hks_blob ciphertext; - HksStBlobInit1(&ciphertext, 1, NUM64 + HKS_SALT_MAX_SIZE, HKS_BLOB_TYPE_CIPHER_TEXT); - statusEncrypt = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(0, statusEncrypt); - - struct hks_blob decrypted; - HksStBlobInit1(&decrypted, 1, NUM64, HKS_BLOB_TYPE_PLAIN_TEXT); - statusDecrypt = hks_aead_decrypt(&key, &keyParam, &cryptParam, &decrypted, &ciphertext); - EXPECT_EQ(0, statusDecrypt); - - size_t k; - for (k = 0; k < decrypted.size; k++) { - EXPECT_EQ(plaintext.data[k], decrypted.data[k]); - } - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&nonce); - HksBlobDestroyT1(&aad); - HksBlobDestroyT1(&plaintext); - HksBlobDestroyT1(&ciphertext); - HksBlobDestroyT1(&decrypted); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0550 - * @tc.name : Aead Encrypt, abnormal input parameters key is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0550, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob *key = nullptr; - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0560 - * @tc.name : Aead Encrypt, abnormal input parameters key.size is not equal to keyParam.key_len divided by 8 - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0560, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = NUM32; - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(NUM1006, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0570 - * @tc.name : Aead Encrypt, abnormal input parameters key.data is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0570, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = NULL; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(NUM1006, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0580 - * @tc.name : Aead Encrypt, abnormal input parameters key.type is not equal to HKS_BLOB_TYPE_KEY - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0580, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = 0; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(NUM1006, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0590 - * @tc.name : Aead Encrypt, abnormal input parameters keyParam is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0590, Function | MediumTest | Level2) -{ - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param *keyParam = nullptr; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0600 - * @tc.name : Aead Encrypt, abnormal input parameters keyParam.key_mode is not equal to HKS_ALG_GCM - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0600, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = 0; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0610 - * @tc.name : Aead Encrypt, abnormal input parameters keyParam.key_len is not equal to 128, 192, 256 - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0610, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM11; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0620 - * @tc.name : Aead Encrypt, abnormal input parameters keyParam.key_type is not equal to HKS_KEY_TYPE_AES - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0620, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = 0; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0630 - * @tc.name : Aead Encrypt, abnormal input parameters keyParam.key_pad is not equal to HKS_PADDING_NONE - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0630, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = NUM88; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0640 - * @tc.name : Aead Encrypt, abnormal input parameters keyParam.key_usage - is not equal to HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0640, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = 0; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(NUM134, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0650 - * @tc.name : Aead Encrypt, abnormal input parameters cryptParam is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0650, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param *cryptParam = nullptr; - - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0660 - * @tc.name : Aead Encrypt, abnormal input parameters nonce.size is less than 12 - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0660, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = NUM10; - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0670 - * @tc.name : Aead Encrypt, abnormal input parameters nonce.data is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0670, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = NULL; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0680 - * @tc.name : Aead Encrypt, abnormal input parameters aad.size is 0 - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0680, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = 0; - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0690 - * @tc.name : Aead Encrypt, abnormal input parameters aad.data is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0690, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = NULL; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0700 - * @tc.name : Aead Encrypt, abnormal input parameters plaintext is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0700, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob *plaintext = nullptr; - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, plaintext, &ciphertext); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0710 - * @tc.name : Aead Encrypt, abnormal input parameters plaintext.data is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0710, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = NULL; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0720 - * @tc.name : Aead Encrypt, abnormal input parameters plaintext.size is 0 - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0720, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = 0; - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0730 - * @tc.name : Aead Encrypt, abnormal input parameters ciphertext is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0730, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob *ciphertext = nullptr; - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, ciphertext); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0740 - * @tc.name : Aead Encrypt, abnormal input parameters ciphertext.data is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0740, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = NULL; - ciphertext.size = sizeof(ciphertext1); - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_0750 - * @tc.name : Aead Encrypt, abnormal input parameters ciphertext.size is less than plaintext.size minus 16 - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksEncTestSuite, securityDataAeadEncrypt0750, Function | MediumTest | Level2) -{ - char alias[] = "test_hks_aead_encrypt"; - - uint8_t key1[NUM16], nonce1[NUM16], aad1[NUM16], plaintext1[NUM64], ciphertext1[NUM100]; - - int32_t status; - struct hks_blob key; - key.type = HKS_BLOB_TYPE_KEY; - key.data = (uint8_t *)key1; - key.size = sizeof(key1); - - struct hks_key_param keyParam; - keyParam.key_type = HKS_KEY_TYPE_AES; - keyParam.key_len = NUM128; - keyParam.key_usage = HKS_KEY_USAGE_ENCRYPT | HKS_KEY_USAGE_DECRYPT; - keyParam.key_mode = HKS_ALG_GCM; - keyParam.key_pad = HKS_PADDING_NONE; - keyParam.key_auth_id.data = (uint8_t *)alias; - keyParam.key_auth_id.size = sizeof(alias); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - - struct hks_crypt_param cryptParam; - - struct hks_blob nonce = {0}; - nonce.data = (uint8_t *)nonce1; - nonce.size = sizeof(nonce1); - - struct hks_blob aad = {0}; - aad.data = (uint8_t *)aad1; - aad.size = sizeof(aad1); - - cryptParam.nonce = nonce; - cryptParam.aad = aad; - - struct hks_blob plaintext; - plaintext.data = (uint8_t *)plaintext1; - plaintext.size = sizeof(plaintext1); - - struct hks_blob ciphertext; - ciphertext.data = (uint8_t *)ciphertext1; - ciphertext.size = NUM10; - - status = hks_aead_encrypt(&key, &keyParam, &cryptParam, &plaintext, &ciphertext); - EXPECT_EQ(NUM135, status); -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Encrypt key -// end==++++++++++++++++++++++++++++++++++++++++++++++++++++0520-0750 - diff --git a/security_lite/huks_posix/src/SecurityDataHuksGenDelTest.cpp b/security_lite/huks_posix/src/SecurityDataHuksGenDelTest.cpp deleted file mode 100755 index d1dad0e29aca19271d3a3238dda3598ac50dade4..0000000000000000000000000000000000000000 --- a/security_lite/huks_posix/src/SecurityDataHuksGenDelTest.cpp +++ /dev/null @@ -1,950 +0,0 @@ -/* Copyright (c) 2020-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. -*/ - -#include "SecurityDataHuks.h" -#include "hks_client.h" -#include "hks_types.h" -#include -#include -#include -#include -#include -#include -#include "gtest/gtest.h" -#include -#include -#include -#include "hks_errno.h" -#include -#include -using namespace std; -using namespace testing::ext; - -errno_t FopenS(FILE **fp, const char *filename, const char *modes) -{ - *fp = fopen(filename, modes); - return 0; -} - -int32_t FileSize(const char *filename) -{ - FILE *fp = nullptr; - errno_t err; - int32_t size; - - if (filename == nullptr) { - return -1; - } - - err = FopenS(&fp, filename, "rb"); - if (err != 0 || fp == nullptr) { - return -1; - } - - if (fseek(fp, 0L, SEEK_END) != 0) { - fclose(fp); - return -1; - } - - size = ftell(fp); - fclose(fp); - - return size; -} -int32_t FileWrite(const char *filename, uint32_t offset, const uint8_t *buf, uint32_t len) -{ - FILE *fp = nullptr; - errno_t err; - size_t size; - - if (filename == NULL || buf == NULL) { - return -1; - } - - err = FopenS(&fp, filename, "wb+"); - if (err != 0 || fp == nullptr) { - return -1; - } - - size = fwrite(buf, 1, len, fp); - fclose(fp); - - if (size != len) { - return -1; - } - - return 0; -} -int32_t FileRead(const char *filename, uint32_t offset, uint8_t *buf, uint32_t len) -{ - FILE* fp = nullptr; - errno_t err; - size_t size; - - if (filename == NULL || buf == NULL) { - return -1; - } - - if (access(filename, 0) == -1) { - return 0; - } - - err = FopenS(&fp, filename, "rb"); - if (err == NUM2) { - return 0; - } - if (err != 0 || fp == nullptr) { - return -1; - } - - size = fread(buf, 1, len, fp); - fclose(fp); - - if (size == 0) { - return -1; - } - - return size; -} - -uint64_t GetTimeMs() -{ - struct timeval timeVal; - gettimeofday(&timeVal, nullptr); - - return (uint64_t)NUM1000000 * timeVal.tv_sec + timeVal.tv_usec; -} - -void AddLog(const char* logType, const char *tag, const char *func, const char *format, const va_list* ap) -{ - char* buf = (char*)malloc(NUM2048); - if (buf == nullptr) { - return; - } - int offset = sprintf_s(buf, (NUM2048), "[%s][%llu]%s %s: ", logType, (unsigned long long)GetTimeMs(), tag, func); - if (offset >= 0) { - offset += vsprintf_s(buf + offset, (NUM2048) - offset, format, *ap); - } - - free(buf); - buf = nullptr; -} - -void Logi(const char *tag, const char *func, const char *format, ...) -{ - va_list args; - va_start(args, format); - AddLog("Info", tag, func, format, &args); - va_end(args); -} - -void Logw(const char *tag, const char *func, const char *format, ...) -{ - va_list args; - va_start(args, format); - AddLog("Warn", tag, func, format, &args); - va_end(args); -} - -void Loge(const char *tag, const char *func, const char *format, ...) -{ - va_list args; - va_start(args, format); - AddLog("Error", tag, func, format, &args); - va_end(args); -} - -void Logd(const char *tag, const char *func, const char *format, ...) -{ - va_list args; - va_start(args, format); - AddLog("Debug", tag, func, format, &args); - va_end(args); -} - -uint8_t g_hksHardwareUdidId[32] = { - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0C, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0x1A, 0x1C, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, -}; - -int32_t HksTestGetHardwareUdid(uint8_t* udid, uint32_t udidLen) -{ - int err; - if ((udid == NULL) || (udidLen != NUM32)) { - return -1; - } - - int32_t rc = 1234567; - if (rc <= 0) { - err = memcpy_s(udid, NUM32, g_hksHardwareUdidId, NUM32); - if (err != EOK) { - return -1; - } - } - - char buf[128] = {0}; - uint32_t offset = 0; - for (uint32_t i = 0; i < udidLen; ++i) { - offset += sprintf_s(buf + offset, NUM128 - offset, "%02x ", udid[i]); - } - - Logd("[hks_tester]", __func__, buf); - return 0; -} - -void HksStBlobInit1(struct hks_blob *blob, size_t nmemb, size_t size, uint8_t type) -{ - if (blob == nullptr || nmemb == 0 || size == 0) { - EXPECT_EQ(0, 1); - return; - } - blob->data = (uint8_t *)calloc(nmemb, size); - if (blob->data == NULL) { - EXPECT_EQ(0, 1); - return; - } - if (memset_s(blob->data, size, 0, size) != EOK) { - EXPECT_EQ(0, 1); - return; - } - blob->size = size; - blob->type = type; -} - -void HksBlobDestroyT1(struct hks_blob *blob) -{ - if (blob == nullptr) { - EXPECT_EQ(0, 1); - return; - } - if (blob && blob->data) { - if (memset_s(blob->data, blob->size, 0, blob->size) != EOK) { - EXPECT_EQ(0, 1); - return; - } - HKS_FREE_PTR1(blob->data); - } - blob->data = NULL; - blob->size = 0; - blob->type = HKS_BLOB_TYPE_RAW; -} - -void HexStringToByte(const char *str, int nLen, unsigned char *pHex) -{ - unsigned int number = 4; - if (nLen % NUM2) { - EXPECT_EQ(0, 1); - return; - } - int nHexLen = nLen / NUM2; - unsigned char nibble[2]; - - if (nHexLen >= MAX_INT) { - return; - } - for (int i = 0; i < nHexLen; i++) { - nibble[0] = str[i * NUM2]; - nibble[1] = str[i * NUM2 + NUM1]; - for (int j = 0; j < NUM2; j++) { - if (nibble[j] <= 'F' && nibble[j] >= 'A') { - nibble[j] = nibble[j] - 'A' + NUM10; - } else if (nibble[j] <= 'f' && nibble[j] >= 'a') { - nibble[j] = nibble[j] - 'a' + NUM10; - } else if (nibble[j] >= '0' && nibble[j] <= '9') { - nibble[j] = nibble[j] - '0'; - } else { - EXPECT_EQ(0, 1); - return; - } - } - pHex[i] = nibble[0] << number; - pHex[i] |= nibble[1]; - } -} - -void BuildBlobData(struct hks_blob *param, const char *str, uint8_t type, uint32_t size, uint8_t isDataNull) -{ - if (param == nullptr) { - EXPECT_EQ(0, 1); - return; - } - param->type = type; - param->size = size; - if (isDataNull == 1) - param->data = NULL; - else { - if (size + NUM2 == 0) { - EXPECT_EQ(0, 1); - return; - } - unsigned char *buff = (unsigned char *)malloc(size + NUM2); - if (buff == nullptr) { - EXPECT_EQ(0, 1); - return; - } - if (memset_s(buff, size + NUM2, 0, size + NUM2) != EOK) { - EXPECT_EQ(0, 1); - free(buff); - buff = nullptr; - return; - } - HexStringToByte(str, size * NUM2, buff); - param->data = (uint8_t *)buff; - } -} - -class SecurityDataHuksGenDelTestSuite : public testing::Test { -protected: - // SetUpTestCase: Testsuit setup, run before 1st testcase - static void SetUpTestCase(void) {} - // TearDownTestCase: Testsuit teardown, run after last testcase - static void TearDownTestCase(void) {} - // Testcase setup - virtual void SetUp() - { - int32_t status; - struct hks_file_callbacks fileCallbacks; - - fileCallbacks.read = FileRead; - fileCallbacks.write = FileWrite; - fileCallbacks.file_size = FileSize; - - status = hks_register_file_callbacks(&fileCallbacks); - EXPECT_EQ(0, status); - - struct hks_log_f_group logFunc; - logFunc.log_info = Logi; - logFunc.log_warn = Logw; - logFunc.log_error = Loge; - logFunc.log_debug = Logd; - - status = hks_register_log_interface(&logFunc); - EXPECT_EQ(0, status); - - status = hks_register_get_hardware_udid_callback(HksTestGetHardwareUdid); - - EXPECT_EQ(0, status); - - status = hks_init(); - if (status != 0) { - status = hks_refresh_key_info(); - } - EXPECT_EQ(0, status); - } - // Testcase teardown - virtual void TearDown() {} -}; - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++generate key -// begin+++++++++++++++++++++++++++++++++++++++++++++++++++0000-0120 - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL1_0000 - * @tc.name : Generate key, normal input parameters keyAlias and keyParam - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0000, Function | MediumTest | Level1) -{ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - int32_t statusGenerate; - int32_t statusDelete; - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - struct hks_blob keyAliasGenerate; - HksStBlobInit1(&keyAliasGenerate, sizeof(uint8_t), sizeof(testFileName) + NUM3, HKS_BLOB_TYPE_ALIAS); - if (memcpy_s(keyAliasGenerate.data, sizeof(testFileName), testFileName, sizeof(testFileName)) != EOK) { - HksBlobDestroyT1(&keyAliasGenerate); - EXPECT_EQ(0, 1); - return; - } - char tmpGenerate[NUM3] = { 0 }; - if (strcat_s((char *)keyAliasGenerate.data, - strlen((char *)keyAliasGenerate.data) + strlen(tmpGenerate) + 1, - tmpGenerate) != EOK) { - HksBlobDestroyT1(&keyAliasGenerate); - EXPECT_EQ(0, 1); - return; - } - keyAliasGenerate.size = strlen((char *)keyAliasGenerate.data); - statusGenerate = hks_generate_key(&keyAliasGenerate, &keyParam); - EXPECT_EQ(0, statusGenerate); - HksBlobDestroyT1(&keyAliasGenerate); - struct hks_blob keyAliasDelete; - HksStBlobInit1(&keyAliasDelete, sizeof(uint8_t), sizeof(testFileName) + NUM3, HKS_BLOB_TYPE_ALIAS); - if (memcpy_s(keyAliasDelete.data, sizeof(testFileName), testFileName, sizeof(testFileName)) != EOK) { - HksBlobDestroyT1(&keyAliasDelete); - EXPECT_EQ(0, 1); - return; - } - char tmpDelete[NUM3] = { 0 }; - if (strcat_s((char *)keyAliasDelete.data, - strlen((char *)keyAliasDelete.data) + strlen(tmpDelete) + 1, - tmpDelete) != EOK) { - HksBlobDestroyT1(&keyAliasDelete); - EXPECT_EQ(0, 1); - return; - } - keyAliasDelete.size = strlen((char *)keyAliasDelete.data); - statusDelete = hks_delete_key(&keyAliasDelete); - EXPECT_EQ(0, statusDelete); - HksBlobDestroyT1(&keyAliasDelete); -}; - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL1_0010 - * @tc.name : Generate key, abnormal input parameters keyAlias is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0010, Function | MediumTest | Level2) -{ - char testFileName1[] = "key_auth_id1"; - struct hks_blob *keyAlias = nullptr; - int32_t status; - - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - - status = hks_generate_key(keyAlias, &keyParam); - EXPECT_EQ(NUM1000, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL1_0020 - * @tc.name : Generate key, abnormal input parameters keyAlias.size is 0 - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0020, Function | MediumTest | Level2) -{ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - struct hks_blob keyAlias; - int32_t status; - - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = 0; - - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - - status = hks_generate_key(&keyAlias, &keyParam); - EXPECT_EQ(NUM135, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL1_0030 - * @tc.name : Generate key, abnormal input parameters keyAlias.size is more than 64 - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0030, Function | MediumTest | Level2) -{ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - struct hks_blob keyAlias; - int32_t status; - - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = NUM65; - - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - - status = hks_generate_key(&keyAlias, &keyParam); - EXPECT_EQ(NUM135, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL1_0040 - * @tc.name : Generate key, abnormal input parameters keyAlias.type is not equal to HKS_BLOB_TYPE_ALIAS - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0040, Function | MediumTest | Level2) -{ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - struct hks_blob keyAlias; - int32_t status; - - keyAlias.type = 0; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - - status = hks_generate_key(&keyAlias, &keyParam); - EXPECT_EQ(NUM135, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL1_0050 - * @tc.name : Generate key, abnormal input parameters keyAlias.data is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0050, Function | MediumTest | Level2) -{ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - struct hks_blob keyAlias; - - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - keyAlias.data = NULL; - keyAlias.size = sizeof(testFileName); - - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - - int32_t status = hks_generate_key(&keyAlias, &keyParam); - EXPECT_EQ(NUM135, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL1_0060 - * @tc.name : Generate key, abnormal input parameters keyParam is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0060, Function | MediumTest | Level2) -{ - char testFileName[] = "keyalias1"; - struct hks_blob keyAlias; - int32_t status; - - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - - struct hks_key_param *keyParam = nullptr; - - status = hks_generate_key(&keyAlias, keyParam); - EXPECT_EQ(NUM1000, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL1_0070 - * @tc.name : Generate key, abnormal input parameters keyParam.key_type - is not equal to HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519 - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0070, Function | MediumTest | Level2) -{ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - struct hks_blob keyAlias; - int32_t status; - - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = 1; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - - status = hks_generate_key(&keyAlias, &keyParam); - EXPECT_EQ(NUM134, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL1_0080 - * @tc.name : Generate key, abnormal input parameters keyParam.key_auth_id.size is 0 - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0080, Function | MediumTest | Level2) -{ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - struct hks_blob keyAlias; - int32_t status; - - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = 0; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - - status = hks_generate_key(&keyAlias, &keyParam); - EXPECT_EQ(NUM135, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL1_0090 - * @tc.name : Generate key, abnormal input parameters keyParam.key_auth_id.size is more than 64 - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0090, Function | MediumTest | Level2) -{ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - struct hks_blob keyAlias; - int32_t status; - - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = NUM65; - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - - status = hks_generate_key(&keyAlias, &keyParam); - EXPECT_EQ(NUM135, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL1_0100 - * @tc.name : Generate key, abnormal input parameters keyParam.key_auth_id.type - is not equal to HKS_BLOB_TYPE_AUTHID - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0100, Function | MediumTest | Level2) -{ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - struct hks_blob keyAlias; - int32_t status; - - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = 0; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - - status = hks_generate_key(&keyAlias, &keyParam); - EXPECT_EQ(NUM135, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL1_0110 - * @tc.name : Generate key, abnormal input parameters keyParam.key_auth_id.data is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0110, Function | MediumTest | Level2) -{ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - struct hks_blob keyAlias; - int32_t status; - - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - - struct hks_key_param keyParam; - keyParam.key_auth_id.data = NULL; - keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - - status = hks_generate_key(&keyAlias, &keyParam); - EXPECT_EQ(NUM1000, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL1_0120 - * @tc.name : Generate key, the number of stored keys is more than 20 - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksGenDelTestSuite, securityDataGenerateKey0120, Function | MediumTest | Level2) -{ - char testFileName[] = "keyalias1", testFileName1[] = "key_auth_id1"; - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t*)testFileName1; keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; keyParam.key_usage = 0; keyParam.key_pad = 0; - for (int j = 0; j < NUM21; j++) { - struct hks_blob keyAlias; - HksStBlobInit1(&keyAlias, sizeof(uint8_t), sizeof(testFileName) + NUM3, HKS_BLOB_TYPE_ALIAS); - if (memcpy_s(keyAlias.data, sizeof(testFileName), testFileName, sizeof(testFileName)) != EOK) { - HksBlobDestroyT1(&keyAlias); - EXPECT_EQ(0, 1); - return; - } - char tmp[NUM3] = { 0 }; - sprintf_s(tmp, sizeof(tmp), "%d", j); - if (strcat_s((char*)keyAlias.data, strlen((char*)keyAlias.data) + strlen(tmp) + 1, tmp) != EOK) { - HksBlobDestroyT1(&keyAlias); - EXPECT_EQ(0, 1); - return; - } - keyAlias.size = strlen((char*)keyAlias.data); - int status = hks_generate_key(&keyAlias, &keyParam); - if (j < NUM20){EXPECT_EQ(0, status); } - else {EXPECT_EQ(NUM142, status); } - HksBlobDestroyT1(&keyAlias); - } - for (int j = 0; j < NUM20; j++) { - struct hks_blob keyAlias; - HksStBlobInit1(&keyAlias, sizeof(uint8_t), sizeof(testFileName) + NUM3, HKS_BLOB_TYPE_ALIAS); - if (memcpy_s(keyAlias.data, sizeof(testFileName), testFileName, sizeof(testFileName)) != EOK) { - HksBlobDestroyT1(&keyAlias); - EXPECT_EQ(0, 1); - return; - } - char tmp[NUM3] = { 0 }; - sprintf_s(tmp, sizeof(tmp), "%d", j); - if (strcat_s((char*)keyAlias.data, strlen((char*)keyAlias.data) + strlen(tmp) + 1, tmp) != EOK) { - HksBlobDestroyT1(&keyAlias); - EXPECT_EQ(0, 1); - return; - } - keyAlias.size = strlen((char*)keyAlias.data); - int status = hks_delete_key(&keyAlias); - EXPECT_EQ(0, status); - HksBlobDestroyT1(&keyAlias); - } -} - - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++generate key -// end+++++++++++++++++++++++++++++++++++++++++++++++++++++0000-0120 - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Delete key -// begin+++++++++++++++++++++++++++++++++++++++++++++++++++++0130-0190 - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL1_0130 - * @tc.name : Delete key, normal input parameters keyAlias and keyParam - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksGenDelTestSuite, securityDataDeleteKey0130, Function | MediumTest | Level1) -{ - char testFileName[] = "keyalias1"; - char testFileName1[] = "key_auth_id1"; - int32_t statusGenerate; - int32_t statusDelete; - struct hks_key_param keyParam; - keyParam.key_auth_id.data = (uint8_t *)testFileName1; - keyParam.key_auth_id.size = sizeof(testFileName1); - keyParam.key_auth_id.type = HKS_BLOB_TYPE_AUTH_ID; - keyParam.key_type = HKS_KEY_TYPE_EDDSA_KEYPAIR_ED25519; - keyParam.key_len = 0; - keyParam.key_usage = 0; - keyParam.key_pad = 0; - struct hks_blob keyAliasGenerate; - HksStBlobInit1(&keyAliasGenerate, sizeof(uint8_t), sizeof(testFileName) + NUM3, HKS_BLOB_TYPE_ALIAS); - if (memcpy_s(keyAliasGenerate.data, sizeof(testFileName), testFileName, sizeof(testFileName)) != EOK) { - HksBlobDestroyT1(&keyAliasGenerate); - EXPECT_EQ(0, 1); - return; - } - char tmpGenerate[NUM3] = { 0 }; - if (strcat_s((char *)keyAliasGenerate.data, - strlen((char *)keyAliasGenerate.data) + strlen(tmpGenerate) + 1, - tmpGenerate) != EOK) { - HksBlobDestroyT1(&keyAliasGenerate); - EXPECT_EQ(0, 1); - return; - } - keyAliasGenerate.size = strlen((char *)keyAliasGenerate.data); - statusGenerate = hks_generate_key(&keyAliasGenerate, &keyParam); - EXPECT_EQ(0, statusGenerate); - HksBlobDestroyT1(&keyAliasGenerate); - struct hks_blob keyAliasDelete; - HksStBlobInit1(&keyAliasDelete, sizeof(uint8_t), sizeof(testFileName) + NUM3, HKS_BLOB_TYPE_ALIAS); - if (memcpy_s(keyAliasDelete.data, sizeof(testFileName), testFileName, sizeof(testFileName)) != EOK) { - HksBlobDestroyT1(&keyAliasDelete); - EXPECT_EQ(0, 1); - return; - } - char tmpDelete[NUM3] = { 0 }; - if (strcat_s((char *)keyAliasDelete.data, - strlen((char *)keyAliasDelete.data) + strlen(tmpDelete) + 1, - tmpDelete) != EOK) { - HksBlobDestroyT1(&keyAliasDelete); - EXPECT_EQ(0, 1); - return; - } - keyAliasDelete.size = strlen((char *)keyAliasDelete.data); - statusDelete = hks_delete_key(&keyAliasDelete); - EXPECT_EQ(0, statusDelete); - HksBlobDestroyT1(&keyAliasDelete); -}; - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL1_0140 - * @tc.name : Delete key, abnormal input parameters keyAlias is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksGenDelTestSuite, securityDataDeleteKey0140, Function | MediumTest | Level2) -{ - int32_t status; - struct hks_blob *keyAlias = nullptr; - - status = hks_delete_key(keyAlias); - EXPECT_EQ(NUM1000, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL1_0150 - * @tc.name : Delete key, abnormal input parameters keyAlias.data is null - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksGenDelTestSuite, securityDataDeleteKey0150, Function | MediumTest | Level2) -{ - int32_t status; - char testFileName[] = "Test_file_north_interfaces"; - struct hks_blob keyAlias = { 0 }; - - keyAlias.data = NULL; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - status = hks_delete_key(&keyAlias); - EXPECT_EQ(NUM135, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL1_0160 - * @tc.name : Delete key, abnormal input parameters keyAlias.type is not equal to HKS_BLOB_TYPE_ALIAS - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksGenDelTestSuite, securityDataDeleteKey0160, Function | MediumTest | Level2) -{ - int32_t status; - char testFileName[] = "Test_file_north_interfaces"; - struct hks_blob keyAlias = { 0 }; - - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = 0; - - status = hks_delete_key(&keyAlias); - EXPECT_EQ(NUM135, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL1_0170 - * @tc.name : Delete key, abnormal input parameters keyAlias.size is 0 - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksGenDelTestSuite, securityDataDeleteKey0170, Function | MediumTest | Level2) -{ - int32_t status; - char testFileName[] = "Test_file_north_interfaces"; - struct hks_blob keyAlias = { 0 }; - - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = 0; - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - status = hks_delete_key(&keyAlias); - EXPECT_EQ(NUM135, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL1_0180 - * @tc.name : Delete key, abnormal input parameters keyAlias.size is more than 64 - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksGenDelTestSuite, securityDataDeleteKey0180, Function | MediumTest | Level2) -{ - int32_t status; - char testFileName[] = "Test_file_north_interfaces"; - struct hks_blob keyAlias = { 0 }; - - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = NUM65; - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - status = hks_delete_key(&keyAlias); - EXPECT_EQ(NUM135, status); -} - -/* * - * @tc.number : SUB_SEC_DataPro_HuksL1_0190 - * @tc.name : Delete key, the key does not exist - * @tc.desc : [C- SECURITY -1500] - */ -HWTEST_F(SecurityDataHuksGenDelTestSuite, securityDataDeleteKey0190, Function | MediumTest | Level2) -{ - int32_t status; - char testFileName[] = "Test_file_north_interfaces"; - struct hks_blob keyAlias = { 0 }; - - keyAlias.data = (uint8_t *)testFileName; - keyAlias.size = sizeof(testFileName); - keyAlias.type = HKS_BLOB_TYPE_ALIAS; - - status = hks_delete_key(&keyAlias); - EXPECT_EQ(NUM1010, status); -} -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Delete key -// end+++++++++++++++++++++++++++++++++++++++++++++++++++++++0130-0190 diff --git a/security_lite/huks_posix/src/SecurityDataHuksHashRandomHmacTest.cpp b/security_lite/huks_posix/src/SecurityDataHuksHashRandomHmacTest.cpp deleted file mode 100755 index ed5218bb03d838620b9f446447094829b916f953..0000000000000000000000000000000000000000 --- a/security_lite/huks_posix/src/SecurityDataHuksHashRandomHmacTest.cpp +++ /dev/null @@ -1,778 +0,0 @@ -/* Copyright (c) 2020-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. -*/ -#include "SecurityDataHuks.h" -#include "hks_client.h" -#include "hks_types.h" -#include -#include -#include -#include -#include -#include "gtest/gtest.h" -using namespace std; -using namespace testing::ext; - -class SecurityDataHuksHashRandomHmacTestSuite : public testing::Test { -protected: - // SetUpTestCase: Testsuit setup, run before 1st testcase - static void SetUpTestCase(void) {} - // TearDownTestCase: Testsuit teardown, run after last testcase - static void TearDownTestCase(void) {} - // Testcase setup - virtual void SetUp() - { - int32_t status; - struct hks_file_callbacks fileCallbacks; - - fileCallbacks.read = FileRead; - fileCallbacks.write = FileWrite; - fileCallbacks.file_size = FileSize; - - status = hks_register_file_callbacks(&fileCallbacks); - EXPECT_EQ(0, status); - - struct hks_log_f_group logFunc; - logFunc.log_info = Logi; - logFunc.log_warn = Logw; - logFunc.log_error = Loge; - logFunc.log_debug = Logd; - - status = hks_register_log_interface(&logFunc); - EXPECT_EQ(0, status); - - status = hks_register_get_hardware_udid_callback(HksTestGetHardwareUdid); - - EXPECT_EQ(0, status); - - status = hks_init(); - if (status != 0) { - status = hks_refresh_key_info(); - } - EXPECT_EQ(0, status); - } - - // Testcase teardown - virtual void TearDown() {} -}; - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Hash -// begin+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++1100-1190 - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1100 - * @tc.name : Hash, normal input parameters SHA256, src, dst - * @tc.desc : [C- SECURITY -1600] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHash1100, Function | MediumTest | Level1) -{ - struct hks_blob src, dst; - src.data = (uint8_t *)"123456"; - src.size = NUM6; - dst.data = (uint8_t *)malloc(NUM65); - if (dst.data == NULL) { - EXPECT_EQ(0, 1); - } - dst.size = NUM65; - - int32_t res = hks_hash(HKS_ALG_HASH_SHA_256, &src, &dst); - EXPECT_EQ(0, res); - free(dst.data); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1110 - * @tc.name : Hash, normal input parameters SHA512, src, dst - * @tc.desc : [C- SECURITY -1600] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHash1110, Function | MediumTest | Level1) -{ - struct hks_blob src, dst; - src.data = (uint8_t *)"123456"; - src.size = NUM6; - dst.data = (uint8_t *)malloc(NUM65); - if (dst.data == NULL) { - EXPECT_EQ(0, 1); - } - dst.size = NUM65; - - int32_t res = hks_hash(HKS_ALG_HASH_SHA_512, &src, &dst); - EXPECT_EQ(0, res); - free(dst.data); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1120 - * @tc.name : Hash, abnormal input parameters alg is not equal to HKS_ALG_HASH_SHA_256 or HKS_ALG_HASH_SHA_512 - * @tc.desc : [C- SECURITY -1600] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHash1120, Function | MediumTest | Level2) -{ - struct hks_blob srcData = { 0 }; - char tmpData6[] = "30313233343536373839616263646566"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM16, 0); - - struct hks_blob hash = { 0 }; - char tmpData7[] = "3031323334353637383961626364656630313233343536373839616263646566"; - BuildBlobData(&hash, tmpData7, HKS_BLOB_TYPE_RAW, NUM32, 0); - - uint32_t alg = HKS_ALG_HASH_SHA_1; - int32_t status = hks_hash(alg, &srcData, &hash); - HksBlobDestroyT1(&srcData); - HksBlobDestroyT1(&hash); - EXPECT_EQ(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1130 - * @tc.name : Hash, abnormal input parameters srcData is null - * @tc.desc : [C- SECURITY -1600] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHash1130, Function | MediumTest | Level2) -{ - struct hks_blob *srcData = nullptr; - - struct hks_blob hash = { 0 }; - const char tmpData7[] = "3031323334353637383961626364656630313233343536373839616263646566"; - BuildBlobData(&hash, tmpData7, HKS_BLOB_TYPE_RAW, NUM32, 0); - - uint32_t alg = HKS_ALG_HASH_SHA_256; - int32_t status = hks_hash(alg, srcData, &hash); - HksBlobDestroyT1(&hash); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1140 - * @tc.name : Hash, abnormal input parameters srcData.data is null - * @tc.desc : [C- SECURITY -1600] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHash1140, Function | MediumTest | Level2) -{ - struct hks_blob srcData = { 0 }; - const char tmpData6[] = "30313233343536373839616263646566"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM16, 1); - struct hks_blob hash = { 0 }; - const char tmpData7[] = "3031323334353637383961626364656630313233343536373839616263646566"; - BuildBlobData(&hash, tmpData7, HKS_BLOB_TYPE_RAW, NUM32, 0); - - uint32_t alg = HKS_ALG_HASH_SHA_256; - int32_t status = hks_hash(alg, &srcData, &hash); - HksBlobDestroyT1(&srcData); - HksBlobDestroyT1(&hash); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1150 - * @tc.name : Hash, abnormal input parameters srcData.size is 0 - * @tc.desc : [C- SECURITY -1600] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHash1150, Function | MediumTest | Level2) -{ - struct hks_blob srcData = { 0 }; - srcData.data = (uint8_t *)"1234567890abcdefghigkl0123456789"; - srcData.size = 0; - srcData.type = HKS_BLOB_TYPE_RAW; - - struct hks_blob hash = { 0 }; - const char tmpData7[] = "3031323334353637383961626364656630313233343536373839616263646566"; - BuildBlobData(&hash, tmpData7, HKS_BLOB_TYPE_RAW, NUM32, 0); - - uint32_t alg = HKS_ALG_HASH_SHA_256; - int32_t status = hks_hash(alg, &srcData, &hash); - HksBlobDestroyT1(&hash); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1160 - * @tc.name : Hash, abnormal input parameters hash is null - * @tc.desc : [C- SECURITY -1600] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHash1160, Function | MediumTest | Level2) -{ - struct hks_blob srcData = { 0 }; - const char tmpData6[] = "30313233343536373839616263646566"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM16, 0); - - struct hks_blob *hash = nullptr; - - uint32_t alg = HKS_ALG_HASH_SHA_256; - int32_t status = hks_hash(alg, &srcData, hash); - HksBlobDestroyT1(&srcData); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1170 - * @tc.name : Hash, abnormal input parameters hash.data is null - * @tc.desc : [C- SECURITY -1600] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHash1170, Function | MediumTest | Level2) -{ - struct hks_blob srcData = { 0 }; - const char tmpData6[] = "30313233343536373839616263646566"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM16, 0); - - struct hks_blob hash = { 0 }; - const char tmpData7[] = "3031323334353637383961626364656630313233343536373839616263646566"; - BuildBlobData(&hash, tmpData7, HKS_BLOB_TYPE_RAW, NUM32, 1); - - uint32_t alg = HKS_ALG_HASH_SHA_256; - int32_t status = hks_hash(alg, &srcData, &hash); - HksBlobDestroyT1(&srcData); - HksBlobDestroyT1(&hash); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1180 - * @tc.name : Hash, abnormal input parameters hash.size is less than 32 - * @tc.desc : [C- SECURITY -1600] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHash1180, Function | MediumTest | Level2) -{ - struct hks_blob srcData = { 0 }; - const char tmpData6[] = "30313233343536373839616263646566"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM16, 0); - - struct hks_blob hash = { 0 }; - const char tmpData7[] = "303132333435363738396162636465663031323334353637383961611266"; - BuildBlobData(&hash, tmpData7, HKS_BLOB_TYPE_RAW, NUM30, 0); - - uint32_t alg = HKS_ALG_HASH_SHA_256; - int32_t status = hks_hash(alg, &srcData, &hash); - HksBlobDestroyT1(&srcData); - HksBlobDestroyT1(&hash); - EXPECT_EQ(NUM1007, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1190 - * @tc.name : Hash, abnormal input parameters hash.size is less than 64 - * @tc.desc : [C- SECURITY -1600] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHash1190, Function | MediumTest | Level2) -{ - struct hks_blob srcData = { 0 }; - const char tmpData6[] = "30313233343536373839616263646566"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM16, 0); - - struct hks_blob hash = { 0 }; - const char tmpData7[] = "30313233343536373839616263646566303132333435363738396162636465663031323334" - "3536373839616263646566303132333435363738396162"; - BuildBlobData(&hash, tmpData7, HKS_BLOB_TYPE_RAW, NUM60, 0); - - uint32_t alg = HKS_ALG_HASH_SHA_512; - int32_t status = hks_hash(alg, &srcData, &hash); - HksBlobDestroyT1(&srcData); - HksBlobDestroyT1(&hash); - EXPECT_EQ(NUM1007, status); -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Hash -// end+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++1100-1190 - - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Generate random -// beign++++++++++++++++++++++++++++++++++++++++++++++++1200-1230 - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1200 - * @tc.name : Generate Random, normal input parameters random - * @tc.desc : [C- SECURITY -1700] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataGenerateRandom1200, Function | MediumTest | Level1) -{ - int32_t status; - struct hks_blob random = { 0 }; - - random.data = (uint8_t *)calloc(1, NUM64); - if (random.data == NULL) { - EXPECT_EQ(0, 1); - return; - } - if (memset_s(random.data, NUM64, 0, NUM64) != EOK) { - EXPECT_EQ(0, 1); - } - random.size = NUM64; - random.type = 0; - status = hks_generate_random(&random); - EXPECT_EQ(0, status); - - HksBlobDestroyT1(&random); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1210 - * @tc.name : Generate Random, abnormal input parameters random is null - * @tc.desc : [C- SECURITY -1700] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataGenerateRandom1210, Function | MediumTest | Level2) -{ - int32_t status; - struct hks_blob *random = nullptr; - - status = hks_generate_random(random); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1220 - * @tc.name : Generate Random, abnormal input parameters random.data is null - * @tc.desc : [C- SECURITY -1700] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataGenerateRandom1220, Function | MediumTest | Level2) -{ - int32_t status; - struct hks_blob random = { 0 }; - - random.data = NULL; - random.size = NUM32; - random.type = HKS_BLOB_TYPE_KEY; - - status = hks_generate_random(&random); - EXPECT_EQ(NUM1000, status); - HksBlobDestroyT1(&random); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1230 - * @tc.name : Generate Random, abnormal input parameters random.size is more than 1024 - * @tc.desc : [C- SECURITY -1700] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataGenerateRandom1230, Function | MediumTest | Level2) -{ - int32_t status; - struct hks_blob random = { 0 }; - - random.data = (uint8_t *)malloc(NUM1025); - if (random.data == NULL) { - EXPECT_EQ(0, 1); - } - random.size = NUM1025; - random.type = HKS_BLOB_TYPE_KEY; - - status = hks_generate_random(&random); - EXPECT_EQ(NUM135, status); - HksBlobDestroyT1(&random); -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Generate random -// end++++++++++++++++++++++++++++++++++++++++++++++++++1200-1230 - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Hmac -// begin+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++1240-1380 - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1240 - * @tc.name : Hmac, normal input parameters SHA256, keyAlias, alg, srcData, output - * @tc.desc : [C- SECURITY -2000] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHmac1240, Function | MediumTest | Level1) -{ - struct hks_blob keyAlias; - uint32_t alg = hks_alg_hmac(HKS_ALG_HASH_SHA_256); - struct hks_blob srcData; - srcData.data = (uint8_t *)"123456789"; - srcData.size = NUM9; - - struct hks_blob output; - output.data = (uint8_t *)malloc(NUM65); - output.size = NUM65; - keyAlias.data = (uint8_t *)"1234567890abcdefghigkl0123456789"; - keyAlias.size = NUM32; - keyAlias.type = HKS_KEY_USAGE_EXPORT; - - int32_t status = hks_hmac(&keyAlias, alg, &srcData, &output); - EXPECT_EQ(0, status); - - HKS_FREE_PTR1(output.data); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1250 - * @tc.name : Hmac, normal input parameters SHA512, keyAlias, alg, srcData, output - * @tc.desc : [C- SECURITY -2000] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHmac1250, Function | MediumTest | Level1) -{ - struct hks_blob keyAlias; - uint32_t alg = hks_alg_hmac(HKS_ALG_HASH_SHA_512); - struct hks_blob srcData; - srcData.data = (uint8_t *)"123456789"; - srcData.size = NUM9; - - struct hks_blob output; - output.data = (uint8_t *)malloc(NUM65); - output.size = NUM65; - keyAlias.data = (uint8_t *)"1234567890abcdefghigkl0123456789"; - keyAlias.size = NUM65; - keyAlias.type = HKS_KEY_USAGE_EXPORT; - - int32_t status = hks_hmac(&keyAlias, alg, &srcData, &output); - EXPECT_EQ(0, status); - - HKS_FREE_PTR1(output.data); -}; - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1260 - * @tc.name : Hmac, abnormal input parameters key is null - * @tc.desc : [C- SECURITY -2000] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHmac1260, Function | MediumTest | Level2) -{ - struct hks_blob *key = nullptr; - struct hks_blob srcData = { 0 }; - const char tmpData6[] = "3031323334353637"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM8, 0); - - struct hks_blob output = { 0 }; - const char tmpData7[] = "3031323334353637303132333435363730313233343536373031323334353637"; - BuildBlobData(&output, tmpData7, HKS_BLOB_TYPE_RAW, NUM32, 0); - - uint32_t alg = hks_alg_hmac(HKS_ALG_HASH_SHA_256); - int32_t status = hks_hmac(key, alg, &srcData, &output); - HksBlobDestroyT1(&srcData); - HksBlobDestroyT1(&output); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1270 - * @tc.name : Hmac, abnormal input parameters key.data is null - * @tc.desc : [C- SECURITY -2000] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHmac1270, Function | MediumTest | Level2) -{ - struct hks_blob key = { 0 }; - const char tmpData5[] = "3031323334353637303132333435363730313233343536373031323334353637"; - BuildBlobData(&key, tmpData5, HKS_BLOB_TYPE_RAW, NUM32, NUM1); - - struct hks_blob srcData = { 0 }; - const char tmpData6[] = "3031323334353637"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM8, 0); - - struct hks_blob output = { 0 }; - const char tmpData7[] = "3031323334353637303132333435363730313233343536373031323334353637"; - BuildBlobData(&output, tmpData7, HKS_BLOB_TYPE_RAW, NUM32, 0); - - uint32_t alg = hks_alg_hmac(HKS_ALG_HASH_SHA_256); - int32_t status = hks_hmac(&key, alg, &srcData, &output); - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&srcData); - HksBlobDestroyT1(&output); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1280 - * @tc.name : Hmac, abnormal input parameters key.size is 0 - * @tc.desc : [C- SECURITY -2000] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHmac1280, Function | MediumTest | Level2) -{ - struct hks_blob key = { 0 }; - key.data = (uint8_t *)"1234567890abcdefghigkl0123456789"; - key.size = 0; - key.type = HKS_BLOB_TYPE_RAW; - - struct hks_blob srcData = { 0 }; - const char tmpData6[] = "3031323334353637"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM8, 0); - - struct hks_blob output = { 0 }; - const char tmpData7[] = "3031323334353637303132333435363730313233343536373031323334353637"; - BuildBlobData(&output, tmpData7, HKS_BLOB_TYPE_RAW, NUM32, 0); - - uint32_t alg = hks_alg_hmac(HKS_ALG_HASH_SHA_256); - int32_t status = hks_hmac(&key, alg, &srcData, &output); - HksBlobDestroyT1(&srcData); - HksBlobDestroyT1(&output); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1290 - * @tc.name : Hmac, abnormal input parameters alg is not equal to sha256 or sha512 - * @tc.desc : [C- SECURITY -2000] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHmac1290, Function | MediumTest | Level2) -{ - struct hks_blob key = { 0 }; - const char tmpData5[] = "3031323334353637303132333435363730313233343536373031323334353637"; - BuildBlobData(&key, tmpData5, HKS_BLOB_TYPE_RAW, NUM32, 0); - - struct hks_blob srcData = { 0 }; - const char tmpData6[] = "3031323334353637"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM8, 0); - - struct hks_blob output = { 0 }; - const char tmpData7[] = "3031323334353637303132333435363730313233343536373031323334353637"; - BuildBlobData(&output, tmpData7, HKS_BLOB_TYPE_RAW, NUM32, 0); - - uint32_t alg = hks_alg_hmac(HKS_ALG_HASH_SHA_1); - int32_t status = hks_hmac(&key, alg, &srcData, &output); - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&srcData); - HksBlobDestroyT1(&output); - EXPECT_EQ(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1300 - * @tc.name : Hmac, abnormal input parameters srcData is null - * @tc.desc : [C- SECURITY -2000] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHmac1300, Function | MediumTest | Level2) -{ - struct hks_blob key = { 0 }; - const char tmpData5[] = "3031323334353637303132333435363730313233343536373031323334353637"; - BuildBlobData(&key, tmpData5, HKS_BLOB_TYPE_RAW, NUM32, 0); - - struct hks_blob *srcData = nullptr; - - struct hks_blob output = { 0 }; - const char tmpData7[] = "3031323334353637303132333435363730313233343536373031323334353637"; - BuildBlobData(&output, tmpData7, HKS_BLOB_TYPE_RAW, NUM32, 0); - - uint32_t alg = hks_alg_hmac(HKS_ALG_HASH_SHA_256); - int32_t status = hks_hmac(&key, alg, srcData, &output); - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&output); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1310 - * @tc.name : Hmac, abnormal input parameters srcData.data is null - * @tc.desc : [C- SECURITY -2000] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHmac1310, Function | MediumTest | Level2) -{ - struct hks_blob key = { 0 }; - const char tmpData5[] = "3031323334353637303132333435363730313233343536373031323334353637"; - BuildBlobData(&key, tmpData5, HKS_BLOB_TYPE_RAW, NUM32, 0); - - struct hks_blob srcData = { 0 }; - const char tmpData6[] = "3031323334353637"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM8, NUM1); - - struct hks_blob output = { 0 }; - const char tmpData7[] = "3031323334353637303132333435363730313233343536373031323334353637"; - BuildBlobData(&output, tmpData7, HKS_BLOB_TYPE_RAW, NUM32, 0); - - uint32_t alg = hks_alg_hmac(HKS_ALG_HASH_SHA_256); - int32_t status = hks_hmac(&key, alg, &srcData, &output); - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&srcData); - HksBlobDestroyT1(&output); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1320 - * @tc.name : Hmac, abnormal input parameters srcData.size is 0 - * @tc.desc : [C- SECURITY -2000] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHmac1320, Function | MediumTest | Level2) -{ - struct hks_blob key = { 0 }; - const char tmpData5[] = "3031323334353637303132333435363730313233343536373031323334353637"; - BuildBlobData(&key, tmpData5, HKS_BLOB_TYPE_RAW, NUM32, 0); - - struct hks_blob srcData = { 0 }; - srcData.data = (uint8_t *)"1234567890abcdefghigkl0123456789"; - srcData.size = 0; - srcData.type = HKS_BLOB_TYPE_RAW; - - struct hks_blob output = { 0 }; - const char tmpData7[] = "3031323334353637303132333435363730313233343536373031323334353637"; - BuildBlobData(&output, tmpData7, HKS_BLOB_TYPE_RAW, NUM32, 0); - - uint32_t alg = hks_alg_hmac(HKS_ALG_HASH_SHA_256); - int32_t status = hks_hmac(&key, alg, &srcData, &output); - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&output); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1330 - * @tc.name : Hmac, abnormal input parameters output is null - * @tc.desc : [C- SECURITY -2000] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHmac1330, Function | MediumTest | Level2) -{ - struct hks_blob key = { 0 }; - const char tmpData5[] = "3031323334353637303132333435363730313233343536373031323334353637"; - BuildBlobData(&key, tmpData5, HKS_BLOB_TYPE_RAW, NUM32, 0); - - struct hks_blob srcData = { 0 }; - const char tmpData6[] = "3031323334353637"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM8, 0); - - struct hks_blob *output = nullptr; - - uint32_t alg = hks_alg_hmac(HKS_ALG_HASH_SHA_256); - int32_t status = hks_hmac(&key, alg, &srcData, output); - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&srcData); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1340 - * @tc.name : Hmac, abnormal input parameters output.data is null - * @tc.desc : [C- SECURITY -2000] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHmac1340, Function | MediumTest | Level2) -{ - struct hks_blob key = { 0 }; - const char tmpData5[] = "3031323334353637303132333435363730313233343536373031323334353637"; - BuildBlobData(&key, tmpData5, HKS_BLOB_TYPE_RAW, NUM32, 0); - - struct hks_blob srcData = { 0 }; - const char tmpData6[] = "3031323334353637"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM8, 0); - - struct hks_blob output = { 0 }; - const char tmpData7[] = "3031323334353637303132333435363730313233343536373031323334353637"; - BuildBlobData(&output, tmpData7, HKS_BLOB_TYPE_RAW, NUM32, NUM1); - - uint32_t alg = hks_alg_hmac(HKS_ALG_HASH_SHA_256); - int32_t status = hks_hmac(&key, alg, &srcData, &output); - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&srcData); - HksBlobDestroyT1(&output); - EXPECT_EQ(NUM1000, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1350 - * @tc.name : Hmac, abnormal input parameters alg is sha256 and key.size is less than 32 - * @tc.desc : [C- SECURITY -2000] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHmac1350, Function | MediumTest | Level2) -{ - struct hks_blob key = { 0 }; - const char tmpData5[] = "303132333435363730313233343536373031323334353637303132333411"; - BuildBlobData(&key, tmpData5, HKS_BLOB_TYPE_RAW, NUM30, 0); - - struct hks_blob srcData = { 0 }; - const char tmpData6[] = "3031323334353637"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM8, 0); - - struct hks_blob output = { 0 }; - const char tmpData7[] = "3031323334353637303132333435363730313233343536373031323334353637"; - BuildBlobData(&output, tmpData7, HKS_BLOB_TYPE_RAW, NUM32, 0); - - uint32_t alg = hks_alg_hmac(HKS_ALG_HASH_SHA_256); - int32_t status = hks_hmac(&key, alg, &srcData, &output); - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&srcData); - HksBlobDestroyT1(&output); - EXPECT_EQ(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1360 - * @tc.name : Hmac, abnormal input parameters alg is sha512 and key.size is less than 64 - * @tc.desc : [C- SECURITY -2000] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHmac1360, Function | MediumTest | Level2) -{ - struct hks_blob key = { 0 }; - const char tmpData5[] = "30313233343536373031323334353637303132333435363730313233343536373031323334" - "35363730313233343536373031323334353637303132333435"; - BuildBlobData(&key, tmpData5, HKS_BLOB_TYPE_RAW, NUM62, 0); - - struct hks_blob srcData = { 0 }; - const char tmpData6[] = "3031323334353637"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM8, 0); - - struct hks_blob output = { 0 }; - const char tmpData7[] = "30313233343536373031323334353637303132333435363730313233343536373031323334" - "353637303132333435363730313233343536373031323334353637"; - BuildBlobData(&output, tmpData7, HKS_BLOB_TYPE_RAW, NUM64, 0); - - uint32_t alg = hks_alg_hmac(HKS_ALG_HASH_SHA_512); - int32_t status = hks_hmac(&key, alg, &srcData, &output); - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&srcData); - HksBlobDestroyT1(&output); - EXPECT_EQ(NUM135, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1370 - * @tc.name : Hmac, abnormal input parameters alg is sha256 and output.size is less than 32 - * @tc.desc : [C- SECURITY -2000] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHmac1370, Function | MediumTest | Level2) -{ - struct hks_blob key = { 0 }; - const char tmpData5[] = "3031323334353637303132333435363730313233343536373031323334353637"; - BuildBlobData(&key, tmpData5, HKS_BLOB_TYPE_RAW, NUM32, 0); - - struct hks_blob srcData = { 0 }; - const char tmpData6[] = "3031323334353637"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM8, 0); - - - struct hks_blob output = { 0 }; - const char tmpData7[] = "303132333435363730313233343536373031323334353637303132333413"; - BuildBlobData(&output, tmpData7, HKS_BLOB_TYPE_RAW, NUM30, 0); - - uint32_t alg = hks_alg_hmac(HKS_ALG_HASH_SHA_256); - int32_t status = hks_hmac(&key, alg, &srcData, &output); - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&srcData); - HksBlobDestroyT1(&output); - EXPECT_EQ(NUM1007, status); -} - -/* - * @tc.number : SUB_SEC_DataPro_HuksL1_1380 - * @tc.name : Hmac, abnormal input parameters alg is sha512 and output.size is less than 64 - * @tc.desc : [C- SECURITY -2000] - */ -HWTEST_F(SecurityDataHuksHashRandomHmacTestSuite, securityDataHmac1380, Function | MediumTest | Level2) -{ - struct hks_blob key = { 0 }; - const char tmpData5[] = "303132333435363730313233343536373031323334353637303132333435363730313233343" - "53637303132333435363730313233343536373031323334353637"; - BuildBlobData(&key, tmpData5, HKS_BLOB_TYPE_RAW, NUM64, 0); - - struct hks_blob srcData = { 0 }; - const char tmpData6[] = "3031323334353637"; - BuildBlobData(&srcData, tmpData6, HKS_BLOB_TYPE_RAW, NUM8, 0); - - struct hks_blob output = { 0 }; - const char tmpData7[] = "303132333435363730313233343536373031323334353637303132333435363730313233343" - "5363730313233343536373031323334353637303132333435"; - BuildBlobData(&output, tmpData7, HKS_BLOB_TYPE_RAW, NUM62, 0); - - uint32_t alg = hks_alg_hmac(HKS_ALG_HASH_SHA_512); - int32_t status = hks_hmac(&key, alg, &srcData, &output); - HksBlobDestroyT1(&key); - HksBlobDestroyT1(&srcData); - HksBlobDestroyT1(&output); - EXPECT_EQ(NUM1007, status); -} - -// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Hmac -// end+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++1240-1380 -