From 529ce1bc3ea814366a3c1639ff34ecdab9b1b918 Mon Sep 17 00:00:00 2001 From: jiyong Date: Sat, 8 Jan 2022 10:45:03 +0800 Subject: [PATCH] delete c++'s code Signed-off-by: jiyong --- hiviewdfx/BUILD.gn | 19 - .../hiappeventtest/hiappeventjstest/BUILD.gn | 31 - .../hiappeventtest/hiappeventjstest/Test.json | 18 - .../signature/openharmony_sx.p7b | Bin 3437 -> 0 bytes .../hiappeventjstest/src/main/config.json | 60 -- .../src/main/js/default/app.js | 22 - .../src/main/js/default/i18n/en-US.json | 6 - .../src/main/js/default/i18n/zh-CN.json | 6 - .../src/main/js/default/pages/index/index.css | 9 - .../src/main/js/default/pages/index/index.hml | 5 - .../src/main/js/default/pages/index/index.js | 46 -- .../main/js/default/test/HiAppEvent.test.js | 595 ------------------ .../src/main/js/default/test/List.test.js | 15 - .../main/resources/base/element/string.json | 12 - .../src/main/resources/base/media/icon.png | Bin 6790 -> 0 bytes security/BUILD.gn | 27 - .../huks_standard_adapter/BUILD.gn | 82 --- .../huks_standard_adapter/Test.json | 18 - .../src/hks_aes_test.cpp | 95 --- .../src/hks_agreement_test.cpp | 206 ------ .../src/hks_bn_exp_mod_test.cpp | 144 ----- .../src/hks_cipher_test.cpp | 120 ---- .../src/hks_curve25519_test.cpp | 95 --- .../src/hks_delete_test.cpp | 91 --- .../src/hks_derive_test.cpp | 223 ------- .../src/hks_exist_test.cpp | 94 --- .../src/hks_generate_key_test.cpp | 130 ---- .../src/hks_generate_random_test.cpp | 87 --- .../src/hks_hash_test.cpp | 114 ---- .../src/hks_mac_test.cpp | 203 ------ .../src/hks_modify_key_test.cpp | 363 ----------- .../src/hks_others_test.cpp | 143 ----- .../src/hks_safe_cipher_key_test.cpp | 123 ---- .../src/hks_safe_compare_key_test.cpp | 168 ----- .../deviceauth/deviceauth_basic_deps/BUILD.gn | 98 --- .../deviceauth_basic_deps/Test.json | 18 - .../device_auth_test.cpp | 202 ------ .../deviceauth_basic_deps/hc_alg_test.cpp | 1 - .../hc_condition_test.cpp | 1 - .../hc_dev_info_test.cpp | 1 - .../deviceauth_basic_deps/hc_file_common.cpp | 1 - .../deviceauth_basic_deps/hc_file_f_test.cpp | 1 - .../hc_file_iot_flash_test.cpp | 1 - .../deviceauth_basic_deps/hc_file_test.cpp | 1 - .../hc_file_utils_test.cpp | 1 - .../deviceauth_basic_deps/hc_mutex_test.cpp | 1 - .../deviceauth_basic_deps/hc_thread_test.cpp | 1 - .../deviceauth_basic_deps/hc_time_test.cpp | 1 - .../deviceauth/deviceauth_basic_deps/hctest.h | 45 -- .../deviceauth_basic_deps/print_log.cpp | 1 - .../deviceauth_basic_deps/test_timer.cpp | 1 - .../deviceauth/deviceauth_function/BUILD.gn | 74 --- .../deviceauth/deviceauth_function/Test.json | 18 - .../include/deviceauth_standard_test.h | 44 -- .../include/deviceauth_test_mock.h | 25 - .../src/deviceauth_standard_test.cpp | 121 ---- .../src/deviceauth_test_mock.cpp | 47 -- test_packages.gni | 6 +- 58 files changed, 4 insertions(+), 4077 deletions(-) delete mode 100755 hiviewdfx/BUILD.gn delete mode 100755 hiviewdfx/hiappeventtest/hiappeventjstest/BUILD.gn delete mode 100755 hiviewdfx/hiappeventtest/hiappeventjstest/Test.json delete mode 100755 hiviewdfx/hiappeventtest/hiappeventjstest/signature/openharmony_sx.p7b delete mode 100755 hiviewdfx/hiappeventtest/hiappeventjstest/src/main/config.json delete mode 100755 hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/app.js delete mode 100755 hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/i18n/en-US.json delete mode 100755 hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/i18n/zh-CN.json delete mode 100755 hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/pages/index/index.css delete mode 100755 hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/pages/index/index.hml delete mode 100755 hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/pages/index/index.js delete mode 100755 hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/test/HiAppEvent.test.js delete mode 100755 hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/test/List.test.js delete mode 100755 hiviewdfx/hiappeventtest/hiappeventjstest/src/main/resources/base/element/string.json delete mode 100755 hiviewdfx/hiappeventtest/hiappeventjstest/src/main/resources/base/media/icon.png delete mode 100755 security/BUILD.gn delete mode 100644 security/dataprotect/huks_standard_adapter/BUILD.gn delete mode 100644 security/dataprotect/huks_standard_adapter/Test.json delete mode 100644 security/dataprotect/huks_standard_adapter/src/hks_aes_test.cpp delete mode 100644 security/dataprotect/huks_standard_adapter/src/hks_agreement_test.cpp delete mode 100644 security/dataprotect/huks_standard_adapter/src/hks_bn_exp_mod_test.cpp delete mode 100644 security/dataprotect/huks_standard_adapter/src/hks_cipher_test.cpp delete mode 100644 security/dataprotect/huks_standard_adapter/src/hks_curve25519_test.cpp delete mode 100644 security/dataprotect/huks_standard_adapter/src/hks_delete_test.cpp delete mode 100644 security/dataprotect/huks_standard_adapter/src/hks_derive_test.cpp delete mode 100644 security/dataprotect/huks_standard_adapter/src/hks_exist_test.cpp delete mode 100644 security/dataprotect/huks_standard_adapter/src/hks_generate_key_test.cpp delete mode 100644 security/dataprotect/huks_standard_adapter/src/hks_generate_random_test.cpp delete mode 100644 security/dataprotect/huks_standard_adapter/src/hks_hash_test.cpp delete mode 100644 security/dataprotect/huks_standard_adapter/src/hks_mac_test.cpp delete mode 100644 security/dataprotect/huks_standard_adapter/src/hks_modify_key_test.cpp delete mode 100644 security/dataprotect/huks_standard_adapter/src/hks_others_test.cpp delete mode 100644 security/dataprotect/huks_standard_adapter/src/hks_safe_cipher_key_test.cpp delete mode 100644 security/dataprotect/huks_standard_adapter/src/hks_safe_compare_key_test.cpp delete mode 100644 security/deviceauth/deviceauth_basic_deps/BUILD.gn delete mode 100644 security/deviceauth/deviceauth_basic_deps/Test.json delete mode 100644 security/deviceauth/deviceauth_basic_deps/device_auth_test.cpp delete mode 120000 security/deviceauth/deviceauth_basic_deps/hc_alg_test.cpp delete mode 120000 security/deviceauth/deviceauth_basic_deps/hc_condition_test.cpp delete mode 120000 security/deviceauth/deviceauth_basic_deps/hc_dev_info_test.cpp delete mode 120000 security/deviceauth/deviceauth_basic_deps/hc_file_common.cpp delete mode 120000 security/deviceauth/deviceauth_basic_deps/hc_file_f_test.cpp delete mode 120000 security/deviceauth/deviceauth_basic_deps/hc_file_iot_flash_test.cpp delete mode 120000 security/deviceauth/deviceauth_basic_deps/hc_file_test.cpp delete mode 120000 security/deviceauth/deviceauth_basic_deps/hc_file_utils_test.cpp delete mode 120000 security/deviceauth/deviceauth_basic_deps/hc_mutex_test.cpp delete mode 120000 security/deviceauth/deviceauth_basic_deps/hc_thread_test.cpp delete mode 120000 security/deviceauth/deviceauth_basic_deps/hc_time_test.cpp delete mode 100644 security/deviceauth/deviceauth_basic_deps/hctest.h delete mode 120000 security/deviceauth/deviceauth_basic_deps/print_log.cpp delete mode 120000 security/deviceauth/deviceauth_basic_deps/test_timer.cpp delete mode 100644 security/deviceauth/deviceauth_function/BUILD.gn delete mode 100644 security/deviceauth/deviceauth_function/Test.json delete mode 100644 security/deviceauth/deviceauth_function/include/deviceauth_standard_test.h delete mode 100644 security/deviceauth/deviceauth_function/include/deviceauth_test_mock.h delete mode 100644 security/deviceauth/deviceauth_function/src/deviceauth_standard_test.cpp delete mode 100644 security/deviceauth/deviceauth_function/src/deviceauth_test_mock.cpp diff --git a/hiviewdfx/BUILD.gn b/hiviewdfx/BUILD.gn deleted file mode 100755 index cc5382b53..000000000 --- a/hiviewdfx/BUILD.gn +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -import("//build/ohos_var.gni") -group("hiviewdfxtestacts") { - testonly = true - if (is_standard_system) { - deps = [ "hiappeventtest/hiappeventjstest:ActsHiAppEventJsTest" ] - } -} diff --git a/hiviewdfx/hiappeventtest/hiappeventjstest/BUILD.gn b/hiviewdfx/hiappeventtest/hiappeventjstest/BUILD.gn deleted file mode 100755 index 03725eb74..000000000 --- a/hiviewdfx/hiappeventtest/hiappeventjstest/BUILD.gn +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//test/xts/tools/build/suite.gni") - -ohos_js_hap_suite("ActsHiAppEventJsTest") { - hap_profile = "./src/main/config.json" - deps = [ - ":hiappevent_js_assets", - ":hiappevent_resources", - ] - certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsHiAppEventJsTest" -} -ohos_js_assets("hiappevent_js_assets") { - source_dir = "./src/main/js/default" -} -ohos_resources("hiappevent_resources") { - sources = [ "./src/main/resources" ] - hap_profile = "./src/main/config.json" -} diff --git a/hiviewdfx/hiappeventtest/hiappeventjstest/Test.json b/hiviewdfx/hiappeventtest/hiappeventjstest/Test.json deleted file mode 100755 index e1695ea81..000000000 --- a/hiviewdfx/hiappeventtest/hiappeventjstest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for hjunit demo Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "270000", - "package": "ohos.acts.hiviewdfx.hilog.function", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHiAppEventJsTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/hiviewdfx/hiappeventtest/hiappeventjstest/signature/openharmony_sx.p7b b/hiviewdfx/hiappeventtest/hiappeventjstest/signature/openharmony_sx.p7b deleted file mode 100755 index 9be1e98fa4c0c28ca997ed660112fa16b194f0f5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3437 zcmcgvX>b$g8MY4FF(5FQyMT=#m||qU)nQ9cId-MBB-<-lvSdq&snM}IENNF>t+bK| zgowuF2vC|SxSZxNN5eHhV%(WPpbeB9Fc3;JDMtzMBv1-XAc2N~c2_tCXW&OCGw6qQ z-s9VS-tT?h=bI0tMS+~WDXqHJyCPmLzdbE-fV8Nd&*MRZfG8(#POFZG3xs@Lb{0ry z=R8j3wWo!5g=yjKx#BoZMFS)uA)H}cTp@-^K`9VV?RC3J59@}eik*>n|pRKOLZ zxdn7G!Yv@9O#y<&eUy{)vMXb;fQR)ffVAADQsEMXm;IBMDLfLD0w^U;6%HVo-0Q_5 zCHEa?DBuauNpZzoF+tK27w#n~?u%toS-DhR4k@Q*{7x^8Q=D6&kd^_~J#VVG2LXkL zaAy=}U*?Jto)9hx5MGjdp9hcQAu@tfk_;l!PeyxPY<8b&+&D!CyaBh9=8BSVKLpk4 z4Ml3yY|&Th)vyK4cpC{!uU8v2YBlVV`d~(nz&<@{G1oe*DHub1z7~J5*;s2bX<)_* zV_GbsPQg`(&rpxRb_*Od7}++3+liSw-$!1 zs5*g}EHWhI3i|!-FcfzYL0`SL-rq>LENC;PMl)G(0(1U2%Va|smp0UFx0xd@soZA* zD5LYc4OlbE7@ARt#h}rr3>K@bf%B#^-c+xz8Hr)0D5ExIFltezN@Hn8>o5d~bSfYtkc+_Z&kI#-N5_GhCg*V-^TSO=!G~ z(fXy{n2XV+k}6w_W`dTOP2a4u0ly;ANZ>4OxSKAzFB!yBzdo`gX zO?o|H@WiAw$y6l?=^3jA_Hy0S)nTYs12;4hKE&ekQ|>?|ZLJ}#F`2BczC7kdE4@xV zZBD_)Otwjhz+NSaz?d45!;FsGSu-#qh#hStD%B}f!mCT!KqzSo>I`NGH_9Dea$1Qi zg29Ydt!~lQVR99_T7#Hije~(12drl-P)SV?QR*9sus`8th-8^OQ7@xI$(Yp|^;bL1 zR50O$mDXw6P>i7B(TJ)ciPzTE>XY%X6HAa)b#OBRXv&~%Bw|J#Y><i4=e%95bjtw|cJp=#P#Pf#*luqI_wR;fISDCJhAqSG6R%xItn%~QtZ@m%&u zjGGLX;t6Ls62eQvNmf@v+}J%54^CygxRZ`?8X#r|wkev7(s;Ou4T#y1XNNf)h;o7z z8a^Lfq<1uH`E{G9E z*(=)Css_LSk=>E9jr)s5^2-!+MN=Ds}>1hRma4`uCIz9%p3O77839E{xf z4c_I?**|1`K2tg4!Hvyrou4BsJQuv*UfF)<%CelYIS>D^o?X)3+MK%la6kooW8&G@BU)Y0hT`+mOm$Z_%rB=a%o>I z!2c6lHyKQN)VjiFwa!eE^p8jc$sy$vB+8i25lI~6KPFFh$!o$avA~rj#L6xvR|Z83 z*WD6T9e+5Pyy=F+)pNTf{ny3cy>7Rkd3o*TS?TZJ`NS^NF2%HMkyS{?uJ$`!P4_L^ z1`NFDUbNyg_qREifgktnp1_v{Jbb`7m}2PTyUdOmtJj~m z9bB=ecw4_^rw1IW=of+>nrW5=d3k`3qHCxsIN_F{T1A545};;+fsyC&qChi+YV zr~M63H8ZLCPYmsjY>ls9cL%I)F|JIW-#+48$+lD4k*(P*kDM%zx_fvu4u5ZYUnI}5 zdrycFq>xFU)&X3p@pP2u%$o}}YcRn(MhJ&B2o?KS@cIVz>Ye%o^xV?CB{_Qhu z;}_q1bvO^g{8<3!gYbo4Di{8qzV+(9 zdlmksohQmRTs@qB;(Wo?dER_ux6XQb@q$tQPW?CMu6GVQd;R=iR;-S{Kr%Zks7>b1 zNs{|-+jhObYE}NR&`TGGr^h^4bjh%c>R#@=8nM&Md>_a+zVulsl;){flFekV1t9ob z+SqfV_Pv3$2f)bQ8%Ul2>fdYR^1zs0BQF~olsOj5AodC&Q_7SMFzsz2 z9newxE&jodk~tNHwl%LBMMDbrk=(^b diff --git a/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/config.json b/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/config.json deleted file mode 100755 index 2aa4396bb..000000000 --- a/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/config.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "app": { - "bundleName": "ohos.acts.hiviewdfx.hilog.function", - "vendor": "example", - "version": { - "code": 1, - "name": "1.0" - }, - "apiVersion": { - "compatible": 4, - "target": 5 - } - }, - "deviceConfig": {}, - "module": { - "package": "ohos.acts.hiviewdfx.hilog.function", - "name": ".MyApplication", - "deviceType": [ - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry" - }, - "abilities": [ - { - "visible": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "name": "ohos.acts.hiviewdfx.hilog.function.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "MyApplication", - "type": "page", - "launchType": "standard" - } - ], - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": false - } - } - ] - } -} diff --git a/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/app.js b/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/app.js deleted file mode 100755 index 3ee099f58..000000000 --- a/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/app.js +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } -}; diff --git a/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/i18n/en-US.json b/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/i18n/en-US.json deleted file mode 100755 index e63c70d97..000000000 --- a/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/i18n/en-US.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - } -} \ No newline at end of file diff --git a/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/i18n/zh-CN.json b/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/i18n/zh-CN.json deleted file mode 100755 index de6ee5748..000000000 --- a/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/i18n/zh-CN.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - } -} \ No newline at end of file diff --git a/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/pages/index/index.css b/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/pages/index/index.css deleted file mode 100755 index 6fda79275..000000000 --- a/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/pages/index/index.hml b/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/pages/index/index.hml deleted file mode 100755 index f64b040a5..000000000 --- a/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,5 +0,0 @@ -
- - {{ $t('strings.hello') }} {{ title }} - -
diff --git a/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/pages/index/index.js b/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/pages/index/index.js deleted file mode 100755 index d1af64d75..000000000 --- a/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/pages/index/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import app from '@system.app' -import device from '@system.device' -import router from '@system.router' -import {Core, ExpectExtend, Constant} from 'deccjsunit/index' - -const injectRef = Object.getPrototypeOf(global) || global -injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow finish') - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - core.init() - const configService = core.getDefaultService('config') - configService.setConfig(this) - - require('../../test/List.test') - core.execute() - }, - onReady() { - }, -} \ No newline at end of file diff --git a/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/test/HiAppEvent.test.js b/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/test/HiAppEvent.test.js deleted file mode 100755 index 5ccbf9fb0..000000000 --- a/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/test/HiAppEvent.test.js +++ /dev/null @@ -1,595 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import HiAppEvent from '@ohos.hiAppEvent' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' -import Constant from 'deccjsunit/src/Constant' - -describe('HiAppEventApiTest', function () { - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_0100 - * @tc.name testHiAppEventApi01 - * @tc.desc HiAppEvent write interface test. - */ - it('testHiAppEventApi01', 1, async function (done) { - console.info('testHiAppEventApi01 start') - HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_int": 100, "key_string": "demo", - "key_bool":true, "key_float":1.1,"key_array_int": [1, 2, 3], "key_array_float": [1.1, 2.2, 3.3], - "key_array_str": ["a", "b", "c"], "key_array_bool": [true, false],"key_array_int2": [1, 2, 3], - "key_arr_float2": [1.1, 2.2, 3.3], "key_arr_str2": ["a", "b", "c"], "key_array_bool2": [true, false]}, - (err, value) => { - console.log('HiAppEvent into json-callback'); - if (err) { - console.error('HiAppEvent json-callback-error code=${err.code}'); - expect().assertFail(); - done(); - } else { - console.log('HiAppEvent json-callback-success value=${value}'); - expect(value == 0).assertTrue(); - done(); - } - }); - }) - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_0300 - * @tc.name testHiAppEventApi03 - * @tc.desc HiAppEvent write EventType of STATISTIC. - */ - it('testHiAppEventApi03', 2, async function (done) { - console.info('testHiAppEventApi03 start') - HiAppEvent.write("write", HiAppEvent.EventType.STATISTIC, {"key_int": 100, "key_string": "demo", - "key_bool":true, "key_float":1.1,"key_array_int": [1, 2, 3], "key_array_float": [1.1, 2.2, 3.3], - "key_array_str": ["a", "b", "c"], "key_array_bool": [true, false],"key_array_int2": [1, 2, 3], - "key_arr_float2": [1.1, 2.2, 3.3], "key_arr_str2": ["a", "b", "c"], "key_array_bool2": [true, false]}, - (err, value) => { - console.log('HiAppEvent into json-callback'); - if (err) { - console.error('HiAppEvent json-callback-error code=${err.code}'); - expect().assertFail(); - done(); - } else { - console.log('HiAppEvent json-callback-success value=${value}'); - expect(value == 0).assertTrue(); - done(); - } - }); - console.info('testHiAppEventApi03 end') - }) - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_0400 - * @tc.name testHiAppEventApi04 - * @tc.desc HiAppEvent write EventType of SECURITY. - */ - it('testHiAppEventApi04', 2, async function (done) { - console.info('testHiAppEventApi04 start') - HiAppEvent.write("write", HiAppEvent.EventType.SECURITY, {"key_int": 100, "key_string": "demo", - "key_bool":true, "key_float":1.1,"key_array_int": [1, 2, 3], "key_array_float": [1.1, 2.2, 3.3], - "key_array_str": ["a", "b", "c"], "key_array_bool": [true, false],"key_array_int2": [1, 2, 3], - "key_arr_float2": [1.1, 2.2, 3.3], "key_arr_str2": ["a", "b", "c"], "key_array_bool2": [true, false]}, - (err, value) => { - console.log('HiAppEvent into json-callback'); - if (err) { - console.error('HiAppEvent json-callback-error code=${err.code}'); - expect().assertFail(); - done(); - } else { - console.log('HiAppEvent json-callback-success value=${value}'); - expect(value == 0).assertTrue(); - done(); - } - }); - console.info('testHiAppEventApi04 end') - }) - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_0500 - * @tc.name testHiAppEventApi05 - * @tc.desc HiAppEvent write EventType of BEHAVIOR. - */ - it('testHiAppEventApi05', 2, async function (done) { - console.info('testHiAppEventApi05 start') - HiAppEvent.write("write", HiAppEvent.EventType.BEHAVIOR, {"key_int": 100, "key_string": "demo", - "key_bool":true, "key_float":1.1,"key_array_int": [1, 2, 3], "key_array_float": [1.1, 2.2, 3.3], - "key_array_str": ["a", "b", "c"], "key_array_bool": [true, false],"key_array_int2": [1, 2, 3], - "key_arr_float2": [1.1, 2.2, 3.3], "key_arr_str2": ["a", "b", "c"], "key_array_bool2": [true, false]}, - (err, value) => { - console.log('HiAppEvent into json-callback'); - if (err) { - console.error('HiAppEvent json-callback-error code=${err.code}'); - expect().assertFail(); - done(); - } else { - console.log('HiAppEvent json-callback-success value=${value}'); - expect(value == 0).assertTrue(); - done(); - } - }); - console.info('testHiAppEventApi05 end') - }) - - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_0600 - * @tc.name testHiAppEventApi06 - * @tc.desc HiAppEvent write datatype of int. - */ - it('testHiAppEventApi06', 2, async function (done) { - console.info('testHiAppEventApi06 start') - HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_int":100}, - (err, value) => { - console.log('HiAppEvent into json-callback'); - if (err) { - console.error('HiAppEvent json-callback-error code=${err.code}'); - expect().assertFail(); - done(); - } else { - console.log('HiAppEvent json-callback-success value=${value}'); - expect(value == 0).assertTrue(); - done(); - } - }); - console.info('testHiAppEventApi06 end') - }) - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_0700 - * @tc.name testHiAppEventApi07 - * @tc.desc HiAppEvent write datatype of int array. - */ - it('testHiAppEventApi07', 2, async function (done) { - console.info('testHiAppEventApi07 start') - HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_int_array":[100, 200]}, - (err, value) => { - console.log('HiAppEvent into json-callback'); - if (err) { - console.error('HiAppEvent json-callback-error code=${err.code}'); - expect().assertFail(); - done(); - } else { - console.log('HiAppEvent json-callback-success value=${value}'); - expect(value == 0).assertTrue(); - done(); - } - }); - console.info('testHiAppEventApi07 end') - }) - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_0800 - * @tc.name testHiAppEventApi08 - * @tc.desc HiAppEvent write datatype of float. - */ - it('testHiAppEventApi08', 2, async function (done) { - console.info('testHiAppEventApi08 start') - HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_float":1.1}, - (err, value) => { - console.log('HiAppEvent into json-callback'); - if (err) { - console.error('HiAppEvent json-callback-error code=${err.code}'); - expect().assertFail(); - done(); - } else { - console.log('HiAppEvent json-callback-success value=${value}'); - expect(value == 0).assertTrue(); - done(); - } - }); - console.info('testHiAppEventApi08 end') - }) - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_0900 - * @tc.name testHiAppEventApi09 - * @tc.desc HiAppEvent write datatype of float array. - */ - it('testHiAppEventApi09', 3, async function (done) { - console.info('testHiAppEventApi09 start') - HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_float_array":[1.1, 1.2]}, - (err, value) => { - console.log('HiAppEvent into json-callback'); - if (err) { - console.error('HiAppEvent json-callback-error code=${err.code}'); - expect().assertFail(); - done(); - } else { - console.log('HiAppEvent json-callback-success value=${value}'); - expect(value == 0).assertTrue(); - done(); - } - }); - console.info('testHiAppEventApi09 end') - }) - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_1000 - * @tc.name testHiAppEventApi10 - * @tc.desc HiAppEvent write datatype of string. - */ - it('testHiAppEventApi10', 3, async function (done) { - console.info('testHiAppEventApi10 start') - HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_string":"hello world"}, - (err, value) => { - console.log('HiAppEvent into json-callback'); - if (err) { - console.error('HiAppEvent json-callback-error code=${err.code}'); - expect().assertFail(); - done(); - } else { - console.log('HiAppEvent json-callback-success value=${value}'); - expect(value == 0).assertTrue(); - done(); - } - }); - console.info('testHiAppEventApi10 end') - }) - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_1100 - * @tc.name testHiAppEventApi11 - * @tc.desc HiAppEvent write datatype of string array. - */ - it('testHiAppEventApi11', 3, async function (done) { - console.info('testHiAppEventApi11 start') - HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_string_array":["hello world", "hello world2"]}, - (err, value) => { - console.log('HiAppEvent into json-callback'); - if (err) { - console.error('HiAppEvent json-callback-error code=${err.code}'); - expect().assertFail(); - done(); - } else { - console.log('HiAppEvent json-callback-success value=${value}'); - expect(value == 0).assertTrue(); - done(); - } - }); - console.info('testHiAppEventApi11 end') - }) - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_1200 - * @tc.name testHiAppEventApi12 - * @tc.desc HiAppEvent write datatype of bool with true. - */ - it('testHiAppEventApi12', 3, async function (done) { - console.info('testHiAppEventApi12 start') - HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_bool":true}, - (err, value) => { - console.log('HiAppEvent into json-callback'); - if (err) { - console.error('HiAppEvent json-callback-error code=${err.code}'); - expect().assertFail(); - done(); - } else { - console.log('HiAppEvent json-callback-success value=${value}'); - expect(value == 0).assertTrue(); - done(); - } - }); - console.info('testHiAppEventApi12 end') - }) - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_1300 - * @tc.name testHiAppEventApi13 - * @tc.desc HiAppEvent write datatype of bool with false. - */ - it('testHiAppEventApi13', 3, async function (done) { - console.info('testHiAppEventApi13 start') - HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_bool":false}, - (err, value) => { - console.log('HiAppEvent into json-callback'); - if (err) { - console.error('HiAppEvent json-callback-error code=${err.code}'); - expect().assertFail(); - done(); - } else { - console.log('HiAppEvent json-callback-success value=${value}'); - expect(value == 0).assertTrue(); - done(); - } - }); - console.info('testHiAppEventApi13 end') - }) - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_1400 - * @tc.name testHiAppEventApi14 - * @tc.desc HiAppEvent write datatype of bool array. - */ - it('testHiAppEventApi14', 3, async function (done) { - console.info('testHiAppEventApi14 start') - HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_bool_array":[false, true]}, - (err, value) => { - console.log('HiAppEvent into json-callback'); - if (err) { - console.error('HiAppEvent json-callback-error code=${err.code}'); - expect().assertFail(); - done(); - } else { - console.log('HiAppEvent json-callback-success value=${value}'); - expect(value == 0).assertTrue(); - done(); - } - }); - console.info('testHiAppEventApi14 end') - }) - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_1500 - * @tc.name testHiAppEventApi15 - * @tc.desc HiAppEvent write datatype of char. - */ - it('testHiAppEventApi15', 3, async function (done) { - console.info('testHiAppEventApi15 start') - HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_char":'c'}, - (err, value) => { - console.log('HiAppEvent into json-callback'); - if (err) { - console.error('HiAppEvent json-callback-error code=${err.code}'); - expect().assertFail(); - done(); - } else { - console.log('HiAppEvent json-callback-success value=${value}'); - expect(value == 0).assertTrue(); - done(); - } - }); - console.info('testHiAppEventApi15 end') - }) - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_1600 - * @tc.name testHiAppEventApi16 - * @tc.desc HiAppEvent write datatype of long. - */ - it('testHiAppEventApi16', 3, async function (done) { - console.info('testHiAppEventApi16 start') - HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_long":2147483647}, - (err, value) => { - console.log('HiAppEvent into json-callback'); - if (err) { - console.error('HiAppEvent json-callback-error code=${err.code}'); - expect().assertFail(); - done(); - } else { - console.log('HiAppEvent json-callback-success value=${value}'); - expect(value == 0).assertTrue(); - done(); - } - }); - console.info('testHiAppEventApi16 end') - }) - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_1700 - * @tc.name testHiAppEventApi17 - * @tc.desc HiAppEvent write datatype of double. - */ - it('testHiAppEventApi17', 3, async function (done) { - console.info('testHiAppEventApi17 start') - HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_double":100.123}, - (err, value) => { - console.log('HiAppEvent into json-callback'); - if (err) { - console.error('HiAppEvent json-callback-error code=${err.code}'); - expect().assertFail(); - done(); - } else { - console.log('HiAppEvent json-callback-success value=${value}'); - expect(value == 0).assertTrue(); - done(); - } - }); - console.info('testHiAppEventApi17 end') - }) - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_1800 - * @tc.name testHiAppEventApi18 - * @tc.desc HiAppEvent write datatype of long. - */ - it('testHiAppEventApi18', 3, async function (done) { - console.info('testHiAppEventApi18 start') - HiAppEvent.write("write", HiAppEvent.EventType.FAULT, {"key_longlong":2147483647}, - (err, value) => { - console.log('HiAppEvent into json-callback'); - if (err) { - console.error('HiAppEvent json-callback-error code=${err.code}'); - expect().assertFail(); - done(); - } else { - console.log('HiAppEvent json-callback-success value=${value}'); - expect(value == 0).assertTrue(); - done(); - } - }); - console.info('testHiAppEventApi18 end') - }) - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_1900 - * @tc.name testHiAppEventApi19 - * @tc.desc HiAppEvent write eventtype of none exists. - */ - it('testHiAppEventApi19', 3, async function (done) { - console.info('testHiAppEventApi19 start') - HiAppEvent.write("write", HiAppEvent.EventType.BEHAVIOR + 1, {"key_longlong":2147483647}, - (err, value) => { - console.log('HiAppEvent into json-callback'); - if (err) { - console.error('HiAppEvent json-callback-error code=${err.code}'); - expect().assertFail(); - done(); - } else { - console.log('HiAppEvent json-callback-success value=${value}'); - expect(value == 0).assertTrue(); - done(); - } - }); - console.info('testHiAppEventApi19 end') - }) - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_2000 - * @tc.name testHiAppEventApi20 - * @tc.desc HiAppEvent write empty eventname . - */ - it('testHiAppEventApi20', 3, async function (done) { - console.info('testHiAppEventApi20 start') - HiAppEvent.write("", HiAppEvent.EventType.FAULT, {"key_longlong":2147483647}, - (err, value) => { - console.log('HiAppEvent20 into json-callback'); - if (err) { - console.error('HiAppEvent20 json-callback-error code=${err.code}'); - expect(err.code == -1).assertTrue(); - done(); - } else { - console.log('HiAppEvent20 json-callback-success value=${value}'); - expect().assertFail(); - done(); - } - }); - console.info('testHiAppEventApi20 end') - }) - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_2100 - * @tc.name testHiAppEventApi21 - * @tc.desc HiAppEvent write long eventname . - */ - it('testHiAppEventApi21', 3, async function (done) { - console.info('testHiAppEventApi21 start') - var i = 0; - var strlong = ""; - while (i < 1000) { - strlong = strlong + "eventnamelong"; - i = i + 1; - } - HiAppEvent.write(strlong, HiAppEvent.EventType.FAULT, {"key_longlong":2147483647}, - (err, value) => { - console.log('HiAppEvent into json-callback'); - if (err) { - console.error('HiAppEvent21 json-callback-error code=${err.code}'); - expect(err.code == -1).assertTrue(); - done(); - } else { - console.log('HiAppEvent21 json-callback-success value=${value}'); - expect().assertFail(); - done(); - } - }); - console.info('testHiAppEventApi21 end') - }) - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_2200 - * @tc.name testHiAppEventApi22 - * @tc.desc HiAppEvent configure interface with disable option set true. - */ - it('testHiAppEventApi22', 3, function () { - console.info('testHiAppEventApi22 start') - let configret =false; - configret = HiAppEvent.configure({disable:true}); - expect(configret == true).assertTrue(); - HiAppEvent.configure({disable: false}); - console.info('testHiAppEventApi22 end') - }) - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_2300 - * @tc.name testHiAppEventApi23 - * @tc.desc HiAppEvent configure interface with disable option set false. - */ - it('testHiAppEventApi23', 3, function () { - console.info('testHiAppEventApi23 start') - let configret =false; - configret = HiAppEvent.configure({disable: false}); - expect(configret == true).assertTrue(); - console.info('testHiAppEventApi23 end') - }) - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_2400 - * @tc.name testHiAppEventApi24 - * @tc.desc HiAppEvent configure interface with maxStorage option set 100M. - */ - it('testHiAppEventApi24', 3, function () { - console.info('testHiAppEventApi24 start') - let configret =false; - configret = HiAppEvent.configure({maxStorage:'100M'}); - console.info('configret = %d', configret); - expect(configret == true).assertTrue(); - console.info('testHiAppEventApi24 end') - }) - - /** - * @tc.number DFX_DFT_HiviewKit_HiAppEvent_JSNAPI_2500 - * @tc.name testHiAppEventApi25 - * @tc.desc HiAppEvent with predefined event and param. - */ - it('testHiAppEventApi25', 3, async function (done) { - console.info('testHiAppEventApi25 start') - HiAppEvent.write(HiAppEvent.Event.USER_LOGIN, HiAppEvent.EventType.BEHAVIOR, - {[HiAppEvent.Param.USER_ID]: 'userlogin', [HiAppEvent.Param.DISTRIBUTED_SERVICE_NAME]: 'HiAppEvent', - [HiAppEvent.Param.DISTRIBUTED_SERVICE_INSTANCE_ID]: 100}, - (err, value) => { - console.log('HiAppEvent into json-callback'); - if (err) { - console.error('HiAppEvent json-callback-error code=${err.code}'); - expect().assertFail(); - done(); - } else { - console.log('HiAppEvent json-callback-success value=${value}'); - expect(value == 0).assertTrue(); - done(); - } - }); - - HiAppEvent.write(HiAppEvent.Event.USER_LOGOUT, HiAppEvent.EventType.BEHAVIOR, - {[HiAppEvent.Param.USER_ID]: 'userlogout', [HiAppEvent.Param.DISTRIBUTED_SERVICE_NAME]: 'HiAppEvent', - [HiAppEvent.Param.DISTRIBUTED_SERVICE_INSTANCE_ID]: 100}, - (err, value) => { - console.log('HiAppEvent into json-callback'); - if (err) { - console.error('HiAppEvent json-callback-error code=${err.code}'); - expect().assertFail(); - done(); - } else { - console.log('HiAppEvent json-callback-success value=${value}'); - expect(value == 0).assertTrue(); - done(); - } - }); - - HiAppEvent.write(HiAppEvent.Event.DISTRIBUTED_SERVICE_START, HiAppEvent.EventType.BEHAVIOR, - {[HiAppEvent.Param.USER_ID]: 'distributedservicestart', [HiAppEvent.Param.DISTRIBUTED_SERVICE_NAME]: 'HiAppEvent', - [HiAppEvent.Param.DISTRIBUTED_SERVICE_INSTANCE_ID]: 100}, - (err, value) => { - console.log('HiAppEvent into json-callback'); - if (err) { - console.error('HiAppEvent json-callback-error code=${err.code}'); - expect().assertFail(); - done(); - } else { - console.log('HiAppEvent json-callback-success value=${value}'); - expect(value == 0).assertTrue(); - done(); - } - }); - console.info('testHiAppEventApi25 end') - }) -}) diff --git a/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/test/List.test.js b/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/test/List.test.js deleted file mode 100755 index c5a9b7824..000000000 --- a/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/js/default/test/List.test.js +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -require('./HiAppEvent.test.js') diff --git a/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/resources/base/element/string.json b/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/resources/base/element/string.json deleted file mode 100755 index ab025e765..000000000 --- a/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "test2demo" - }, - { - "name": "mainability_description", - "value": "hap sample empty page" - } - ] -} diff --git a/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/resources/base/media/icon.png b/hiviewdfx/hiappeventtest/hiappeventjstest/src/main/resources/base/media/icon.png deleted file mode 100755 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K1_<>M?MBqb#!ASf&# zEX?<)!RH(7>1P+j=jqG(58}TVN-$psA6K}atCuI!KTJD&FMmH-78ZejBm)0qc{ESp z|LuG1{QnBUJRg_E=h1#XMWt2%fcoN@l7eAS!Es?Q+;XsRNPhiiE=@AqlLkJzF`O18 zbsbSmKN=aaq8k3NFYZfDWpKmM!coBU0(XnL8R{4=i|wi{!uWYM2je{U{B*K2PVdu&=E zTq*-XsEsJ$u5H4g6DIm2Y!DN`>^v|AqlwuCD;w45K0@eqauiqWf7l&o)+YLHm~|L~ z7$0v5mkobriU!H<@mVJHLlmQqzQ3d6Rh_-|%Yy2li*tHO>_vcnuZ7OR_xkAIuIU&x z-|8Y0wj|6|a6_I(v91y%k_kNw6pnkNdxjqG8!%Vz_d%c_!X+6-;1`GC9_FpjoHev5fEV7RhJ>r=mh-jp$fqbqRJ=obwdgLDVP5+s zy1=_DWG0Y-Jb3t^WXmkr(d9~08k-|#Ly zaNOmT(^9tIb&eb4%CzIT zAm3CUtWSr1t4?h1kk#NBi{U|pJslvME{q|_eS^3En>SOqSxyuN1x;Is@8~m?*>}** znrRFArP!K_52RpX*&JHMR<^lVdm8ypJ}0R(SD(51j;6@ni$6bQ+2XL+R^|NnSp5}(kzvMZ^(@4fD_{QVu$(&K6H|C37TG1Am9Re{<<3gd zh@`>;BqkXMW&p0T6rt|iB$)~CvFe(XC)F9WgAZn*0@t$oZo;!*}r@_`h?KKH&6A@3= zISXoQB+~`op>NP-buiA*^0n{@i{_?MRG)&k)c)k_F+-2Lud!S9pc+i`s74NpBCaGF zXN+pHkubw*msGBTY27BKHv)RRh3;nMg4&$fD_6X9Vt~;_4D+5XPH~#Kn-yjcy!$}1 zigv#FNY>TqMhtIBb@UoF!cE~Q8~;!Pek>SQQwHnHuWKoVBosAiOr}q>!>aE*Krc)V zBUMEcJ5NU0g8}-h6i1zpMY9>m4ne?=U2~`w7K7Q0gB_=p@$5K7p6}thw z-~3dMj?YNX2X$lZ+7ngQ$=s}3mizNN@kE%OtB)?c&i~2L55z8^=yz;xMHLmlY>&Q# zJj?!)M#q_SyfkQh)k?j8IfLtB)ZCp|*vf4_B zos?73yd^h-Ac+;?E4*bpf=o*^3x3-`TVjbY4n6!EN10K6o@fxdyps05Vo3PU)otB} z`3kR+2w7_C#8Z!q`J)p{Vh!+m9-UP!$STp+Hb}}#@#_u^SsUQg<}59< zTvH3%XS4G+6FF^(m6bVF&nSUIXcl;nw{=H$%fgeJ>CgDYiLdpDXr{;-AnG z8dvcrHYVMI&`R6;GWekI@Ir3!uo)oz4^{6q0m^}@f2tM9&=YHNi6-?rh0-{+k@cQm zdp`g#YdQn%MDVg2GR>wZ`n2<0l4)9nx1Wfr&!Dvz=bPwU!h2S?ez6MVc5APE4-xLB zi&W9Q8k2@0w!C53g?iAIQ}~p*3O(@zja6KQ=M3zfW*_6o5SwR-)6VBh~m7{^-=MC-owYH5-u40a}a0liho3QZZ5L{bS_xM1)4}19)zTU$$MY zq3eZML1WC{K%YFd`Be0M-rkO^l?h{kM{$2oK1*A@HVJ57*yhDkUF!2WZ&oA4Y-sK( zCY69%#`mBCi6>6uw(x4gbFaP0+FD*JKJ-q!F1E?vLJ+d35!I5d7@^eU?(CS|C^tmI5?lv@s{{*|1F zFg|OzNpZ0hxljdjaW%45O0MOttRrd(Z?h{HYbB-KFUx&9GfFL3b8NwZ$zNu)WbBD` zYkj$^UB5%3Pj1MDr>S2Ejr9pUcgA!;ZG!@{uAy12)vG=*^9-|dNQBc8&`oxBlU~#y zs!anJX&T?57Jdr^sb>e+V`MVfY>Y0ESg7MG<7W0g&bR-ZYzzZ%2H&Etcp zcd6QeXO1D!5A#zM0lx*GH}`M)2~ZFLE;sP^RSB5wVMNfiZXPd(cmO>j=OSA3`o5r& zna(|^jGXbdN7PK)U8b7^zYtYkkeb%<%F~=OqB~kXMQkq}ii|skh@WSRt>5za;cjP0 zZ~nD%6)wzedqE}BMLt~qKwlvTr33))#uP~xyw#*Eaa|DbMQ_%mG0U8numf8)0DX`r zRoG2bM;#g|p-8gWnwRV5SCW0tLjLO&9Z?K>FImeIxlGUgo0Zk`9Qzhj1eco~7XZy+hXc@YF&ZQ=? zn*^1O56yK^x{y}q`j7}blGCx%dydV!c7)g~tJzmHhV=W~jbWRRR{1<^oDK+1clprm zz$eCy7y9+?{E|YgkW~}}iB#I4XoJ*xr8R?i_Hv$=Cof5bo-Nj~f`-DLebH}&0% zfQj9@WGd4;N~Y?mzQsHJTJq6!Qzl^-vwol(+fMt#Pl=Wh#lI5Vmu@QM0=_r+1wHt` z+8WZ~c2}KQQ+q)~2Ki77QvV&`xb|xVcTms99&cD$Zz4+-^R4kvUBxG8gDk7Y`K*)JZ^2rL(+ZWV~%W(@6 z)0bPArG#BROa_PHs~&WplQ_UIrpd)1N1QGPfv!J(Z9jNT#i%H?CE6|pPZb9hJ1JW4 z^q;ft#!HRNV0YgPojzIYT`8LuET2rUe-J|c!9l4`^*;4WtY@Ew@pL>wkjmMgGfN7 ze}}GtmU0@<_#08~I-Suk=^*9GLW=H4xhsml;vAV{%hy5Eegl@!6qKqbG024%n2HHw zCc@ivW_$@5ZoHP70(7D+(`PvgjW1Pd`wsiuv-aCukMrafwDm)B!xXVy*j2opohhoU zcJz%ADmj>i3`-3-$7nQKBQQuGY;2Qt&+(L~C>vSGFj5{Mlv?T_^dql;{zkpe4R1}R z%XfZyQ}wr*sr>jrKgm*PWLjuVc%6&&`Kbf1SuFpHPN&>W)$GmqC;pIoBC`=4-hPY8 zT*>%I2fP}vGW;R=^!1be?ta2UQd2>alOFFbVl;(SQJ4Jk#)4Z0^wpWEVvY4=vyDk@ zqlModi@iVPMC+{?rm=4(n+<;|lmUO@UKYA>EPTS~AndtK^Wy^%#3<;(dQdk3WaUkRtzSMC9}7x2||CNpF#(3T4C)@ z$~RWs`BNABKX|{cmBt>Q=&gkXl&x!!NK_%5hW0LS)Z4PB>%sV?F-{Wyj#s7W%$F{D zXdK^Fp3wvy+48+GP6F_|^PCRx=ddcTO3sG;B23A49~Qaw31SZ0Rc~`r4qqt%#OGW{ zCA_(LG5^N>yzUn&kAgVmxb=EA8s&tBXC}S1CZ(KoW)(%^JjLTPo^fs`Va;`=YlVPgmB$!yB}<(4ym6OeZ3xAJJ#;)2+B%p3P1Wt+d$eo`vz`T zXfUP2))kBDPoscH;Jc7I3NU<({|@wM$&GaDt`n7WLgIY3IA7A6-_R?z8N3mz|}*i z(zl5ot--Oq@f2-nv{X(ujT2T(k1vY_qh93pK@>H-qc%2Xta)IP0Q%zt%bqYgI`o!wv!0QerB`nCN^1n|@$sVOQ!V0teVG!I z_fD%JvfDeT1cK#-{o6Gv7}& zY0#NWin~kVaf$aufV&;63Hbs|`QVZWpDX6IMk1Hj2G}fiH9e-^6u2zf^FIr^BwD<6zjw63+{yUe8PUFvk8v{sJ=R{d#`O!sz`Q13~< zPT$JS(w=yQfU2`zPCNfSw=&zup@DXc(98afjhv@1w_f!m2Z>rMJ19AB&dB%P#Ls3b z=lK7OILM+SQ&VEd=1GN6o&>YVVtIzoZ%=Z_SdqJN2}E43{bE`>w+A;=y->@^k{oCC z$F*WTY&?34;kfyFV?b*Xb1Pq`Z=%OgwEg)Rz)tx=`f%5#w_INP=x&z5!jI;#;N$ma zhO)+MDm;SxOEVL15; zGq(v2pL3&P1Sl)8P*;G-fd{l1QJsv@e@d8)1PK4w2m*M%V3j-V~L^$i|&C@b?D?9tfwE{B^}Z$k8e5FmQ>v7Xz)sG32g9t}YBt zyR$+*_00RmPx+0mW+vVG4mxd(n$(eQf3-w>JPl2UJpafrPaL5@2j}%{VE-) zBI%6Qpj*dsdH<;g!S!avA~bv^0E+ zfyJbSjPb+j;J52U)<|cIcntQBI2T#>2;tOxu{%D?kML476AErF(qN9hPva5Nkc@BF zC-tLF@3ZFb%Kpj)M<{)x*l|*Ia@ECeXo2E4h2f!aV=cHAhi_E_mfUth(sM4^hJq7B zQsGWqdZUm9S%F`$nQ*_#NcuD`&)Ek%_s{&^78{9Hm ztri&rYLOxgFdG>O@+XHy z9#;|&vBCPXH5Mon^I`jSuR$&~ZWtyB67ujzFSj!51>#C}C17~TffQ{c-!QFQkTQ%! zIR^b1`zHx|*1GU?tbBx23weFLz5H?y_Q%N&t$}k?w+``2A=aotj0;2v$~AL z{scF-cL{wsdrmPvf#a9OHyYLcwQD4Kcm)`LLwMh4WT~p29f7M!iafJSU`IV}QY5Wa z(n44-9oA}?J{a+ah*@31WTs#&J#o1`H98#6IQf;Wv0N_!);f&9g7o-k(lW5rWnDUR zQBFIRG+X=6NnsI@mxnwm;tf5;_Uxg?jZ8m-m0}&6+DA!qam(p$mN5R})yA_7m$q@| zFEd|dpS595rxQr-n#GjI5i-AhnUE>Cr;jpCqSrD~EwK_DqI^7%3#p5)%T_od!t3SOmH9MyXeeGO2(UQL;ax|x?Ncixmeo1=$ z{-);Au{*tfzOG?KQ~K|ak8-HQ?`Pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y/data/local/tmp/ActsHuksStdFunctionTest" - ], - "type": "PushKit" - } - ], - "driver": { - "native-test-timeout": "120000", - "type": "CppTest", - "module-name": "ActsHuksStdFunctionTest", - "runtime-hint": "1s", - "native-test-device-path": "/data/local/tmp" - }, - "description": "Configuration for ActsHuksStdFunctionTest Tests" -} \ No newline at end of file diff --git a/security/dataprotect/huks_standard_adapter/src/hks_aes_test.cpp b/security/dataprotect/huks_standard_adapter/src/hks_aes_test.cpp deleted file mode 100644 index 4dcc6d884..000000000 --- a/security/dataprotect/huks_standard_adapter/src/hks_aes_test.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "hks_aes_test.h" - -#include "hks_api.h" -#include "hks_param.h" -#include "hks_test_aes.h" - -using namespace testing::ext; -namespace { -class HksAesTest : public testing::Test { -public: - static void SetUpTestCase(void); - - static void TearDownTestCase(void); - - void SetUp(); - - void TearDown(); -}; - -void HksAesTest::SetUpTestCase(void) -{ -} - -void HksAesTest::TearDownTestCase(void) -{ -} - -void HksAesTest::SetUp() -{ - EXPECT_EQ(HksInitialize(), 0); -} - -void HksAesTest::TearDown() -{ -} - -#ifndef _CUT_AUTHENTICATE_ -/** - * @tc.name: HksCipherTest.HksCipherTest001 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksAesTest, HksAesTest001, TestSize.Level1) -{ - ASSERT_TRUE(TestAes256ByAgree() == 0); -} - -/** - * @tc.name: HksCipherTest.HksCipherTest002 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksAesTest, HksAesTest002, TestSize.Level1) -{ - ASSERT_TRUE(TestAes256ByAgree1() == 0); -} - -/** - * @tc.name: HksCipherTest.HksCipherTest003 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksAesTest, HksAesTest003, TestSize.Level1) -{ - ASSERT_TRUE(TestAes256ByAgree2() == 0); -} -#endif /* _CUT_AUTHENTICATE_ */ - -/** - * @tc.name: HksCipherTest.HksCipherTest003 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksAesTest, HksAesTest004, TestSize.Level1) -{ - ASSERT_EQ(TestAes256ByLocal(), 0); -} -} diff --git a/security/dataprotect/huks_standard_adapter/src/hks_agreement_test.cpp b/security/dataprotect/huks_standard_adapter/src/hks_agreement_test.cpp deleted file mode 100644 index 251c6a59d..000000000 --- a/security/dataprotect/huks_standard_adapter/src/hks_agreement_test.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "hks_agreement_test.h" - -#include "hks_api.h" -#include "hks_param.h" -#include "hks_test_api_performance.h" -#include "hks_test_common.h" -#include "hks_test_log.h" -#include "hks_type.h" - -using namespace testing::ext; -namespace { -#ifndef _CUT_AUTHENTICATE_ - -class HksAgreementTest : public testing::Test { -public: - static void SetUpTestCase(void); - - static void TearDownTestCase(void); - - void SetUp(); - - void TearDown(); -}; - -void HksAgreementTest::SetUpTestCase(void) -{ -} - -void HksAgreementTest::TearDownTestCase(void) -{ -} - -void HksAgreementTest::SetUp() -{ - EXPECT_EQ(HksInitialize(), 0); -} - -void HksAgreementTest::TearDown() -{ -} - -const int TMP_SIZE = 512; -const int X25519_KEY_SIZE = 32; -const struct HksTestAgreeParams g_testAgreeParams[] = { - /* ree x25519 success */ - { 0, HKS_SUCCESS, { true, DEFAULT_KEY_ALIAS_SIZE, true, DEFAULT_KEY_ALIAS_SIZE }, - { true, DEFAULT_KEY_ALIAS_SIZE, true, DEFAULT_KEY_ALIAS_SIZE }, - { true, true, HKS_ALG_X25519, true, HKS_CURVE25519_KEY_SIZE_256, true, - HKS_KEY_PURPOSE_SIGN | HKS_KEY_PURPOSE_VERIFY, true, HKS_DIGEST_SHA256, - false, 0, false, 0, true, HKS_STORAGE_TEMP }, - { 0 }, - { true, true, HKS_ALG_X25519, true, HKS_CURVE25519_KEY_SIZE_256, true, false }, - { true, TMP_SIZE, true, TMP_SIZE }, - { true, X25519_KEY_SIZE, true, X25519_KEY_SIZE }, - { true, X25519_KEY_SIZE, true, X25519_KEY_SIZE }, - { true, X25519_KEY_SIZE, true, X25519_KEY_SIZE } - }, -}; - -static int32_t AgreeKey(const struct HksTestAgreeParamSet *agreeParamSetParams, struct HksBlob *privateKey, - struct HksBlob *peerPublicKey, struct HksBlob *agreedKey) -{ - struct HksParamSet *agreeParamSet = NULL; - struct TestAgreeParamSetStructure paramStruct = { - &agreeParamSet, - agreeParamSetParams->paramSetExist, - agreeParamSetParams->setAlg, agreeParamSetParams->alg, - agreeParamSetParams->setKeySize, agreeParamSetParams->keySize, - agreeParamSetParams->setIsKeyAlias, agreeParamSetParams->isKeyAlias - }; - int32_t ret = TestConstructAgreeParamSet(¶mStruct); - HKS_TEST_ASSERT(ret == 0); - - ret = HksAgreeKeyRun(agreeParamSet, privateKey, peerPublicKey, agreedKey, 1); - HksFreeParamSet(&agreeParamSet); - return ret; -} - -/** - * @tc.name: HksDeleteTest.HksDeleteTest001 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksAgreementTest, HksAgreementTest001, TestSize.Level1) -{ - /* 1. generate key */ - struct HksBlob *privateKey = NULL; - struct HksBlob *peerPubKeyAlias = NULL; - struct HksBlob *peerPublicKey = NULL; - int32_t ret; - - if (g_testAgreeParams[0].genKeyParamSetParams.setKeyStorageFlag && - (g_testAgreeParams[0].genKeyParamSetParams.keyStorageFlag == HKS_STORAGE_TEMP)) { - ret = GenerateLocalX25519Key(&privateKey, NULL, &g_testAgreeParams[0].localPrivateKeyParams, NULL); - ASSERT_TRUE(ret == 0); - ret = GenerateLocalX25519Key(NULL, &peerPublicKey, NULL, &g_testAgreeParams[0].localPublicKeyParams); - ASSERT_TRUE(ret == 0); - } - /* 2. agreeKey */ - struct HksBlob *agreeKey = NULL; - ret = TestConstuctBlob(&agreeKey, - g_testAgreeParams[0].agreedKeyParams.blobExist, - g_testAgreeParams[0].agreedKeyParams.blobSize, - g_testAgreeParams[0].agreedKeyParams.blobDataExist, - g_testAgreeParams[0].agreedKeyParams.blobDataSize); - ASSERT_TRUE(ret == 0); - - ret = AgreeKey(&g_testAgreeParams[0].agreeParamSetParams, privateKey, peerPublicKey, agreeKey); - ASSERT_TRUE(ret == g_testAgreeParams[0].expectResult); - - /* 3. delete key */ - if (!(g_testAgreeParams[0].genKeyParamSetParams.setKeyStorageFlag && - (g_testAgreeParams[0].genKeyParamSetParams.keyStorageFlag == HKS_STORAGE_TEMP)) && - ((g_testAgreeParams[0].keyAlias1Params.blobExist) && - (g_testAgreeParams[0].keyAlias2Params.blobExist))) { - ret = HksDeleteKey(privateKey, NULL); - ASSERT_TRUE(ret == 0); - ret = HksDeleteKey(peerPubKeyAlias, NULL); - ASSERT_TRUE(ret == 0); - } - TestFreeBlob(&privateKey); - TestFreeBlob(&peerPubKeyAlias); - TestFreeBlob(&peerPublicKey); - TestFreeBlob(&agreeKey); - ASSERT_TRUE(ret == 0); -} - -/** - * @tc.name: HksDeleteTest.HksDeleteTest001 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksAgreementTest, HksAgreementTest002, TestSize.Level1) -{ - /* 1. generate key */ - struct HksBlob *privateKey = NULL; - struct HksBlob *peerPubKeyAlias = NULL; - struct HksBlob *peerPublicKey = NULL; - struct HksBlob *privateKey2 = NULL; - // struct HksBlob *peerPubKeyAlias2 = NULL; - struct HksBlob *peerPublicKey2 = NULL; - int32_t ret; - - if (g_testAgreeParams[0].genKeyParamSetParams.setKeyStorageFlag && - (g_testAgreeParams[0].genKeyParamSetParams.keyStorageFlag == HKS_STORAGE_TEMP)) { - ret = GenerateLocalX25519Key(&privateKey, &peerPublicKey, &g_testAgreeParams[0].localPrivateKeyParams, \ - &g_testAgreeParams[0].localPublicKeyParams); - ASSERT_TRUE(ret == 0); - ret = GenerateLocalX25519Key(&privateKey2, &peerPublicKey2, &g_testAgreeParams[0].localPrivateKeyParams, \ - &g_testAgreeParams[0].localPublicKeyParams); - ASSERT_TRUE(ret == 0); - } - /* 2. agreeKey */ - struct HksBlob *agreeKey = NULL; - ret = TestConstuctBlob(&agreeKey, g_testAgreeParams[0].agreedKeyParams.blobExist, \ - g_testAgreeParams[0].agreedKeyParams.blobSize, g_testAgreeParams[0].agreedKeyParams.blobDataExist, \ - g_testAgreeParams[0].agreedKeyParams.blobDataSize); - ASSERT_TRUE(ret == 0); - - struct HksBlob *agreeKey2 = NULL; - ret = TestConstuctBlob(&agreeKey2, g_testAgreeParams[0].agreedKeyParams.blobExist, \ - g_testAgreeParams[0].agreedKeyParams.blobSize, g_testAgreeParams[0].agreedKeyParams.blobDataExist, \ - g_testAgreeParams[0].agreedKeyParams.blobDataSize); - ASSERT_TRUE(ret == 0); - - ret = AgreeKey(&g_testAgreeParams[0].agreeParamSetParams, privateKey, peerPublicKey2, agreeKey); - ASSERT_TRUE(ret == g_testAgreeParams[0].expectResult); - - ret = AgreeKey(&g_testAgreeParams[0].agreeParamSetParams, privateKey2, peerPublicKey, agreeKey2); - ASSERT_TRUE(ret == g_testAgreeParams[0].expectResult); - EXPECT_EQ(agreeKey->size, agreeKey2->size); - EXPECT_EQ(memcmp(agreeKey->data, agreeKey2->data, agreeKey->size), 0); - - /* 3. delete key */ - if (!(g_testAgreeParams[0].genKeyParamSetParams.setKeyStorageFlag && \ - (g_testAgreeParams[0].genKeyParamSetParams.keyStorageFlag == HKS_STORAGE_TEMP)) && \ - ((g_testAgreeParams[0].keyAlias1Params.blobExist) && (g_testAgreeParams[0].keyAlias2Params.blobExist))) { - ASSERT_TRUE(HksDeleteKey(privateKey, NULL) == 0); - ASSERT_TRUE(HksDeleteKey(peerPubKeyAlias, NULL) == 0); - } - TestFreeBlob(&privateKey); - TestFreeBlob(&peerPubKeyAlias); - TestFreeBlob(&peerPublicKey); - TestFreeBlob(&agreeKey); -} - - -#endif /* _CUT_AUTHENTICATE_ */ -} diff --git a/security/dataprotect/huks_standard_adapter/src/hks_bn_exp_mod_test.cpp b/security/dataprotect/huks_standard_adapter/src/hks_bn_exp_mod_test.cpp deleted file mode 100644 index fa182c317..000000000 --- a/security/dataprotect/huks_standard_adapter/src/hks_bn_exp_mod_test.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "hks_bn_exp_mod_test.h" - -#include "hks_api.h" -#include "hks_param.h" -#include "hks_test_api_performance.h" -#include "hks_test_common.h" -#include "hks_test_log.h" -#include "hks_type.h" - -using namespace testing::ext; -namespace { -class HksBnExpModTest : public testing::Test { -public: - static void SetUpTestCase(void); - - static void TearDownTestCase(void); - - void SetUp(); - - void TearDown(); -}; - -void HksBnExpModTest::SetUpTestCase(void) -{ -} - -void HksBnExpModTest::TearDownTestCase(void) -{ -} - -void HksBnExpModTest::SetUp() -{ - EXPECT_EQ(HksInitialize(), 0); -} - -void HksBnExpModTest::TearDown() -{ -} - -const int DEFAULT_X_SIZE = 256; -const int DEFAULT_A_SIZE = 256; -const int DEFAULT_E_SIZE = 256; -const int DEFAULT_N_SIZE = 256; -const int HKS_TEST_2 = 2; -const int HKS_TEST_8 = 8; - -const struct HksTestBnExpModParams g_testBnExpModParams[] = { - /* normal case */ - { 0, HKS_SUCCESS, false, - { true, DEFAULT_X_SIZE, true, DEFAULT_X_SIZE }, - { true, DEFAULT_A_SIZE, true, DEFAULT_A_SIZE }, - { true, DEFAULT_E_SIZE, true, DEFAULT_E_SIZE }, - { true, DEFAULT_N_SIZE, true, DEFAULT_N_SIZE } - }, -}; - -static int32_t TestValue() -{ - HKS_TEST_LOG_I("test value"); - uint8_t bufX[HKS_TEST_8] = { 0, 0, 0, 0, 0, 0, 0, 0x40 }; - uint8_t bufA[HKS_TEST_8] = { 1, 2, 3, 4, 5, 6, 7, 8 }; - uint8_t bufE[HKS_TEST_2] = { 0, 2 }; - uint8_t bufN[HKS_TEST_8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; - uint8_t tmpBufX[HKS_TEST_8] = {0}; - struct HksBlob tmpX = { HKS_TEST_8, tmpBufX }; - struct HksBlob tmpA = { HKS_TEST_8, bufA }; - struct HksBlob tmpE = { HKS_TEST_2, bufE }; - struct HksBlob tmpN = { HKS_TEST_8, bufN }; - int32_t ret = HksBnExpModRun(&tmpX, &tmpA, &tmpE, &tmpN, 1); - for (int i = 0; i < HKS_TEST_8; ++i) { - HKS_TEST_LOG_I("%x, %x", tmpBufX[i], bufX[i]); - HKS_TEST_ASSERT(tmpBufX[i] == bufX[i]); - } - return ret; -} - -/** - * @tc.name: HksBnExpModTest.HksBnExpModTest001 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksBnExpModTest, HksBnExpModTest001, TestSize.Level1) -{ - int32_t ret; - if (g_testBnExpModParams[0].isTestValue) { - ret = TestValue(); - ASSERT_TRUE(ret == 0); - } else { - struct HksBlob *x = NULL; - struct HksBlob *a = NULL; - struct HksBlob *e = NULL; - struct HksBlob *n = NULL; - ret = TestConstuctBlob(&x, g_testBnExpModParams[0].xParams.blobExist, - g_testBnExpModParams[0].xParams.blobSize, g_testBnExpModParams[0].xParams.blobDataExist, - g_testBnExpModParams[0].xParams.blobDataSize); - HKS_TEST_ASSERT(ret == 0); - - ret = TestConstructBlobOut(&a, g_testBnExpModParams[0].aParams.blobExist, - g_testBnExpModParams[0].aParams.blobSize, g_testBnExpModParams[0].aParams.blobDataExist, - g_testBnExpModParams[0].aParams.blobDataSize); - HKS_TEST_ASSERT(ret == 0); - - ret = TestConstuctBlob(&e, g_testBnExpModParams[0].eParams.blobExist, - g_testBnExpModParams[0].eParams.blobSize, g_testBnExpModParams[0].eParams.blobDataExist, - g_testBnExpModParams[0].eParams.blobDataSize); - HKS_TEST_ASSERT(ret == 0); - - ret = TestConstuctBlob(&n, g_testBnExpModParams[0].nParams.blobExist, - g_testBnExpModParams[0].nParams.blobSize, g_testBnExpModParams[0].nParams.blobDataExist, - g_testBnExpModParams[0].nParams.blobDataSize); - HKS_TEST_ASSERT(ret == 0); - if ((n != NULL) && (n->data != NULL) && (n->size != 0)) { - n->data[n->size - 1] = n->data[n->size - 1] | 0x00000001; /* make sure n is odd */ - } - - ret = HksBnExpModRun(x, a, e, n, 1); - - HKS_TEST_ASSERT(ret == g_testBnExpModParams[0].expectResult); - - TestFreeBlob(&x); - TestFreeBlob(&a); - TestFreeBlob(&e); - TestFreeBlob(&n); - ASSERT_TRUE(ret == 0); - } -} -} \ No newline at end of file diff --git a/security/dataprotect/huks_standard_adapter/src/hks_cipher_test.cpp b/security/dataprotect/huks_standard_adapter/src/hks_cipher_test.cpp deleted file mode 100644 index 22de5c8e6..000000000 --- a/security/dataprotect/huks_standard_adapter/src/hks_cipher_test.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "hks_cipher_test.h" - -#include "hks_api.h" -#include "hks_param.h" -#include "hks_test_cipher.h" - -using namespace testing::ext; -namespace { -class HksCipherTest : public testing::Test { -public: - static void SetUpTestCase(void); - - static void TearDownTestCase(void); - - void SetUp(); - - void TearDown(); -}; - -void HksCipherTest::SetUpTestCase(void) -{ -} - -void HksCipherTest::TearDownTestCase(void) -{ -} - -void HksCipherTest::SetUp() -{ - EXPECT_EQ(HksInitialize(), 0); -} - -void HksCipherTest::TearDown() -{ -} - -/** - * @tc.name: HksCipherTest.HksCipherTest001 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksCipherTest, HksCipherTest001, TestSize.Level1) -{ - ASSERT_TRUE(BaseTestCipher(1, 0, 1) == 0); -} - -#ifndef _CUT_AUTHENTICATE_ -HWTEST_F(HksCipherTest, HksCipherTest002, TestSize.Level1) -{ - ASSERT_TRUE(BaseTestCipher(1, 1, 1) == 0); -} - -HWTEST_F(HksCipherTest, HksCipherTest003, TestSize.Level1) -{ - ASSERT_TRUE(BaseTestEncrypt(1, 0, 1) == 0); -} - -HWTEST_F(HksCipherTest, HksCipherTest004, TestSize.Level1) -{ - ASSERT_TRUE(BaseTestEncrypt(1, 1, 1) == 0); -} - -HWTEST_F(HksCipherTest, HksCipherTest005, TestSize.Level1) -{ - ASSERT_TRUE(BaseTestEncrypt(1, 2, 1) == 0); -} - -HWTEST_F(HksCipherTest, HksCipherTest006, TestSize.Level1) -{ - ASSERT_TRUE(BaseTestEncrypt(1, 3, 1) == 0); -} - -HWTEST_F(HksCipherTest, HksCipherTest007, TestSize.Level1) -{ - ASSERT_TRUE(BaseTestEncrypt(1, 4, 1) == 0); -} - -HWTEST_F(HksCipherTest, HksCipherTest008, TestSize.Level1) -{ - ASSERT_TRUE(BaseTestDecrypt(1, 0, 1) == 0); -} - -HWTEST_F(HksCipherTest, HksCipherTest009, TestSize.Level1) -{ - ASSERT_TRUE(BaseTestDecrypt(1, 1, 1) == 0); -} - -HWTEST_F(HksCipherTest, HksCipherTest010, TestSize.Level1) -{ - ASSERT_TRUE(BaseTestDecrypt(1, 2, 1) == 0); -} - -HWTEST_F(HksCipherTest, HksCipherTest011, TestSize.Level1) -{ - ASSERT_TRUE(BaseTestDecrypt(1, 3, 1) == 0); -} - -HWTEST_F(HksCipherTest, HksCipherTest012, TestSize.Level1) -{ - ASSERT_TRUE(BaseTestDecrypt(1, 4, 1) == 0); -} -#endif /* _CUT_AUTHENTICATE_ */ -} \ No newline at end of file diff --git a/security/dataprotect/huks_standard_adapter/src/hks_curve25519_test.cpp b/security/dataprotect/huks_standard_adapter/src/hks_curve25519_test.cpp deleted file mode 100644 index 13bd2c35f..000000000 --- a/security/dataprotect/huks_standard_adapter/src/hks_curve25519_test.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "hks_curve25519_test.h" - -#include "hks_api.h" -#include "hks_param.h" -#include "hks_test_curve25519.h" - -using namespace testing::ext; -namespace { -#ifndef _CUT_AUTHENTICATE_ -class HksCurve25519Test : public testing::Test { -public: - static void SetUpTestCase(void); - - static void TearDownTestCase(void); - - void SetUp(); - - void TearDown(); -}; - -void HksCurve25519Test::SetUpTestCase(void) -{ -} - -void HksCurve25519Test::TearDownTestCase(void) -{ -} - -void HksCurve25519Test::SetUp() -{ - EXPECT_EQ(HksInitialize(), 0); -} - -void HksCurve25519Test::TearDown() -{ -} - -/** - * @tc.name: HksCurve25519Test.HksCurve25519Test001 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksCurve25519Test, HksCurve25519Test001, TestSize.Level1) -{ - ASSERT_TRUE(TestCurve25519All() == 0); -} - -/** - * @tc.name: HksCurve25519Test.HksCurve25519Test002 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksCurve25519Test, HksCurve25519Test002, TestSize.Level1) -{ - ASSERT_TRUE(TestEd25519SignTeeVerifyLocal() == 0); -} - -/** - * @tc.name: HksCurve25519Test.HksCurve25519Test003 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksCurve25519Test, HksCurve25519Test003, TestSize.Level1) -{ - ASSERT_TRUE(TestCurve25519SignWrong() == 0); -} - -/** - * @tc.name: HksCurve25519Test.HksCurve25519Test004 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksCurve25519Test, HksCurve25519Test004, TestSize.Level1) -{ - ASSERT_TRUE(TestCurve25519verifyWrong() == 0); -} -#endif /* _CUT_AUTHENTICATE_ */ -} \ No newline at end of file diff --git a/security/dataprotect/huks_standard_adapter/src/hks_delete_test.cpp b/security/dataprotect/huks_standard_adapter/src/hks_delete_test.cpp deleted file mode 100644 index db5c83415..000000000 --- a/security/dataprotect/huks_standard_adapter/src/hks_delete_test.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "hks_delete_test.h" - -#include "hks_api.h" -#include "hks_param.h" -#include "hks_test_api_performance.h" -#include "hks_test_common.h" -#include "hks_test_log.h" -#include "hks_type.h" - -using namespace testing::ext; -namespace { -#ifndef _CUT_AUTHENTICATE_ -class HksDeleteTest : public testing::Test { -public: - static void SetUpTestCase(void); - - static void TearDownTestCase(void); - - void SetUp(); - - void TearDown(); -}; - -void HksDeleteTest::SetUpTestCase(void) -{ -} - -void HksDeleteTest::TearDownTestCase(void) -{ -} - -void HksDeleteTest::SetUp() -{ - EXPECT_EQ(HksInitialize(), 0); -} - -void HksDeleteTest::TearDown() -{ -} - -const struct HksTestKeyExistParams g_testKeyExistParams[] = { - /* normal case */ - { 0, HKS_SUCCESS, true, { true, DEFAULT_KEY_ALIAS_SIZE, true, DEFAULT_KEY_ALIAS_SIZE } }, -}; - -/** - * @tc.name: HksDeleteTest.HksDeleteTest001 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksDeleteTest, HksDeleteTest001, TestSize.Level1) -{ - int32_t ret; - struct HksBlob *keyAlias = NULL; - if (g_testKeyExistParams[0].isGenKey) { - HKS_TEST_ASSERT(TestGenDefaultKeyAndGetAlias(&keyAlias) == 0); - } else { - ret = TestConstuctBlob(&keyAlias, - g_testKeyExistParams[0].keyAliasParams.blobExist, - g_testKeyExistParams[0].keyAliasParams.blobSize, - g_testKeyExistParams[0].keyAliasParams.blobDataExist, - g_testKeyExistParams[0].keyAliasParams.blobDataSize); - HKS_TEST_ASSERT(ret == 0); - } - - ret = HksDeleteKeyRun(keyAlias, 1); - HKS_TEST_ASSERT(ret == g_testKeyExistParams[0].expectResult); - - TestFreeBlob(&keyAlias); - ASSERT_TRUE(ret == 0); -} - -#endif /* _CUT_AUTHENTICATE_ */ -} \ No newline at end of file diff --git a/security/dataprotect/huks_standard_adapter/src/hks_derive_test.cpp b/security/dataprotect/huks_standard_adapter/src/hks_derive_test.cpp deleted file mode 100644 index 2f0f33a8f..000000000 --- a/security/dataprotect/huks_standard_adapter/src/hks_derive_test.cpp +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "hks_derive_test.h" - -#include "hks_api.h" -#include "hks_param.h" -#include "hks_test_api_performance.h" -#include "hks_test_common.h" -#include "hks_test_log.h" - -using namespace testing::ext; -namespace { -class HksDeriveTest : public testing::Test { -public: - static void SetUpTestCase(void); - - static void TearDownTestCase(void); - - void SetUp(); - - void TearDown(); -}; - -void HksDeriveTest::SetUpTestCase(void) -{ -} - -void HksDeriveTest::TearDownTestCase(void) -{ -} - -void HksDeriveTest::SetUp() -{ - EXPECT_EQ(HksInitialize(), 0); -} - -void HksDeriveTest::TearDown() -{ -} - -const int DEFAULT_DERIVE_SIZE = 32; -const int DEFAULT_INFO_SIZE = 55; -const int DEFAULT_SALT_SIZE = 16; - -const struct HksTestDeriveParams g_testDeriveParams[] = { - /* hkdf-sha256-salt-info */ - { 0, HKS_SUCCESS, { true, DEFAULT_KEY_ALIAS_SIZE, true, DEFAULT_KEY_ALIAS_SIZE }, - { - true, /* genKey params */ - true, HKS_ALG_AES, - true, HKS_AES_KEY_SIZE_256, - true, HKS_KEY_PURPOSE_DERIVE, - true, HKS_DIGEST_SHA256, - false, 0, - false, 0, - false, 0 }, - { 0 }, - { - true, /* derive params */ - true, HKS_ALG_HKDF, - true, HKS_KEY_PURPOSE_DERIVE, - true, HKS_DIGEST_SHA256, - false, 0, - true, DEFAULT_SALT_SIZE, - true, DEFAULT_INFO_SIZE, - false, true }, - { - true, DEFAULT_DERIVE_SIZE, true, DEFAULT_DERIVE_SIZE }, - { - false, 0, false, 0 } - }, - - /* local: hkdf-sha256-salt-info */ - { 1, HKS_SUCCESS, { true, DEFAULT_KEY_ALIAS_SIZE, true, DEFAULT_KEY_ALIAS_SIZE }, - { - true, /* genKey params */ - true, HKS_ALG_AES, - true, HKS_AES_KEY_SIZE_256, - true, HKS_KEY_PURPOSE_DERIVE, - true, HKS_DIGEST_SHA256, - false, 0, - false, 0, - true, HKS_STORAGE_TEMP }, - { 0 }, - { - true, /* derive params */ - true, HKS_ALG_HKDF, - true, HKS_KEY_PURPOSE_DERIVE, - true, HKS_DIGEST_SHA256, - false, 0, - true, DEFAULT_SALT_SIZE, - true, DEFAULT_INFO_SIZE, - true, false }, - { - true, DEFAULT_DERIVE_SIZE, true, DEFAULT_DERIVE_SIZE }, - { - true, DEFAULT_LOCAL_KEY_SIZE, true, DEFAULT_LOCAL_KEY_SIZE } - }, -}; - -static int32_t DeriveKey(const struct HksTestDeriveParamSet *deriveParamSetParams, const struct HksBlob *masterKey, - struct HksBlob *derivedKey, struct HksBlob **saltData, struct HksBlob **infoData) -{ - struct HksParamSet *deriveParamSet = NULL; - uint32_t saltSize = deriveParamSetParams->saltSize; - uint32_t infoSize = deriveParamSetParams->infoSize; - if (saltSize != 0) { - HKS_TEST_ASSERT(TestConstuctBlob(saltData, true, saltSize, true, saltSize) == 0); - } - if (infoSize != 0) { - HKS_TEST_ASSERT(TestConstuctBlob(infoData, true, infoSize, true, infoSize) == 0); - } - struct TestDeriveParamSetStructure paramStruct = { - &deriveParamSet, - deriveParamSetParams->paramSetExist, - deriveParamSetParams->setAlg, deriveParamSetParams->alg, - deriveParamSetParams->setPurpose, deriveParamSetParams->purpose, - deriveParamSetParams->setDigest, deriveParamSetParams->digest, - deriveParamSetParams->setIteration, deriveParamSetParams->iteration, - deriveParamSetParams->setSalt, *saltData, - deriveParamSetParams->setInfo, *infoData, - deriveParamSetParams->setIsKeyAlias, deriveParamSetParams->isKeyAlias - }; - int32_t ret = TestConstructDeriveParamSet(¶mStruct); - HKS_TEST_ASSERT(ret == 0); - - ret = HksDeriveKeyRun(deriveParamSet, masterKey, derivedKey, 1); - HksFreeParamSet(&deriveParamSet); - return ret; -} - -static int32_t BaseTestDerive(uint32_t index) -{ - /* 1. generate key */ - struct HksBlob *keyAlias = NULL; - int32_t ret; - if (g_testDeriveParams[index].genKeyParamSetParams.setKeyStorageFlag && - (g_testDeriveParams[index].genKeyParamSetParams.keyStorageFlag == HKS_STORAGE_TEMP)) { - ret = GenerateLocalRandomKey(&keyAlias, &g_testDeriveParams[index].localKeyParams); - } else { - if (g_testDeriveParams[index].keyAliasParams.blobExist) { - ret = GenerateKey(&keyAlias, &g_testDeriveParams[index].keyAliasParams, - &g_testDeriveParams[index].genKeyParamSetParams, NULL); - } else { - ret = TestConstuctBlob(&keyAlias, - g_testDeriveParams[index].masterKeyParams.blobExist, - g_testDeriveParams[index].masterKeyParams.blobSize, - g_testDeriveParams[index].masterKeyParams.blobDataExist, - g_testDeriveParams[index].masterKeyParams.blobDataSize); - } - } - HKS_TEST_ASSERT(ret == 0); - - /* 2. derive */ - struct HksBlob *derivedKey = NULL; - ret = TestConstuctBlob(&derivedKey, - g_testDeriveParams[index].derivedKeyParams.blobExist, - g_testDeriveParams[index].derivedKeyParams.blobSize, - g_testDeriveParams[index].derivedKeyParams.blobDataExist, - g_testDeriveParams[index].derivedKeyParams.blobDataSize); - HKS_TEST_ASSERT(ret == 0); - - struct HksBlob *saltData = NULL; - struct HksBlob *infoData = NULL; - ret = DeriveKey(&g_testDeriveParams[index].deriveParamSetParams, keyAlias, derivedKey, &saltData, &infoData); - if (ret != g_testDeriveParams[index].expectResult) { - HKS_TEST_LOG_I("failed, ret[%u] = %d", g_testDeriveParams[index].testId, ret); - } - HKS_TEST_ASSERT(ret == g_testDeriveParams[index].expectResult); - - /* 3. delete key */ - if (!(g_testDeriveParams[index].genKeyParamSetParams.setKeyStorageFlag && - (g_testDeriveParams[index].genKeyParamSetParams.keyStorageFlag == HKS_STORAGE_TEMP)) && - (g_testDeriveParams[index].keyAliasParams.blobExist)) { - HKS_TEST_ASSERT(HksDeleteKey(keyAlias, NULL) == 0); - } - TestFreeBlob(&keyAlias); - TestFreeBlob(&derivedKey); - TestFreeBlob(&saltData); - TestFreeBlob(&infoData); - - return ret; -} - -#ifndef _CUT_AUTHENTICATE_ -/** - * @tc.name: HksDeriveTest.HksDeriveTest001 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksDeriveTest, HksDeriveTest001, TestSize.Level1) -{ - int32_t ret = BaseTestDerive(0); - ASSERT_TRUE(ret == 0); -} -#endif /* _CUT_AUTHENTICATE_ */ - -/** - * @tc.name: HksDeriveTest.HksDeriveTest002 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksDeriveTest, HksDeriveTest002, TestSize.Level1) -{ - int32_t ret = BaseTestDerive(1); - ASSERT_TRUE(ret == 0); -} -} \ No newline at end of file diff --git a/security/dataprotect/huks_standard_adapter/src/hks_exist_test.cpp b/security/dataprotect/huks_standard_adapter/src/hks_exist_test.cpp deleted file mode 100644 index d347851e7..000000000 --- a/security/dataprotect/huks_standard_adapter/src/hks_exist_test.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "hks_exist_test.h" - -#include "hks_api.h" -#include "hks_param.h" -#include "hks_test_api_performance.h" -#include "hks_test_common.h" -#include "hks_test_log.h" -#include "hks_type.h" - -using namespace testing::ext; -namespace { -#ifndef _CUT_AUTHENTICATE_ -class HksExistTest : public testing::Test { -public: - static void SetUpTestCase(void); - - static void TearDownTestCase(void); - - void SetUp(); - - void TearDown(); -}; - -void HksExistTest::SetUpTestCase(void) -{ -} - -void HksExistTest::TearDownTestCase(void) -{ -} - -void HksExistTest::SetUp() -{ - EXPECT_EQ(HksInitialize(), 0); -} - -void HksExistTest::TearDown() -{ -} - -const struct HksTestKeyExistParams g_testKeyExistParams[] = { - /* normal case */ - { 0, HKS_SUCCESS, true, { true, DEFAULT_KEY_ALIAS_SIZE, true, DEFAULT_KEY_ALIAS_SIZE } }, -}; - -/** - * @tc.name: HksExistTest.HksExistTest001 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksExistTest, HksExistTest001, TestSize.Level1) -{ - int32_t ret; - struct HksBlob *keyAlias = NULL; - if (g_testKeyExistParams[0].isGenKey) { - HKS_TEST_ASSERT(TestGenDefaultKeyAndGetAlias(&keyAlias) == 0); - ret = HksKeyExistRun(keyAlias, 1); - HKS_TEST_ASSERT(ret == g_testKeyExistParams[0].expectResult); - HKS_TEST_ASSERT(HksDeleteKey(keyAlias, NULL) == HKS_SUCCESS); - } else { - ret = TestConstuctBlob(&keyAlias, - g_testKeyExistParams[0].keyAliasParams.blobExist, - g_testKeyExistParams[0].keyAliasParams.blobSize, - g_testKeyExistParams[0].keyAliasParams.blobDataExist, - g_testKeyExistParams[0].keyAliasParams.blobDataSize); - HKS_TEST_ASSERT(ret == 0); - ret = HksKeyExistRun(keyAlias, 1); - if (ret != g_testKeyExistParams[0].expectResult) { - HKS_TEST_LOG_I("HksKeyExistRun 2 failed, ret[%u] = %d", g_testKeyExistParams[0].testId, ret); - } - HKS_TEST_ASSERT(ret == g_testKeyExistParams[0].expectResult); - } - TestFreeBlob(&keyAlias); - ASSERT_TRUE(ret == 0); -} -#endif /* _CUT_AUTHENTICATE_ */ -} \ No newline at end of file diff --git a/security/dataprotect/huks_standard_adapter/src/hks_generate_key_test.cpp b/security/dataprotect/huks_standard_adapter/src/hks_generate_key_test.cpp deleted file mode 100644 index 43894c0e3..000000000 --- a/security/dataprotect/huks_standard_adapter/src/hks_generate_key_test.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "hks_generate_key_test.h" - -#include "hks_api.h" -#include "hks_param.h" -#include "hks_test_api_performance.h" -#include "hks_test_common.h" -#include "hks_test_log.h" - -using namespace testing::ext; -namespace { -#ifndef _CUT_AUTHENTICATE_ -class HksGenerateKeyTest : public testing::Test { -public: - static void SetUpTestCase(void); - - static void TearDownTestCase(void); - - void SetUp(); - - void TearDown(); -}; - -void HksGenerateKeyTest::SetUpTestCase(void) -{ -} - -void HksGenerateKeyTest::TearDownTestCase(void) -{ -} - -void HksGenerateKeyTest::SetUp() -{ - EXPECT_EQ(HksInitialize(), 0); -} - -void HksGenerateKeyTest::TearDown() -{ -} - -const int DEFAULT_X25519_PARAM_SET_OUT = 104; - -const struct HksTestGenKeyParams g_testGenKeyParams[] = { - /* x25519: ree sign/verify */ - { 0, HKS_SUCCESS, { true, DEFAULT_KEY_ALIAS_SIZE, true, DEFAULT_KEY_ALIAS_SIZE }, { - true, - true, HKS_ALG_X25519, - true, HKS_CURVE25519_KEY_SIZE_256, - true, HKS_KEY_PURPOSE_SIGN | HKS_KEY_PURPOSE_VERIFY, - false, 0, - false, 0, - false, 0, - true, HKS_STORAGE_TEMP }, - { true, DEFAULT_X25519_PARAM_SET_OUT }, - }, -}; - -/** - * @tc.name: HksGenerateKeyTest.HksGenerateKeyTest001 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksGenerateKeyTest, HksGenerateKeyTest001, TestSize.Level1) -{ - uint32_t times = 1; - uint32_t index = 0; - uint32_t performTimes = 1; - struct HksBlob *keyAlias = NULL; - int32_t ret = TestConstuctBlob(&keyAlias, - g_testGenKeyParams[index].keyAliasParams.blobExist, - g_testGenKeyParams[index].keyAliasParams.blobSize, - g_testGenKeyParams[index].keyAliasParams.blobDataExist, - g_testGenKeyParams[index].keyAliasParams.blobDataSize); - HKS_TEST_ASSERT(ret == 0); - - struct HksParamSet *paramSet = NULL; - struct GenerateKeyParamSetStructure paramStruct = { ¶mSet, - g_testGenKeyParams[index].paramSetParams.paramSetExist, - g_testGenKeyParams[index].paramSetParams.setAlg, g_testGenKeyParams[index].paramSetParams.alg, - g_testGenKeyParams[index].paramSetParams.setKeySize, g_testGenKeyParams[index].paramSetParams.keySize, - g_testGenKeyParams[index].paramSetParams.setPurpose, g_testGenKeyParams[index].paramSetParams.purpose, - g_testGenKeyParams[index].paramSetParams.setDigest, g_testGenKeyParams[index].paramSetParams.digest, - g_testGenKeyParams[index].paramSetParams.setPadding, g_testGenKeyParams[index].paramSetParams.padding, - g_testGenKeyParams[index].paramSetParams.setBlockMode, g_testGenKeyParams[index].paramSetParams.mode, - g_testGenKeyParams[index].paramSetParams.setKeyStorageFlag, - g_testGenKeyParams[index].paramSetParams.keyStorageFlag }; - ret = TestConstructGenerateKeyParamSet(¶mStruct); - HKS_TEST_ASSERT(ret == 0); - - struct HksParamSet *paramSetOut = NULL; - ret = TestConstructGenerateKeyParamSetOut(¶mSetOut, - g_testGenKeyParams[index].paramSetParamsOut.paramSetExist, - g_testGenKeyParams[index].paramSetParamsOut.paramSetSize); - HKS_TEST_ASSERT(ret == 0); - - ret = HksGenerateKeyRun(keyAlias, paramSet, paramSetOut, performTimes); - if (ret != g_testGenKeyParams[index].expectResult) { - HKS_TEST_LOG_I("failed, ret[%u] = %d", g_testGenKeyParams[index].testId, ret); - } - HKS_TEST_ASSERT(ret == g_testGenKeyParams[index].expectResult); - - if ((ret == HKS_SUCCESS) && - !(g_testGenKeyParams[index].paramSetParams.setKeyStorageFlag == true) && - (g_testGenKeyParams[index].paramSetParams.keyStorageFlag == HKS_STORAGE_TEMP)) { - HKS_TEST_ASSERT(HksDeleteKey(keyAlias, NULL) == 0); - } - TestFreeBlob(&keyAlias); - HksFreeParamSet(¶mSet); - HksFreeParamSet(¶mSetOut); - HKS_TEST_LOG_I("[%u]TestGenerateKey, Testcase_GenerateKey_[%03u] pass!", times, g_testGenKeyParams[index].testId); - ASSERT_TRUE(ret == 0); -} -#endif /* _CUT_AUTHENTICATE_ */ -} \ No newline at end of file diff --git a/security/dataprotect/huks_standard_adapter/src/hks_generate_random_test.cpp b/security/dataprotect/huks_standard_adapter/src/hks_generate_random_test.cpp deleted file mode 100644 index f5ad2e91e..000000000 --- a/security/dataprotect/huks_standard_adapter/src/hks_generate_random_test.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "hks_generate_random_test.h" - -#include "hks_api.h" -#include "hks_param.h" -#include "hks_test_api_performance.h" -#include "hks_test_common.h" -#include "hks_test_log.h" -#include "hks_type.h" - -using namespace testing::ext; -namespace { -class HksGenerateRandomTest : public testing::Test { -public: - static void SetUpTestCase(void); - - static void TearDownTestCase(void); - - void SetUp(); - - void TearDown(); -}; - -void HksGenerateRandomTest::SetUpTestCase(void) -{ -} - -void HksGenerateRandomTest::TearDownTestCase(void) -{ -} - -void HksGenerateRandomTest::SetUp() -{ - EXPECT_EQ(HksInitialize(), 0); -} - -void HksGenerateRandomTest::TearDown() -{ -} - -const struct HksTestGenRandomParams g_testGenRandomParams[] = { - /* normal case */ - { 0, HKS_SUCCESS, { true, HKS_MAX_RANDOM_LEN, true, HKS_MAX_RANDOM_LEN } }, -}; -/** - * @tc.name: HksGenerateRandomTest.HksGenerateRandomTest001 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksGenerateRandomTest, HksGenerateRandomTest001, TestSize.Level1) -{ - int32_t ret; - struct HksBlob *random = NULL; - - ret = TestConstructBlobOut(&random, - g_testGenRandomParams[0].randomParams.blobExist, - g_testGenRandomParams[0].randomParams.blobSize, - g_testGenRandomParams[0].randomParams.blobDataExist, - g_testGenRandomParams[0].randomParams.blobDataSize); - HKS_TEST_ASSERT(ret == 0); - - ret = HksGenerateRandomRun(random, 1); - if (ret != g_testGenRandomParams[0].expectResult) { - HKS_TEST_LOG_I("HksGenerateRandomRun failed, ret[%u] = %d", g_testGenRandomParams[0].testId, ret); - } - HKS_TEST_ASSERT(ret == g_testGenRandomParams[0].expectResult); - - TestFreeBlob(&random); - ASSERT_TRUE(ret == 0); -} -} \ No newline at end of file diff --git a/security/dataprotect/huks_standard_adapter/src/hks_hash_test.cpp b/security/dataprotect/huks_standard_adapter/src/hks_hash_test.cpp deleted file mode 100644 index f6cbaf20a..000000000 --- a/security/dataprotect/huks_standard_adapter/src/hks_hash_test.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "hks_hash_test.h" - -#include "hks_api.h" -#include "hks_param.h" -#include "hks_test_api_performance.h" -#include "hks_test_common.h" -#include "hks_test_log.h" -#include "hks_type.h" - -using namespace testing::ext; -namespace { -#ifndef _CUT_AUTHENTICATE_ - -class HksHashTest : public testing::Test { -public: - static void SetUpTestCase(void); - - static void TearDownTestCase(void); - - void SetUp(); - - void TearDown(); -}; - -void HksHashTest::SetUpTestCase(void) -{ -} - -void HksHashTest::TearDownTestCase(void) -{ -} - -void HksHashTest::SetUp() -{ - EXPECT_EQ(HksInitialize(), 0); -} - -void HksHashTest::TearDown() -{ -} - -const int DEFAULT_SRC_DATA_SIZE = 200; -const int DIGEST_SHA256_HASH_SIZE = 32; - -const struct HksTestHashParams g_testHashParams[] = { - /* normal case */ - { 0, HKS_SUCCESS, - { true, true, HKS_DIGEST_SHA256 }, - { true, DEFAULT_SRC_DATA_SIZE, true, DEFAULT_SRC_DATA_SIZE }, - { true, DIGEST_SHA256_HASH_SIZE, true, DIGEST_SHA256_HASH_SIZE } - }, -}; - -/** - * @tc.name: HksHashTest.HksHashTest001 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksHashTest, HksHashTest001, TestSize.Level1) -{ - struct HksParamSet *paramSet = NULL; - struct HksBlob *srcData = NULL; - struct HksBlob *hash = NULL; - - int32_t ret = TestConstructHashParamSet(¶mSet, - g_testHashParams[0].paramSetParams.paramSetExist, - g_testHashParams[0].paramSetParams.setDigest, g_testHashParams[0].paramSetParams.digest); - HKS_TEST_ASSERT(ret == 0); - - ret = TestConstuctBlob(&srcData, - g_testHashParams[0].srcDataParams.blobExist, - g_testHashParams[0].srcDataParams.blobSize, - g_testHashParams[0].srcDataParams.blobDataExist, - g_testHashParams[0].srcDataParams.blobDataSize); - HKS_TEST_ASSERT(ret == 0); - - ret = TestConstructBlobOut(&hash, - g_testHashParams[0].hashParams.blobExist, - g_testHashParams[0].hashParams.blobSize, - g_testHashParams[0].hashParams.blobDataExist, - g_testHashParams[0].hashParams.blobDataSize); - HKS_TEST_ASSERT(ret == 0); - - ret = HksHashRun(paramSet, srcData, hash, 1); - if (ret != g_testHashParams[0].expectResult) { - HKS_TEST_LOG_I("HksHashRun failed, ret[%u] = %d", g_testHashParams[0].testId, ret); - } - HKS_TEST_ASSERT(ret == g_testHashParams[0].expectResult); - - HksFreeParamSet(¶mSet); - TestFreeBlob(&srcData); - TestFreeBlob(&hash); - HKS_TEST_LOG_I("[%u]TestHash, Testcase_Hash_[%03u] pass!", 1, g_testHashParams[0].testId); - ASSERT_TRUE(ret == 0); -} -#endif /* _CUT_AUTHENTICATE_ */ -} diff --git a/security/dataprotect/huks_standard_adapter/src/hks_mac_test.cpp b/security/dataprotect/huks_standard_adapter/src/hks_mac_test.cpp deleted file mode 100644 index cd4ce35a4..000000000 --- a/security/dataprotect/huks_standard_adapter/src/hks_mac_test.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "hks_mac_test.h" - -#include "hks_api.h" -#include "hks_param.h" -#include "hks_test_api_performance.h" -#include "hks_test_common.h" -#include "hks_test_log.h" - -using namespace testing::ext; -namespace { -class HksMacTest : public testing::Test { -public: - static void SetUpTestCase(void); - - static void TearDownTestCase(void); - - void SetUp(); - - void TearDown(); -}; - -void HksMacTest::SetUpTestCase(void) -{ -} - -void HksMacTest::TearDownTestCase(void) -{ -} - -void HksMacTest::SetUp() -{ - EXPECT_EQ(HksInitialize(), 0); -} - -void HksMacTest::TearDown() -{ -} - -const int HKS_TEST_MAC_REE_KEY_SIZE_32 = 32; -const int HKS_DEFAULT_MAC_SRCDATA_SIZE = 253; -const int HKS_DEFAULT_MAC_SHA256_SIZE = 32; - - -const struct HksTestMacParams g_testMacParams[] = { - /* success: ree-sha256 */ - { 0, HKS_SUCCESS, HKS_TEST_MAC_TYPE_REE, { 0 }, { 0 }, - { true, HKS_TEST_MAC_REE_KEY_SIZE_32, true, HKS_TEST_MAC_REE_KEY_SIZE_32 }, - { true, true, HKS_KEY_PURPOSE_MAC, true, HKS_DIGEST_SHA256 }, - { true, HKS_DEFAULT_MAC_SRCDATA_SIZE, true, HKS_DEFAULT_MAC_SRCDATA_SIZE }, - { true, HKS_DEFAULT_MAC_SHA256_SIZE, true, HKS_DEFAULT_MAC_SHA256_SIZE } - }, - - /* success: tee-sha256 */ - { 1, HKS_SUCCESS, HKS_TEST_MAC_TYPE_TEE, { true, DEFAULT_KEY_ALIAS_SIZE, true, DEFAULT_KEY_ALIAS_SIZE }, - { true, true, HKS_ALG_AES, true, HKS_AES_KEY_SIZE_256, true, HKS_KEY_PURPOSE_MAC, - true, HKS_DIGEST_SHA256, false, 0, false, 0 }, - { 0 }, - { true, true, HKS_KEY_PURPOSE_MAC, true, HKS_DIGEST_SHA256 }, - { true, HKS_DEFAULT_MAC_SRCDATA_SIZE, true, HKS_DEFAULT_MAC_SRCDATA_SIZE }, - { true, HKS_DEFAULT_MAC_SHA256_SIZE, true, HKS_DEFAULT_MAC_SHA256_SIZE } - }, -}; - -static int32_t ConstructDataToBlob(struct HksBlob **srcData, struct HksBlob **macData, - const struct HksTestBlobParams *srcDataParams, const struct HksTestBlobParams *macDataParams) -{ - int32_t ret = TestConstuctBlob(srcData, - srcDataParams->blobExist, - srcDataParams->blobSize, - srcDataParams->blobDataExist, - srcDataParams->blobDataSize); - HKS_TEST_ASSERT(ret == 0); - - ret = TestConstuctBlob(macData, - macDataParams->blobExist, - macDataParams->blobSize, - macDataParams->blobDataExist, - macDataParams->blobDataSize); - HKS_TEST_ASSERT(ret == 0); - return ret; -} - -static int32_t Mac(const struct HksBlob *key, const struct HksBlob *srcData, struct HksBlob *macData, - const struct HksTestMacParamSet *macParamSetParams, enum HksTestMacType macType) -{ - struct HksParamSet *macParamSet = NULL; - int32_t ret; - if (macType == HKS_TEST_MAC_TYPE_REE) { - struct TestMacParamSetStructure paramStructTrue = { - &macParamSet, - macParamSetParams->paramSetExist, - macParamSetParams->setPurpose, macParamSetParams->purpose, - macParamSetParams->setDigest, macParamSetParams->digest, true, false - }; - ret = TestConstructMacParamSet(¶mStructTrue); - } else { - struct TestMacParamSetStructure paramStructFalse = { - &macParamSet, - macParamSetParams->paramSetExist, - macParamSetParams->setPurpose, macParamSetParams->purpose, - macParamSetParams->setDigest, macParamSetParams->digest, false, false - }; - ret = TestConstructMacParamSet(¶mStructFalse); - } - HKS_TEST_ASSERT(ret == 0); - - ret = HksMacRun(key, macParamSet, srcData, macData, 1); - HksFreeParamSet(&macParamSet); - return ret; -} - -static int32_t BaseTestMac(uint32_t index) -{ - /* 1. generate key */ - struct HksBlob *key = NULL; - int32_t ret; - - if (g_testMacParams[index].macType == HKS_TEST_MAC_TYPE_REE) { - ret = TestConstuctBlob(&key, - g_testMacParams[index].keyParams.blobExist, - g_testMacParams[index].keyParams.blobSize, - g_testMacParams[index].keyParams.blobDataExist, - g_testMacParams[index].keyParams.blobDataSize); - } else { - if (g_testMacParams[index].keyAliasParams.blobExist) { - ret = GenerateKey(&key, &(g_testMacParams[index].keyAliasParams), - &g_testMacParams[index].genKeyParamSetParams, NULL); - } else { - ret = TestConstuctBlob(&key, - g_testMacParams[index].keyParams.blobExist, - g_testMacParams[index].keyParams.blobSize, - g_testMacParams[index].keyParams.blobDataExist, - g_testMacParams[index].keyParams.blobDataSize); - } - } - HKS_TEST_ASSERT(ret == 0); - - /* 2. mac */ - struct HksBlob *srcData = NULL; - struct HksBlob *macData = NULL; - ret = ConstructDataToBlob(&srcData, &macData, - &g_testMacParams[index].srcDataParams, &g_testMacParams[index].macParams); - HKS_TEST_ASSERT(ret == 0); - - ret = Mac(key, srcData, macData, &g_testMacParams[index].macParamSetParams, g_testMacParams[index].macType); - if (ret != g_testMacParams[index].expectResult) { - HKS_TEST_LOG_I("failed, ret[%u] = %d", g_testMacParams[index].testId, ret); - } - HKS_TEST_ASSERT(ret == g_testMacParams[index].expectResult); - - /* 3. deletekey */ - if ((g_testMacParams[index].macType == HKS_TEST_MAC_TYPE_TEE) && - (g_testMacParams[index].keyAliasParams.blobExist)) { - ret = HksDeleteKey(key, NULL); - HKS_TEST_ASSERT(ret == 0); - } - TestFreeBlob(&key); - TestFreeBlob(&srcData); - TestFreeBlob(&macData); - return ret; -} - -/** - * @tc.name: HksMacTest.HksMacTest001 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksMacTest, HksMacTest001, TestSize.Level1) -{ - int32_t ret = BaseTestMac(0); - ASSERT_TRUE(ret == 0); -} - -#ifndef _CUT_AUTHENTICATE_ -/** - * @tc.name: HksMacTest.HksMacTest002 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksMacTest, HksMacTest002, TestSize.Level1) -{ - int32_t ret = BaseTestMac(1); - ASSERT_TRUE(ret == 0); -} -#endif /* _CUT_AUTHENTICATE_ */ -} diff --git a/security/dataprotect/huks_standard_adapter/src/hks_modify_key_test.cpp b/security/dataprotect/huks_standard_adapter/src/hks_modify_key_test.cpp deleted file mode 100644 index 6c7690672..000000000 --- a/security/dataprotect/huks_standard_adapter/src/hks_modify_key_test.cpp +++ /dev/null @@ -1,363 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "hks_modify_key_test.h" - -#include "hks_api.h" -#include "hks_param.h" -#include "hks_test_api_performance.h" -#include "hks_test_cipher.h" -#include "hks_test_common.h" -#include "hks_test_file_operator.h" -#include "hks_test_log.h" -#include "hks_test_mem.h" - -#include "securec.h" - -using namespace testing::ext; -namespace { -#ifndef _CUT_AUTHENTICATE_ - -class HksModifyKeyTest : public testing::Test { -public: - static void SetUpTestCase(void); - - static void TearDownTestCase(void); - - void SetUp(); - - void TearDown(); -}; - -void HksModifyKeyTest::SetUpTestCase(void) -{ -} - -void HksModifyKeyTest::TearDownTestCase(void) -{ -} - -void HksModifyKeyTest::SetUp() -{ - EXPECT_EQ(HksInitialize(), 0); -} - -void HksModifyKeyTest::TearDown() -{ -} - -const int DEFAULT_AES_CIPHER_PLAIN_SIZE = 1000; -const int AES_DEFAULT_GCM_NONCE_LENGTH = 12; -const int AES_DEFAULT_AAD_LEN = 4; -#ifdef _STANDARD_SYSTEM_ - const char *g_storePath = "/data/data/maindata/+0+0+0+0/key"; -#endif -#ifdef _LITEONE_SYSTEM_ - const char *g_storePath = "/storage/maindata/hks_client/key"; -#endif - -const char *g_testName = "TestName"; - -const struct HksTestCipherParams g_testCipherParams[] = { - /* success: aes256-gcm-none */ - { 0, HKS_SUCCESS, { true, DEFAULT_KEY_ALIAS_SIZE, true, DEFAULT_KEY_ALIAS_SIZE }, - { - true, /* genKey params */ - true, HKS_ALG_AES, - true, HKS_AES_KEY_SIZE_256, - true, HKS_KEY_PURPOSE_ENCRYPT | HKS_KEY_PURPOSE_DECRYPT, - false, 0, - true, HKS_PADDING_NONE, - true, HKS_MODE_GCM, - false, 0 - }, - { false, 0 }, - { - HKS_TEST_CIPHER_TYPE_AES, true, /* encrypt params */ - true, HKS_ALG_AES, - true, HKS_KEY_PURPOSE_ENCRYPT, - false, 0, - true, HKS_PADDING_NONE, - true, HKS_MODE_GCM, - false, 0, - true, AES_DEFAULT_GCM_NONCE_LENGTH, - true, AES_DEFAULT_AAD_LEN - }, - { - HKS_TEST_CIPHER_TYPE_AES, true, /* decrypt params */ - true, HKS_ALG_AES, - true, HKS_KEY_PURPOSE_DECRYPT, - false, 0, - true, HKS_PADDING_NONE, - true, HKS_MODE_GCM, - false, 0, - true, AES_DEFAULT_GCM_NONCE_LENGTH, - true, AES_DEFAULT_AAD_LEN - }, - { true, DEFAULT_AES_CIPHER_PLAIN_SIZE, true, DEFAULT_AES_CIPHER_PLAIN_SIZE }, - { true, DEFAULT_AES_CIPHER_PLAIN_SIZE + 16, true, DEFAULT_AES_CIPHER_PLAIN_SIZE + 16 }, - { true, DEFAULT_AES_CIPHER_PLAIN_SIZE, true, DEFAULT_AES_CIPHER_PLAIN_SIZE }, - { false, 0, false, 0 } - }, -}; - -static int32_t ConstructDataToBlob(struct HksBlob **inData, struct HksBlob **outData, - const struct HksTestBlobParams *inTextParams, const struct HksTestBlobParams *outTextParams) -{ - int32_t ret = TestConstuctBlob(inData, - inTextParams->blobExist, - inTextParams->blobSize, - inTextParams->blobDataExist, - inTextParams->blobDataSize); - HKS_TEST_ASSERT(ret == 0); - - ret = TestConstuctBlob(outData, - outTextParams->blobExist, - outTextParams->blobSize, - outTextParams->blobDataExist, - outTextParams->blobDataSize); - HKS_TEST_ASSERT(ret == 0); - return ret; -} - -static int32_t Encrypt(struct CipherEncryptStructure *encryptStruct) -{ - int32_t ret; - struct HksParamSet *encryptParamSet = NULL; - - uint32_t ivSize = encryptStruct->cipherParms->ivSize; - uint32_t nonceSize = encryptStruct->cipherParms->nonceSize; - uint32_t aadSize = encryptStruct->cipherParms->aadSize; - if (ivSize != 0) { - ret = TestConstuctBlob(encryptStruct->ivData, true, ivSize, true, ivSize); - HKS_TEST_ASSERT(ret == 0); - } - if (nonceSize != 0) { - ret = TestConstuctBlob(encryptStruct->nonceData, true, nonceSize, true, nonceSize); - HKS_TEST_ASSERT(ret == 0); - } - if (aadSize != 0) { - ret = TestConstuctBlob(encryptStruct->aadData, true, aadSize, true, aadSize); - HKS_TEST_ASSERT(ret == 0); - } - struct AesCipherParamSetStructure enParamStruct = { - &encryptParamSet, - encryptStruct->cipherParms->paramSetExist, - encryptStruct->cipherParms->setAlg, encryptStruct->cipherParms->alg, - encryptStruct->cipherParms->setPurpose, encryptStruct->cipherParms->purpose, - encryptStruct->cipherParms->setPadding, encryptStruct->cipherParms->padding, - encryptStruct->cipherParms->setBlockMode, encryptStruct->cipherParms->mode, - encryptStruct->cipherParms->setIv, *(encryptStruct->ivData), - encryptStruct->cipherParms->setNonce, *(encryptStruct->nonceData), - encryptStruct->cipherParms->setAad, *(encryptStruct->aadData), - encryptStruct->cipherParms->setIsKeyAlias, encryptStruct->cipherParms->isKeyAlias - }; - ret = TestConstructAesCipherParamSet(&enParamStruct); - HKS_TEST_ASSERT(ret == 0); - - ret = HksEncryptRun(encryptStruct->keyAlias, encryptParamSet, encryptStruct->plainData, encryptStruct->cipherData, - encryptStruct->performTimes); - HksFreeParamSet(&encryptParamSet); - return ret; -} - -static int32_t DecryptCipher(struct CipherDecryptStructure *decryptStruct) -{ - int32_t ret = TestConstuctBlob(decryptStruct->decryptedData, - decryptStruct->cipherParms->decryptedTextParams.blobExist, - decryptStruct->cipherParms->decryptedTextParams.blobSize, - decryptStruct->cipherParms->decryptedTextParams.blobDataExist, - decryptStruct->cipherParms->decryptedTextParams.blobDataSize); - HKS_TEST_ASSERT(ret == 0); - - struct HksParamSet *decryptParamSet = NULL; - struct AesCipherParamSetStructure deParamStruct = { - &decryptParamSet, - decryptStruct->cipherParms->decryptParamSetParams.paramSetExist, - decryptStruct->cipherParms->decryptParamSetParams.setAlg, - decryptStruct->cipherParms->decryptParamSetParams.alg, - decryptStruct->cipherParms->decryptParamSetParams.setPurpose, - decryptStruct->cipherParms->decryptParamSetParams.purpose, - decryptStruct->cipherParms->decryptParamSetParams.setPadding, - decryptStruct->cipherParms->decryptParamSetParams.padding, - decryptStruct->cipherParms->decryptParamSetParams.setBlockMode, - decryptStruct->cipherParms->decryptParamSetParams.mode, - decryptStruct->cipherParms->decryptParamSetParams.setIv, decryptStruct->ivData, - decryptStruct->cipherParms->decryptParamSetParams.setNonce, decryptStruct->nonceData, - decryptStruct->cipherParms->decryptParamSetParams.setAad, decryptStruct->aadData, - decryptStruct->cipherParms->decryptParamSetParams.setIsKeyAlias, - decryptStruct->cipherParms->decryptParamSetParams.isKeyAlias - }; - ret = TestConstructAesCipherParamSet(&deParamStruct); - HKS_TEST_ASSERT(ret == 0); - - ret = HksDecryptRun(decryptStruct->keyAlias, decryptParamSet, decryptStruct->cipherData, - *(decryptStruct->decryptedData), decryptStruct->performTimes); - HksFreeParamSet(&decryptParamSet); - return ret; -} - -int32_t GenerateKeyTwo(struct HksBlob *keyAlias, const struct HksTestBlobParams *keyAliasParams, - const struct HksTestGenKeyParamsParamSet *genKeyParamSetParams, - const struct HksTestGenKeyParamsParamSetOut *genKeyParamSetParamsOut) -{ - struct HksParamSet *paramSet = NULL; - struct GenerateKeyParamSetStructure paramStruct = { - ¶mSet, - genKeyParamSetParams->paramSetExist, - genKeyParamSetParams->setAlg, genKeyParamSetParams->alg, - genKeyParamSetParams->setKeySize, genKeyParamSetParams->keySize, - genKeyParamSetParams->setPurpose, genKeyParamSetParams->purpose, - genKeyParamSetParams->setDigest, genKeyParamSetParams->digest, - genKeyParamSetParams->setPadding, genKeyParamSetParams->padding, - genKeyParamSetParams->setBlockMode, genKeyParamSetParams->mode, - genKeyParamSetParams->setKeyStorageFlag, genKeyParamSetParams->keyStorageFlag - }; - int32_t ret = TestConstructGenerateKeyParamSet(¶mStruct); - HKS_TEST_ASSERT(ret == 0); - - struct HksParamSet *paramSetOut = NULL; - if (genKeyParamSetParamsOut != NULL) { - ret = TestConstructGenerateKeyParamSetOut(¶mSet, - genKeyParamSetParamsOut->paramSetExist, genKeyParamSetParamsOut->paramSetSize); - HKS_TEST_ASSERT(ret == 0); - } - - ret = HksGenerateKey(keyAlias, paramSet, paramSetOut); - HKS_TEST_ASSERT(ret == 0); - - HksFreeParamSet(¶mSet); - return ret; -} - -static int32_t ModifyKey(struct HksBlob *keyAlias) -{ - uint32_t sizeOne = HksTestFileSize(g_storePath, (char *)keyAlias->data); - uint8_t *bufOne = (uint8_t *)HksTestMalloc(sizeOne); - if (bufOne == NULL) { - return HKS_ERROR_MALLOC_FAIL; - } - uint32_t sizeRead = HksTestFileRead(g_storePath, (char *)keyAlias->data, 0, bufOne, sizeOne); - (void)memset_s(bufOne, sizeRead, 0, sizeRead); - - int32_t ret = HksTestFileWrite(g_storePath, (char *)keyAlias->data, 0, bufOne, sizeOne); - HksTestFree(bufOne); - - return ret; -} - - -int32_t BaseTestCipherProcess(struct HksBlob *keyAlias, uint32_t index) -{ - struct HksBlob *plainData = NULL; - struct HksBlob *cipherData = NULL; - int32_t ret = ConstructDataToBlob(&plainData, &cipherData, - &g_testCipherParams[index].plainTextParams, &g_testCipherParams[index].cipherTextParams); - HKS_TEST_ASSERT(ret == 0); - struct HksBlob *ivData = NULL; - struct HksBlob *nonceData = NULL; - struct HksBlob *aadData = NULL; - struct HksBlob *decryptedData = NULL; - /* 2. encrypt */ - do { - struct CipherEncryptStructure testEncryptStruct = { - keyAlias, &g_testCipherParams[index].encryptParamSetParams, - plainData, cipherData, &ivData, &nonceData, &aadData, 1 - }; - ret = Encrypt(&testEncryptStruct); - if (ret != g_testCipherParams[index].expectResult) { - break; - } - /* 3. decrypt */ - struct CipherDecryptStructure testDecryptStruct = { - keyAlias, &g_testCipherParams[index], cipherData, - &decryptedData, ivData, nonceData, aadData, 1 - }; - ret = DecryptCipher(&testDecryptStruct); - if (ret != g_testCipherParams[index].expectResult) { - break; - } - - if (ret == g_testCipherParams[index].expectResult) { - if (plainData->size != decryptedData->size) { - break; - }; - ret = memcmp(plainData->data, decryptedData->data, plainData->size); - } - } while (0); - TestFreeBlob(&plainData); - TestFreeBlob(&cipherData); - TestFreeBlob(&decryptedData); - TestFreeBlob(&ivData); - TestFreeBlob(&nonceData); - TestFreeBlob(&aadData); - return ret; -} - -/** - * @tc.name: HksModifyKeyTest.HksModifyKeyTest001 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksModifyKeyTest, HksModifyKeyTest001, TestSize.Level1) -{ - uint32_t index = 0; - struct HksBlob keyAlias = { strlen(g_testName), (uint8_t *)g_testName }; - int32_t ret = GenerateKeyTwo(&keyAlias, &g_testCipherParams[index].keyAliasParams, - &g_testCipherParams[index].genKeyParamSetParams, &g_testCipherParams[index].genKeyParamSetParamsOut); - EXPECT_EQ(ret, 0); - - ret = BaseTestCipherProcess(&keyAlias, 0); - EXPECT_EQ(ret, 0); - - struct HksBlob *plainData = NULL; - struct HksBlob *cipherData = NULL; - ret = ConstructDataToBlob(&plainData, &cipherData, - &g_testCipherParams[index].plainTextParams, &g_testCipherParams[index].cipherTextParams); - EXPECT_EQ(ret, 0); - struct HksBlob *ivData = NULL; - struct HksBlob *nonceData = NULL; - struct HksBlob *aadData = NULL; - - /* 2. encrypt */ - struct CipherEncryptStructure testEncryptStruct = { - &keyAlias, &g_testCipherParams[index].encryptParamSetParams, - plainData, cipherData, &ivData, &nonceData, &aadData, 1 - }; - ret = Encrypt(&testEncryptStruct); - EXPECT_EQ(ret, 0); - ret = ModifyKey(&keyAlias); - EXPECT_EQ(ret, 0); - /* 3. decrypt */ - struct HksBlob *decryptedData = NULL; - struct CipherDecryptStructure testDecryptStruct = { - &keyAlias, &g_testCipherParams[index], cipherData, - &decryptedData, ivData, nonceData, aadData, 1 - }; - ret = DecryptCipher(&testDecryptStruct); - - HKS_TEST_ASSERT(ret != g_testCipherParams[index].expectResult); - TestFreeBlob(&plainData); - TestFreeBlob(&cipherData); - TestFreeBlob(&decryptedData); - TestFreeBlob(&ivData); - TestFreeBlob(&nonceData); - TestFreeBlob(&aadData); - EXPECT_NE(ret, 0); -} -#endif /* _CUT_AUTHENTICATE_ */ -} \ No newline at end of file diff --git a/security/dataprotect/huks_standard_adapter/src/hks_others_test.cpp b/security/dataprotect/huks_standard_adapter/src/hks_others_test.cpp deleted file mode 100644 index 359c21681..000000000 --- a/security/dataprotect/huks_standard_adapter/src/hks_others_test.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "hks_others_test.h" - -#include "hks_api.h" -#include "hks_param.h" -#include "hks_type.h" - -using namespace testing::ext; -namespace { -#ifndef _CUT_AUTHENTICATE_ -class HksOthersTest : public testing::Test { -public: - static void SetUpTestCase(void); - - static void TearDownTestCase(void); - - void SetUp(); - - void TearDown(); -}; - -void HksOthersTest::SetUpTestCase(void) -{ -} - -void HksOthersTest::TearDownTestCase(void) -{ -} - -void HksOthersTest::SetUp() -{ - EXPECT_EQ(HksInitialize(), 0); -} - -void HksOthersTest::TearDown() -{ -} - -/** - * @tc.name: HksOthersTest.HksOthersTest001 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksOthersTest, HksOthersTest001, TestSize.Level1) -{ - int32_t ret = HksGetKeyParamSet(NULL, NULL, NULL); - ASSERT_TRUE(ret == HKS_ERROR_NULL_POINTER); -} - -/** - * @tc.name: HksOthersTest.HksOthersTest002 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksOthersTest, HksOthersTest002, TestSize.Level1) -{ - int32_t ret = HksGetKeyInfoList(NULL, NULL, NULL); - ASSERT_TRUE(ret == HKS_ERROR_NULL_POINTER); -} - -/** - * @tc.name: HksOthersTest.HksOthersTest003 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksOthersTest, HksOthersTest003, TestSize.Level1) -{ - int32_t ret = HksAttestKey(NULL, NULL, NULL); - ASSERT_TRUE(ret == HKS_ERROR_NOT_SUPPORTED); -} - -/** - * @tc.name: HksOthersTest.HksOthersTest004 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksOthersTest, HksOthersTest004, TestSize.Level1) -{ - int32_t ret = HksGetCertificateChain(NULL, NULL, NULL); - ASSERT_TRUE(ret == HKS_ERROR_NOT_SUPPORTED); -} - -/** - * @tc.name: HksOthersTest.HksOthersTest005 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksOthersTest, HksOthersTest005, TestSize.Level1) -{ - int32_t ret = HksWrapKey(NULL, NULL, NULL, NULL); - ASSERT_TRUE(ret == HKS_ERROR_NOT_SUPPORTED); -} - -/** - * @tc.name: HksOthersTest.HksOthersTest006 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksOthersTest, HksOthersTest006, TestSize.Level1) -{ - int32_t ret = HksUnwrapKey(NULL, NULL, NULL, NULL); - ASSERT_TRUE(ret == HKS_ERROR_NOT_SUPPORTED); -} - -/** - * @tc.name: HksOthersTest.HksOthersTest006 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksOthersTest, HksOthersTest007, TestSize.Level1) -{ - int32_t ret = HksGetSdkVersion(NULL); - ASSERT_TRUE(ret == HKS_ERROR_NULL_POINTER); -} - -/** - * @tc.name: HksOthersTest.HksOthersTest008 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksOthersTest, HksOthersTest008, TestSize.Level1) -{ - int32_t ret = HksInitialize(); - ASSERT_TRUE(ret == HKS_SUCCESS); -} -#endif /* _CUT_AUTHENTICATE_ */ -} \ No newline at end of file diff --git a/security/dataprotect/huks_standard_adapter/src/hks_safe_cipher_key_test.cpp b/security/dataprotect/huks_standard_adapter/src/hks_safe_cipher_key_test.cpp deleted file mode 100644 index 627b680c4..000000000 --- a/security/dataprotect/huks_standard_adapter/src/hks_safe_cipher_key_test.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "hks_safe_cipher_key_test.h" - -#include "hks_api.h" -#include "hks_param.h" -#include "hks_test_api_performance.h" -#include "hks_test_curve25519.h" -#include "hks_test_file_operator.h" -#include "hks_test_log.h" -#include "hks_test_mem.h" - -using namespace testing::ext; -namespace { -#ifndef _CUT_AUTHENTICATE_ -class HksSafeCipherKeyTest : public testing::Test { -public: - static void SetUpTestCase(void); - - static void TearDownTestCase(void); - - void SetUp(); - - void TearDown(); -}; - -void HksSafeCipherKeyTest::SetUpTestCase(void) -{ -} - -void HksSafeCipherKeyTest::TearDownTestCase(void) -{ -} - -void HksSafeCipherKeyTest::SetUp() -{ - EXPECT_EQ(HksInitialize(), 0); -} - -void HksSafeCipherKeyTest::TearDown() -{ -} - -#ifdef _STANDARD_SYSTEM_ - const char *g_storePath = "/data/data/maindata/+0+0+0+0/key"; -#endif -#ifdef _LITEONE_SYSTEM_ - const char *g_storePath = "/storage/maindata/hks_client/key"; -#endif -const char *g_testEd25519 = "test_ed25519"; - -static int32_t CompareTwoKey(struct HksBlob *keyAliasOne, struct HksBlob *keyAliasTwo) -{ - uint32_t sizeOne = HksTestFileSize(g_storePath, (char *)keyAliasOne->data); - uint8_t *bufOne = (uint8_t *)HksTestMalloc(sizeOne); - if (bufOne == NULL) { - return HKS_ERROR_MALLOC_FAIL; - } - uint32_t sizeRead = HksTestFileRead(g_storePath, (char *)keyAliasOne->data, 0, bufOne, sizeOne); - - uint32_t sizeTwo = HksTestFileSize(g_storePath, (char *)keyAliasTwo->data); - uint8_t *bufTwo = (uint8_t *)HksTestMalloc(sizeTwo); - if (bufTwo == NULL) { - HksTestFree(bufOne); - return HKS_ERROR_MALLOC_FAIL; - } - sizeRead = HksTestFileRead(g_storePath, (char *)keyAliasTwo->data, 0, bufTwo, sizeOne); - int32_t ret = memcmp(bufOne, bufTwo, sizeRead); - HksTestFree(bufOne); - HksTestFree(bufTwo); - return ret; -} - -/** - * @tc.name: HksSafeCipherKeyTest.HksSafeCipherKeyTest001 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksSafeCipherKeyTest, HksSafeCipherKeyTest001, TestSize.Level1) -{ - struct HksBlob ed25519Alias = { strlen(g_testEd25519), (uint8_t *)g_testEd25519 }; - int32_t ret = TestGenerateEd25519Key(ed25519Alias); - uint8_t pubKey[32] = {0}; - uint32_t pubKeyLen = 32; - struct HksBlob pubKeyInfo = { pubKeyLen, pubKey }; - ret = HksExportPublicKey(&ed25519Alias, NULL, &pubKeyInfo); - EXPECT_EQ(ret, 0); - ret = HksDeleteKey(&ed25519Alias, NULL); - EXPECT_EQ(ret, 0); - - struct HksBlob newAliasOne = { strlen("test_ed25519_1"), (uint8_t *)"test_ed25519_1" }; - ret = TestImportEd25519(newAliasOne, &pubKeyInfo); - EXPECT_EQ(ret, 0); - - struct HksBlob newAliasTwo = { strlen("test_ed25519_2"), (uint8_t *)"test_ed25519_2" }; - ret = TestImportEd25519(newAliasTwo, &pubKeyInfo); - EXPECT_EQ(ret, 0); - - ret = CompareTwoKey(&newAliasOne, &newAliasTwo); - EXPECT_NE(ret, 0); - - ret = HksDeleteKey(&newAliasOne, NULL); - EXPECT_EQ(ret, 0); - ret = HksDeleteKey(&newAliasTwo, NULL); - EXPECT_EQ(ret, 0); -} -#endif /* _CUT_AUTHENTICATE_ */ -} \ No newline at end of file diff --git a/security/dataprotect/huks_standard_adapter/src/hks_safe_compare_key_test.cpp b/security/dataprotect/huks_standard_adapter/src/hks_safe_compare_key_test.cpp deleted file mode 100644 index d1a81f840..000000000 --- a/security/dataprotect/huks_standard_adapter/src/hks_safe_compare_key_test.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "hks_safe_compare_key_test.h" - -#include "hks_api.h" -#include "hks_param.h" -#include "hks_test_api_performance.h" -#include "hks_test_common.h" -#include "hks_test_file_operator.h" -#include "hks_test_log.h" -#include "hks_test_mem.h" - -using namespace testing::ext; -namespace { -#ifndef _CUT_AUTHENTICATE_ -class HksSafeCompareKeyTest : public testing::Test { -public: - static void SetUpTestCase(void); - - static void TearDownTestCase(void); - - void SetUp(); - - void TearDown(); -}; - -void HksSafeCompareKeyTest::SetUpTestCase(void) -{ -} - -void HksSafeCompareKeyTest::TearDownTestCase(void) -{ -} - -void HksSafeCompareKeyTest::SetUp() -{ - EXPECT_EQ(HksInitialize(), 0); -} - -void HksSafeCompareKeyTest::TearDown() -{ -} -#ifdef _STANDARD_SYSTEM_ - const char *g_storePath = "/data/data/maindata/+0+0+0+0/key"; -#endif -#ifdef _LITEONE_SYSTEM_ - const char *g_storePath = "/storage/maindata/hks_client/key"; -#endif -const char *g_testOne = "TestOne"; -const char *g_testTwo = "TestTwo"; - -static const struct HksTestGenKeyParams g_testGenKeyParams[] = { - /* x25519: tee sign/verify */ - { 0, HKS_SUCCESS, { true, DEFAULT_KEY_ALIAS_SIZE, true, DEFAULT_KEY_ALIAS_SIZE }, - { - true, - true, HKS_ALG_X25519, - true, HKS_CURVE25519_KEY_SIZE_256, - true, HKS_KEY_PURPOSE_SIGN | HKS_KEY_PURPOSE_VERIFY, - false, 0, - false, 0, - false, 0, - false, 0 - }, - { false, 0 }, - }, -}; - -static int32_t SafeTestGenerateKey(struct HksBlob *keyAlias) -{ - uint32_t index = 0; - uint32_t performTimes = 1; - - struct HksParamSet *paramSet = NULL; - struct GenerateKeyParamSetStructure paramStruct = { - ¶mSet, - g_testGenKeyParams[index].paramSetParams.paramSetExist, - g_testGenKeyParams[index].paramSetParams.setAlg, g_testGenKeyParams[index].paramSetParams.alg, - g_testGenKeyParams[index].paramSetParams.setKeySize, g_testGenKeyParams[index].paramSetParams.keySize, - g_testGenKeyParams[index].paramSetParams.setPurpose, g_testGenKeyParams[index].paramSetParams.purpose, - g_testGenKeyParams[index].paramSetParams.setDigest, g_testGenKeyParams[index].paramSetParams.digest, - g_testGenKeyParams[index].paramSetParams.setPadding, g_testGenKeyParams[index].paramSetParams.padding, - g_testGenKeyParams[index].paramSetParams.setBlockMode, g_testGenKeyParams[index].paramSetParams.mode, - g_testGenKeyParams[index].paramSetParams.setKeyStorageFlag, - g_testGenKeyParams[index].paramSetParams.keyStorageFlag - }; - int32_t ret = TestConstructGenerateKeyParamSet(¶mStruct); - HKS_TEST_ASSERT(ret == 0); - - struct HksParamSet *paramSetOut = NULL; - ret = TestConstructGenerateKeyParamSetOut(¶mSetOut, - g_testGenKeyParams[index].paramSetParamsOut.paramSetExist, - g_testGenKeyParams[index].paramSetParamsOut.paramSetSize); - HKS_TEST_ASSERT(ret == 0); - - ret = HksGenerateKeyRun(keyAlias, paramSet, paramSetOut, performTimes); - if (ret != g_testGenKeyParams[index].expectResult) { - HKS_TEST_LOG_I("failed, ret[%u] = %d", g_testGenKeyParams[index].testId, ret); - } - EXPECT_EQ(ret, g_testGenKeyParams[index].expectResult); - - if (ret == g_testGenKeyParams[index].expectResult) { - ret = 0; - } else { - ret = 1; - } - HksFreeParamSet(¶mSet); - HksFreeParamSet(¶mSetOut); - return ret; -} - -static int32_t CompareKeyData(struct HksBlob *keyAliasOne, struct HksBlob *keyAliasTwo) -{ - uint32_t sizeOne = HksTestFileSize(g_storePath, (char *)keyAliasOne->data); - uint8_t *bufOne = (uint8_t *)HksTestMalloc(sizeOne); - if (bufOne == NULL) { - return HKS_ERROR_MALLOC_FAIL; - } - uint32_t sizeRead = HksTestFileRead(g_storePath, (char *)keyAliasOne->data, 0, bufOne, sizeOne); - - uint32_t sizeTwo = HksTestFileSize(g_storePath, (char *)keyAliasTwo->data); - uint8_t *bufTwo = (uint8_t *)HksTestMalloc(sizeTwo); - if (bufTwo == NULL) { - HksTestFree(bufOne); - return HKS_ERROR_MALLOC_FAIL; - } - sizeRead = HksTestFileRead(g_storePath, (char *)keyAliasTwo->data, 0, bufTwo, sizeOne); - int32_t ret = memcmp(bufOne, bufTwo, sizeOne); - HksTestFree(bufOne); - HksTestFree(bufTwo); - return ret; -} - -/** - * @tc.name: HksSafeCompareKeyTest.HksSafeCompareKeyTest001 - * @tc.desc: The static function will return true; - * @tc.type: FUNC - */ -HWTEST_F(HksSafeCompareKeyTest, HksSafeCompareKeyTest001, TestSize.Level1) -{ - struct HksBlob keyAliasOne = { strlen(g_testOne), (uint8_t *)g_testOne }; - int32_t ret = SafeTestGenerateKey(&keyAliasOne); - EXPECT_EQ(ret, 0); - - struct HksBlob keyAliasTwo = { strlen(g_testTwo), (uint8_t *)g_testTwo }; - ret = SafeTestGenerateKey(&keyAliasTwo); - EXPECT_EQ(ret, 0); - - ret = CompareKeyData(&keyAliasOne, &keyAliasTwo); - EXPECT_NE(ret, 0); -} -#endif /* _CUT_AUTHENTICATE_ */ -} \ No newline at end of file diff --git a/security/deviceauth/deviceauth_basic_deps/BUILD.gn b/security/deviceauth/deviceauth_basic_deps/BUILD.gn deleted file mode 100644 index 9130f50fa..000000000 --- a/security/deviceauth/deviceauth_basic_deps/BUILD.gn +++ /dev/null @@ -1,98 +0,0 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//test/xts/acts/security_lite/deviceauth_basic_deps/deviceauth.gni") -import("//test/xts/tools/build/suite.gni") - -config("module_private_config") { - visibility = [ ":*" ] - include_dirs = [ - "//utils/native/base/include", - "//third_party/bounds_checking_function/include", - ] -} - -DEVICEAUTH_BASIC_DEPS_CPP_DIR = - "//test/xts/acts/security/deviceauth/deviceauth_basic_deps" - -DEVICEAUTH_BASIC_DEPS_CPP_SOURCE = [ - "${DEVICEAUTH_BASIC_DEPS_CPP_DIR}/print_log.cpp", - "${DEVICEAUTH_BASIC_DEPS_CPP_DIR}/test_timer.cpp", - "${DEVICEAUTH_BASIC_DEPS_CPP_DIR}/hc_file_test.cpp", - "${DEVICEAUTH_BASIC_DEPS_CPP_DIR}/hc_mutex_test.cpp", - "${DEVICEAUTH_BASIC_DEPS_CPP_DIR}/hc_file_f_test.cpp", - "${DEVICEAUTH_BASIC_DEPS_CPP_DIR}/hc_thread_test.cpp", - "${DEVICEAUTH_BASIC_DEPS_CPP_DIR}/hc_dev_info_test.cpp", - "${DEVICEAUTH_BASIC_DEPS_CPP_DIR}/hc_condition_test.cpp", - "${DEVICEAUTH_BASIC_DEPS_CPP_DIR}/hc_file_utils_test.cpp", - "${DEVICEAUTH_BASIC_DEPS_CPP_DIR}/hc_file_iot_flash_test.cpp", - "${DEVICEAUTH_BASIC_DEPS_CPP_DIR}/hc_time_test.cpp", - "${DEVICEAUTH_BASIC_DEPS_CPP_DIR}/hc_file_common.cpp", - "${DEVICEAUTH_BASIC_DEPS_CPP_DIR}/hc_alg_test.cpp", -] - -ohos_moduletest_suite("ActsDeviceAuthBasicDepsTest") { - configs = [ ":module_private_config" ] - - cflags_cc = [ - "-DHILOG_ENABLE", - "-Werror", - ] - - sources = [ "device_auth_test.cpp" ] - - sources += DEVICEAUTH_BASIC_DEPS_CPP_SOURCE - - include_dirs = [ - "//third_party/googletest/googlemock/include", - - # hctest.h compatible with c++ - "//test/xts/acts/security/deviceauth/deviceauth_basic_deps", - - "//utils/native/base/include", - "//third_party/bounds_checking_function/include", - "//base/security/deviceauth/deps_adapter/os_adapter/interfaces/liteos", - "//base/startup/syspara_lite/interfaces/kits", - "//test/xts/acts/security_lite/deviceauth_basic_deps", - ] - - include_dirs += DEVICEAUTH_BASIC_DEPS_INC - - deps = [ - "//base/security/deviceauth/deps_adapter:deviceauth_hal_linux", - "//third_party/bounds_checking_function:libsec_static", - "//utils/native/base:utils", - ] - - cflags = [ "-Werror" ] - - defines = [ - "MKDIR_IMPLEMENTED=1", - "STAT_IMPLEMENTED=1", - "ACCESS_IMPLEMENTED=1", - "F_API_IMPLEMENTED=1", - "FLASH_START_ADDRESS_HICHAIN=0", - "UTILS_FILE_IMPLEMENTED=0", - "TEST_PTHREAD_CREATE_DETACHED=1", - "TEST_HC_FILE_OPEN_SERIES=1", - - "TEST_HKDF_WITH_KEY_ALIAS_TRUE=1", - "TEST_IMPORT_ASYMMETRIC_KEY=0", - "TEST_COMPUTEHMAC_WITH_ISALIAS_TRUE=0", - "TEST_HASH_TO_POINT=1", - "TEST_GENERATE_KEY_PAIR_WITH_STORAGE=1", - "TEST_AGREE_SHARED_SECRET_WITH_STORAGE=1", - "TEST_AGREE_SHARED_SECRET=1", - "TEST_BIG_NUM_EXP_MOD=1", - ] -} diff --git a/security/deviceauth/deviceauth_basic_deps/Test.json b/security/deviceauth/deviceauth_basic_deps/Test.json deleted file mode 100644 index 2c632c877..000000000 --- a/security/deviceauth/deviceauth_basic_deps/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "kits": [ - { - "push": [ - "ActsDeviceAuthBasicDepsTest->/data/local/tmp/ActsDeviceAuthBasicDepsTest" - ], - "type": "PushKit" - } - ], - "driver": { - "native-test-timeout": "120000", - "type": "CppTest", - "module-name": "ActsDeviceAuthBasicDepsTest", - "runtime-hint": "1s", - "native-test-device-path": "/data/local/tmp" - }, - "description": "Configuration for ActsDeviceAuthBasicDepsTest Tests" -} diff --git a/security/deviceauth/deviceauth_basic_deps/device_auth_test.cpp b/security/deviceauth/deviceauth_basic_deps/device_auth_test.cpp deleted file mode 100644 index 83dc1fe10..000000000 --- a/security/deviceauth/deviceauth_basic_deps/device_auth_test.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "hc_alg_test.h" -#include "hc_condition_test.h" -#include "hc_dev_info_test.h" -#include "hc_file_f_test.h" -#include "hc_file_iot_flash_test.h" -#include "hc_file_test.h" -#include "hc_file_utils_test.h" -#include "hc_mutex_test.h" -#include "hc_thread_test.h" -#include "hc_time_test.h" -#include "print_log.h" - -using namespace testing::ext; -namespace { -class DeviceAuthTest : public testing::Test { -public: - static void SetUpTestCase(void); - - static void TearDownTestCase(void); - - void SetUp(); - - void TearDown(); -}; - -void DeviceAuthTest::SetUpTestCase(void) -{ - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); -} - -void DeviceAuthTest::TearDownTestCase(void) -{ - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); -} - -void DeviceAuthTest::SetUp() -{ - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); - (void)(srand(time(nullptr))); - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); -} - -void DeviceAuthTest::TearDown() -{ - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); -} - -/** - * @tc.name: DeviceAuthTest.TestCaseHcMutex - * @tc.desc: - * @tc.type: FUNC - */ -HWTEST_F(DeviceAuthTest, TestCaseHcMutex, TestSize.Level1) -{ - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); - TestHcMutex(); - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); -} - -/** - * @tc.name: DeviceAuthTest.TestCaseHcThread - * @tc.desc: - * @tc.type: FUNC - */ -HWTEST_F(DeviceAuthTest, TestCaseHcThread, TestSize.Level1) -{ - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); - TestHcThread(); - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); -} - -/** - * @tc.name: DeviceAuthTest.TestCaseHcGetUdid - * @tc.desc: - * @tc.type: FUNC - */ -HWTEST_F(DeviceAuthTest, TestCaseHcGetUdid, TestSize.Level1) -{ - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); - TestHcGetUdid(); - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); -} - -/** - * @tc.name: DeviceAuthTest.TestCaseHcFile - * @tc.desc: - * @tc.type: FUNC - */ -HWTEST_F(DeviceAuthTest, TestCaseHcFile, TestSize.Level1) -{ - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); - TestHcFile(); - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); -} - -/** - * @tc.name: DeviceAuthTest.TestCaseHcFileFApi - * @tc.desc: - * @tc.type: FUNC - */ -HWTEST_F(DeviceAuthTest, TestCaseHcFileFApi, TestSize.Level1) -{ - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); - TestHcFileFApi(); - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); -} - -/** - * @tc.name: DeviceAuthTest.TestCaseHcFileUtilsFile - * @tc.desc: - * @tc.type: FUNC - */ -HWTEST_F(DeviceAuthTest, TestCaseHcFileUtilsFile, TestSize.Level1) -{ - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); - TestHcFileUtilsFile(); - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); -} - -/** - * @tc.name: DeviceAuthTest.TestCaseSemCondition - * @tc.desc: - * @tc.type: FUNC - */ -HWTEST_F(DeviceAuthTest, TestCaseSemCondition, TestSize.Level1) -{ - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); - TestHcSemCondition(); - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); -} - -/** - * @tc.name: DeviceAuthTest.TestCasePthreadCondition - * @tc.desc: - * @tc.type: FUNC - */ -HWTEST_F(DeviceAuthTest, TestCasePthreadCondition, TestSize.Level1) -{ - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); - TestHcPthreadCondition(); - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); -} - -/** - * @tc.name: DeviceAuthTest.TestCaseHcFileIotFlash - * @tc.desc: - * @tc.type: FUNC - */ -HWTEST_F(DeviceAuthTest, TestCaseHcFileIotFlash, TestSize.Level1) -{ - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); - TestHcFileIotFlash(); - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); -} - -/** - * @tc.name: DeviceAuthTest.TestCaseHcTime - * @tc.desc: - * @tc.type: FUNC - */ -HWTEST_F(DeviceAuthTest, TestCaseHcTime, TestSize.Level1) -{ - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); - TestHcTime(); - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); -} - -/** - * @tc.name: DeviceAuthTest.TestCaseHcAlg - * @tc.desc: - * @tc.type: FUNC - */ -HWTEST_F(DeviceAuthTest, TestCaseHcAlg, TestSize.Level1) -{ - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); - TestHcAlg(); - LOGI("++++++++++++++++++++++++++++++++++++++++\n"); -} -} // namespace diff --git a/security/deviceauth/deviceauth_basic_deps/hc_alg_test.cpp b/security/deviceauth/deviceauth_basic_deps/hc_alg_test.cpp deleted file mode 120000 index c1d65161e..000000000 --- a/security/deviceauth/deviceauth_basic_deps/hc_alg_test.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../security_lite/deviceauth_basic_deps/hc_alg_test.c \ No newline at end of file diff --git a/security/deviceauth/deviceauth_basic_deps/hc_condition_test.cpp b/security/deviceauth/deviceauth_basic_deps/hc_condition_test.cpp deleted file mode 120000 index be8b5aae8..000000000 --- a/security/deviceauth/deviceauth_basic_deps/hc_condition_test.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../security_lite/deviceauth_basic_deps/hc_condition_test.c \ No newline at end of file diff --git a/security/deviceauth/deviceauth_basic_deps/hc_dev_info_test.cpp b/security/deviceauth/deviceauth_basic_deps/hc_dev_info_test.cpp deleted file mode 120000 index 41ce0b58b..000000000 --- a/security/deviceauth/deviceauth_basic_deps/hc_dev_info_test.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../security_lite/deviceauth_basic_deps/hc_dev_info_test.c \ No newline at end of file diff --git a/security/deviceauth/deviceauth_basic_deps/hc_file_common.cpp b/security/deviceauth/deviceauth_basic_deps/hc_file_common.cpp deleted file mode 120000 index 2b0664acd..000000000 --- a/security/deviceauth/deviceauth_basic_deps/hc_file_common.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../security_lite/deviceauth_basic_deps/hc_file_common.c \ No newline at end of file diff --git a/security/deviceauth/deviceauth_basic_deps/hc_file_f_test.cpp b/security/deviceauth/deviceauth_basic_deps/hc_file_f_test.cpp deleted file mode 120000 index 91f342969..000000000 --- a/security/deviceauth/deviceauth_basic_deps/hc_file_f_test.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../security_lite/deviceauth_basic_deps/hc_file_f_test.c \ No newline at end of file diff --git a/security/deviceauth/deviceauth_basic_deps/hc_file_iot_flash_test.cpp b/security/deviceauth/deviceauth_basic_deps/hc_file_iot_flash_test.cpp deleted file mode 120000 index f7cef42ab..000000000 --- a/security/deviceauth/deviceauth_basic_deps/hc_file_iot_flash_test.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../security_lite/deviceauth_basic_deps/hc_file_iot_flash_test.c \ No newline at end of file diff --git a/security/deviceauth/deviceauth_basic_deps/hc_file_test.cpp b/security/deviceauth/deviceauth_basic_deps/hc_file_test.cpp deleted file mode 120000 index e789e922d..000000000 --- a/security/deviceauth/deviceauth_basic_deps/hc_file_test.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../security_lite/deviceauth_basic_deps/hc_file_test.c \ No newline at end of file diff --git a/security/deviceauth/deviceauth_basic_deps/hc_file_utils_test.cpp b/security/deviceauth/deviceauth_basic_deps/hc_file_utils_test.cpp deleted file mode 120000 index 2ab4711c8..000000000 --- a/security/deviceauth/deviceauth_basic_deps/hc_file_utils_test.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../security_lite/deviceauth_basic_deps/hc_file_utils_test.c \ No newline at end of file diff --git a/security/deviceauth/deviceauth_basic_deps/hc_mutex_test.cpp b/security/deviceauth/deviceauth_basic_deps/hc_mutex_test.cpp deleted file mode 120000 index 0bae17762..000000000 --- a/security/deviceauth/deviceauth_basic_deps/hc_mutex_test.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../security_lite/deviceauth_basic_deps/hc_mutex_test.c \ No newline at end of file diff --git a/security/deviceauth/deviceauth_basic_deps/hc_thread_test.cpp b/security/deviceauth/deviceauth_basic_deps/hc_thread_test.cpp deleted file mode 120000 index c3aabc145..000000000 --- a/security/deviceauth/deviceauth_basic_deps/hc_thread_test.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../security_lite/deviceauth_basic_deps/hc_thread_test.c \ No newline at end of file diff --git a/security/deviceauth/deviceauth_basic_deps/hc_time_test.cpp b/security/deviceauth/deviceauth_basic_deps/hc_time_test.cpp deleted file mode 120000 index 99de63286..000000000 --- a/security/deviceauth/deviceauth_basic_deps/hc_time_test.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../security_lite/deviceauth_basic_deps/hc_time_test.c \ No newline at end of file diff --git a/security/deviceauth/deviceauth_basic_deps/hctest.h b/security/deviceauth/deviceauth_basic_deps/hctest.h deleted file mode 100644 index 0ee1ead85..000000000 --- a/security/deviceauth/deviceauth_basic_deps/hctest.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef HC_COMPATIBLE_GTEST_TEST_H -#define HC_COMPATIBLE_GTEST_TEST_H - -#include -#include -#include -#include - -#define TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements) \ - EXPECT_THAT(std::vector((actual), (actual) + (num_elements)), \ - ::testing::ElementsAreArray((expected), (num_elements))) -#define TEST_ASSERT_EQUAL_HEX8_ARRAY_MESSAGE(expected, actual, num_elements, message) \ - EXPECT_THAT(std::vector((actual), (actual) + (num_elements)), \ - ::testing::ElementsAreArray((expected), (num_elements))) << (message) -#define TEST_ASSERT_EQUAL(expected, actual) EXPECT_EQ((actual), (expected)) -#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) EXPECT_EQ((actual), (expected)) << (message) -#define TEST_ASSERT_EQUAL_STRING(expected, actual) EXPECT_STREQ((actual), (expected)) -#define TEST_ASSERT_GREATER_OR_EQUAL(threshold, actual) EXPECT_GE((actual), (threshold)) -#define TEST_ASSERT_GREATER_THAN(threshold, actual) EXPECT_GT((actual), (threshold)) -#define TEST_ASSERT_LESS_OR_EQUAL(threshold, actual) EXPECT_LE((actual), (threshold)) -#define TEST_ASSERT_LESS_THAN(threshold, actual) EXPECT_LT((actual), (threshold)) -#define TEST_ASSERT_MESSAGE(condition, message) EXPECT_TRUE((condition)) << (message) -#define TEST_ASSERT_NOT_EQUAL(expected, actual) EXPECT_NE((actual), (expected)) -#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) EXPECT_NE((actual), (expected)) << (message) -#define TEST_ASSERT_NOT_NULL(pointer) EXPECT_NE((pointer), nullptr) -#define TEST_ASSERT_NULL(pointer) EXPECT_EQ((pointer), nullptr) -#define TEST_ASSERT_TRUE(condition) EXPECT_TRUE((condition)) -#define TEST_ASSERT_TRUE_MESSAGE(condition, message) EXPECT_TRUE((condition)) << (message) - -#endif // HC_COMPATIBLE_GTEST_TEST_H diff --git a/security/deviceauth/deviceauth_basic_deps/print_log.cpp b/security/deviceauth/deviceauth_basic_deps/print_log.cpp deleted file mode 120000 index df93622d9..000000000 --- a/security/deviceauth/deviceauth_basic_deps/print_log.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../security_lite/deviceauth_basic_deps/print_log.c \ No newline at end of file diff --git a/security/deviceauth/deviceauth_basic_deps/test_timer.cpp b/security/deviceauth/deviceauth_basic_deps/test_timer.cpp deleted file mode 120000 index 321f266c7..000000000 --- a/security/deviceauth/deviceauth_basic_deps/test_timer.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../security_lite/deviceauth_basic_deps/test_timer.c \ No newline at end of file diff --git a/security/deviceauth/deviceauth_function/BUILD.gn b/security/deviceauth/deviceauth_function/BUILD.gn deleted file mode 100644 index 626ca2edc..000000000 --- a/security/deviceauth/deviceauth_function/BUILD.gn +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//test/xts/tools/build/suite.gni") - -######################################################## -config("module_private_config") { - visibility = [ ":*" ] - include_dirs = [ - "//utils/native/base/include", - "//third_party/bounds_checking_function/include", - "//test/xts/acts/security_lite/huks/common/include", - ] -} - -######################################################## -ohos_moduletest_suite("ActsDeviceAuthFunctionTest") { - configs = [ ":module_private_config" ] - cflags_cc = [ "-DHILOG_ENABLE" ] - defines = [ "_STANDARD_SYSTEM_" ] - - sources = [ - "src/deviceauth_standard_test.cpp", - "src/deviceauth_test_mock.cpp", - ] - - include_dirs = [ - "./include", - "//third_party/json/include", - "//utils/native/base/include", - "//foundation/communication/dsoftbus/interfaces/kits/common", - "//foundation/communication/dsoftbus/interfaces/kits/transport", - "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", - "//base/security/deviceauth/common_lib/interfaces/", - "//base/security/deviceauth/deps_adapter/key_management_adapter/interfaces/", - "//base/security/deviceauth/deps_adapter/key_management_adapter/impl/inc", - "//base/security/deviceauth/interfaces/innerkits", - "//base/security/deviceauth/services/dev/inc", - "//base/security/deviceauth/services/data_manager/inc/", - "//base/security/deviceauth/services/group_manager/inc/broadcast_manager", - "//base/security/deviceauth/services/frameworks/inc/", - "//base/security/deviceauth/deps_adapter/os_adapter/impl/interfaces/", - "//base/security/deviceauth/deps_adapter/os_adapter/impl/interfaces/linux/", - "//base/security/deviceauth/deps_adapter/os_adapter/interfaces/liteos", - "//base/security/deviceauth/deps_adapter/os_adapter/interfaces", - ] - - deps = [ - "//base/security/deviceauth/services:deviceauth", - "//base/security/deviceauth/services:deviceauth_service", - "//base/security/huks/interfaces/innerkits/huks_standard/main:libhukssdk", - "//third_party/bounds_checking_function:libsec_static", - "//third_party/cJSON:cjson_static", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - "//third_party/openssl:libcrypto_static", - "//utils/native/base:utils", - ] - - external_deps = [ - "dsoftbus_standard:softbus_client", - "hiviewdfx_hilog_native:libhilog", - ] -} diff --git a/security/deviceauth/deviceauth_function/Test.json b/security/deviceauth/deviceauth_function/Test.json deleted file mode 100644 index 721e97210..000000000 --- a/security/deviceauth/deviceauth_function/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "kits": [ - { - "push": [ - "ActsDeviceAuthFunctionTest->/data/local/tmp/ActsDeviceAuthFunctionTest" - ], - "type": "PushKit" - } - ], - "driver": { - "native-test-timeout": "120000", - "type": "CppTest", - "module-name": "ActsDeviceAuthFunctionTest", - "runtime-hint": "1s", - "native-test-device-path": "/data/local/tmp" - }, - "description": "Configuration for ActsDeviceAuthFunctionTest Tests" -} diff --git a/security/deviceauth/deviceauth_function/include/deviceauth_standard_test.h b/security/deviceauth/deviceauth_function/include/deviceauth_standard_test.h deleted file mode 100644 index 48c32363e..000000000 --- a/security/deviceauth/deviceauth_function/include/deviceauth_standard_test.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DEVICEAUTH_STANDARD_TEST_H -#define DEVICEAUTH_STANDARD_TEST_H -#include -#include "gmock/gmock.h" - - -const char *TEST_APP_NAME = "TestApp"; -const int32_t TEMP_REQUEST_ID = 123; -const int32_t BUFFER_SIZE = 2048; -const char *CLIENT_AUTH_ID = "3C58C27533D8"; -const char *SERVER_AUTH_ID = "CAF34E13190CBA510AA8DABB70CDFF8E9F623656DED400EF0D4CFD9E88FD6202"; -const char *PIN_CODE = "123456"; -const int32_t CLIENT_REQUEST_ID = 123; -const int32_t SERVER_REQUEST_ID = 345; -const int32_t STR_BUFF_SZ_MIN = 32; -const int32_t STR_BUFF_SZ_NORMAL = 128; -const int32_t MAX_GROUP_NUMBER = 101; - - -typedef enum { - ON_REQUEST = 1, - ON_ERROR = 2, - ON_FINISH = 3, - ON_SESSION_KEY_RETURNED = 4, - ON_TRANSMIT = 5 -} CallbackType; - -#endif - diff --git a/security/deviceauth/deviceauth_function/include/deviceauth_test_mock.h b/security/deviceauth/deviceauth_function/include/deviceauth_test_mock.h deleted file mode 100644 index ffe387d20..000000000 --- a/security/deviceauth/deviceauth_function/include/deviceauth_test_mock.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DEVICEAUTH_STANDARD_MOCK_H -#define DEVICEAUTH_STANDARD_MOCK_H - -#include -#include - -void SetClient(bool tag); -bool GetClient(); - -#endif diff --git a/security/deviceauth/deviceauth_function/src/deviceauth_standard_test.cpp b/security/deviceauth/deviceauth_function/src/deviceauth_standard_test.cpp deleted file mode 100644 index eeb2a482b..000000000 --- a/security/deviceauth/deviceauth_function/src/deviceauth_standard_test.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include "deviceauth_test_mock.h" -#include "deviceauth_standard_test.h" -extern "C" { -#include "common_defs.h" -#include "json_utils.h" -#include "device_auth.h" -#include "device_auth_defines.h" -#include "database_manager.h" -#include "hc_condition.h" -#include "hc_mutex.h" -#include "hc_types.h" -} - -using namespace std; -using namespace testing::ext; - -namespace -{ - static bool g_isNeedContinue = false; - static int64_t g_requestId = 0L; - static int g_operationCode = -1; - static int g_errorCode = 1; - static char *g_tempStr = nullptr; - static int g_messageCode = -1; - -void ClearTempValue() -{ - g_isNeedContinue = false; - g_requestId = 0L; - g_operationCode = -1; - g_errorCode = 1; - g_tempStr = nullptr; - g_messageCode = -1; -} - -enum { - GROUP_CREATED = 0, - GROUP_DELETED, - DEVICE_BOUND, - DEVICE_UNBOUND, - DEVICE_NOT_TRUSTED, - LAST_GROUP_DELETED, - TRUSTED_DEVICE_NUM_CHANGED -}; - -/* test suit - GET_INSTANCE */ -class GET_INSTANCE : public testing::Test { -public: - static void SetUpTestCase(void); - - static void TearDownTestCase(void); - - void SetUp(); - - void TearDown(); -}; - -void GET_INSTANCE::SetUpTestCase() -{ - int32_t ret = InitDeviceAuthService(); - ASSERT_EQ(ret == HC_SUCCESS, true); -} - -void GET_INSTANCE::TearDownTestCase() -{ - DestroyDeviceAuthService(); - ClearTempValue(); -} - -void GET_INSTANCE::SetUp() -{ -} - -void GET_INSTANCE::TearDown() -{ -} - - - -class REGISTER_CALLBACK : public testing::Test { -public: - const DeviceGroupManager *gm = GetGmInstance(); - static void SetUpTestCase(void); - - static void TearDownTestCase(void); - - void SetUp(); - - void TearDown(); -}; - - -/* start cases */ -/** - * @tc.name: GET_INSTANCE.TC_GET_GM_INSTANCE - * @tc.desc: Test GetGmInstance interface function; - * @tc.type: FUNC - */ -HWTEST_F(GET_INSTANCE, TC_GET_GM_INSTANCE, TestSize.Level1) -{ - const DeviceGroupManager *gm = GetGmInstance(); - ASSERT_NE(gm, nullptr); -} -} \ No newline at end of file diff --git a/security/deviceauth/deviceauth_function/src/deviceauth_test_mock.cpp b/security/deviceauth/deviceauth_function/src/deviceauth_test_mock.cpp deleted file mode 100644 index 074e8440e..000000000 --- a/security/deviceauth/deviceauth_function/src/deviceauth_test_mock.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include "securec.h" -#include "deviceauth_test_mock.h" -static bool g_testForClient = false; - -void SetClient(bool tag) -{ - g_testForClient = tag; -} - -bool GetClient() -{ - return g_testForClient; -} - -int32_t HcGetUdid(uint8_t *udid, int32_t udidLen) -{ - const char *clientUdid = "D6350E39AD8F11963C181BEEDC11AC85158E04466B68F1F4E6D895237E0FE81C"; - const char *serverUdid = "ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00"; - if (g_testForClient) { - (void)memcpy_s(udid, udidLen - 1, clientUdid, strlen(clientUdid)); - return 0; - } - (void)memcpy_s(udid, udidLen - 1, serverUdid, strlen(serverUdid)); - return 0; -} - -const char *GetStoragePath() -{ - return "/data/data/deviceauth/hcgroup.dat"; -} diff --git a/test_packages.gni b/test_packages.gni index ad46ac92d..4febf0145 100755 --- a/test_packages.gni +++ b/test_packages.gni @@ -15,9 +15,11 @@ import("//test/xts/tools/build/suite.gni") _all_test_packages = [ "${ACTS_ROOT}/global:global", - "${ACTS_ROOT}/security:security", + + #"${ACTS_ROOT}/security:security", "${ACTS_ROOT}/multimedia:multimedia", - "${ACTS_ROOT}/hiviewdfx:hiviewdfxtestacts", + + #"${ACTS_ROOT}/hiviewdfx:hiviewdfxtestacts", "${ACTS_ROOT}/barrierfree:barrierfree", # "${ACTS_ROOT}/telephony:telephony", -- GitLab