diff --git a/UniversalKeystoreKit/KeyDeletion/.gitignore b/UniversalKeystoreKit/KeyDeletion/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/AppScope/app.json5 b/UniversalKeystoreKit/KeyDeletion/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..dddc4dae3eabe2acc674968b64d9175df3693160
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.keydeletion",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyDeletion/AppScope/resources/base/element/string.json b/UniversalKeystoreKit/KeyDeletion/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..6871b23fb433023d1988284b0685d810565e66ee
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "KeyDeletion"
+ }
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyDeletion/AppScope/resources/base/media/app_icon.png b/UniversalKeystoreKit/KeyDeletion/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/UniversalKeystoreKit/KeyDeletion/AppScope/resources/base/media/app_icon.png differ
diff --git a/UniversalKeystoreKit/KeyDeletion/README.md b/UniversalKeystoreKit/KeyDeletion/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..9c9b1321b3419e4e69aa198049ed972670a43085
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/README.md
@@ -0,0 +1,92 @@
+## 密钥删除(ArkTS)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-delete-key-arkts.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### KeyDeletion
+
+##### 介绍
+
+1. 本示例主要介绍为保证数据安全性,当不需要使用密钥时,删除HKDF256密钥。
+
+##### 效果预览
+
+| 主页 | 删除 |
+| ---------------------------------------------------------- | ---------------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击Call KeyDeletion按钮调用接口deleteKeyItem,删除密钥。
+
+## 密钥删除(C/C++)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-delete-key-ndk.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### Call C/C++
+
+##### 介绍
+
+1. 本示例主要介绍为保证数据安全性,当不需要使用密钥时,删除HKDF256密钥。
+
+##### 效果预览
+
+| 主页 | 跳转页 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+|
|
|
+
+使用说明
+
+1. 点击Call C/C++按钮调用OH_Huks_DeleteKeyItem接口,删除密钥。
+
+## 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---Index.ets // 首页
+|---|---|---KeyDeletion.ets
+|---cpp
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---KeyDeletion.test.ets // 自动化测试用例
+```
+
+
+## 相关权限
+
+无。
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo UniversalKeystoreKit/KeyDeletion > .git/info/sparse-checkout
+git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/build-profile.json5 b/UniversalKeystoreKit/KeyDeletion/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..fb5a1ab654ae6715a0ab69a31900ad26dcf2487f
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/build-profile.json5
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ "buildOption": {
+ "strictMode": {
+ "caseSensitiveCheck": true,
+ "useNormalizedOHMUrl": true
+ }
+ }
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/code-linter.json5 b/UniversalKeystoreKit/KeyDeletion/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/.gitignore b/UniversalKeystoreKit/KeyDeletion/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/build-profile.json5 b/UniversalKeystoreKit/KeyDeletion/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2d8b081b615348a99aa197f90186f3d8891b7dc1
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/build-profile.json5
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ "externalNativeOptions": {
+ "path": "./src/main/cpp/CMakeLists.txt",
+ "arguments": "",
+ "cppFlags": "",
+ "abiFilters": [
+ "arm64-v8a",
+ "x86_64"
+ ]
+ }
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ },
+ "nativeLib": {
+ "debugSymbol": {
+ "strip": true,
+ "exclude": []
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/hvigorfile.ts b/UniversalKeystoreKit/KeyDeletion/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/oh-package.json5 b/UniversalKeystoreKit/KeyDeletion/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..118bdd4fe7699368a010e04c24f5bfc887cf1298
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/oh-package.json5
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {
+ "libentry.so": "file:./src/main/cpp/types/libentry"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/CMakeLists.txt b/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..7395e4fc05762f8c66ed070d71c1abddaddc4c37
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,15 @@
+# the minimum version of CMake.
+cmake_minimum_required(VERSION 3.5.0)
+project(KeyDeletion)
+
+set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+if(DEFINED PACKAGE_FIND_FILE)
+ include(${PACKAGE_FIND_FILE})
+endif()
+
+include_directories(${NATIVERENDER_ROOT_PATH}
+ ${NATIVERENDER_ROOT_PATH}/include)
+
+add_library(entry SHARED napi_init.cpp)
+target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so)
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/napi_init.cpp b/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/napi_init.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..086974eaa59e20903140b7b0ce4b3d05027392ca
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/napi_init.cpp
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start key_deletion]
+#include "huks/native_huks_api.h"
+#include "huks/native_huks_param.h"
+#include "napi/native_api.h"
+#include
+// [StartExclude key_deletion]
+/* 以下以生成ECC密钥为例 */
+OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params,
+ uint32_t paramCount)
+{
+ OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_AddParams(*paramSet, params, paramCount);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ ret = OH_Huks_BuildParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ return ret;
+}
+
+struct OH_Huks_Param g_testGenerateKeyParam[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECC},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256},
+ {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}};
+
+static OH_Huks_Result GenerateKeyHelper(const char *alias)
+{
+ struct OH_Huks_Blob aliasBlob = {.size = (uint32_t)strlen(alias), .data = (uint8_t *)alias};
+ struct OH_Huks_ParamSet *testGenerateKeyParamSet = nullptr;
+ struct OH_Huks_Result ohResult;
+ do {
+ /* 1.初始化密钥属性集 */
+ ohResult = InitParamSet(&testGenerateKeyParamSet, g_testGenerateKeyParam,
+ sizeof(g_testGenerateKeyParam) / sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ /* 2.生成密钥 */
+ ohResult = OH_Huks_GenerateKeyItem(&aliasBlob, testGenerateKeyParamSet, nullptr);
+ } while (0);
+ OH_Huks_FreeParamSet(&testGenerateKeyParamSet);
+ return ohResult;
+}
+// [EndExclude key_deletion]
+static napi_value DeleteKey(napi_env env, napi_callback_info info)
+{
+ /* 1.获取密钥别名 */
+ const char *alias = "test_key";
+ struct OH_Huks_Blob keyAlias = {
+ (uint32_t)strlen("test_key"),
+ (uint8_t *)"test_key"
+ };
+ // [StartExclude key_deletion]
+ /* 生成密钥 */
+ OH_Huks_Result genResult = GenerateKeyHelper(alias);
+ if (genResult.errorCode != OH_HUKS_SUCCESS) {
+ napi_value ret;
+ napi_create_int32(env, genResult.errorCode, &ret);
+ return ret;
+ }
+ // [EndExclude key_deletion]
+
+ /* 2.调用OH_Huks_DeleteKeyItem删除密钥 */
+ struct OH_Huks_Result ohResult = OH_Huks_DeleteKeyItem(&keyAlias, nullptr);
+
+ napi_value ret;
+ napi_create_int32(env, ohResult.errorCode, &ret);
+ return ret;
+}
+// [End key_deletion]
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports)
+{
+ napi_property_descriptor desc[] = {
+ { "deleteKey", nullptr, DeleteKey, nullptr, nullptr, nullptr, napi_default, nullptr }
+ };
+ napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "entry",
+ .nm_priv = ((void*)0),
+ .reserved = { 0 },
+};
+
+extern "C" __attribute__((constructor)) void RegisterEntryModule(void)
+{
+ napi_module_register(&demoModule);
+}
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/types/libentry/index.d.ts b/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/types/libentry/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..70baf682c5d9bb1e866d36a2ed3c1d008143a0c9
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/types/libentry/index.d.ts
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2025 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 const deleteKey: () => number;
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/types/libentry/oh-package.json5 b/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/types/libentry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2826cc7d6bd199c1008bb51d898dffa922201e6c
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/types/libentry/oh-package.json5
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "libentry.so",
+ "types": "./index.d.ts",
+ "version": "1.0.0",
+ "description": "Please describe the basic information."
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/entryability/EntryAbility.ets b/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..edc2839f203ba057c186e19b0cbbbf80c8faa8b3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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 { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/pages/Index.ets b/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..9ad9b7133d708d78f4413188f89fe671d046eba7
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2025 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 { router } from '@kit.ArkUI';
+import testNapi from 'libentry.so';
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'KeyDeletion';
+
+ goToSample(url: string): void {
+ router.pushUrl({
+ url: url,
+ }, router.RouterMode.Single, (err) => {
+ if (err) {
+ console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
+ return;
+ }
+ console.info('pushUrl success');
+ })
+ }
+
+ build() {
+ Column({ space: 5 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.key_deletion'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/KeyDeletion')
+ })
+ Button($r('app.string.call_cpp_delete_key'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ let ret: number = testNapi.deleteKey();
+ this.message = 'Call C/C++ Result: ' + ret.toString();
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/pages/KeyDeletion.ets b/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/pages/KeyDeletion.ets
new file mode 100644
index 0000000000000000000000000000000000000000..30a8e4ea27fce67a20ca7ce0258db7f0ab337683
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/pages/KeyDeletion.ets
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+/*
+ * 以下以HKDF256密钥的Promise操作使用为例
+ */
+// [Start key_deletions]
+import { huks } from '@kit.UniversalKeystoreKit';
+
+/* 1.确定密钥别名 */
+let keyAlias = 'test_Key';
+// [StartExclude key_deletions]
+/* 2.初始化密钥属性集 */
+let generateProperties: huks.HuksParam[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_DH
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_DH_KEY_SIZE_2048
+ }
+];
+
+let generateHuksOptions: huks.HuksOptions = {
+ properties: generateProperties,
+ inData: new Uint8Array([])
+}
+
+/* 3.生成密钥 */
+function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.generateKeyItem(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions): Promise {
+ console.info(`enter promise generateKeyItem`);
+ try {
+ await generateKeyItem(keyAlias, huksOptions)
+ .then((data) => {
+ console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`);
+ });
+ return 'Success';
+ } catch (error) {
+ console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`);
+ return 'Failed';
+ }
+}
+
+async function testGenKey(): Promise {
+ let ret = await publicGenKeyFunc(keyAlias, generateHuksOptions);
+ return ret;
+}
+
+// [EndExclude key_deletions]
+/* 4.构造空对象 */
+let deleteHuksOptions: huks.HuksOptions = {
+ properties: []
+}
+
+class ThrowObject {
+ public isThrow = false;
+}
+
+function deleteKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.deleteKeyItem(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+/* 3.删除密钥*/
+async function publicDeleteKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions): Promise {
+ console.info(`enter promise deleteKeyItem`);
+ let throwObject: ThrowObject = { isThrow: false };
+ try {
+ console.log('start genKey...')
+ await testGenKey();
+ console.log('end genKey...')
+ await deleteKeyItem(keyAlias, huksOptions, throwObject)
+ .then((data) => {
+ console.info(`promise: deleteKeyItem key success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: deleteKeyItem failed, ${JSON.stringify(error)}`);
+ }
+ });
+ return 'Success';
+ } catch (error) {
+ console.error(`promise: deleteKeyItem input arg invalid, ${JSON.stringify(error)}`);
+ return 'Failed';
+ }
+}
+
+async function testDerive(): Promise {
+ let ret = await publicDeleteKeyFunc(keyAlias, deleteHuksOptions);
+ return ret;
+}
+// [End key_deletions]
+@Entry
+@Component
+struct Index {
+ @State message: string = 'KeyDeletion';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.call_key_deletion'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ let ret = await testDerive();
+ this.message = 'KeyDeletion Result: ' + ret;
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/main/module.json5 b/UniversalKeystoreKit/KeyDeletion/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..4144486d1af4c03b0d767cce1cda86fc0d697f91
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/src/main/module.json5
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/element/color.json b/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/element/string.json b/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..e43f1932dba2c12667c3be0fb9d9550c5c94c2f6
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,40 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "KeyDeletion"
+ },
+ {
+ "name": "key_deletion",
+ "value": "KeyDeletion"
+ },
+ {
+ "name": "call_cpp_delete_key",
+ "value": "Call C/C++"
+ },
+ {
+ "name": "call_cpp_result",
+ "value": "Call C/C++ Result: "
+ },
+ {
+ "name": "call_key_deletion",
+ "value": "Call KeyDeletion"
+ },
+ {
+ "name": "key_deletion_result",
+ "value": "KeyDeletion Result: "
+ },
+ {
+ "name": "key_deletion_failed",
+ "value": "KeyDeletion Result: Failed"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/background.png b/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/background.png differ
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/foreground.png b/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/foreground.png differ
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/layered_image.json b/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/startIcon.png b/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/profile/backup_config.json b/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/profile/main_pages.json b/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..f915b3dbbb373f02f4983ad62bccc25bafb49545
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,6 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/KeyDeletion"
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/dark/element/color.json b/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/dark/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/src/main/resources/dark/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#000000"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/ets/test/Ability.test.ets b/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/ets/test/KeyDeletion.test.ets b/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/ets/test/KeyDeletion.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..23df4b73762c536f91139e12073a1ab091d4ccda
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/ets/test/KeyDeletion.test.ets
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, it, expect, beforeAll } from '@ohos/hypium';
+// 导入测试依赖kit
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+let want: Want;
+
+export default function keyDeletionTest() {
+ describe('keyDeletionTest', () => {
+ /**
+ * 打开应用
+ */
+ beforeAll(async () => {
+ want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ await driver.delayMs(1000);
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ })
+
+ /**
+ * 点击按钮,密钥删除(ArkTS)
+ */
+ it('testKeyDeletion001', 0, async () => {
+ console.info('uitest: testKeyDeletion001 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('KeyDeletion').type('Button'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('Call KeyDeletion'));
+ await button2.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('KeyDeletion Result: Success'));
+ console.info('uitest: testKeyDeletion001 end');
+ await driver.pressBack();
+ })
+
+ /**
+ * 点击按钮,密钥删除(C/C++)
+ */
+ it('testKeyDeletion002', 0, async () => {
+ console.info('uitest: testKeyDeletion002 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('Call C/C++'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('Call C/C++ Result: 0'));
+ console.info('uitest: testKeyDeletion002 end');
+ await driver.pressBack();
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/ets/test/List.test.ets b/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7cb7a69e6d2f8c3eb7dac9ef0f2d2ec53af2cb2b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 keyDeletionTest from './KeyDeletion.test';
+
+export default function testsuite() {
+ keyDeletionTest();
+}
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/module.json5 b/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/test/List.test.ets b/UniversalKeystoreKit/KeyDeletion/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/entry/src/test/LocalUnit.test.ets b/UniversalKeystoreKit/KeyDeletion/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/hvigor/hvigor-config.json5 b/UniversalKeystoreKit/KeyDeletion/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..d584c19c247db9a7caee4b606bb931aa9279c637
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/UniversalKeystoreKit/KeyDeletion/hvigorfile.ts b/UniversalKeystoreKit/KeyDeletion/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyDeletion/oh-package.json5 b/UniversalKeystoreKit/KeyDeletion/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e41bae026aab3b50d0abb42fece08ba43b4a772b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyDeletion/ohosTest.md b/UniversalKeystoreKit/KeyDeletion/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..f123e6d1846e212b4feefa096a316dc17daec380
--- /dev/null
+++ b/UniversalKeystoreKit/KeyDeletion/ohosTest.md
@@ -0,0 +1,9 @@
+# 密钥删除测试用例归档
+
+## 用例表
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------------- | ------------ | ---- | ---------------- | -------- | -------- |
+| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass |
+| 点击按钮,密钥删除(ArkTS) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass |
+| 点击按钮,密钥删除(C/C++) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass |
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletionCpp_1.png b/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletionCpp_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..ed5cfeb2c5d199ea2d00d25bc9ba5e674e271b14
Binary files /dev/null and b/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletionCpp_1.png differ
diff --git a/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletionCpp_2.png b/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletionCpp_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..7d7524d80efa657d41a5d15bf82bbde2f5bfd1e6
Binary files /dev/null and b/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletionCpp_2.png differ
diff --git a/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletion_1.png b/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletion_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..338157108702c6c6920a4bbba9b39a71786fccd3
Binary files /dev/null and b/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletion_1.png differ
diff --git a/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletion_2.png b/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletion_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..56abc90490ba44a49476e3c8dbecbc6952d7ada7
Binary files /dev/null and b/UniversalKeystoreKit/KeyDeletion/screenshots/KeyDeletion_2.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/.gitignore b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/AppScope/app.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..013014463590069c923be75705b96c9b11176793
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.generatekey",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/AppScope/resources/base/element/string.json b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..99baa78e80bf9d2a9f479bcf02577c5419b11b7c
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "GenerateKey"
+ }
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/AppScope/resources/base/media/app_icon.png b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/AppScope/resources/base/media/app_icon.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/README.md b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..3a2ee05bc210e58dfcb0216203affe25e8aac171
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/README.md
@@ -0,0 +1,91 @@
+## 生成密钥(ArkTS)
+
+### 介绍
+
+1. 本工程实现了对以下 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-key-generation-arkts.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### Call ArkTS
+
+##### 介绍
+
+1. 本示例主要介绍生成密钥,以生成DH密钥为例生成随机密钥,指定待生成的密钥别名keyAlias。
+
+##### 效果预览
+
+| 主页 | |
+| ---------------------------------------------------- | ---------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击Call ArkTS按钮调用huks.generateKeyItem,传入密钥别名和密钥属性集,生成密钥。
+
+## 生成密钥(C/C++)
+
+### 介绍
+
+1. 本工程实现了对以下示例代码片段的工程化,目标是实现指南中示例代码与sample工程文件同源。示例代码来源:https://gitee.com/openharmony/docs/blob/OpenHarmony-5.0.1-Release/zh-cn/application-dev/security/UniversalKeystoreKit/huks-key-generation-ndk.md
+
+#### Call C/C++
+
+##### 介绍
+
+1. 本示例主要介绍生成密钥,以生成ECC密钥为例,生成随机密钥。
+
+##### 效果预览
+
+| 主页 | |
+| -------------------------------------------------- | -------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击Call C/C++按钮调用OH_Huks_GenerateKeyItem,传入密钥别名和密钥属性集,生成密钥。
+
+## 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---Index.ets // 首页
+|---cpp
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---GenerateKey.test.ets // 自动化测试用例
+```
+
+
+## 相关权限
+
+无。
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey > .git/info/sparse-checkout
+git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/build-profile.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..fb5a1ab654ae6715a0ab69a31900ad26dcf2487f
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/build-profile.json5
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ "buildOption": {
+ "strictMode": {
+ "caseSensitiveCheck": true,
+ "useNormalizedOHMUrl": true
+ }
+ }
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/code-linter.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/.gitignore b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/build-profile.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2d8b081b615348a99aa197f90186f3d8891b7dc1
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/build-profile.json5
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ "externalNativeOptions": {
+ "path": "./src/main/cpp/CMakeLists.txt",
+ "arguments": "",
+ "cppFlags": "",
+ "abiFilters": [
+ "arm64-v8a",
+ "x86_64"
+ ]
+ }
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ },
+ "nativeLib": {
+ "debugSymbol": {
+ "strip": true,
+ "exclude": []
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/hvigorfile.ts b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/oh-package.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..118bdd4fe7699368a010e04c24f5bfc887cf1298
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/oh-package.json5
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {
+ "libentry.so": "file:./src/main/cpp/types/libentry"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/CMakeLists.txt b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..0a6fa49673dd77e7b109b82e84f31911ec5b5e9f
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,15 @@
+# the minimum version of CMake.
+cmake_minimum_required(VERSION 3.5.0)
+project(GenerateKey)
+
+set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+if(DEFINED PACKAGE_FIND_FILE)
+ include(${PACKAGE_FIND_FILE})
+endif()
+
+include_directories(${NATIVERENDER_ROOT_PATH}
+ ${NATIVERENDER_ROOT_PATH}/include)
+
+add_library(entry SHARED napi_init.cpp)
+target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so)
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/napi_init.cpp b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/napi_init.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a66fe4fc99a505eabc91aa6dfa12ab18a87d2289
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/napi_init.cpp
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start generate_key]
+/* 以下以生成ECC密钥为例 */
+#include "huks/native_huks_api.h"
+#include "huks/native_huks_param.h"
+#include "napi/native_api.h"
+#include
+
+OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params,
+ uint32_t paramCount)
+{
+ OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_AddParams(*paramSet, params, paramCount);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ ret = OH_Huks_BuildParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ return ret;
+}
+
+struct OH_Huks_Param g_testGenerateKeyParam[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECC},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256},
+ {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}};
+
+static napi_value GenerateKey(napi_env env, napi_callback_info info)
+{
+ /* 1.确定密钥别名 */
+ const char *alias = "test_generate";
+ struct OH_Huks_Blob aliasBlob = {.size = (uint32_t)strlen(alias), .data = (uint8_t *)alias};
+ struct OH_Huks_ParamSet *testGenerateKeyParamSet = nullptr;
+ struct OH_Huks_Result ohResult;
+ do {
+ /* 2.初始化密钥属性集 */
+ ohResult = InitParamSet(&testGenerateKeyParamSet, g_testGenerateKeyParam,
+ sizeof(g_testGenerateKeyParam) / sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ /* 3.生成密钥 */
+ ohResult = OH_Huks_GenerateKeyItem(&aliasBlob, testGenerateKeyParamSet, nullptr);
+ } while (0);
+ OH_Huks_FreeParamSet(&testGenerateKeyParamSet);
+ napi_value ret;
+ napi_create_int32(env, ohResult.errorCode, &ret);
+ return ret;
+}
+// [End generate_key]
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports)
+{
+ napi_property_descriptor desc[] = {
+ {"generateKey", nullptr, GenerateKey, nullptr, nullptr, nullptr, napi_default, nullptr}};
+ napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "entry",
+ .nm_priv = ((void *)0),
+ .reserved = {0},
+};
+
+extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); }
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/types/libentry/Index.d.ts b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/types/libentry/Index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..589dd8a4f8f75e5b3684e5fb6275cf43a829840d
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/types/libentry/Index.d.ts
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2025 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 const generateKey: () => number;
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/types/libentry/oh-package.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/types/libentry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..6abf3b7c20f22c62aaac6a995a25cae672f73f35
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/types/libentry/oh-package.json5
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "libentry.so",
+ "types": "./Index.d.ts",
+ "version": "1.0.0",
+ "description": "Please describe the basic information."
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/entryability/EntryAbility.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..965554bb3a331e2418180b86da1993baf5e8d536
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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 { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+};
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/pages/Index.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..1da69929bdb7d39b5f8d234cdfc4874367153d47
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+
+// [Start generate_key_ar]
+
+import { huks } from '@kit.UniversalKeystoreKit';
+import testNapi from 'libentry.so';
+
+/* 1.确定密钥别名 */
+let keyAlias = 'dh_key';
+/* 2.初始化密钥属性集 */
+let properties1: huks.HuksParam[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_DH
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_DH_KEY_SIZE_2048
+ }
+];
+
+let huksOptions: huks.HuksOptions = {
+ properties: properties1,
+ inData: new Uint8Array([])
+}
+
+/* 3.生成密钥 */
+function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.generateKeyItem(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions): Promise {
+ console.info(`enter promise generateKeyItem`);
+ try {
+ await generateKeyItem(keyAlias, huksOptions)
+ .then((data) => {
+ console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`);
+ });
+ return 'Success';
+ } catch (error) {
+ console.error(`promise: generateKeyItem input arg invalid, ` + JSON.stringify(error));
+ return 'Failed';
+ }
+}
+
+async function testGenKey(): Promise {
+ let ret = await publicGenKeyFunc(keyAlias, huksOptions);
+ return ret;
+}
+
+
+// [End generate_key_ar]
+
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'GenerateKey';
+
+ build() {
+ Column({ space: 5 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.call_cpp'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ let ret: number = testNapi.generateKey();
+ this.message = 'C/C++ Call Result: ' + ret.toString();
+ })
+ Button($r('app.string.call_arkts'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ let ret = await testGenKey();
+ this.message = 'ArkTS Call Result: ' + ret;
+ })
+ }
+ .width('100%')
+ .height('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/module.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..4144486d1af4c03b0d767cce1cda86fc0d697f91
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/module.json5
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/element/color.json b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/element/string.json b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..0d407cd54ed67189fa3533391a7441314a13326a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,24 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "GenerateKey"
+ },
+ {
+ "name": "call_cpp",
+ "value": "Call C/C++"
+ },
+ {
+ "name": "call_arkts",
+ "value": "Call ArkTS"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/background.png b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/background.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/foreground.png b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/foreground.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/layered_image.json b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/startIcon.png b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/profile/backup_config.json b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/profile/main_pages.json b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,5 @@
+{
+ "src": [
+ "pages/Index"
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/dark/element/color.json b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/dark/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/resources/dark/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#000000"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/ets/test/Ability.test.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/ets/test/GenerateKey.test.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/ets/test/GenerateKey.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..3eb32fe70b6b57efde0ac2504a2dcd3ec4d9c60d
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/ets/test/GenerateKey.test.ets
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, it, expect, beforeAll } from '@ohos/hypium';
+// 导入测试依赖kit
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+let want: Want;
+
+export default function generateKeyTest() {
+ describe('generateKeyTest', () => {
+ /**
+ * 打开应用
+ */
+ beforeAll(async () => {
+ want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ await driver.delayMs(1000);
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ })
+
+ /**
+ * 点击按钮,生成密钥(C/C++)
+ */
+ it('testGenerateKey001', 0, async () => {
+ console.info('uitest: testGenerateKey001 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('Call C/C++'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('C/C++ Call Result: 0'));
+ console.info('uitest: testGenerateKey001 end');
+ })
+
+ /**
+ * 点击按钮,生成密钥(ArkTS)
+ */
+ it('testGenerateKey002', 0, async () => {
+ console.info('uitest: testGenerateKey002 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('Call ArkTS'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('ArkTS Call Result: Success'));
+ console.info('uitest: testGenerateKey002 end');
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/ets/test/List.test.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..821bf71052454eff3054b9b1746cedc2e78a57b6
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 generateKeyTest from './GenerateKey.test';
+
+export default function testsuite() {
+ generateKeyTest();
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/module.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/test/List.test.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/test/LocalUnit.test.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/hvigor/hvigor-config.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..d584c19c247db9a7caee4b606bb931aa9279c637
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/hvigorfile.ts b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/oh-package.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e41bae026aab3b50d0abb42fece08ba43b4a772b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/ohosTest.md b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..f123e6d1846e212b4feefa096a316dc17daec380
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/ohosTest.md
@@ -0,0 +1,9 @@
+# 密钥删除测试用例归档
+
+## 用例表
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------------- | ------------ | ---- | ---------------- | -------- | -------- |
+| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass |
+| 点击按钮,密钥删除(ArkTS) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass |
+| 点击按钮,密钥删除(C/C++) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass |
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/ArkTS_1.png b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/ArkTS_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..504a5c10f6a9402a1b25348c5021d3a830c4dcc9
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/ArkTS_1.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/ArkTS_2.png b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/ArkTS_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..d37a9524bc0b474eb583a0dd085e1d7080370bae
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/ArkTS_2.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/Cpp_1.png b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/Cpp_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..504a5c10f6a9402a1b25348c5021d3a830c4dcc9
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/Cpp_1.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/Cpp_2.png b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/Cpp_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..3fbc46b8d142e5de7e56f044eeb845e2d70ce08c
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/screenshots/Cpp_2.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/.gitignore b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/AppScope/app.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e676f61bef5991fe2810e330b189c67e77e48e25
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.importencryptedkey",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/AppScope/resources/base/element/string.json b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..53ff5b073bf1236f68127b5a191ecb270d2dbb82
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "ImportEncryptedKey"
+ }
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/AppScope/resources/base/media/app_icon.png b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/AppScope/resources/base/media/app_icon.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/README.md b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..7f09878691398ce6bfed032e54e7cf253045b0fe
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/README.md
@@ -0,0 +1,92 @@
+## 加密导入密钥(ArkTS)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://gitee.com/openharmony/docs/blob/OpenHarmony-5.0.1-Release/zh-cn/application-dev/security/UniversalKeystoreKit/huks-import-wrapped-key-arkts.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### ImportEncryptedKey
+
+##### 介绍
+
+1. 本示例主要介绍为保证数据安全性加密导入ECDH密钥对。
+
+##### 效果预览
+
+| 主页 | 删除 |
+| ---------------------------------------------------------- | ---------------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击Call ArkTS按钮调用接口ImportWrappedKey,加密导入密钥对为。
+
+## 加密导入密钥(C/C++)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://gitee.com/openharmony/docs/blob/OpenHarmony-5.0.1-Release/zh-cn/application-dev/security/UniversalKeystoreKit/huks-import-wrapped-key-ndk.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### Call C/C++
+
+##### 介绍
+
+1. 本示例主要介绍为保证数据安全性加密导入ECDH密钥对。
+
+##### 效果预览
+
+| 主页 | 跳转页 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+|
|
|
+
+使用说明
+
+1. 点击Call C/C++按钮调用接口importWrappedKey,加密导入密钥对为。
+
+## 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---Index.ets // 首页
+|---|---|---ImportEncryptedKey.ets
+|---cpp
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---ImportEncryptedKey.test.ets // 自动化测试用例
+```
+
+
+## 相关权限
+
+无。
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.3 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.3 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.3 Release及以上。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey > .git/info/sparse-checkout
+git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/build-profile.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..daa1501186f0d59acd88753ba00f4f75eb4c262b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/build-profile.json5
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.3(15)",
+ "targetSdkVersion": "5.0.3(15)",
+ "runtimeOS": "HarmonyOS",
+ "buildOption": {
+ "strictMode": {
+ "caseSensitiveCheck": true,
+ "useNormalizedOHMUrl": true
+ }
+ }
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/code-linter.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/.gitignore b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/build-profile.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..7c77d211bf430d212e7d906e3d5f0b7402e1d28b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/build-profile.json5
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ "externalNativeOptions": {
+ "path": "./src/main/cpp/CMakeLists.txt",
+ "arguments": "",
+ "cppFlags": "",
+ "abiFilters": [
+ "arm64-v8a",
+ "x86_64"
+ ]
+ }
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ },
+ "nativeLib": {
+ "debugSymbol": {
+ "strip": true,
+ "exclude": []
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default",
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/hvigorfile.ts b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/oh-package.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..118bdd4fe7699368a010e04c24f5bfc887cf1298
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/oh-package.json5
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {
+ "libentry.so": "file:./src/main/cpp/types/libentry"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/CMakeLists.txt b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..8bfc96301103ed13381219de2ae6287d77a7ea17
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,15 @@
+# the minimum version of CMake.
+cmake_minimum_required(VERSION 3.5.0)
+project(ImportEncryptedKey)
+
+set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+if(DEFINED PACKAGE_FIND_FILE)
+ include(${PACKAGE_FIND_FILE})
+endif()
+
+include_directories(${NATIVERENDER_ROOT_PATH}
+ ${NATIVERENDER_ROOT_PATH}/include)
+
+add_library(entry SHARED napi_init.cpp)
+target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so)
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/napi_init.cpp b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/napi_init.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d9a1f609f11d9b844d320244d923f6cac21b1168
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/napi_init.cpp
@@ -0,0 +1,611 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+// [Start encrypt_import_key]
+
+#include "huks/native_huks_api.h"
+#include "huks/native_huks_param.h"
+#include "napi/native_api.h"
+#include
+
+#define MAX_MALLOC_SIZE 0x800000
+
+OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params,
+ uint32_t paramCount)
+{
+ OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_AddParams(*paramSet, params, paramCount);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ ret = OH_Huks_BuildParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ return ret;
+}
+struct HksImportWrappedKeyTestParams {
+ // server key, for real.
+ struct OH_Huks_Blob *wrappingKeyAlias;
+ struct OH_Huks_ParamSet *genWrappingKeyParamSet;
+ uint32_t publicKeySize;
+ struct OH_Huks_Blob *callerKeyAlias;
+ struct OH_Huks_ParamSet *genCallerKeyParamSet;
+ struct OH_Huks_Blob *callerKekAlias;
+ struct OH_Huks_Blob *callerKek;
+ struct OH_Huks_ParamSet *importCallerKekParamSet;
+ struct OH_Huks_Blob *callerAgreeKeyAlias;
+ struct OH_Huks_ParamSet *agreeParamSet;
+ struct OH_Huks_ParamSet *importWrappedKeyParamSet;
+ struct OH_Huks_Blob *importedKeyAlias;
+ struct OH_Huks_Blob *importedPlainKey;
+ uint32_t keyMaterialLen;
+};
+static const uint32_t IV_SIZE = 16;
+static uint8_t IV[IV_SIZE] = "bababababababab"; // 此处仅为测试数据,实际使用时该值每次应该不同。
+static const uint32_t WRAPPED_KEY_IV_SIZE = 16;
+static uint8_t WRAPPED_KEY_IV[IV_SIZE] = "bababababababab"; // 此处仅为测试数据,实际使用时该值每次应该不同。
+static const uint32_t AAD_SIZE = 16;
+static uint8_t AAD[AAD_SIZE] = "abababababababa"; // 此处仅为测试数据,实际使用时该值每次应该不同。
+static const uint32_t NONCE_SIZE = 12;
+static uint8_t NONCE[NONCE_SIZE] = "hahahahahah"; // 此处仅为测试数据,实际使用时该值每次应该不同。
+static const uint32_t AEAD_TAG_SIZE = 16;
+static const uint32_t X25519_256_SIZE = 256;
+static struct OH_Huks_Blob g_wrappingKeyAliasAes256 = {.size = (uint32_t)strlen("test_wrappingKey_x25519_aes256"),
+ .data = (uint8_t *)"test_wrappingKey_x25519_aes256"};
+static struct OH_Huks_Blob g_callerKeyAliasAes256 = {.size = (uint32_t)strlen("test_caller_key_x25519_aes256"),
+ .data = (uint8_t *)"test_caller_key_x25519_aes256"};
+static struct OH_Huks_Blob g_callerKekAliasAes256 = {.size = (uint32_t)strlen("test_caller_kek_x25519_aes256"),
+ .data = (uint8_t *)"test_caller_kek_x25519_aes256"};
+static struct OH_Huks_Blob g_callerAes256Kek = {.size = (uint32_t)strlen("This is kek to encrypt plain key"),
+ .data = (uint8_t *)"This is kek to encrypt plain key"};
+static struct OH_Huks_Blob g_callerAgreeKeyAliasAes256 = {.size =
+ (uint32_t)strlen("test_caller_agree_key_x25519_aes256"),
+ .data = (uint8_t *)"test_caller_agree_key_x25519_aes256"};
+static struct OH_Huks_Blob g_importedKeyAliasAes256 = {.size = (uint32_t)strlen("test_import_key_x25519_aes256"),
+ .data = (uint8_t *)"test_import_key_x25519_aes256"};
+static struct OH_Huks_Blob g_importedAes256PlainKey = {.size = (uint32_t)strlen("This is plain key to be imported"),
+ .data = (uint8_t *)"This is plain key to be imported"};
+static struct OH_Huks_Param g_importWrappedAes256Params[] = {
+ {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT | OH_HUKS_KEY_PURPOSE_DECRYPT},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256},
+ {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE},
+ {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_GCM},
+ {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE},
+ {.tag = OH_HUKS_TAG_UNWRAP_ALGORITHM_SUITE, .uint32Param = OH_HUKS_UNWRAP_SUITE_X25519_AES_256_GCM_NOPADDING},
+ {.tag = OH_HUKS_TAG_ASSOCIATED_DATA,
+ .blob = {.size = AAD_SIZE, .data = (uint8_t *)AAD}}, // 此处仅为测试数据,实际使用时该值应与调用者信息相关。
+ {.tag = OH_HUKS_TAG_NONCE,
+ .blob = {.size = NONCE_SIZE, .data = (uint8_t *)NONCE}}}; // 此处仅为测试数据,实际使用时该值每次应该不同。
+static const uint32_t g_x25519PubKeySize = 32;
+static struct OH_Huks_Param g_genWrappingKeyParams[] = {
+ {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_X25519},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_UNWRAP},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_CURVE25519_KEY_SIZE_256}};
+static struct OH_Huks_Param g_genCallerX25519Params[] = {
+ {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_X25519},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_CURVE25519_KEY_SIZE_256}};
+static struct OH_Huks_Param g_importParamsCallerKek[] = {
+ {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256},
+ {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE},
+ {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_GCM},
+ {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE},
+ {.tag = OH_HUKS_TAG_IV,
+ .blob = {.size = WRAPPED_KEY_IV_SIZE,
+ .data = (uint8_t *)WRAPPED_KEY_IV}}}; // 此处仅为测试数据,实际使用时该值每次应该不同。
+static struct OH_Huks_Param g_callerAgreeParams[] = {
+ {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_X25519},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_CURVE25519_KEY_SIZE_256}};
+static struct OH_Huks_Param g_aesKekEncryptParams[] = {
+ {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256},
+ {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE},
+ {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_GCM},
+ {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE},
+ {.tag = OH_HUKS_TAG_ASSOCIATED_DATA,
+ .blob = {.size = AAD_SIZE, .data = (uint8_t *)AAD}}, // 此处仅为测试数据,实际使用时该值应与调用者信息相关。
+ {.tag = OH_HUKS_TAG_NONCE,
+ .blob = {.size = NONCE_SIZE, .data = (uint8_t *)NONCE}}}; // 此处仅为测试数据,实际使用时该值每次应该不同。
+static struct OH_Huks_Param g_importAgreeKeyParams[] = {
+ {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256},
+ {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE},
+ {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_GCM},
+ {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE},
+ {.tag = OH_HUKS_TAG_IV,
+ .blob = {.size = IV_SIZE, .data = (uint8_t *)IV}}}; // 此处仅为测试数据,实际使用时该值每次应该不同。
+OH_Huks_Result HuksAgreeKey(const struct OH_Huks_ParamSet *paramSet, const struct OH_Huks_Blob *keyAlias,
+ const struct OH_Huks_Blob *peerPublicKey, struct OH_Huks_Blob *agreedKey)
+{
+ uint8_t temp[10] = {0};
+ struct OH_Huks_Blob inData = {sizeof(temp), temp};
+ uint8_t handleU[sizeof(uint64_t)] = {0};
+ struct OH_Huks_Blob handle = {sizeof(uint64_t), handleU};
+ OH_Huks_Result ret = OH_Huks_InitSession(keyAlias, paramSet, &handle, nullptr);
+ if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ uint8_t outDataU[1024] = {0};
+ struct OH_Huks_Blob outDataUpdate = {1024, outDataU};
+ ret = OH_Huks_UpdateSession(&handle, paramSet, peerPublicKey, &outDataUpdate);
+ if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_FinishSession(&handle, paramSet, &inData, agreedKey);
+ if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ return ret;
+}
+OH_Huks_Result MallocAndCheckBlobData(struct OH_Huks_Blob *blob, const uint32_t blobSize)
+{
+ struct OH_Huks_Result ret;
+ ret.errorCode = OH_HUKS_SUCCESS;
+ if (blobSize == 0 || blobSize > MAX_MALLOC_SIZE) {
+ ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR;
+ }
+ blob->data = (uint8_t *)malloc(blobSize);
+ if (blob->data == NULL) {
+ ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR;
+ }
+ return ret;
+}
+static const uint32_t TIMES = 4;
+static const uint32_t MAX_UPDATE_SIZE = 64;
+static const uint32_t MAX_OUTDATA_SIZE = MAX_UPDATE_SIZE * TIMES;
+#define HUKS_FREE_BLOB(blob) \
+ do { \
+ if ((blob).data != nullptr) { \
+ free((blob).data); \
+ (blob).data = nullptr; \
+ } \
+ (blob).size = 0; \
+ } while (0)
+#define OH_HUKS_KEY_BYTES(keySize) (((keySize) + 7) / 8)
+static OH_Huks_Result HksEncryptLoopUpdate(const struct OH_Huks_Blob *handle, const struct OH_Huks_ParamSet *paramSet,
+ const struct OH_Huks_Blob *inData, struct OH_Huks_Blob *outData)
+{
+ struct OH_Huks_Result ret;
+ ret.errorCode = OH_HUKS_SUCCESS;
+ struct OH_Huks_Blob inDataSeg = *inData;
+ uint8_t *lastPtr = inData->data + inData->size - 1;
+ struct OH_Huks_Blob outDataSeg = {MAX_OUTDATA_SIZE, NULL};
+ uint8_t *cur = outData->data;
+ outData->size = 0;
+ inDataSeg.size = MAX_UPDATE_SIZE;
+ bool isFinished = false;
+ while (inDataSeg.data <= lastPtr) {
+ if (inDataSeg.data + MAX_UPDATE_SIZE <= lastPtr) {
+ outDataSeg.size = MAX_OUTDATA_SIZE;
+ } else {
+ isFinished = true;
+ inDataSeg.size = lastPtr - inDataSeg.data + 1;
+ break;
+ }
+ if (MallocAndCheckBlobData(&outDataSeg, outDataSeg.size).errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR;
+ return ret;
+ }
+ ret = OH_Huks_UpdateSession(handle, paramSet, &inDataSeg, &outDataSeg);
+ if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ free(outDataSeg.data);
+ return ret;
+ }
+ std::copy(outDataSeg.data, outDataSeg.data + outDataSeg.size, cur);
+ cur += outDataSeg.size;
+ outData->size += outDataSeg.size;
+ free(outDataSeg.data);
+ if ((isFinished == false) && (inDataSeg.data + MAX_UPDATE_SIZE > lastPtr)) {
+ ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR;
+ return ret;
+ }
+ inDataSeg.data += MAX_UPDATE_SIZE;
+ }
+ struct OH_Huks_Blob outDataFinish = {inDataSeg.size * TIMES, NULL};
+ if (MallocAndCheckBlobData(&outDataFinish, outDataFinish.size).errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR;
+ return ret;
+ }
+ ret = OH_Huks_FinishSession(handle, paramSet, &inDataSeg, &outDataFinish);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ free(outDataFinish.data);
+ return ret;
+ }
+ std::copy(outDataFinish.data, outDataFinish.data + outDataFinish.size, cur);
+ outData->size += outDataFinish.size;
+ free(outDataFinish.data);
+ return ret;
+}
+OH_Huks_Result HuksEncrypt(const struct OH_Huks_Blob *key, const struct OH_Huks_ParamSet *paramSet,
+ const struct OH_Huks_Blob *plainText, struct OH_Huks_Blob *cipherText)
+{
+ uint8_t handle[sizeof(uint64_t)] = {0};
+ struct OH_Huks_Blob handleBlob = {sizeof(uint64_t), handle};
+ OH_Huks_Result ret = OH_Huks_InitSession(key, paramSet, &handleBlob, nullptr);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = HksEncryptLoopUpdate(&handleBlob, paramSet, plainText, cipherText);
+ return ret;
+}
+static OH_Huks_Result BuildWrappedKeyData(struct OH_Huks_Blob **blobArray, uint32_t size,
+ struct OH_Huks_Blob *outData)
+{
+ uint32_t totalLength = size * sizeof(uint32_t);
+ struct OH_Huks_Result ret;
+ ret.errorCode = OH_HUKS_SUCCESS;
+ /* 计算大小 */
+ for (uint32_t i = 0; i < size; ++i) {
+ totalLength += blobArray[i]->size;
+ }
+ struct OH_Huks_Blob outBlob = {0, nullptr};
+ outBlob.size = totalLength;
+ ret = MallocAndCheckBlobData(&outBlob, outBlob.size);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ uint32_t offset = 0;
+ /* 拷贝数据 */
+ for (uint32_t i = 0; i < size; ++i) {
+ if (totalLength - offset >= sizeof(blobArray[i]->size)) {
+ std::copy(reinterpret_cast(&blobArray[i]->size),
+ reinterpret_cast(&blobArray[i]->size) + sizeof(blobArray[i]->size),
+ outBlob.data + offset);
+ } else {
+ ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR;
+ return ret;
+ }
+ offset += sizeof(blobArray[i]->size);
+ if (totalLength - offset >= blobArray[i]->size) {
+ std::copy(blobArray[i]->data, blobArray[i]->data + blobArray[i]->size, outBlob.data + offset);
+ } else {
+ ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR;
+ return ret;
+ }
+ offset += blobArray[i]->size;
+ }
+ outData->size = outBlob.size;
+ outData->data = outBlob.data;
+ return ret;
+}
+static OH_Huks_Result CheckParamsValid(const struct HksImportWrappedKeyTestParams *params)
+{
+ struct OH_Huks_Result ret;
+ ret.errorCode = OH_HUKS_SUCCESS;
+ if (params == nullptr) {
+ ret.errorCode = OH_HUKS_ERR_CODE_ILLEGAL_ARGUMENT;
+ return ret;
+ }
+ if (params->wrappingKeyAlias == nullptr || params->genWrappingKeyParamSet == nullptr ||
+ params->callerKeyAlias == nullptr || params->genCallerKeyParamSet == nullptr ||
+ params->callerKekAlias == nullptr || params->callerKek == nullptr ||
+ params->importCallerKekParamSet == nullptr || params->callerAgreeKeyAlias == nullptr ||
+ params->agreeParamSet == nullptr || params->importWrappedKeyParamSet == nullptr ||
+ params->importedKeyAlias == nullptr || params->importedPlainKey == nullptr) {
+ ret.errorCode = OH_HUKS_ERR_CODE_ILLEGAL_ARGUMENT;
+ return ret;
+ }
+ return ret;
+}
+static OH_Huks_Result GenerateAndExportHuksPublicKey(const struct HksImportWrappedKeyTestParams *params,
+ struct OH_Huks_Blob *huksPublicKey)
+{
+ OH_Huks_Result ret = OH_Huks_GenerateKeyItem(params->wrappingKeyAlias, params->genWrappingKeyParamSet, nullptr);
+ if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ huksPublicKey->size = params->publicKeySize;
+ ret = MallocAndCheckBlobData(huksPublicKey, huksPublicKey->size);
+ if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_ExportPublicKeyItem(params->wrappingKeyAlias, nullptr, huksPublicKey);
+ return ret;
+}
+static OH_Huks_Result GenerateAndExportCallerPublicKey(const struct HksImportWrappedKeyTestParams *params,
+ struct OH_Huks_Blob *callerSelfPublicKey)
+{
+ OH_Huks_Result ret = OH_Huks_GenerateKeyItem(params->callerKeyAlias, params->genCallerKeyParamSet, nullptr);
+ if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ callerSelfPublicKey->size = params->publicKeySize;
+ ret = MallocAndCheckBlobData(callerSelfPublicKey, callerSelfPublicKey->size);
+ if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_ExportPublicKeyItem(params->callerKeyAlias, params->genWrappingKeyParamSet, callerSelfPublicKey);
+ return ret;
+}
+static OH_Huks_Result ImportKekAndAgreeSharedSecret(const struct HksImportWrappedKeyTestParams *params,
+ const struct OH_Huks_Blob *huksPublicKey,
+ struct OH_Huks_Blob *outSharedKey)
+{
+ OH_Huks_Result ret =
+ OH_Huks_ImportKeyItem(params->callerKekAlias, params->importCallerKekParamSet, params->callerKek);
+ if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = MallocAndCheckBlobData(outSharedKey, outSharedKey->size);
+ if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = HuksAgreeKey(params->agreeParamSet, params->callerKeyAlias, huksPublicKey, outSharedKey);
+ if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ struct OH_Huks_ParamSet *importAgreeKeyParams = nullptr;
+ ret = InitParamSet(&importAgreeKeyParams, g_importAgreeKeyParams,
+ sizeof(g_importAgreeKeyParams) / sizeof(OH_Huks_Param));
+ if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_ImportKeyItem(params->callerAgreeKeyAlias, importAgreeKeyParams, outSharedKey);
+ OH_Huks_FreeParamSet(&importAgreeKeyParams);
+ return ret;
+}
+static OH_Huks_Result EncryptImportedPlainKeyAndKek(const struct HksImportWrappedKeyTestParams *params,
+ struct OH_Huks_Blob *plainCipherText,
+ struct OH_Huks_Blob *kekCipherText)
+{
+ struct OH_Huks_ParamSet *encryptParamSet = nullptr;
+ OH_Huks_Result ret =
+ InitParamSet(&encryptParamSet, g_aesKekEncryptParams, sizeof(g_aesKekEncryptParams) / sizeof(OH_Huks_Param));
+ if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = HuksEncrypt(params->callerKekAlias, encryptParamSet, params->importedPlainKey, plainCipherText);
+ if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = HuksEncrypt(params->callerAgreeKeyAlias, encryptParamSet, params->callerKek, kekCipherText);
+ OH_Huks_FreeParamSet(&encryptParamSet);
+ return ret;
+}
+static OH_Huks_Result ImportWrappedKey(const struct HksImportWrappedKeyTestParams *params,
+ struct OH_Huks_Blob *plainCipher, struct OH_Huks_Blob *kekCipherText,
+ struct OH_Huks_Blob *peerPublicKey, struct OH_Huks_Blob *wrappedKeyData)
+{
+ struct OH_Huks_Blob commonAad = {.size = AAD_SIZE, .data = reinterpret_cast(AAD)};
+ struct OH_Huks_Blob commonNonce = {.size = NONCE_SIZE, .data = reinterpret_cast(NONCE)};
+ struct OH_Huks_Blob keyMaterialLen = {.size = sizeof(uint32_t), .data = (uint8_t *)¶ms->keyMaterialLen};
+ /* 从密文中拷贝AEAD的tag并缩小其大小 */
+ const uint32_t tagSize = AEAD_TAG_SIZE;
+ uint8_t kekTagBuf[tagSize] = {0};
+ struct OH_Huks_Blob kekTag = {.size = tagSize, .data = kekTagBuf};
+ std::copy(plainCipher->data + (plainCipher->size - tagSize),
+ plainCipher->data + (plainCipher->size - tagSize) + tagSize, kekTag.data);
+ plainCipher->size -= tagSize;
+ /* 从密钥加密密钥的密文中拷贝AEAD的tag并缩小其大小 */
+ uint8_t agreeKeyTagBuf[tagSize] = {0};
+ struct OH_Huks_Blob agreeKeyTag = {.size = tagSize, .data = agreeKeyTagBuf};
+ std::copy(kekCipherText->data + (kekCipherText->size - tagSize),
+ kekCipherText->data + (kekCipherText->size - tagSize) + tagSize, agreeKeyTagBuf);
+ kekCipherText->size -= tagSize;
+ struct OH_Huks_Blob *blobArray[] = {peerPublicKey, &commonAad, &commonNonce, &agreeKeyTag, kekCipherText,
+ &commonAad, &commonNonce, &kekTag, &keyMaterialLen, plainCipher};
+ OH_Huks_Result ret = BuildWrappedKeyData(blobArray, OH_HUKS_IMPORT_WRAPPED_KEY_TOTAL_BLOBS, wrappedKeyData);
+ if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ struct OH_Huks_Param *purpose = nullptr;
+ ret = OH_Huks_GetParam(params->importWrappedKeyParamSet, OH_HUKS_TAG_PURPOSE, &purpose);
+ if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_ImportWrappedKeyItem(params->importedKeyAlias, params->wrappingKeyAlias,
+ params->importWrappedKeyParamSet, wrappedKeyData);
+ return ret;
+}
+OH_Huks_Result HksImportWrappedKeyTestCommonCase(const struct HksImportWrappedKeyTestParams *params)
+{
+ OH_Huks_Result ret = CheckParamsValid(params);
+ if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ struct OH_Huks_Blob huksPublicKey = {0, nullptr};
+ struct OH_Huks_Blob callerSelfPublicKey = {0, nullptr};
+ struct OH_Huks_Blob outSharedKey = {.size = OH_HUKS_KEY_BYTES(OH_HUKS_AES_KEY_SIZE_256), .data = nullptr};
+ struct OH_Huks_Blob wrappedKeyData = {0, nullptr};
+ uint8_t plainKeyCipherBuffer[OH_HUKS_MAX_KEY_SIZE] = {0};
+ struct OH_Huks_Blob plainCipherText = {OH_HUKS_MAX_KEY_SIZE, plainKeyCipherBuffer};
+ uint8_t kekCipherTextBuffer[OH_HUKS_MAX_KEY_SIZE] = {0};
+ struct OH_Huks_Blob kekCipherText = {OH_HUKS_MAX_KEY_SIZE, kekCipherTextBuffer};
+ /* 模拟加密导入密钥场景,设备A为远端设备(导入设备),设备B为本端设备(被导入设备) */
+ do {
+ /**
+ * 1.设备A将待导入密钥转换成HUKS密钥材料格式To_Import_Key(仅针对非对称密钥,若待导入密钥是对称密钥则可省略此步骤),
+ * 本示例使用g_importedAes256PlainKey(对称密钥)作为模拟
+ */
+ /* 2.设备B生成一个加密导入用途的、用于协商的非对称密钥对Wrapping_Key(公钥Wrapping_Pk,私钥Wrapping_Sk),
+ * 其密钥用途设置为unwrap,导出Wrapping_Key公钥Wrapping_Pk存放在变量huksPublicKey中
+ */
+ ret = GenerateAndExportHuksPublicKey(params, &huksPublicKey);
+ if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ break;
+ }
+ /* 3.设备A使用和设备B同样的算法,生成一个加密导入用途的、用于协商的非对称密钥对Caller_Key(公钥Caller_Pk,私钥Caller_Sk),
+ * 导出Caller_Key公钥Caller_Pk存放在变量callerSelfPublicKey中
+ */
+ ret = GenerateAndExportCallerPublicKey(params, &callerSelfPublicKey);
+ if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ break;
+ }
+ /**
+ * 4. 设备A生成一个对称密钥Caller_Kek,该密钥后续将用于加密To_Import_Key
+ * 5. 设备A基于Caller_Key的私钥Caller_Sk和设备B Wrapping_Key的公钥Wrapping_Pk,协商出Shared_Key
+ */
+ ret = ImportKekAndAgreeSharedSecret(params, &huksPublicKey, &outSharedKey);
+ if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ break;
+ }
+ /**
+ * 6. 设备A使用Caller_Kek加密To_Import_Key,生成To_Import_Key_Enc
+ * 7. 设备A使用Shared_Key加密Caller_Kek,生成Caller_Kek_Enc
+ */
+ ret = EncryptImportedPlainKeyAndKek(params, &plainCipherText, &kekCipherText);
+ if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ break;
+ }
+ /* 8. 设备A封装Caller_Pk、To_Import_Key_Enc、Caller_Kek_Enc等加密导入的材料并发送给设备B。
+ * 本示例作为变量存放在callerSelfPublicKey,plainCipherText,kekCipherText
+ * 9. 设备B导入封装的加密密钥材料
+ */
+ ret = ImportWrappedKey(params, &plainCipherText, &kekCipherText, &callerSelfPublicKey, &wrappedKeyData);
+ } while (0);
+ /* 10. 设备A、B删除用于加密导入的密钥 */
+ HUKS_FREE_BLOB(huksPublicKey);
+ HUKS_FREE_BLOB(callerSelfPublicKey);
+ HUKS_FREE_BLOB(outSharedKey);
+ HUKS_FREE_BLOB(wrappedKeyData);
+ return ret;
+}
+void HksClearKeysForWrappedKeyTest(const struct HksImportWrappedKeyTestParams *params)
+{
+ OH_Huks_Result ret = CheckParamsValid(params);
+ if (ret.errorCode != (int32_t)OH_HUKS_SUCCESS) {
+ return;
+ }
+ (void)OH_Huks_DeleteKeyItem(params->wrappingKeyAlias, nullptr);
+ (void)OH_Huks_DeleteKeyItem(params->callerKeyAlias, nullptr);
+ (void)OH_Huks_DeleteKeyItem(params->callerKekAlias, nullptr);
+ (void)OH_Huks_DeleteKeyItem(params->callerAgreeKeyAlias, nullptr);
+ (void)OH_Huks_DeleteKeyItem(params->importedKeyAlias, nullptr);
+}
+static OH_Huks_Result InitCommonTestParamsAndDoImport(struct HksImportWrappedKeyTestParams *importWrappedKeyTestParams,
+ const struct OH_Huks_Param *importedKeyParamSetArray,
+ uint32_t arraySize)
+{
+ struct OH_Huks_ParamSet *genX25519KeyParamSet = nullptr;
+ struct OH_Huks_ParamSet *genCallerKeyParamSet = nullptr;
+ struct OH_Huks_ParamSet *callerImportParamsKek = nullptr;
+ struct OH_Huks_ParamSet *agreeParamSet = nullptr;
+ struct OH_Huks_ParamSet *importPlainKeyParams = nullptr;
+ OH_Huks_Result ret;
+ do {
+ ret = InitParamSet(&genX25519KeyParamSet, g_genWrappingKeyParams,
+ sizeof(g_genWrappingKeyParams) / sizeof(OH_Huks_Param));
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ importWrappedKeyTestParams->genWrappingKeyParamSet = genX25519KeyParamSet;
+ importWrappedKeyTestParams->publicKeySize = g_x25519PubKeySize;
+ ret = InitParamSet(&genCallerKeyParamSet, g_genCallerX25519Params,
+ sizeof(g_genCallerX25519Params) / sizeof(OH_Huks_Param));
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ importWrappedKeyTestParams->genCallerKeyParamSet = genCallerKeyParamSet;
+ ret = InitParamSet(&callerImportParamsKek, g_importParamsCallerKek,
+ sizeof(g_importParamsCallerKek) / sizeof(OH_Huks_Param));
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ importWrappedKeyTestParams->importCallerKekParamSet = callerImportParamsKek;
+ ret = InitParamSet(&agreeParamSet, g_callerAgreeParams, sizeof(g_callerAgreeParams) / sizeof(OH_Huks_Param));
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ importWrappedKeyTestParams->agreeParamSet = agreeParamSet;
+ ret = InitParamSet(&importPlainKeyParams, importedKeyParamSetArray, arraySize);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ importWrappedKeyTestParams->importWrappedKeyParamSet = importPlainKeyParams;
+ ret = HksImportWrappedKeyTestCommonCase(importWrappedKeyTestParams);
+ } while (0);
+ OH_Huks_FreeParamSet(&genX25519KeyParamSet);
+ OH_Huks_FreeParamSet(&genCallerKeyParamSet);
+ OH_Huks_FreeParamSet(&callerImportParamsKek);
+ OH_Huks_FreeParamSet(&agreeParamSet);
+ OH_Huks_FreeParamSet(&importPlainKeyParams);
+ return ret;
+}
+static napi_value NAPI_Global_importWrappedKey(napi_env env, napi_callback_info info)
+{
+ struct HksImportWrappedKeyTestParams importWrappedKeyTestParams001 = {0};
+ importWrappedKeyTestParams001.wrappingKeyAlias = &g_wrappingKeyAliasAes256;
+ importWrappedKeyTestParams001.keyMaterialLen = g_importedAes256PlainKey.size;
+ importWrappedKeyTestParams001.callerKeyAlias = &g_callerKeyAliasAes256;
+ importWrappedKeyTestParams001.callerKekAlias = &g_callerKekAliasAes256;
+ importWrappedKeyTestParams001.callerKek = &g_callerAes256Kek;
+ importWrappedKeyTestParams001.callerAgreeKeyAlias = &g_callerAgreeKeyAliasAes256;
+ importWrappedKeyTestParams001.importedKeyAlias = &g_importedKeyAliasAes256;
+ importWrappedKeyTestParams001.importedPlainKey = &g_importedAes256PlainKey;
+ OH_Huks_Result ohResult =
+ InitCommonTestParamsAndDoImport(&importWrappedKeyTestParams001, g_importWrappedAes256Params,
+ sizeof(g_importWrappedAes256Params) / sizeof(struct OH_Huks_Param));
+ HksClearKeysForWrappedKeyTest(&importWrappedKeyTestParams001);
+ napi_value ret;
+ napi_create_int32(env, ohResult.errorCode, &ret);
+ return ret;
+}
+
+
+// [End encrypt_import_key]
+
+
+// [Start encryption_import_key_commissioning_and_verification]
+static napi_value IsKeyExist(napi_env env, napi_callback_info info)
+{
+ /* 1.指定密钥别名 */
+ struct OH_Huks_Blob keyAlias = {
+ (uint32_t)strlen("test_key"),
+ (uint8_t *)"test_key"
+ };
+
+ /* 2.调用OH_Huks_IsKeyItemExist判断密钥是否存在 */
+ struct OH_Huks_Result ohResult = OH_Huks_IsKeyItemExist(&keyAlias, NULL);
+ napi_value ret;
+ napi_create_int32(env, ohResult.errorCode, &ret);
+ return ret;
+}
+
+// [End encryption_import_key_commissioning_and_verification]
+
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports)
+{
+ napi_property_descriptor desc[] = {
+ {"isKeyExist", nullptr, IsKeyExist, nullptr, nullptr, nullptr, napi_default, nullptr },
+ {"importWrappedKey", nullptr, NAPI_Global_importWrappedKey, nullptr, nullptr, nullptr, napi_default, nullptr }};
+ napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "entry",
+ .nm_priv = ((void *)0),
+ .reserved = {0},
+};
+
+extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); }
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/types/libentry/index.d.ts b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/types/libentry/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e8fa214af4c18f95f777db9dc895130efeef7322
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/types/libentry/index.d.ts
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2025 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 const importWrappedKey: () => number;
+export const isKeyExist: () => number;
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/types/libentry/oh-package.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/types/libentry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2826cc7d6bd199c1008bb51d898dffa922201e6c
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/types/libentry/oh-package.json5
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "libentry.so",
+ "types": "./index.d.ts",
+ "version": "1.0.0",
+ "description": "Please describe the basic information."
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/entryability/EntryAbility.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..edc2839f203ba057c186e19b0cbbbf80c8faa8b3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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 { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/pages/ImportEncryptedKey.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/pages/ImportEncryptedKey.ets
new file mode 100644
index 0000000000000000000000000000000000000000..acac78f6500c357569cf9487f19ae54536ccb31f
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/pages/ImportEncryptedKey.ets
@@ -0,0 +1,661 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start encrypt_the_import_key]
+
+import { huks } from '@kit.UniversalKeystoreKit';
+
+let IV = '0000000000000000';
+let AAD = 'abababababababab';
+let NONCE = 'hahahahahaha';
+let TAG_SIZE = 16;
+let FILED_LENGTH = 4;
+let importedAes192PlainKey = 'The aes192 key to import';
+let callerAes256Kek = 'The is kek to encrypt aes192 key';
+let callerKeyAlias = 'test_caller_key_ecdh_aes192';
+let callerKekAliasAes256 = 'test_caller_kek_ecdh_aes256';
+let callerAgreeKeyAliasAes256 = 'test_caller_agree_key_ecdh_aes256';
+let importedKeyAliasAes192 = 'test_import_key_ecdh_aes192';
+let huksPubKey: Uint8Array;
+let callerSelfPublicKey: Uint8Array;
+let outSharedKey: Uint8Array;
+let outPlainKeyEncData: Uint8Array;
+let outKekEncData: Uint8Array;
+let outKekEncTag: Uint8Array;
+let outAgreeKeyEncTag: Uint8Array;
+let mask = [0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000];
+
+function subUint8ArrayOf(arrayBuf: Uint8Array, start: number, end: number) {
+ let arr: number[] = [];
+ for (let i = start; i < end && i < arrayBuf.length; ++i) {
+ arr.push(arrayBuf[i]);
+ }
+ return new Uint8Array(arr);
+}
+
+function stringToUint8Array(str: string) {
+ let arr: number[] = [];
+ for (let i = 0, j = str.length; i < j; ++i) {
+ arr.push(str.charCodeAt(i));
+ }
+ return new Uint8Array(arr);
+}
+
+function assignLength(length: number, arrayBuf: Uint8Array, startIndex: number) {
+ let index = startIndex;
+ for (let i = 0; i < 4; i++) {
+ arrayBuf[index++] = (length & mask[i]) >> (i * 8);
+ }
+ return 4;
+}
+
+function assignData(data: Uint8Array, arrayBuf: Uint8Array, startIndex: number) {
+ let index = startIndex;
+ for (let i = 0; i < data.length; i++) {
+ arrayBuf[index++] = data[i];
+ }
+ return data.length;
+}
+
+let genWrappingKeyParams: huks.HuksOptions = {
+ properties: [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_ECC
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_NONE
+ }
+ ]
+}
+
+let genCallerEcdhParams: huks.HuksOptions = {
+ properties: [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_ECC
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256
+ }
+ ]
+}
+
+let importParamsCallerKek: huks.HuksOptions = {
+ properties: [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_AES
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_NONE
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_GCM
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_NONE
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_IV,
+ value: stringToUint8Array(IV)
+ }
+ ],
+ inData: stringToUint8Array(callerAes256Kek)
+}
+
+let importParamsAgreeKey: huks.HuksOptions = {
+ properties: [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_AES
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_NONE
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_GCM
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_NONE
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_IV,
+ value: stringToUint8Array(IV)
+ }
+ ],
+}
+
+let callerAgreeParams: huks.HuksOptions = {
+ properties: [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_ECDH
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256
+ }
+ ]
+}
+
+let encryptKeyCommonParams: huks.HuksOptions = {
+ properties: [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_AES
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_NONE
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_GCM
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_NONCE,
+ value: stringToUint8Array(NONCE)
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_ASSOCIATED_DATA,
+ value: stringToUint8Array(AAD)
+ }
+ ],
+}
+
+let importWrappedAes192Params: huks.HuksOptions = {
+ properties: [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_AES
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT |
+ huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_192
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_NONE
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_CBC
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_NONE
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_UNWRAP_ALGORITHM_SUITE,
+ value: huks.HuksUnwrapSuite.HUKS_UNWRAP_SUITE_ECDH_AES_256_GCM_NOPADDING
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_IV,
+ value: stringToUint8Array(IV)
+ }
+ ]
+}
+
+async function publicGenerateItemFunc(keyAlias: string, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise generateKeyItem`);
+ try {
+ await huks.generateKeyItem(keyAlias, huksOptions)
+ .then(data => {
+ console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((err: Error) => {
+ console.error(`promise: generateKeyItem failed, ${JSON.stringify(err)}`);
+ throw (err as Error);
+ })
+ } catch (err) {
+ console.error(`promise: generateKeyItem invalid, ${JSON.stringify(err)}`);
+ throw (err as Error);
+ }
+}
+
+async function publicImportKeyItemFunc(keyAlias: string, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise importKeyItem`);
+ try {
+ await huks.importKeyItem(keyAlias, huksOptions)
+ .then(data => {
+ console.info(`promise: importKeyItem success, data = ${JSON.stringify(data)}`);
+ }).catch((err: Error) => {
+ console.error(`promise: importKeyItem failed, ${JSON.stringify(err)}`);
+ throw (err as Error);
+ })
+ } catch (err) {
+ console.error(`promise: importKeyItem input arg invalid, ${JSON.stringify(err)}`);
+ throw (err as Error);
+ }
+}
+
+async function publicDeleteKeyItemFunc(keyAlias: string, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise deleteKeyItem`);
+ try {
+ await huks.deleteKeyItem(keyAlias, huksOptions)
+ .then(data => {
+ console.info(`promise: deleteKeyItem key success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((err: Error) => {
+ console.error(`promise: deleteKeyItem failed, ${JSON.stringify(err)}`);
+ throw (err as Error);
+ })
+ } catch (err) {
+ console.error(`promise: deleteKeyItem input arg invalid, ${JSON.stringify(err)}`);
+ throw (err as Error);
+ }
+}
+
+function importWrappedKeyItem(keyAlias: string, wrappingKeyAlias: string, huksOptions: huks.HuksOptions) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.importWrappedKeyItem(keyAlias, wrappingKeyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicImportWrappedKeyFunc(keyAlias: string, wrappingKeyAlias: string, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise importWrappedKeyItem`);
+ for (let i = 0; i < huksOptions.inData!.length; i++) {
+ console.error(`${i}: ${huksOptions.inData![i]}`);
+ }
+ try {
+ await importWrappedKeyItem(keyAlias, wrappingKeyAlias, huksOptions)
+ .then((data) => {
+ console.info(`promise: importWrappedKeyItem success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ console.error(`promise: importWrappedKeyItem failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ });
+ } catch (error) {
+ console.error(`promise: importWrappedKeyItem input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+}
+
+async function publicImportWrappedKeyPromise(keyAlias: string, wrappingKeyAlias: string,
+ huksOptions: huks.HuksOptions) {
+ console.info(`enter promise importWrappedKeyItem`);
+ try {
+ await huks.importWrappedKeyItem(keyAlias, wrappingKeyAlias, huksOptions)
+ .then((data) => {
+ console.info(`promise: importWrappedKeyItem success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ console.error(`promise: importWrappedKeyItem failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ });
+ } catch (error) {
+ console.error(`promise: importWrappedKeyItem input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+}
+
+async function publicInitFunc(srcKeyAlias: string, huksOptions: huks.HuksOptions) {
+ let handle: number = 0;
+ console.info(`enter promise doInit`);
+ try {
+ await huks.initSession(srcKeyAlias, huksOptions)
+ .then((data) => {
+ console.info(`promise: doInit success, data = ${JSON.stringify(data)}`);
+ handle = data.handle;
+ })
+ .catch((error: Error) => {
+ console.error(`promise: doInit key failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ });
+ } catch (error) {
+ console.error(`promise: doInit input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+ return handle;
+}
+
+async function publicUpdateSessionFunction(handle: number, huksOptions: huks.HuksOptions) {
+ const maxUpdateSize = 64;
+ const inData = huksOptions.inData!;
+ const lastInDataPosition = inData.length - 1;
+ let inDataSegSize = maxUpdateSize;
+ let inDataSegPosition = 0;
+ let isFinished = false;
+ let outData: number[] = [];
+
+ while (inDataSegPosition <= lastInDataPosition) {
+ if (inDataSegPosition + maxUpdateSize > lastInDataPosition) {
+ isFinished = true;
+ inDataSegSize = lastInDataPosition - inDataSegPosition + 1;
+ console.info(`enter promise doUpdate`);
+ break;
+ }
+ huksOptions.inData = new Uint8Array(
+ Array.from(inData).slice(inDataSegPosition, inDataSegPosition + inDataSegSize)
+ );
+ console.info(`enter promise doUpdate`);
+ try {
+ await huks.updateSession(handle, huksOptions)
+ .then((data) => {
+ console.info(`promise: doUpdate success, data = ${JSON.stringify(data)}`);
+ outData = outData.concat(Array.from(data.outData!));
+ })
+ .catch((error: Error) => {
+ console.error(`promise: doUpdate failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ });
+ } catch (error) {
+ console.error(`promise: doUpdate input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+ if ((!isFinished) && (inDataSegPosition + maxUpdateSize > lastInDataPosition)) {
+ console.error(`update size invalid isFinished = ${isFinished}`);
+ console.error(`inDataSegPosition = ${inDataSegPosition}`);
+ console.error(`lastInDataPosition = ${lastInDataPosition}`);
+ return;
+ }
+ inDataSegPosition += maxUpdateSize;
+ }
+ return outData;
+}
+
+async function publicFinishSession(handle: number, huksOptions: huks.HuksOptions, inData: number[]) {
+ let outData: number[] = [];
+ console.info(`enter promise doFinish`);
+ try {
+ await huks.finishSession(handle, huksOptions)
+ .then((data) => {
+ console.info(`promise: doFinish success, data = ${JSON.stringify(data)}`);
+ outData = inData.concat(Array.from(data.outData!));
+ })
+ .catch((error: Error) => {
+ console.error(`promise: doFinish key failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ });
+ } catch (error) {
+ console.error(`promise: doFinish input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+ return new Uint8Array(outData);
+}
+
+async function cipherFunction(keyAlias: string, huksOptions: huks.HuksOptions) {
+ let handle = await publicInitFunc(keyAlias, huksOptions);
+ let tmpData = await publicUpdateSessionFunction(handle, huksOptions);
+ let outData = await publicFinishSession(handle, huksOptions, tmpData!);
+ return outData;
+}
+
+async function agreeFunction(keyAlias: string, huksOptions: huks.HuksOptions, huksPublicKey: Uint8Array) {
+ let handle = await publicInitFunc(keyAlias, huksOptions);
+ let outSharedKey: Uint8Array = new Uint8Array;
+ huksOptions.inData = huksPublicKey;
+ console.info(`enter promise doUpdate`);
+ try {
+ await huks.updateSession(handle, huksOptions)
+ .then((data) => {
+ console.error(`promise: doUpdate success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ console.error(`promise: doUpdate failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ });
+ } catch (error) {
+ console.error(`promise: doUpdate input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+ console.info(`enter promise doInit`);
+ try {
+ await huks.finishSession(handle, huksOptions)
+ .then((data) => {
+ console.info(`promise: doInit success, data = ${JSON.stringify(data)}`);
+ outSharedKey = data.outData as Uint8Array;
+ })
+ .catch((error: Error) => {
+ console.error(`promise: doInit key failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ });
+ } catch (error) {
+ console.error(`promise: doInit input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+ return outSharedKey;
+}
+
+async function importKekAndAgreeSharedSecret(callerKekAlias: string, importKekParams: huks.HuksOptions,
+ callerKeyAlias: string, huksPublicKey: Uint8Array, agreeParams: huks.HuksOptions) {
+ await publicImportKeyItemFunc(callerKekAlias, importKekParams);
+ outSharedKey = await agreeFunction(callerKeyAlias, agreeParams, huksPublicKey);
+ importParamsAgreeKey.inData = outSharedKey;
+ await publicImportKeyItemFunc(callerAgreeKeyAliasAes256, importParamsAgreeKey);
+}
+
+async function generateAndExportPublicKey(keyAlias: string, huksOptions: huks.HuksOptions, caller: Boolean) {
+ await publicGenerateItemFunc(keyAlias, huksOptions);
+ try {
+ await huks.exportKeyItem(keyAlias, huksOptions)
+ .then((data) => {
+ console.info(`promise: exportKeyItem success, data = ${JSON.stringify(data)}`);
+ if (caller) {
+ callerSelfPublicKey = data.outData as Uint8Array;
+ } else {
+ huksPubKey = data.outData as Uint8Array;
+ }
+ })
+ .catch((error: Error) => {
+ console.error(`promise: exportKeyItem failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ });
+ } catch (error) {
+ console.error(`promise: generate pubKey failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+}
+
+async function encryptImportedPlainKeyAndKek(keyAlias: string) {
+ encryptKeyCommonParams.inData = stringToUint8Array(keyAlias)
+ let plainKeyEncData = await cipherFunction(callerKekAliasAes256, encryptKeyCommonParams);
+ outKekEncTag = subUint8ArrayOf(plainKeyEncData, plainKeyEncData.length - TAG_SIZE, plainKeyEncData.length)
+ outPlainKeyEncData = subUint8ArrayOf(plainKeyEncData, 0, plainKeyEncData.length - TAG_SIZE)
+ encryptKeyCommonParams.inData = stringToUint8Array(callerAes256Kek)
+ let kekEncData = await cipherFunction(callerAgreeKeyAliasAes256, encryptKeyCommonParams)
+ outAgreeKeyEncTag = subUint8ArrayOf(kekEncData, kekEncData.length - TAG_SIZE, kekEncData.length)
+ outKekEncData = subUint8ArrayOf(kekEncData, 0, kekEncData.length - TAG_SIZE)
+}
+
+async function buildWrappedDataAndImportWrappedKey(plainKey: string) {
+ let plainKeySizeBuff = new Uint8Array(4);
+ assignLength(plainKey.length, plainKeySizeBuff, 0);
+ let wrappedData = new Uint8Array(
+ FILED_LENGTH + huksPubKey.length +
+ FILED_LENGTH + AAD.length +
+ FILED_LENGTH + NONCE.length +
+ FILED_LENGTH + TAG_SIZE +
+ FILED_LENGTH + outKekEncData.length +
+ FILED_LENGTH + AAD.length +
+ FILED_LENGTH + NONCE.length +
+ FILED_LENGTH + TAG_SIZE +
+ FILED_LENGTH + plainKeySizeBuff.length +
+ FILED_LENGTH + outPlainKeyEncData.length
+ );
+ let index = 0;
+ let aadUint8Array = stringToUint8Array(AAD);
+ let nonceArray = stringToUint8Array(NONCE);
+ index += assignLength(callerSelfPublicKey.length, wrappedData, index); // 4
+ index += assignData(callerSelfPublicKey, wrappedData, index); // 91
+ index += assignLength(aadUint8Array.length, wrappedData, index); // 4
+ index += assignData(aadUint8Array, wrappedData, index); // 16
+ index += assignLength(nonceArray.length, wrappedData, index); // 4
+ index += assignData(nonceArray, wrappedData, index); // 12
+ index += assignLength(outAgreeKeyEncTag.length, wrappedData, index); // 4
+ index += assignData(outAgreeKeyEncTag, wrappedData, index); // 16
+ index += assignLength(outKekEncData.length, wrappedData, index); // 4
+ index += assignData(outKekEncData, wrappedData, index); // 32
+ index += assignLength(aadUint8Array.length, wrappedData, index); // 4
+ index += assignData(aadUint8Array, wrappedData, index); // 16
+ index += assignLength(nonceArray.length, wrappedData, index); // 4
+ index += assignData(nonceArray, wrappedData, index); // 12
+ index += assignLength(outKekEncTag.length, wrappedData, index); // 4
+ index += assignData(outKekEncTag, wrappedData, index); // 16
+ index += assignLength(plainKeySizeBuff.length, wrappedData, index); // 4
+ index += assignData(plainKeySizeBuff, wrappedData, index); // 4
+ index += assignLength(outPlainKeyEncData.length, wrappedData, index); // 4
+ index += assignData(outPlainKeyEncData, wrappedData, index); // 24
+ return wrappedData;
+}
+
+/* 模拟加密导入密钥场景,设备A为远端设备(导入设备),设备B为本端设备(被导入设备) */
+async function ImportWrappedKey() {
+ /**
+ * 1.设备A将待导入密钥转换成HUKS密钥材料格式To_Import_Key(仅针对非对称密钥,若待导入密钥是对称密钥则可省略此步骤),
+ * 本示例使用importedAes256PlainKey(对称密钥)作为模拟
+ */
+
+ /* 2.设备B生成一个加密导入用途的、用于协商的非对称密钥对Wrapping_Key(公钥Wrapping_Pk,私钥Wrapping_Sk),
+ * 其密钥用途设置为unwrap,导出Wrapping_Key公钥Wrapping_Pk存放在变量huksPubKey中
+ */
+ const srcKeyAliasWrap = 'HUKS_Basic_Capability_Import_0200';
+ await generateAndExportPublicKey(srcKeyAliasWrap, genWrappingKeyParams, false);
+
+ /* 3.设备A使用和设备B同样的算法,生成一个加密导入用途的、用于协商的非对称密钥对Caller_Key(公钥Caller_Pk,私钥Caller_Sk),
+ * 导出Caller_Key公钥Caller_Pk存放在变量callerSelfPublicKey中
+ */
+ await generateAndExportPublicKey(callerKeyAlias, genCallerEcdhParams, true);
+
+ /**
+ * 4.设备A生成一个对称密钥Caller_Kek,该密钥后续将用于加密To_Import_Key
+ * 5.设备A基于Caller_Key的私钥Caller_Sk和Wrapping_Key的公钥Wrapping_Pk,协商出Shared_Key
+ */
+ await importKekAndAgreeSharedSecret(callerKekAliasAes256, importParamsCallerKek, callerKeyAlias, huksPubKey,
+ callerAgreeParams);
+
+ /**
+ * 6.设备A使用Caller_Kek加密To_Import_Key,生成To_Import_Key_Enc
+ * 7.设备A使用Shared_Key加密Caller_Kek,生成Caller_Kek_Enc
+ */
+ await encryptImportedPlainKeyAndKek(importedAes192PlainKey);
+
+ /* 8.设备A封装Caller_Pk、To_Import_Key_Enc、Caller_Kek_Enc等加密导入的材料并发送给设备B。
+ 本示例作为变量存放在callerSelfPublicKey,PlainKeyEncData,KekEncData */
+ let wrappedData = await buildWrappedDataAndImportWrappedKey(importedAes192PlainKey);
+ importWrappedAes192Params.inData = wrappedData;
+
+ /* 9.设备B导入封装的加密密钥材料 */
+ await publicImportWrappedKeyFunc(importedKeyAliasAes192, srcKeyAliasWrap, importWrappedAes192Params);
+
+ /* 10.设备A、B删除用于加密导入的密钥 */
+ await publicDeleteKeyItemFunc(srcKeyAliasWrap, genWrappingKeyParams);
+ await publicDeleteKeyItemFunc(callerKeyAlias, genCallerEcdhParams);
+ await publicDeleteKeyItemFunc(importedKeyAliasAes192, importWrappedAes192Params);
+ await publicDeleteKeyItemFunc(callerKekAliasAes256, callerAgreeParams);
+}
+
+
+// [End encrypt_the_import_key]
+
+// [Start encrypt_the_import_key_to_verify_that_the_key_exists]
+/*
+ * 确定密钥别名和封装密钥属性参数集
+ */
+let keyAlias = 'test_import_key_ecdh_aes192';
+let isKeyExist: Boolean;
+let keyProperties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_AES,
+}];
+let huksOptions: huks.HuksOptions = {
+ properties: keyProperties, // 非空填充
+ inData: new Uint8Array([]) // 非空填充
+}
+
+function Check() {
+ try {
+ huks.isKeyItemExist(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ console.error(`callback: isKeyItemExist failed, ${JSON.stringify(error)}`);
+ } else {
+ if (data !== null && data.valueOf() !== null) {
+ isKeyExist = data.valueOf();
+ console.info(`callback: isKeyItemExist success, isKeyExist = ${isKeyExist}`);
+ }
+ }
+ });
+ } catch (error) {
+ console.error(`callback: isKeyItemExist input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+}
+
+// [End encrypt_the_import_key_to_verify_that_the_key_exists]
+export { ImportWrappedKey, Check };
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/pages/Index.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..5f77599495377ba5976cf2f3bf06188464abf5a4
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2025 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 { Check, ImportWrappedKey } from './ImportEncryptedKey';
+import testNapi from 'libentry.so';
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'ImportEncryptedKey';
+
+ build() {
+ Column({ space: 5 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.call_arkts'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ try {
+ await ImportWrappedKey();
+ Check();
+ this.message = 'Call ArkTS Result: Success';
+ } catch (error) {
+ this.message = 'Call ArkTS Result: Failed';
+ }
+ })
+ Button($r('app.string.call_cpp'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ let ret: number = testNapi.importWrappedKey();
+ this.message = 'Call C/C++ Result: ' + ret.toString();
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/module.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..4144486d1af4c03b0d767cce1cda86fc0d697f91
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/module.json5
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/element/color.json b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/element/string.json b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..106420a64138b0e1ecb3154360eff9e6cf826550
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,24 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "ImportEncryptedKey"
+ },
+ {
+ "name": "call_arkts",
+ "value": "Call ArkTS"
+ },
+ {
+ "name": "call_cpp",
+ "value": "Call C/C++"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/background.png b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/background.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/foreground.png b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/foreground.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/layered_image.json b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/startIcon.png b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/profile/backup_config.json b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/profile/main_pages.json b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,5 @@
+{
+ "src": [
+ "pages/Index"
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/dark/element/color.json b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/dark/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/resources/dark/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#000000"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/Ability.test.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/ImportEncryptedKey.test.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/ImportEncryptedKey.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..3d6850fe65b37cdbd6ec2ca961800b8acb35060e
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/ImportEncryptedKey.test.ets
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, it, expect, beforeAll } from '@ohos/hypium';
+// 导入测试依赖kit
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+let want: Want;
+
+export default function hMACTest() {
+ describe('importEncryptedKeyTest', () => {
+
+ /**
+ * 打开应用
+ */
+ beforeAll(async () => {
+ want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ await driver.delayMs(1000);
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ })
+
+ /**
+ * 点击按钮,ImportEncryptedKey(ArkTS)
+ */
+ it('testImportEncryptedKey001', 0, async () => {
+ console.info('uitest: testImportEncryptedKey001 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('Call ArkTS'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('Call ArkTS Result: Success'));
+ console.info('uitest: testImportEncryptedKey001 end');
+ })
+
+ /**
+ * 点击按钮,ImportEncryptedKey(C/C++)
+ */
+ it('testImportEncryptedKey002', 0, async () => {
+ console.info('uitest: testImportEncryptedKey002 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('Call C/C++'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('Call C/C++ Result: 0'));
+ console.info('uitest: testImportEncryptedKey002 end');
+ await driver.pressBack();
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/List.test.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..894688fbdfa33cad33c3da1c1254b5aace0d7640
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 importEncryptedKeyTest from './ImportEncryptedKey.test';
+
+export default function testsuite() {
+ importEncryptedKeyTest();
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/module.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/hvigor/hvigor-config.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..d584c19c247db9a7caee4b606bb931aa9279c637
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/hvigorfile.ts b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/oh-package.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e41bae026aab3b50d0abb42fece08ba43b4a772b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/ohosTest.md b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..6fafce2eb98df20c79c45d496ae985f52e48ddf4
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/ohosTest.md
@@ -0,0 +1,9 @@
+# 密钥删除测试用例归档
+
+## 用例表
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------------- | ------------ | ---- | ---------------- | -------- | -------- |
+| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass |
+| 点击按钮,加密导入密钥(ArkTS) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass |
+| 点击按钮,加密导入密钥(C/C++) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass |
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/screenshots/ImportEncryptedKeyCpp_1.png b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/screenshots/ImportEncryptedKeyCpp_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..bf654c1fc053f18e6e1fa5f271fb802d9f42491c
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/screenshots/ImportEncryptedKeyCpp_1.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/screenshots/ImportEncryptedKeyCpp_2.png b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/screenshots/ImportEncryptedKeyCpp_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..fe05bccea064ef4594bbbb2a759ee09b344c92fd
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/screenshots/ImportEncryptedKeyCpp_2.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/screenshots/ImportEncryptedKey_1.png b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/screenshots/ImportEncryptedKey_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..bf654c1fc053f18e6e1fa5f271fb802d9f42491c
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/screenshots/ImportEncryptedKey_1.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/screenshots/ImportEncryptedKey_2.png b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/screenshots/ImportEncryptedKey_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..e60de243a18e4c8bd2876f853b116f858dc0b8b8
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/screenshots/ImportEncryptedKey_2.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/.gitignore b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/AppScope/app.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..1ce720e3541a7c24313527278b4736e7476da920
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.importkeyplaintext",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/AppScope/resources/base/element/string.json b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..2b7782e7d841d5e794f13c5396c487d0ed2663bc
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "ImportKeyPlainText"
+ }
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/AppScope/resources/base/media/app_icon.png b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/AppScope/resources/base/media/app_icon.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/README.md b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..eacd41ad1ccdb2678656696777670aaf1b056619
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/README.md
@@ -0,0 +1,92 @@
+## 加密导入密钥(ArkTS)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://gitee.com/openharmony/docs/blob/OpenHarmony-5.0.1-Release/zh-cn/application-dev/security/UniversalKeystoreKit/huks-import-wrapped-key-arkts.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### ImportEncryptedKey
+
+##### 介绍
+
+1. 本示例主要介绍为保证数据安全性加密导入ECDH密钥对。
+
+##### 效果预览
+
+| 主页 | 删除 |
+| ---------------------------------------------------------- | ---------------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击Call ArkTS按钮调用接口ImportWrappedKey,加密导入密钥对为。
+
+## 加密导入密钥(C/C++)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://gitee.com/openharmony/docs/blob/OpenHarmony-5.0.1-Release/zh-cn/application-dev/security/UniversalKeystoreKit/huks-import-wrapped-key-ndk.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### Call C/C++
+
+##### 介绍
+
+1. 本示例主要介绍为保证数据安全性加密导入ECDH密钥对。
+
+##### 效果预览
+
+| 主页 | 跳转页 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+|
|
|
+
+使用说明
+
+1. 点击Call C/C++按钮调用接口importWrappedKey,加密导入密钥对为。
+
+## 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---Index.ets // 首页
+|---|---|---ImportEncryptedKey.ets
+|---cpp
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---ImportEncryptedKey.test.ets // 自动化测试用例
+```
+
+
+## 相关权限
+
+无。
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey > .git/info/sparse-checkout
+git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/build-profile.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..fb5a1ab654ae6715a0ab69a31900ad26dcf2487f
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/build-profile.json5
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ "buildOption": {
+ "strictMode": {
+ "caseSensitiveCheck": true,
+ "useNormalizedOHMUrl": true
+ }
+ }
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/code-linter.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/.gitignore b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/build-profile.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2d8b081b615348a99aa197f90186f3d8891b7dc1
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/build-profile.json5
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ "externalNativeOptions": {
+ "path": "./src/main/cpp/CMakeLists.txt",
+ "arguments": "",
+ "cppFlags": "",
+ "abiFilters": [
+ "arm64-v8a",
+ "x86_64"
+ ]
+ }
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ },
+ "nativeLib": {
+ "debugSymbol": {
+ "strip": true,
+ "exclude": []
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/hvigorfile.ts b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/oh-package.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..118bdd4fe7699368a010e04c24f5bfc887cf1298
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/oh-package.json5
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {
+ "libentry.so": "file:./src/main/cpp/types/libentry"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/CMakeLists.txt b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..2b331e5591b4f371f30cc01157777be18bbfa531
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,15 @@
+# the minimum version of CMake.
+cmake_minimum_required(VERSION 3.5.0)
+project(ImportKeyPlainText)
+
+set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+if(DEFINED PACKAGE_FIND_FILE)
+ include(${PACKAGE_FIND_FILE})
+endif()
+
+include_directories(${NATIVERENDER_ROOT_PATH}
+ ${NATIVERENDER_ROOT_PATH}/include)
+
+add_library(entry SHARED napi_init.cpp)
+target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so)
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/napi_init.cpp b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/napi_init.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a0a1f1a31848cc1317495ba83c082eeee8ebac63
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/napi_init.cpp
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+// [Start import_keys_in_plaintext]
+/* 以下以明文导入AES密钥为例 */
+#include "huks/native_huks_api.h"
+#include "huks/native_huks_param.h"
+#include "napi/native_api.h"
+#include
+
+#define OH_HUKS_AES_KEY_SIZE_32 32
+
+OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params,
+ uint32_t paramCount)
+{
+ OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_AddParams(*paramSet, params, paramCount);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ ret = OH_Huks_BuildParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ return ret;
+}
+struct OH_Huks_Param g_testImportKeyParam[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256},
+ {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}};
+
+static napi_value ImportKey(napi_env env, napi_callback_info info)
+{
+ const char *alias = "test_import";
+ struct OH_Huks_Blob aliasBlob = {.size = (uint32_t)strlen(alias), .data = (uint8_t *)alias};
+ /* DER格式的公钥,用于后续导入密钥 */
+ uint8_t pubKey[OH_HUKS_AES_KEY_SIZE_32] = {0xfb, 0x8b, 0x9f, 0x12, 0xa0, 0x83, 0x19, 0xbe, 0x6a, 0x6f, 0x63,
+ 0x2a, 0x7c, 0x86, 0xba, 0xca, 0x64, 0x0b, 0x88, 0x96, 0xe2, 0xfa,
+ 0x77, 0xbc, 0x71, 0xe3, 0x0f, 0x0f, 0x9e, 0x3c, 0xe5, 0xf9};
+ struct OH_Huks_Blob publicKey = {OH_HUKS_AES_KEY_SIZE_32, pubKey};
+ struct OH_Huks_ParamSet *testImportKeyParamSet = nullptr;
+ struct OH_Huks_Result ohResult;
+ do {
+ ohResult = InitParamSet(&testImportKeyParamSet, g_testImportKeyParam,
+ sizeof(g_testImportKeyParam) / sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ /* 4. Import Key */
+ char newKey[] = "test_import";
+ struct OH_Huks_Blob newKeyAlias = {.size = (uint32_t)strlen(newKey), .data = (uint8_t *)newKey};
+ ohResult = OH_Huks_ImportKeyItem(&newKeyAlias, testImportKeyParamSet, &publicKey);
+ } while (0);
+ OH_Huks_FreeParamSet(&testImportKeyParamSet);
+ napi_value ret;
+ napi_create_int32(env, ohResult.errorCode, &ret);
+ return ret;
+}
+
+// [End import_keys_in_plaintext]
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports)
+{
+ napi_property_descriptor desc[] = {
+ {"importKey", nullptr, ImportKey, nullptr, nullptr, nullptr, napi_default, nullptr}};
+ napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "entry",
+ .nm_priv = ((void *)0),
+ .reserved = {0},
+};
+
+extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); }
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/types/libentry/index.d.ts b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/types/libentry/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..d04ac97cd20baad9316c66bc199301636c526174
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/types/libentry/index.d.ts
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2025 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 const importKey: () => number;
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/types/libentry/oh-package.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/types/libentry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2826cc7d6bd199c1008bb51d898dffa922201e6c
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/types/libentry/oh-package.json5
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "libentry.so",
+ "types": "./index.d.ts",
+ "version": "1.0.0",
+ "description": "Please describe the basic information."
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/entryability/EntryAbility.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..edc2839f203ba057c186e19b0cbbbf80c8faa8b3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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 { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/AES256.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/AES256.ets
new file mode 100644
index 0000000000000000000000000000000000000000..17f2c358fee7633c4f9665083eeb5bbf2cb01d86
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/AES256.ets
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+// [Start import_keys_in_plaintext_AES256]
+
+/* 以下以导入AES256密钥的Callback操作使用为例 */
+import { huks } from '@kit.UniversalKeystoreKit'
+
+/* 密钥材料 */
+let plainTextSize32 = new Uint8Array([
+ 0xfb, 0x8b, 0x9f, 0x12, 0xa0, 0x83, 0x19, 0xbe, 0x6a, 0x6f, 0x63, 0x2a, 0x7c, 0x86, 0xba, 0xca,
+ 0x64, 0x0b, 0x88, 0x96, 0xe2, 0xfa, 0x77, 0xbc, 0x71, 0xe3, 0x0f, 0x0f, 0x9e, 0x3c, 0xe5, 0xf9
+]);
+/* 1.确定密钥别名 */
+let keyAlias = 'AES256Alias_sample';
+
+/* 2.封装密钥属性集和密钥材料 */
+let properties: huks.HuksParam[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_AES
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
+ },
+];
+
+let options: huks.HuksOptions = {
+ properties: properties,
+ inData: plainTextSize32
+};
+
+/* 3.明文导入密钥 */
+function importAES256() {
+ try {
+ huks.importKeyItem(keyAlias, options, (error, data) => {
+ if (error) {
+ console.error(`callback: importKeyItem failed` + JSON.stringify(error));
+ } else {
+ console.info(`callback: importKeyItem success`);
+ }
+ });
+ } catch (error) {
+ console.error(`callback: importKeyItem input arg invalid` + JSON.stringify(error));
+ throw (error as Error);
+ }
+}
+
+// [End import_keys_in_plaintext_AES256]
+
+let isKeyExist = false;
+
+let keyProperties: huks.HuksParam[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_AES
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
+ },
+];
+
+let huksOptions: huks.HuksOptions = {
+ properties: keyProperties, // 非空填充
+ inData: new Uint8Array([]) // 非空填充
+}
+
+function check() {
+ try {
+ huks.isKeyItemExist(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ console.error(`callback: isKeyItemExist failed, ` + JSON.stringify(error));
+ } else {
+ if (data !== null && data.valueOf() !== null) {
+ isKeyExist = data.valueOf();
+ console.info(`callback: isKeyItemExist success, isKeyExist = ${isKeyExist}`);
+ }
+ }
+ });
+ } catch (error) {
+ console.error(`callback: isKeyItemExist input arg invalid, ` + JSON.stringify(error));
+ throw (error as Error);
+ }
+}
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'AES256';
+
+ build() {
+ Column({ space: 5 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.call_aes_256'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ try {
+ importAES256();
+ check();
+ this.message = 'AES256 Result: Success';
+ }catch{
+ this.message = 'AES256 Result: Failed';
+ }
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/Index.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..5e93a55d6f80b59c79a039458e3723b8421a53b8
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2025 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 { router } from '@kit.ArkUI';
+import testNapi from 'libentry.so';
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'ImportKeyPlainText';
+
+ goToSample(url: string): void {
+ router.pushUrl({
+ url: url,
+ }, router.RouterMode.Single, (err) => {
+ if (err) {
+ console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
+ return;
+ }
+ console.info('pushUrl success');
+ })
+ }
+
+ build() {
+ Column({ space: 5 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.aes_256'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/AES256');
+ })
+ Button($r('app.string.rsa_2048'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/RSA2048');
+ })
+ Button($r('app.string.x25519'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/X25519');
+ })
+ Button($r('app.string.call_cpp_import_key'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ let ret: number = testNapi.importKey();
+ this.message = 'Call C/C++ Result: ' + ret.toString();
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/RSA2048.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/RSA2048.ets
new file mode 100644
index 0000000000000000000000000000000000000000..86b978bef77c04981b27d938b78abf70e8bd4288
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/RSA2048.ets
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+// [Start import_keys_in_plaintext_RSA2048]
+/* 以下以导入RSA2048密钥的Callback操作使用为例 */
+import { huks } from '@kit.UniversalKeystoreKit'
+
+let rsa2048KeyPairMaterial = new Uint8Array([
+ 0x01, 0x00, 0x00, 0x00, // 密钥算法(小端表示)huks.HuksKeyAlg.HUKS_ALG_RSA = 1
+ 0x00, 0x08, 0x00, 0x00, // 密钥大小(比特):2048
+ 0x00, 0x01, 0x00, 0x00, // 模数n长度(字节):256
+ 0x03, 0x00, 0x00, 0x00, // 公钥指数e长度(字节):3
+ 0x00, 0x01, 0x00, 0x00, // 私钥指数d长度(字节):256
+ // 模数n
+ 0xc5, 0x35, 0x62, 0x48, 0xc4, 0x92, 0x87, 0x73, 0x0d, 0x42, 0x96, 0xfc, 0x7b, 0x11, 0x05, 0x06,
+ 0x0f, 0x8d, 0x66, 0xc1, 0x0e, 0xad, 0x37, 0x44, 0x92, 0x95, 0x2f, 0x6a, 0x55, 0xba, 0xec, 0x1d,
+ 0x54, 0x62, 0x0a, 0x4b, 0xd3, 0xc7, 0x05, 0xe4, 0x07, 0x40, 0xd9, 0xb7, 0xc2, 0x12, 0xcb, 0x9a,
+ 0x90, 0xad, 0xe3, 0x24, 0xe8, 0x5e, 0xa6, 0xf8, 0xd0, 0x6e, 0xbc, 0xd1, 0x69, 0x7f, 0x6b, 0xe4,
+ 0x2b, 0x4e, 0x1a, 0x65, 0xbb, 0x73, 0x88, 0x6b, 0x7c, 0xaf, 0x7e, 0xd0, 0x47, 0x26, 0xeb, 0xa5,
+ 0xbe, 0xd6, 0xe8, 0xee, 0x9c, 0xa5, 0x66, 0xa5, 0xc9, 0xd3, 0x25, 0x13, 0xc4, 0x0e, 0x6c, 0xab,
+ 0x50, 0xb6, 0x50, 0xc9, 0xce, 0x8f, 0x0a, 0x0b, 0xc6, 0x28, 0x69, 0xe9, 0x83, 0x69, 0xde, 0x42,
+ 0x56, 0x79, 0x7f, 0xde, 0x86, 0x24, 0xca, 0xfc, 0xaa, 0xc0, 0xf3, 0xf3, 0x7f, 0x92, 0x8e, 0x8a,
+ 0x12, 0x52, 0xfe, 0x50, 0xb1, 0x5e, 0x8c, 0x01, 0xce, 0xfc, 0x7e, 0xf2, 0x4f, 0x5f, 0x03, 0xfe,
+ 0xa7, 0xcd, 0xa1, 0xfc, 0x94, 0x52, 0x00, 0x8b, 0x9b, 0x7f, 0x09, 0xab, 0xa8, 0xa4, 0xf5, 0xb4,
+ 0xa5, 0xaa, 0xfc, 0x72, 0xeb, 0x17, 0x40, 0xa9, 0xee, 0xbe, 0x8f, 0xc2, 0xd1, 0x80, 0xc2, 0x0d,
+ 0x44, 0xa9, 0x59, 0x44, 0x59, 0x81, 0x3b, 0x5d, 0x4a, 0xde, 0xfb, 0xae, 0x24, 0xfc, 0xa3, 0xd9,
+ 0xbc, 0x57, 0x55, 0xc2, 0x26, 0xbc, 0x19, 0xa7, 0x9a, 0xc5, 0x59, 0xa3, 0xee, 0x5a, 0xef, 0x41,
+ 0x80, 0x7d, 0xf8, 0x5e, 0xc1, 0x1d, 0x32, 0x38, 0x41, 0x5b, 0xb6, 0x92, 0xb8, 0xb7, 0x03, 0x0d,
+ 0x3e, 0x59, 0x0f, 0x1c, 0xb3, 0xe1, 0x2a, 0x95, 0x1a, 0x3b, 0x50, 0x4f, 0xc4, 0x1d, 0xcf, 0x73,
+ 0x7c, 0x14, 0xca, 0xe3, 0x0b, 0xa7, 0xc7, 0x1a, 0x41, 0x4a, 0xee, 0xbe, 0x1f, 0x43, 0xdd, 0xf9,
+ // 公钥指数e
+ 0x01, 0x00, 0x01,
+ // 私钥指数d
+ 0x88, 0x4b, 0x82, 0xe7, 0xe3, 0xe3, 0x99, 0x75, 0x6c, 0x9e, 0xaf, 0x17, 0x44, 0x3e, 0xd9, 0x07,
+ 0xfd, 0x4b, 0xae, 0xce, 0x92, 0xc4, 0x28, 0x44, 0x5e, 0x42, 0x79, 0x08, 0xb6, 0xc3, 0x7f, 0x58,
+ 0x2d, 0xef, 0xac, 0x4a, 0x07, 0xcd, 0xaf, 0x46, 0x8f, 0xb4, 0xc4, 0x43, 0xf9, 0xff, 0x5f, 0x74,
+ 0x2d, 0xb5, 0xe0, 0x1c, 0xab, 0xf4, 0x6e, 0xd5, 0xdb, 0xc8, 0x0c, 0xfb, 0x76, 0x3c, 0x38, 0x66,
+ 0xf3, 0x7f, 0x01, 0x43, 0x7a, 0x30, 0x39, 0x02, 0x80, 0xa4, 0x11, 0xb3, 0x04, 0xd9, 0xe3, 0x57,
+ 0x23, 0xf4, 0x07, 0xfc, 0x91, 0x8a, 0xc6, 0xcc, 0xa2, 0x16, 0x29, 0xb3, 0xe5, 0x76, 0x4a, 0xa8,
+ 0x84, 0x19, 0xdc, 0xef, 0xfc, 0xb0, 0x63, 0x33, 0x0b, 0xfa, 0xf6, 0x68, 0x0b, 0x08, 0xea, 0x31,
+ 0x52, 0xee, 0x99, 0xef, 0x43, 0x2a, 0xbe, 0x97, 0xad, 0xb3, 0xb9, 0x66, 0x7a, 0xae, 0xe1, 0x8f,
+ 0x57, 0x86, 0xe5, 0xfe, 0x14, 0x3c, 0x81, 0xd0, 0x64, 0xf8, 0x86, 0x1a, 0x0b, 0x40, 0x58, 0xc9,
+ 0x33, 0x49, 0xb8, 0x99, 0xc6, 0x2e, 0x94, 0x70, 0xee, 0x09, 0x88, 0xe1, 0x5c, 0x4e, 0x6c, 0x22,
+ 0x72, 0xa7, 0x2a, 0x21, 0xdd, 0xd7, 0x1d, 0xfc, 0x63, 0x15, 0x0b, 0xde, 0x06, 0x9c, 0xf3, 0x28,
+ 0xf3, 0xac, 0x4a, 0xa8, 0xb5, 0x50, 0xca, 0x9b, 0xcc, 0x0a, 0x04, 0xfe, 0x3f, 0x98, 0x68, 0x81,
+ 0xac, 0x24, 0x53, 0xea, 0x1f, 0x1c, 0x6e, 0x5e, 0xca, 0xe8, 0x31, 0x0d, 0x08, 0x12, 0xf3, 0x26,
+ 0xf8, 0x5e, 0xeb, 0x10, 0x27, 0xae, 0xaa, 0xc3, 0xad, 0x6c, 0xc1, 0x89, 0xdb, 0x7d, 0x5a, 0x12,
+ 0x55, 0xad, 0x11, 0x19, 0xa1, 0xa9, 0x8f, 0x0b, 0x6d, 0x78, 0x8d, 0x1c, 0xdf, 0xe5, 0x63, 0x82,
+ 0x0b, 0x7d, 0x23, 0x04, 0xb4, 0x75, 0x8c, 0xed, 0x77, 0xfc, 0x1a, 0x85, 0x29, 0x11, 0xe0, 0x61,
+]);
+
+/* 1.确定密钥别名 */
+let keyAlias = 'RSA_sample';
+/* 2.封装密钥属性集和密钥材料 */
+let properties: huks.HuksParam[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_RSA
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048
+ },
+ {
+ // 此 tag表示密钥导入后的用途,导入后将不可更改
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
+ },
+ {
+ // 此 tag表示需导入的密钥类型
+ tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE,
+ // 此 value表示导入密钥对,若改为HUKS_KEY_TYPE_PUBLIC_KEY时表示仅导入公钥
+ value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR
+ },
+];
+
+let options: huks.HuksOptions = {
+ properties: properties,
+ inData: rsa2048KeyPairMaterial
+};
+
+/* 3.明文导入密钥 */
+function importRSA2048() {
+ try {
+ huks.importKeyItem(keyAlias, options, (error, data) => {
+ if (error) {
+ console.error(`callback: importKeyItem failed` + error);
+ } else {
+ console.info(`callback: importKeyItem success`);
+ }
+ });
+ } catch (error) {
+ console.error(`callback: importKeyItem input arg invalid` + error);
+ throw (error as Error);
+ }
+}
+
+
+
+// [End import_keys_in_plaintext_RSA2048]
+let isKeyExist = false;
+
+let keyProperties: huks.HuksParam[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_RSA
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE,
+ value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR
+ },
+];
+
+let huksOptions: huks.HuksOptions = {
+ properties: keyProperties, // 非空填充
+ inData: new Uint8Array([]) // 非空填充
+}
+
+function check() {
+ try {
+ huks.isKeyItemExist(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ console.error(`callback: isKeyItemExist failed, ` + JSON.stringify(error));
+ } else {
+ if (data !== null && data.valueOf() !== null) {
+ isKeyExist = data.valueOf();
+ console.info(`callback: isKeyItemExist success, isKeyExist = ${isKeyExist}`);
+ }
+ }
+ });
+ } catch (error) {
+ console.error(`callback: isKeyItemExist input arg invalid, ` + JSON.stringify(error));
+ throw (error as Error);
+ }
+}
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'RSA2048';
+
+ build() {
+ Column({ space: 5 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.call_rsa_2048'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ try {
+ importRSA2048();
+ check();
+ this.message = 'RSA2048 Result: Success';
+ }catch{
+ this.message = 'RSA2048 Result: Failed';
+ }
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/X25519.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/X25519.ets
new file mode 100644
index 0000000000000000000000000000000000000000..10a0bdcad8d2c0dc4791b159a60a41772df07e0d
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/X25519.ets
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start import_keys_in_plaintext_X25519]
+/* 以下以导入X25519密钥的Callback操作使用为例 */
+import { huks } from '@kit.UniversalKeystoreKit'
+
+// X25519的公钥数据。X25519 密钥对中的私钥和公钥都是 32 字节(256 位),关于算法原理请自行参考相关密钥学资料。
+let x25519KeyPubMaterial = new Uint8Array([
+ 0x30, 0x2A, 0x30, 0x05, 0x06, 0x03, 0x2B, 0x65, 0x6E, 0x03, 0x21, 0x00, 0xD2, 0x36, 0x9E, 0xCF,
+ 0xF0, 0x61, 0x5B, 0x73, 0xCE, 0x4F, 0xF0, 0x40, 0x2B, 0x89, 0x18, 0x3E, 0x06, 0x33, 0x60, 0xC6
+]);
+
+/* 1.确定密钥别名 */
+let keyAlias = 'X25519_Pub_import_sample';
+/* 2.封装密钥属性集和密钥材料 */
+let properties: huks.HuksParam[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_X25519
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256
+ },
+ {
+ // 此 tag表示密钥导入后的用途,导入后将不可更改
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY
+ },
+ {
+ // 此 tag表示需导入的密钥类型
+ tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE,
+ // 此 value表示导入密钥的公钥,若改为HUKS_KEY_TYPE_KEY_PAIR时表示导入密钥对
+ value: huks.HuksImportKeyType.HUKS_KEY_TYPE_PUBLIC_KEY
+ },
+];
+
+let options: huks.HuksOptions = {
+ properties: properties,
+ inData: x25519KeyPubMaterial
+};
+
+/* 3.明文导入密钥 */
+function importX25519() {
+ try {
+ huks.importKeyItem(keyAlias, options, (error, data) => {
+ if (error) {
+ console.error(`callback: importKeyItem failed` + error);
+ } else {
+ console.info(`callback: importKeyItem success`);
+ }
+ });
+ } catch (error) {
+ console.error(`callback: importKeyItem input arg invalid` + error);
+ throw (error as Error);
+ }
+}
+
+
+// [End import_keys_in_plaintext_X25519]
+
+let isKeyExist = false;
+
+let keyProperties: huks.HuksParam[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_X25519
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE,
+ value: huks.HuksImportKeyType.HUKS_KEY_TYPE_PUBLIC_KEY
+ },
+]
+
+let huksOptions: huks.HuksOptions = {
+ properties: keyProperties, // 非空填充
+ inData: new Uint8Array([]) // 非空填充
+}
+
+function check() {
+ try {
+ huks.isKeyItemExist(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ console.error(`callback: isKeyItemExist failed, ` + JSON.stringify(error));
+ } else {
+ if (data !== null && data.valueOf() !== null) {
+ isKeyExist = data.valueOf();
+ console.info(`callback: isKeyItemExist success, isKeyExist = ${isKeyExist}`);
+ }
+ }
+ });
+ } catch (error) {
+ console.error(`callback: isKeyItemExist input arg invalid, ` + JSON.stringify(error));
+ throw (error as Error);
+ }
+}
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'X25519';
+
+ build() {
+ Column({ space: 5 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.call_x25519'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ try {
+ importX25519();
+ check();
+ this.message = 'X25519 Result: Success';
+ }catch{
+ this.message = 'X25519 Result: Failed';
+ }
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/module.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..4144486d1af4c03b0d767cce1cda86fc0d697f91
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/module.json5
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/element/color.json b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/element/string.json b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..7b058e5c9ac95418c13c343580350c3251163303
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,44 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "ImportKeyPlainText"
+ },
+ {
+ "name": "aes_256",
+ "value": "AES256"
+ },
+ {
+ "name": "rsa_2048",
+ "value": "RSA2048"
+ },
+ {
+ "name": "x25519",
+ "value": "X25519"
+ },
+ {
+ "name": "call_aes_256",
+ "value": "Call AES256"
+ },
+ {
+ "name": "call_rsa_2048",
+ "value": "Call RSA2048"
+ },
+ {
+ "name": "call_x25519",
+ "value": "Call X25519"
+ },
+ {
+ "name": "call_cpp_import_key",
+ "value": "Call C/C++"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/background.png b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/background.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/foreground.png b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/foreground.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/layered_image.json b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/startIcon.png b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/profile/backup_config.json b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/profile/main_pages.json b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..870c2f448628366c7235197e2bbbd3683680311f
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,8 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/AES256",
+ "pages/RSA2048",
+ "pages/X25519"
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/dark/element/color.json b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/dark/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/resources/dark/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#000000"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/ets/test/Ability.test.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/ets/test/ImportKeyPlainText.test.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/ets/test/ImportKeyPlainText.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..cf0e6f603a5b021444fa1cf362c4dc136c998709
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/ets/test/ImportKeyPlainText.test.ets
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, it, expect, beforeAll } from '@ohos/hypium';
+// 导入测试依赖kit
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+let want: Want;
+
+export default function importKeyPlainTextTest() {
+ describe('importKeyPlainTextTest', () => {
+
+ beforeAll(async () => {
+ want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ await driver.delayMs(1000);
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ })
+
+ it('testImportKeyPlainText001', 0, async () => {
+ console.info('uitest: testImportKeyPlainText001 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('AES256'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('Call AES256'));
+ await button2.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('AES256 Result: Success'));
+ console.info('uitest: testImportKeyPlainText001 end');
+ await driver.pressBack();
+ })
+
+ it('testImportKeyPlainText002', 0, async () => {
+ console.info('uitest: testImportKeyPlainText002 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('RSA2048'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('Call RSA2048'));
+ await button2.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('RSA2048 Result: Success'));
+ console.info('uitest: testImportKeyPlainText002 end');
+ await driver.pressBack();
+ })
+
+ it('testImportKeyPlainText003', 0, async () => {
+ console.info('uitest: testImportKeyPlainText003 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('X25519'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('Call X25519'));
+ await button2.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('X25519 Result: Success'));
+ console.info('uitest: testImportKeyPlainText003 end');
+ await driver.pressBack();
+ })
+
+ it('testImportKeyPlainText004', 0, async () => {
+ console.info('uitest: testImportKeyPlainText004 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('Call C/C++'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('Call C/C++ Result: 0'));
+ console.info('uitest: testImportKeyPlainText004 end');
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/ets/test/List.test.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..8e28a7e277d5fb5ccb7373f8463a0ad13d03f38e
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 importKeyPlainTextTest from './ImportKeyPlainText.test';
+
+export default function testsuite() {
+ importKeyPlainTextTest();
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/module.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/test/List.test.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/test/LocalUnit.test.ets b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/hvigor/hvigor-config.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..d584c19c247db9a7caee4b606bb931aa9279c637
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/hvigorfile.ts b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/oh-package.json5 b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e41bae026aab3b50d0abb42fece08ba43b4a772b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/ohosTest.md b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..ca7830387aab9e5aad236cdeea5bc718fefff97c
--- /dev/null
+++ b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/ohosTest.md
@@ -0,0 +1,11 @@
+# 明文导入密钥测试用例归档
+
+## 用例表
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------------- | ------------ | ---- | ---------------- | -------- | -------- |
+| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass |
+| 点击按钮,明文导入AES256密钥(ArkTS) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass |
+| 点击按钮,明文导入ARSA2048密钥对(ArkTS) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass |
+| 点击按钮,明文导入X25519密钥公钥(ArkTS) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass |
+| 点击按钮,明文导入密钥(C/C++) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass |
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/AES256_1.png b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/AES256_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..282e89ee89255c5d8f2133f102cec0fa9aaf0af9
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/AES256_1.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/AES256_2.png b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/AES256_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..c94a17bebadccb55edf8fe3c93af8bca0b2bed3d
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/AES256_2.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/Cpp_1.png b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/Cpp_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..37c4ff2f782869fca305eaa18bdadf98e4afea59
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/Cpp_1.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/Cpp_2.png b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/Cpp_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..d8cd073ccdfa9c00372d49fca3b796a9641667f1
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/Cpp_2.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/RSA2048_1.png b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/RSA2048_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..4f0687b1167cdfb9ca72ee8794bd49138f257170
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/RSA2048_1.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/RSA2048_2.png b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/RSA2048_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..dfad5e1ef8e1eecbf8795ca5c124353a43d86d1f
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/RSA2048_2.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/X25519_1.png b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/X25519_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..b9dcee267bdda62a17806eab8739e7c96d7a771f
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/X25519_1.png differ
diff --git a/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/X25519_2.png b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/X25519_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..9e1bd879c518b65a62b35e6c3e7d3348ce07ed2c
Binary files /dev/null and b/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/screenshots/X25519_2.png differ
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/.gitignore b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/AppScope/app.json5 b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..f2c7feff9328013dd929155aa1c207d15e058341
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.anonymouskeyproof",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/AppScope/resources/base/element/string.json b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..d2ae0e044db93ba46958817a61b732b194a78a48
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "AnonymousKeyProof"
+ }
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/AppScope/resources/base/media/app_icon.png b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/AppScope/resources/base/media/app_icon.png differ
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/README.md b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..49d78e3c1d92cd0d4de9e0ba2beaad064783534e
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/README.md
@@ -0,0 +1,92 @@
+## 匿名密钥证明(ArkTS)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-key-anon-attestation-arkts.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### AnonymousKeyProof
+
+##### 介绍
+
+1. 本示例主要介绍证明密钥,证明特定密钥的有效性和合法性。
+
+##### 效果预览
+
+| 主页 | 删除 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+|
|
|
+
+使用说明
+
+1. 点击Call AnonAttestKeyItem按钮将密钥别名与参数集作为参数传入huks.anonAttestKeyItem方法中,即可证明密钥。
+
+## 匿名密钥证明(C/C++)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-key-anon-attestation-ndk.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### Call C/C++
+
+##### 介绍
+
+1. 本示例主要介绍证明密钥,证明特定密钥的有效性和合法性。
+
+##### 效果预览
+
+| 主页 | 跳转页 |
+| -------------------------------------------------- | -------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击Call C/C++按钮将密钥别名与参数集作为参数传入OH_Huks_AnonAttestKeyItem方法中,即可证明密钥。
+
+## 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---Index.ets // 首页
+|---|---|---AnonymousKeyProof.ets
+|---cpp
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---AnonymousKeyProof.test.ets // 自动化测试用例
+```
+
+
+## 相关权限
+
+无。
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof > .git/info/sparse-checkout
+git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/build-profile.json5 b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..fb5a1ab654ae6715a0ab69a31900ad26dcf2487f
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/build-profile.json5
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ "buildOption": {
+ "strictMode": {
+ "caseSensitiveCheck": true,
+ "useNormalizedOHMUrl": true
+ }
+ }
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/code-linter.json5 b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/.gitignore b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/build-profile.json5 b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2d8b081b615348a99aa197f90186f3d8891b7dc1
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/build-profile.json5
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ "externalNativeOptions": {
+ "path": "./src/main/cpp/CMakeLists.txt",
+ "arguments": "",
+ "cppFlags": "",
+ "abiFilters": [
+ "arm64-v8a",
+ "x86_64"
+ ]
+ }
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ },
+ "nativeLib": {
+ "debugSymbol": {
+ "strip": true,
+ "exclude": []
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/hvigorfile.ts b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/oh-package.json5 b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..118bdd4fe7699368a010e04c24f5bfc887cf1298
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/oh-package.json5
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {
+ "libentry.so": "file:./src/main/cpp/types/libentry"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/CMakeLists.txt b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..2120cc1b577198fc8da5aca0191d1fe768c9963c
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,15 @@
+# the minimum version of CMake.
+cmake_minimum_required(VERSION 3.5.0)
+project(AnonymousKeyProof)
+
+set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+if(DEFINED PACKAGE_FIND_FILE)
+ include(${PACKAGE_FIND_FILE})
+endif()
+
+include_directories(${NATIVERENDER_ROOT_PATH}
+ ${NATIVERENDER_ROOT_PATH}/include)
+
+add_library(entry SHARED napi_init.cpp)
+target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so)
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/napi_init.cpp b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/napi_init.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..859f3a2f1ede72ce2696d6b65ea47db81b3ebbf6
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/napi_init.cpp
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start anonymized_key_proof]
+#include "huks/native_huks_api.h"
+#include "huks/native_huks_param.h"
+#include "napi/native_api.h"
+#include
+
+OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params,
+ uint32_t paramCount)
+{
+ OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_AddParams(*paramSet, params, paramCount);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ ret = OH_Huks_BuildParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ return ret;
+}
+
+static uint32_t g_size = 4096;
+static uint32_t CERT_COUNT = 4;
+void FreeCertChain(struct OH_Huks_CertChain *certChain, const uint32_t pos)
+{
+ if (certChain == nullptr || certChain->certs == nullptr) {
+ return;
+ }
+ for (uint32_t j = 0; j < pos; j++) {
+ if (certChain->certs[j].data != nullptr) {
+ free(certChain->certs[j].data);
+ certChain->certs[j].data = nullptr;
+ }
+ }
+ if (certChain->certs != nullptr) {
+ free(certChain->certs);
+ certChain->certs = nullptr;
+ }
+}
+
+int32_t ConstructDataToCertChain(struct OH_Huks_CertChain *certChain)
+{
+ if (certChain == nullptr) {
+ return OH_HUKS_ERR_CODE_ILLEGAL_ARGUMENT;
+ }
+ certChain->certsCount = CERT_COUNT;
+
+ certChain->certs = (struct OH_Huks_Blob *)malloc(sizeof(struct OH_Huks_Blob) * (certChain->certsCount));
+ if (certChain->certs == nullptr) {
+ return OH_HUKS_ERR_CODE_INTERNAL_ERROR;
+ }
+ for (uint32_t i = 0; i < certChain->certsCount; i++) {
+ certChain->certs[i].size = g_size;
+ certChain->certs[i].data = (uint8_t *)malloc(certChain->certs[i].size);
+ if (certChain->certs[i].data == nullptr) {
+ FreeCertChain(certChain, i);
+ return OH_HUKS_ERR_CODE_ILLEGAL_ARGUMENT;
+ }
+ }
+ return 0;
+}
+
+static struct OH_Huks_Param g_genAnonAttestParams[] = {
+ {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_RSA},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_RSA_KEY_SIZE_2048},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_VERIFY},
+ {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA256},
+ {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_PSS},
+ {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_ECB},
+};
+
+#define CHALLENGE_DATA "hi_challenge_data"
+static struct OH_Huks_Blob g_challenge = {sizeof(CHALLENGE_DATA), (uint8_t *)CHALLENGE_DATA};
+static napi_value AnonAttestKey(napi_env env, napi_callback_info info)
+{
+ /* 1.确定密钥别名 */
+ struct OH_Huks_Blob genAlias = {(uint32_t)strlen("test_anon_attest"), (uint8_t *)"test_anon_attest"};
+ static struct OH_Huks_Param g_anonAttestParams[] = {
+ {.tag = OH_HUKS_TAG_ATTESTATION_CHALLENGE, .blob = g_challenge},
+ {.tag = OH_HUKS_TAG_ATTESTATION_ID_ALIAS, .blob = genAlias},
+ };
+ struct OH_Huks_ParamSet *genParamSet = nullptr;
+ struct OH_Huks_ParamSet *anonAttestParamSet = nullptr;
+ OH_Huks_Result ohResult;
+ OH_Huks_Blob certs = {0};
+ OH_Huks_CertChain certChain = {&certs, 0};
+ do {
+ /* 2.初始化密钥参数集 */
+ ohResult =
+ InitParamSet(&genParamSet, g_genAnonAttestParams, sizeof(g_genAnonAttestParams) / sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ ohResult =
+ InitParamSet(&anonAttestParamSet, g_anonAttestParams, sizeof(g_anonAttestParams) / sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ ohResult = OH_Huks_GenerateKeyItem(&genAlias, genParamSet, nullptr);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+
+ (void)ConstructDataToCertChain(&certChain);
+ /* 3.证明密钥 */
+ ohResult = OH_Huks_AnonAttestKeyItem(&genAlias, anonAttestParamSet, &certChain);
+ } while (0);
+ FreeCertChain(&certChain, CERT_COUNT);
+ OH_Huks_FreeParamSet(&genParamSet);
+ OH_Huks_FreeParamSet(&anonAttestParamSet);
+ (void)OH_Huks_DeleteKeyItem(&genAlias, NULL);
+
+ napi_value ret;
+ napi_create_int32(env, ohResult.errorCode, &ret);
+ return ret;
+}
+// [End anonymized_key_proof]
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports)
+{
+ napi_property_descriptor desc[] = {
+ {"anonAttestKey", nullptr, AnonAttestKey, nullptr, nullptr, nullptr, napi_default, nullptr}};
+ napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "entry",
+ .nm_priv = ((void *)0),
+ .reserved = {0},
+};
+
+extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); }
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/types/libentry/index.d.ts b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/types/libentry/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..b9a785abe30b1a88a915c6f5b28e1ca6fd8adb3f
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/types/libentry/index.d.ts
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2025 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 const anonAttestKey: () => number;
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/types/libentry/oh-package.json5 b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/types/libentry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2826cc7d6bd199c1008bb51d898dffa922201e6c
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/types/libentry/oh-package.json5
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "libentry.so",
+ "types": "./index.d.ts",
+ "version": "1.0.0",
+ "description": "Please describe the basic information."
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/entryability/EntryAbility.ets b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..edc2839f203ba057c186e19b0cbbbf80c8faa8b3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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 { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/pages/AnonymousKeyProof.ets b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/pages/AnonymousKeyProof.ets
new file mode 100644
index 0000000000000000000000000000000000000000..750090ef30adf044aa44d9ee41b2e89e3e158cc0
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/pages/AnonymousKeyProof.ets
@@ -0,0 +1,216 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start anonymous_key_proof]
+/*
+ * 以下以anonAttestKey的Promise接口操作验证为例
+ */
+import { huks } from '@kit.UniversalKeystoreKit';
+
+/* 1.确定密钥别名 */
+let keyAliasString = 'key anon attest';
+let aliasString = keyAliasString;
+let aliasUint8 = stringToUint8Array(keyAliasString);
+let securityLevel = stringToUint8Array('sec_level');
+let challenge = stringToUint8Array('challenge_data');
+let versionInfo = stringToUint8Array('version_info');
+let anonAttestCertChain: string[];
+
+class ThrowObject {
+ public isThrow: boolean = false;
+}
+
+/* 封装生成时的密钥参数集 */
+let genKeyProperties: huks.HuksParam[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_RSA
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_PSS
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_GENERATE_TYPE,
+ value: huks.HuksKeyGenerateType.HUKS_KEY_GENERATE_TYPE_DEFAULT
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_ECB
+ }
+]
+let genOptions: huks.HuksOptions = {
+ properties: genKeyProperties
+};
+
+/* 2.封装证明密钥的参数集 */
+let anonAttestKeyProperties: huks.HuksParam[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO,
+ value: securityLevel
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_ATTESTATION_CHALLENGE,
+ value: challenge
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_VERSION_INFO,
+ value: versionInfo
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_ALIAS,
+ value: aliasUint8
+ }
+]
+let huksOptions: huks.HuksOptions = {
+ properties: anonAttestKeyProperties
+};
+
+function stringToUint8Array(str: string) {
+ let arr: number[] = [];
+ for (let i = 0, j = str.length; i < j; ++i) {
+ arr.push(str.charCodeAt(i));
+ }
+ return new Uint8Array(arr);
+}
+
+function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.generateKeyItem(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+/* 3.生成密钥 */
+async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise generateKeyItem`);
+ let throwObject: ThrowObject = { isThrow: false };
+ try {
+ await generateKeyItem(keyAlias, huksOptions, throwObject)
+ .then((data) => {
+ console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`);
+ }
+ });
+ } catch (error) {
+ console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`);
+ }
+}
+
+/* 4.证明密钥 */
+function anonAttestKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.anonAttestKeyItem(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicAnonAttestKey(keyAlias: string, huksOptions: huks.HuksOptions): Promise {
+ console.info(`enter promise anonAttestKeyItem`);
+ let throwObject: ThrowObject = { isThrow: false };
+ try {
+ await anonAttestKeyItem(keyAlias, huksOptions, throwObject)
+ .then((data) => {
+ console.info(`promise: anonAttestKeyItem success, data = ${JSON.stringify(data)}`);
+ if (data !== null && data.certChains !== null) {
+ anonAttestCertChain = data.certChains as string[];
+ }
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: anonAttestKeyItem failed, ${JSON.stringify(error)}`);
+ }
+ });
+ return 'Success';
+ } catch (error) {
+ console.error(`promise: anonAttestKeyItem input arg invalid, ${JSON.stringify(error)}`);
+ return 'Failed';
+ }
+}
+
+async function anonAttestKeyTest(): Promise {
+ await publicGenKeyFunc(aliasString, genOptions);
+ let ret = await publicAnonAttestKey(aliasString, huksOptions);
+ console.info('anon attest certChain data: ' + anonAttestCertChain)
+ return ret;
+}
+// [End anonymous_key_proof]
+@Entry
+@Component
+struct Index {
+ @State message: string = 'AnonymousKeyProof';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.call_anonymous_key_proof'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ let ret = await anonAttestKeyTest();
+ this.message = 'AnonymousKeyProof Result: ' + ret;
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/pages/Index.ets b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..a3075fa4286261e30babfdf7017e4f90cb55257f
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2025 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 { router } from '@kit.ArkUI';
+import testNapi from 'libentry.so';
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'AnonymousKeyProof';
+
+ goToSample(url: string): void {
+ router.pushUrl({
+ url: url,
+ }, router.RouterMode.Single, (err) => {
+ if (err) {
+ console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
+ return;
+ }
+ console.info('pushUrl success');
+ })
+ }
+
+ build() {
+ Column({ space: 5 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.anonymous_key_proof'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/AnonymousKeyProof')
+ })
+ Button($r('app.string.call_cpp_anon_attest_key'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ let ret: number = testNapi.anonAttestKey();
+ this.message = 'Call C/C++ Result: ' + ret.toString();
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/module.json5 b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..4144486d1af4c03b0d767cce1cda86fc0d697f91
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/module.json5
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/element/color.json b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/element/string.json b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..47bca7cd50c3f87f68cacd9b0c2b135a881137bf
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,28 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "AnonymousKeyProof"
+ },
+ {
+ "name": "anonymous_key_proof",
+ "value": "AnonymousKeyProof"
+ },
+ {
+ "name": "call_cpp_anon_attest_key",
+ "value": "Call C/C++"
+ },
+ {
+ "name": "call_anonymous_key_proof",
+ "value": "Call AnonymousKeyProof"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/background.png b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/background.png differ
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/foreground.png b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/foreground.png differ
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/layered_image.json b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/startIcon.png b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/profile/backup_config.json b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/profile/main_pages.json b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..73d563fe9d9b0cde8fb21eccc06a3389dd62d69b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,6 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/AnonymousKeyProof"
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/dark/element/color.json b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/dark/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/resources/dark/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#000000"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/ets/test/Ability.test.ets b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/ets/test/AnonymousKeyProof.test.ets b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/ets/test/AnonymousKeyProof.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..80afe5c5aa80205fd19b0224002e2fd523037d9c
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/ets/test/AnonymousKeyProof.test.ets
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, it, expect, beforeAll } from '@ohos/hypium';
+// 导入测试依赖kit
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+let want: Want;
+
+export default function anonymousKeyProofTest() {
+ describe('anonymousKeyProofTest', () => {
+ /**
+ * 打开应用
+ */
+ beforeAll(async () => {
+ want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ await driver.delayMs(1000);
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ })
+
+ /**
+ * 点击按钮,匿名密钥证明(ArkTS)
+ */
+ it('testAnonymousKeyProof001', 0, async () => {
+ console.info('uitest: testAnonymousKeyProof001 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('AnonymousKeyProof').type('Button'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('Call AnonymousKeyProof'));
+ await button2.click();
+ await driver.delayMs(5000);
+ await driver.assertComponentExist(ON.text('AnonymousKeyProof Result: Success'));
+ console.info('uitest: testAnonymousKeyProof001 end');
+ await driver.pressBack();
+ })
+
+ /**
+ * 点击按钮,匿名密钥证明(C/C++)
+ */
+ it('testAnonymousKeyProof002', 0, async () => {
+ console.info('uitest: testAnonymousKeyProof002 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('Call C/C++'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(3000);
+ await driver.assertComponentExist(ON.text('Call C/C++ Result: 0'));
+ console.info('uitest: testAnonymousKeyProof002 end');
+ await driver.pressBack();
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/ets/test/List.test.ets b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..9718ab120479fc7f8c30fa4a06c4e7f01a911050
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 anonymousKeyProofTest from './AnonymousKeyProof.test';
+
+export default function testsuite() {
+ anonymousKeyProofTest();
+}
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/module.json5 b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/test/List.test.ets b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/test/LocalUnit.test.ets b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/hvigor/hvigor-config.json5 b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..d584c19c247db9a7caee4b606bb931aa9279c637
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/hvigorfile.ts b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/oh-package.json5 b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e41bae026aab3b50d0abb42fece08ba43b4a772b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/ohosTest.md b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..cd3b5f37c2616a6a9eb4b46fa71e534b73b18a3b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/ohosTest.md
@@ -0,0 +1,9 @@
+# 匿名密钥证明测试用例归档
+
+## 用例表
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ----------------------------- | ------------ | ---- | ---------------- | -------- | -------- |
+| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass |
+| 点击按钮,匿名密钥证明(ArkTS) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass |
+| 点击按钮,匿名密钥证明(C/C++) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass |
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/AnonymousKeyProof_1.png b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/AnonymousKeyProof_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..e782125081697ff08d270b31736b742e3f76b3e6
Binary files /dev/null and b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/AnonymousKeyProof_1.png differ
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/AnonymousKeyProof_2.png b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/AnonymousKeyProof_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..38485363de00ef59082a6886a5d366045d48c0f7
Binary files /dev/null and b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/AnonymousKeyProof_2.png differ
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/Cpp_1.png b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/Cpp_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..25341232498a60fce3c9d3fbdbf4341c2efa2c6b
Binary files /dev/null and b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/Cpp_1.png differ
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/Cpp_2.png b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/Cpp_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..d1b0c6af51b40d2fea489f1e63d3a3eca9e73062
Binary files /dev/null and b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/screenshots/Cpp_2.png differ
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/.gitignore b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/AppScope/app.json5 b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..4b8d9e4aee7c41e5e4904b20fa819f8f02e1e2fd
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.nonanonymouskeyproof",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/AppScope/resources/base/element/string.json b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..b9bd49669a451e15a0b153ce1f53d0e7e0bff326
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "NonAnonymousKeyProof"
+ }
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/AppScope/resources/base/media/app_icon.png b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/AppScope/resources/base/media/app_icon.png differ
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/README.md b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..0cb7877c846d4e069af38f897a4073243c2ca391
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/README.md
@@ -0,0 +1,92 @@
+## 非匿名密钥证明(ArkTS)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-key-attestation-arkts.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### NonAnonymousKeyProof
+
+##### 介绍
+
+1. 本示例主要介绍非匿名密钥证明,非匿名密钥证明是一种安全机制,用于验证密钥的合法性和有效性。
+
+##### 效果预览
+
+| 主页 | 删除 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+|
|
|
+
+使用说明
+
+1. 点击Call NonAnonymousKeyProof按钮将密钥别名与参数集作为参数传入huks.attestKeyItem方法中,即可证明密钥。
+
+## 非匿名密钥证明(C/C++)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-key-attestation-ndk.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### Call C/C++
+
+##### 介绍
+
+1. 本示例主要介绍非匿名密钥证明,非匿名密钥证明是一种安全机制,用于验证密钥的合法性和有效性。
+
+##### 效果预览
+
+| 主页 | 跳转页 |
+| -------------------------------------------------- | -------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击Call C/C++按钮将密钥别名与参数集作为参数传入OH_Huks_AttestKeyItem方法中,即可证明密钥。
+
+## 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---Index.ets // 首页
+|---|---|---AnonymousKeyProof.ets
+|---cpp
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---NonAnonymousKeyProof.test.ets // 自动化测试用例
+```
+
+
+## 相关权限
+
+[ohos.permission.ATTEST_KEY](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionattestkey)
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof > .git/info/sparse-checkout
+git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/build-profile.json5 b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..fb5a1ab654ae6715a0ab69a31900ad26dcf2487f
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/build-profile.json5
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ "buildOption": {
+ "strictMode": {
+ "caseSensitiveCheck": true,
+ "useNormalizedOHMUrl": true
+ }
+ }
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/code-linter.json5 b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/.gitignore b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/build-profile.json5 b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2d8b081b615348a99aa197f90186f3d8891b7dc1
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/build-profile.json5
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ "externalNativeOptions": {
+ "path": "./src/main/cpp/CMakeLists.txt",
+ "arguments": "",
+ "cppFlags": "",
+ "abiFilters": [
+ "arm64-v8a",
+ "x86_64"
+ ]
+ }
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ },
+ "nativeLib": {
+ "debugSymbol": {
+ "strip": true,
+ "exclude": []
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/hvigorfile.ts b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/oh-package.json5 b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..118bdd4fe7699368a010e04c24f5bfc887cf1298
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/oh-package.json5
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {
+ "libentry.so": "file:./src/main/cpp/types/libentry"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/CMakeLists.txt b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..5c714d56e55dfdbc4ba958c69f77c6b525f7cf80
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,15 @@
+# the minimum version of CMake.
+cmake_minimum_required(VERSION 3.5.0)
+project(NonanonymousKeyProof)
+
+set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+if(DEFINED PACKAGE_FIND_FILE)
+ include(${PACKAGE_FIND_FILE})
+endif()
+
+include_directories(${NATIVERENDER_ROOT_PATH}
+ ${NATIVERENDER_ROOT_PATH}/include)
+
+add_library(entry SHARED napi_init.cpp)
+target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so)
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/napi_init.cpp b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/napi_init.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ca39403298336db868f4e573734d88eae2702ece
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/napi_init.cpp
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start non_anonymized_key_proof]
+#include "huks/native_huks_api.h"
+#include "huks/native_huks_param.h"
+#include "napi/native_api.h"
+#include
+
+OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params,
+ uint32_t paramCount)
+{
+ OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_AddParams(*paramSet, params, paramCount);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ ret = OH_Huks_BuildParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ return ret;
+}
+
+static uint32_t g_size = 4096;
+static uint32_t CERT_COUNT = 4;
+
+void FreeCertChain(struct OH_Huks_CertChain *certChain, const uint32_t pos)
+{
+ if (certChain == nullptr || certChain->certs == nullptr) {
+ return;
+ }
+ for (uint32_t j = 0; j < pos; j++) {
+ if (certChain->certs[j].data != nullptr) {
+ free(certChain->certs[j].data);
+ certChain->certs[j].data = nullptr;
+ }
+ }
+ if (certChain->certs != nullptr) {
+ free(certChain->certs);
+ certChain->certs = nullptr;
+ }
+}
+
+int32_t ConstructDataToCertChain(struct OH_Huks_CertChain *certChain)
+{
+ if (certChain == nullptr) {
+ return OH_HUKS_ERR_CODE_ILLEGAL_ARGUMENT;
+ }
+ certChain->certsCount = CERT_COUNT;
+
+ certChain->certs = (struct OH_Huks_Blob *)malloc(sizeof(struct OH_Huks_Blob) * (certChain->certsCount));
+ if (certChain->certs == nullptr) {
+ return OH_HUKS_ERR_CODE_INTERNAL_ERROR;
+ }
+ for (uint32_t i = 0; i < certChain->certsCount; i++) {
+ certChain->certs[i].size = g_size;
+ certChain->certs[i].data = (uint8_t *)malloc(certChain->certs[i].size);
+ if (certChain->certs[i].data == nullptr) {
+ FreeCertChain(certChain, i);
+ return OH_HUKS_ERR_CODE_ILLEGAL_ARGUMENT;
+ }
+ }
+ return 0;
+}
+
+static struct OH_Huks_Param g_genAttestParams[] = {
+ {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_RSA},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_RSA_KEY_SIZE_2048},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_VERIFY},
+ {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA256},
+ {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_PSS},
+ {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_ECB},
+};
+
+#define CHALLENGE_DATA "hi_challenge_data"
+static struct OH_Huks_Blob g_challenge = {sizeof(CHALLENGE_DATA), (uint8_t *)CHALLENGE_DATA};
+static napi_value AttestKey(napi_env env, napi_callback_info info)
+{
+ /* 1.确定密钥别名 */
+ struct OH_Huks_Blob genAlias = {(uint32_t)strlen("test_attest"), (uint8_t *)"test_attest"};
+ static struct OH_Huks_Param g_attestParams[] = {
+ {.tag = OH_HUKS_TAG_ATTESTATION_CHALLENGE, .blob = g_challenge},
+ {.tag = OH_HUKS_TAG_ATTESTATION_ID_ALIAS, .blob = genAlias},
+ };
+ struct OH_Huks_ParamSet *genParamSet = nullptr;
+ struct OH_Huks_ParamSet *attestParamSet = nullptr;
+ OH_Huks_Result ohResult;
+ OH_Huks_Blob certs = {0};
+ OH_Huks_CertChain certChain = {&certs, 0};
+ do {
+ /* 2.初始化密钥参数集 */
+ ohResult = InitParamSet(&genParamSet, g_genAttestParams, sizeof(g_genAttestParams) / sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ ohResult = InitParamSet(&attestParamSet, g_attestParams, sizeof(g_attestParams) / sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ ohResult = OH_Huks_GenerateKeyItem(&genAlias, genParamSet, nullptr);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+
+ (void)ConstructDataToCertChain(&certChain);
+ /* 3.证明密钥 */
+ ohResult = OH_Huks_AttestKeyItem(&genAlias, attestParamSet, &certChain);
+ } while (0);
+ FreeCertChain(&certChain, CERT_COUNT);
+ OH_Huks_FreeParamSet(&genParamSet);
+ OH_Huks_FreeParamSet(&attestParamSet);
+ (void)OH_Huks_DeleteKeyItem(&genAlias, NULL);
+
+ napi_value ret;
+ napi_create_int32(env, ohResult.errorCode, &ret);
+ return ret;
+}
+// [End non_anonymized_key_proof]
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports)
+{
+ napi_property_descriptor desc[] = {
+ {"attestKey", nullptr, AttestKey, nullptr, nullptr, nullptr, napi_default, nullptr}};
+ napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "entry",
+ .nm_priv = ((void *)0),
+ .reserved = {0},
+};
+
+extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); }
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/types/libentry/index.d.ts b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/types/libentry/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..2d7892ea30fd0966e7126764f50a77bc4145ac05
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/types/libentry/index.d.ts
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2025 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 const attestKey: () => number;
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/types/libentry/oh-package.json5 b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/types/libentry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2826cc7d6bd199c1008bb51d898dffa922201e6c
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/types/libentry/oh-package.json5
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "libentry.so",
+ "types": "./index.d.ts",
+ "version": "1.0.0",
+ "description": "Please describe the basic information."
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/entryability/EntryAbility.ets b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..edc2839f203ba057c186e19b0cbbbf80c8faa8b3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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 { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/pages/Index.ets b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0a1ef443050424030ff767f2c787a9c8eb8d70e7
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2025 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 { router } from '@kit.ArkUI';
+import testNapi from 'libentry.so';
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'NonanonymousKeyProof';
+
+ goToSample(url: string): void {
+ router.pushUrl({
+ url: url,
+ }, router.RouterMode.Single, (err) => {
+ if (err) {
+ console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
+ return;
+ }
+ console.info('pushUrl success');
+ })
+ }
+
+ build() {
+ Column({ space: 5 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.non_anonymous_key_proof'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/NonAnonymousKeyProof')
+ })
+ Button($r('app.string.call_cpp_attest_key'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ let ret: number = testNapi.attestKey();
+ this.message = 'Call C/C++ Result: ' + ret.toString();
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/pages/NonAnonymousKeyProof.ets b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/pages/NonAnonymousKeyProof.ets
new file mode 100644
index 0000000000000000000000000000000000000000..a856527b62742a92d5742ef3bc78a7e2d66cd3cf
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/pages/NonAnonymousKeyProof.ets
@@ -0,0 +1,216 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start Start non_anonymized_key_proof]
+/*
+ * 以下以attestKey的Promise接口操作验证为例
+ */
+import { huks } from '@kit.UniversalKeystoreKit';
+
+/* 1.确定密钥别名 */
+let keyAliasString = 'key attest';
+let aliasString = keyAliasString;
+let aliasUint8 = stringToUint8Array(keyAliasString);
+let securityLevel = stringToUint8Array('sec_level');
+let challenge = stringToUint8Array('challenge_data');
+let versionInfo = stringToUint8Array('version_info');
+let attestCertChain: string[];
+
+class ThrowObject {
+ public isThrow: boolean = false;
+}
+
+/* 封装生成时的密钥参数集 */
+let genKeyProperties: huks.HuksParam[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_RSA
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_PSS
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_GENERATE_TYPE,
+ value: huks.HuksKeyGenerateType.HUKS_KEY_GENERATE_TYPE_DEFAULT
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_ECB
+ }
+]
+let genOptions: huks.HuksOptions = {
+ properties: genKeyProperties
+};
+
+/* 2.封装证明密钥的参数集 */
+let attestKeyproperties: huks.HuksParam[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO,
+ value: securityLevel
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_ATTESTATION_CHALLENGE,
+ value: challenge
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_VERSION_INFO,
+ value: versionInfo
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_ALIAS,
+ value: aliasUint8
+ }
+]
+let huksOptions: huks.HuksOptions = {
+ properties: attestKeyproperties
+};
+
+function stringToUint8Array(str: string) {
+ let arr: number[] = [];
+ for (let i = 0, j = str.length; i < j; ++i) {
+ arr.push(str.charCodeAt(i));
+ }
+ return new Uint8Array(arr);
+}
+
+function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.generateKeyItem(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+/* 3.生成密钥 */
+async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise generateKeyItem`);
+ let throwObject: ThrowObject = { isThrow: false };
+ try {
+ await generateKeyItem(keyAlias, huksOptions, throwObject)
+ .then((data) => {
+ console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`);
+ }
+ });
+ } catch (error) {
+ console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`);
+ }
+}
+
+/* 4.证明密钥 */
+function attestKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.attestKeyItem(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicAttestKey(keyAlias: string, huksOptions: huks.HuksOptions): Promise {
+ console.info(`enter promise attestKeyItem`);
+ let throwObject: ThrowObject = { isThrow: false };
+ try {
+ await attestKeyItem(keyAlias, huksOptions, throwObject)
+ .then((data) => {
+ console.info(`promise: attestKeyItem success, data = ${JSON.stringify(data)}`);
+ if (data !== null && data.certChains !== null) {
+ attestCertChain = data.certChains as string[];
+ }
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: attestKeyItem failed, ${JSON.stringify(error)}`);
+ }
+ });
+ return 'Success';
+ } catch (error) {
+ console.error(`promise: attestKeyItem input arg invalid, ${JSON.stringify(error)}`);
+ return 'Failed';
+ }
+}
+
+async function attestKeyTest(): Promise {
+ await publicGenKeyFunc(aliasString, genOptions);
+ let ret = await publicAttestKey(aliasString, huksOptions);
+ console.info('attest certChain data: ' + attestCertChain)
+ return ret;
+}
+// [End Start non_anonymized_key_proof]
+@Entry
+@Component
+struct Index {
+ @State message: string = 'NonAnonymousKeyProof';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.call_non_anonymous_key_proof'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ let ret = await attestKeyTest();
+ this.message = 'NonAnonymousKeyProof Result: ' + ret;
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/module.json5 b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..f0261f2ef4abd37a29780940adb2b5641a24aec6
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/module.json5
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.ATTEST_KEY",
+ "reason": "$string:permissionsReason",
+ "usedScene": {
+ "abilities": [
+ "EntryAbility"
+ ],
+ "when": "inuse"
+ }
+ }
+ ]
+ }
+}
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/element/color.json b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/element/string.json b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..b75880bf0f31667ee1134fb0533e03ef6102362f
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,32 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "NonAnonymousKeyProof"
+ },
+ {
+ "name": "permissionsReason",
+ "value": "NonAnonymousKeyProof"
+ },
+ {
+ "name": "non_anonymous_key_proof",
+ "value": "NonAnonymousKeyProof"
+ },
+ {
+ "name": "call_cpp_attest_key",
+ "value": "Call C/C++"
+ },
+ {
+ "name": "call_non_anonymous_key_proof",
+ "value": "Call NonAnonymousKeyProof"
+ }
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/background.png b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/background.png differ
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/foreground.png b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/foreground.png differ
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/layered_image.json b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/startIcon.png b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/profile/backup_config.json b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/profile/main_pages.json b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..094206f10be10211aa4b4329c8c05e0c0e002491
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,6 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/NonAnonymousKeyProof"
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/dark/element/color.json b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/dark/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/resources/dark/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#000000"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/ets/test/Ability.test.ets b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/ets/test/List.test.ets b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..5444d0691bbb86176ae107f41e65540eb602db0c
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 nonAnonymousKeyProofTest from './NonAnonymousKeyProof.test';
+
+export default function testsuite() {
+ nonAnonymousKeyProofTest();
+}
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/ets/test/NonAnonymousKeyProof.test.ets b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/ets/test/NonAnonymousKeyProof.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..56e3d849aa1dbe3412d497e0238b5ae717cccdd6
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/ets/test/NonAnonymousKeyProof.test.ets
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, it, expect, beforeAll } from '@ohos/hypium';
+// 导入测试依赖kit
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+let want: Want;
+
+export default function nonAnonymousKeyProofTest() {
+ describe('nonAnonymousKeyProofTest', () => {
+ /**
+ * 打开应用
+ */
+ beforeAll(async () => {
+ want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ await driver.delayMs(1000);
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ })
+
+ /**
+ * 点击按钮,非匿名密钥证明(ArkTS)
+ */
+ it('testNonAnonymousKeyProof001', 0, async () => {
+ console.info('uitest: testNonAnonymousKeyProof001 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('NonAnonymousKeyProof').type('Button'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('Call NonAnonymousKeyProof'));
+ await button2.click();
+ await driver.delayMs(3000);
+ await driver.assertComponentExist(ON.text('NonAnonymousKeyProof Result: Success'));
+ console.info('uitest: testNonAnonymousKeyProof001 end');
+ await driver.pressBack();
+ })
+
+ /**
+ * 点击按钮,非匿名密钥证明(C/C++)
+ */
+ it('testNonAnonymousKeyProof002', 0, async () => {
+ console.info('uitest: testNonAnonymousKeyProof002 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('Call C/C++'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('Call C/C++ Result: 0'));
+ console.info('uitest: testNonAnonymousKeyProof002 end');
+ await driver.pressBack();
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/module.json5 b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/test/List.test.ets b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/test/LocalUnit.test.ets b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/hvigor/hvigor-config.json5 b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..d584c19c247db9a7caee4b606bb931aa9279c637
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/hvigorfile.ts b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/oh-package.json5 b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e41bae026aab3b50d0abb42fece08ba43b4a772b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/ohosTest.md b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..d83f44fc10950ef624d4dae1d291dfd279d05bf4
--- /dev/null
+++ b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/ohosTest.md
@@ -0,0 +1,9 @@
+# 非匿名密钥证明测试用例归档
+
+## 用例表
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------------------- | ------------ | ---- | ---------------- | -------- | -------- |
+| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass |
+| 点击按钮,非匿名密钥证明(ArkTS) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass |
+| 点击按钮,非匿名密钥证明(C/C++) | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass |
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/Cpp_1.png b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/Cpp_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..136eafeb0e95ebf65e7c78e7f705fb7fd97dc885
Binary files /dev/null and b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/Cpp_1.png differ
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/Cpp_2.png b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/Cpp_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..5e694a72bc6de17f4fdb72de5c00233c34afd80e
Binary files /dev/null and b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/Cpp_2.png differ
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/NonAnonymousKeyProof_1.png b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/NonAnonymousKeyProof_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..2556fd94144b1c790d1a7541dbbb983231ea0769
Binary files /dev/null and b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/NonAnonymousKeyProof_1.png differ
diff --git a/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/NonAnonymousKeyProof_2.png b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/NonAnonymousKeyProof_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..91f50aaf8599f18eb2601aee13294ab44a1da911
Binary files /dev/null and b/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/screenshots/NonAnonymousKeyProof_2.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/.gitignore b/UniversalKeystoreKit/KeyUsage/AccessControl/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/AppScope/app.json5 b/UniversalKeystoreKit/KeyUsage/AccessControl/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..92d4575e4516617e3ca51f5cfe22cfeecfbd5b4a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.accesscontrol",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/AppScope/resources/base/element/string.json b/UniversalKeystoreKit/KeyUsage/AccessControl/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..daebd0deb4b5593c38ed846cc19a01d68750c875
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "AccessControl"
+ }
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/AppScope/resources/base/media/app_icon.png b/UniversalKeystoreKit/KeyUsage/AccessControl/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/AccessControl/AppScope/resources/base/media/app_icon.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/README.md b/UniversalKeystoreKit/KeyUsage/AccessControl/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..53e6737047c7613818c51588c2594a18506d9a80
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/README.md
@@ -0,0 +1,92 @@
+## 用户身份认证访问控制开发指导
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-user-identity-authentication.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### UserIdentityAuthentication
+
+##### 介绍
+
+1. 本示例主要介绍实现用户身份认证访问控制,确保只有经过PIN认证的用户才能对加密数据进行操作。
+
+##### 效果预览
+
+| 主页 | 删除 |
+| ------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击Call按钮依据预先设定的参数(如 SM4 算法、PIN认证等)生成密钥。
+
+## 细粒度用户身份认证访问控制开发指导
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-refined-user-identity-authentication.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### FineGrainedUserIdentityAuthentication
+
+##### 介绍
+
+1. 本示例主要介绍细粒度用户身份认证访问控制,允许设置密钥在加密、解密、签名、验签、密钥协商、密钥派生的单个或多个场景时是否需要进行身份验证。
+
+##### 效果预览
+
+| 主页 | 跳转页 |
+| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ |
+|
|
|
+
+使用说明
+
+1. 点击Call 按钮生成一个基于 SM4 算法、支持PIN认证且在解密时需身份验证的密钥。
+
+## 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---Index.ets // 首页
+|---|---|---FineGrainedUserIdentityAuthentication.ets
+|---|---|---UserIdentityAuthentication.ets
+|---cpp
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---AccessControl.test.ets // 自动化测试用例
+```
+
+## 相关权限
+
+[ohos.permission.ACCESS_BIOMETRIC](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionaccessbiometric)
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo UniversalKeystoreKit/KeyUsage/AccessControl > .git/info/sparse-checkout
+git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git
+git pull origin master
+```
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/build-profile.json5 b/UniversalKeystoreKit/KeyUsage/AccessControl/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..7dff2433b63be15bfc69a62ef9c59f2530684dbe
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/build-profile.json5
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ "buildOption": {
+ "strictMode": {
+ "caseSensitiveCheck": true,
+ "useNormalizedOHMUrl": true
+ }
+ }
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/code-linter.json5 b/UniversalKeystoreKit/KeyUsage/AccessControl/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/.gitignore b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/build-profile.json5 b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/hvigorfile.ts b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/oh-package.json5 b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/entryability/EntryAbility.ets b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..edc2839f203ba057c186e19b0cbbbf80c8faa8b3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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 { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/FineGrainedUserIdentityAuthentication.ets b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/FineGrainedUserIdentityAuthentication.ets
new file mode 100644
index 0000000000000000000000000000000000000000..be90c53357566d016ba8715a97e357d4e3621157
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/FineGrainedUserIdentityAuthentication.ets
@@ -0,0 +1,444 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+// [Start generate_key_specify_fingerprint_access_control_and_auth_purpose]
+import { huks } from '@kit.UniversalKeystoreKit';
+import { userAuth } from '@kit.UserAuthenticationKit';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+
+let cipherInData = 'Hks_SM4_Cipher_Test_101010101010101010110_string'; // 明文数据。
+let IV = '1234567890123456';
+let handle = 0;
+let cipherText: Uint8Array; // 密文数据。
+let finishOutData: Uint8Array; // 解密后的明文数据。
+let authToken: Uint8Array;
+let challenge: Uint8Array;
+let authType = userAuth.UserAuthType.PIN;
+let authTrustLevel = userAuth.AuthTrustLevel.ATL1;
+
+let keyAlias = 'test_sm4_key_alias';
+class ThrowObject {
+ public isThrow: boolean = false;
+}
+
+function stringToUint8Array(str: string) {
+ let arr: number[] = [];
+ for (let i = 0, j = str.length; i < j; ++i) {
+ arr.push(str.charCodeAt(i));
+ }
+ return new Uint8Array(arr);
+}
+
+/*
+ * 确定封装密钥属性参数集
+ */
+let generateProperties: huks.HuksParam[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_SM4,
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT,
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128,
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_CBC,
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_NONE,
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_USER_AUTH_TYPE,
+ value: huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_PIN
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_ACCESS_TYPE,
+ value: huks.HuksAuthAccessType.HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_CHALLENGE_TYPE,
+ value: huks.HuksChallengeType.HUKS_CHALLENGE_TYPE_NORMAL
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
+ }
+];
+
+let generateHuksOptions: huks.HuksOptions = {
+ properties: generateProperties,
+ inData: new Uint8Array([])
+}
+
+/*
+ * 生成密钥
+ */
+async function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.generateKeyItem(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise generateKeyItem`);
+ let throwObject: ThrowObject = { isThrow: true };
+ try {
+ await generateKeyItem(keyAlias, huksOptions, throwObject)
+ .then((data) => {
+ console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: generateKeyItem failed` + JSON.stringify(error));
+ }
+ });
+ } catch (error) {
+ console.error(`promise: generateKeyItem input arg invalid` + JSON.stringify(error));
+ throw (error as Error);
+ }
+}
+
+async function testGenKeyForFingerprintAccessControl() {
+ await publicGenKeyFunc(keyAlias, generateHuksOptions);
+}
+// [End generate_key_specify_fingerprint_access_control_and_auth_purpose]
+class HuksProperties {
+ public tag: huks.HuksTag = huks.HuksTag.HUKS_TAG_ALGORITHM;
+ public value: huks.HuksKeyAlg | huks.HuksKeySize | huks.HuksKeyPurpose | huks.HuksKeyPadding | huks.HuksCipherMode
+ | Uint8Array = huks.HuksKeyAlg.HUKS_ALG_ECC;
+}
+
+/*
+ * 确定封装密钥属性参数集
+ */
+
+/* 集成生成密钥参数集 & 加密参数集 */
+let propertiesEncrypt: HuksProperties[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_SM4,
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT,
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128,
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_NONE,
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_CBC,
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_IV,
+ value: stringToUint8Array(IV),
+ }
+];
+let encryptOptions: huks.HuksOptions = {
+ properties: propertiesEncrypt,
+ inData: new Uint8Array([])
+}
+
+function initSession(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.initSession(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicInitFunc(keyAlias: string, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise doInit`);
+ let throwObject: ThrowObject = { isThrow: true };
+ try {
+ await initSession(keyAlias, huksOptions, throwObject)
+ .then((data) => {
+ console.info(`promise: doInit success, data = ${JSON.stringify(data)}`);
+ handle = data.handle as number;
+ challenge = data.challenge as Uint8Array;
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: doInit failed` + JSON.stringify(error));
+ }
+ });
+ } catch (error) {
+ console.error(`promise: doInit input arg invalid` + JSON.stringify(error));
+ throw (error as Error);
+ }
+}
+
+function finishEncryptSession(handle: number, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.finishSession(handle, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicEncryptFinishFunc(handle: number, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise doFinish`);
+ let throwObject: ThrowObject = { isThrow: true };
+ try {
+ await finishEncryptSession(handle, huksOptions, throwObject)
+ .then((data) => {
+ cipherText = data.outData as Uint8Array;
+ console.info(`promise: doFinish success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: doFinish failed` + JSON.stringify(error));
+ }
+ });
+ } catch (error) {
+ console.error(`promise: doFinish input arg invalid` + JSON.stringify(error));
+ throw (error as Error);
+ }
+}
+
+async function testSm4Cipher() {
+ /* 初始化密钥会话获取挑战值 */
+ await publicInitFunc(keyAlias, encryptOptions);
+ /* 加密 */
+ encryptOptions.inData = stringToUint8Array(cipherInData);
+ await publicEncryptFinishFunc(handle, encryptOptions);
+}
+
+/* 集成生成密钥参数集 & 加密参数集 */
+class PropertyDecryptType {
+ public tag: huks.HuksTag = huks.HuksTag.HUKS_TAG_ALGORITHM
+ public value: huks.HuksKeyAlg | huks.HuksKeyPurpose | huks.HuksKeySize | huks.HuksKeyPadding | huks.HuksCipherMode
+ | Uint8Array = huks.HuksKeyAlg.HUKS_ALG_SM4
+}
+
+let propertiesDecrypt: PropertyDecryptType[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_SM4,
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT,
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128,
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_NONE,
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_CBC,
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_IV,
+ value: stringToUint8Array(IV),
+ }
+]
+let decryptOptions: huks.HuksOptions = {
+ properties: propertiesDecrypt,
+ inData: new Uint8Array([])
+}
+
+function userIAMAuthFinger(huksChallenge: Uint8Array) {
+ // 获取认证对象。
+ let authTypeList: userAuth.UserAuthType[] = [authType];
+ const authParam: userAuth.AuthParam = {
+ challenge: huksChallenge,
+ authType: authTypeList,
+ authTrustLevel: authTrustLevel
+ };
+ const widgetParam: userAuth.WidgetParam = {
+ title: 'PIN',
+ };
+ let auth: userAuth.UserAuthInstance;
+ try {
+ auth = userAuth.getUserAuthInstance(authParam, widgetParam);
+ console.info('get auth instance success');
+ } catch (error) {
+ console.error('get auth instance failed' + JSON.stringify(error));
+ throw (error as Error);
+ }
+ // 订阅认证结果。
+ try {
+ auth.on('result', {
+ onResult(result) {
+ console.info('[HUKS] -> [IAM] userAuthInstance callback result = ' + JSON.stringify(result));
+ authToken = result.token;
+ testSm4CipherFinish();
+ }
+ });
+ console.info('subscribe authentication event success');
+ } catch (error) {
+ console.error('subscribe authentication event failed ' + JSON.stringify(error));
+ throw (error as Error);
+ }
+ // 开始认证。
+ try {
+ auth.start();
+ console.info('authV9 start auth success');
+ } catch (error) {
+ console.error('authV9 start auth failed, error = ' + JSON.stringify(error));
+ throw (error as Error);
+ }
+}
+
+function finishDecryptSession(handle: number, huksOptions: huks.HuksOptions, token: Uint8Array,
+ throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.finishSession(handle, huksOptions, token, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicDecryptFinishFunc(handle: number, token: Uint8Array, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise doFinish`);
+ let throwObject: ThrowObject = { isThrow: true };
+ try {
+ await finishDecryptSession(handle, huksOptions, token, throwObject)
+ .then((data) => {
+ finishOutData = data.outData as Uint8Array;
+ console.info(`promise: doFinish success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: BusinessError) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: doFinish failed` + JSON.stringify(error));
+ }
+ });
+ } catch (error) {
+ console.error(`promise: doFinish input arg invalid` + JSON.stringify(error));
+ throw (error as Error);
+ }
+}
+
+async function testSm4CipherInit() {
+ /* 初始化密钥会话获取挑战值 */
+ await publicInitFunc(keyAlias, decryptOptions);
+ /* 调用userIAM进行身份认证 */
+ console.log('challenge value: ' + challenge.toString());
+ userIAMAuthFinger(challenge);
+}
+
+async function testSm4CipherFinish() {
+ /* 认证成功后进行解密, 需要传入Auth获取到的authToken值 */
+ decryptOptions.inData = cipherText;
+ await publicDecryptFinishFunc(handle, authToken, decryptOptions);
+ if (finishOutData === stringToUint8Array(cipherInData)) {
+ console.error('test finish decrypt error');
+ } else {
+ console.info('test finish decrypt success');
+ }
+}
+
+async function main() {
+ await testGenKeyForFingerprintAccessControl();
+ await testSm4Cipher();
+ await testSm4CipherInit();
+}
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'FineGrainedUserIdentityAuthentication';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.fine_grained_user_identity_authentication_call'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ try {
+ await main();
+ this.message = 'Call Result: Success';
+ } catch (error) {
+ this.message = 'Call Result: Failed' + error.message;
+ }
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/Index.ets b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..e012e25431385cb41b6a4e5eb139561e43d60375
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2025 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 { router } from '@kit.ArkUI';
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'AccessControl';
+
+ goToSample(url: string): void {
+ router.pushUrl({
+ url: url,
+ }, router.RouterMode.Single, (err) => {
+ if (err) {
+ console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
+ return;
+ }
+ console.info('pushUrl success');
+ })
+ }
+
+ build() {
+ Column({ space: 5 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button('UserIdentityAuthentication')
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/UserIdentityAuthentication');
+ })
+ Button('FineGrainedUserIdentityAuthentication')
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/FineGrainedUserIdentityAuthentication');
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/UserIdentityAuthentication.ets b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/UserIdentityAuthentication.ets
new file mode 100644
index 0000000000000000000000000000000000000000..225d1590aae94b90a92b2d00798010ca55dabc7a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/UserIdentityAuthentication.ets
@@ -0,0 +1,417 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+
+// [Start user_authentication_and_access_control_guide]
+import { huks } from '@kit.UniversalKeystoreKit';
+import { userAuth } from '@kit.UserAuthenticationKit';
+
+/*
+* 确定密钥别名和封装密钥属性参数集
+*/
+let keyAlias = 'test_sm4_key_alias';
+let IV = '1234567890123456';
+let handle: number;
+let challenge: Uint8Array;
+let fingerAuthToken: Uint8Array;
+let authType = userAuth.UserAuthType.PIN;
+let authTrustLevel = userAuth.AuthTrustLevel.ATL1;
+let cipherInData = 'Hks_SM4_Cipher_Test_101010101010101010110_string';
+let finishOutData: Uint8Array;
+
+class ThrowObject {
+ public isThrow: boolean = false;
+}
+
+let generateProperties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_SM4
+}, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
+}, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_CBC,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_NONE,
+},
+ // 指定密钥身份认证的类型:PIN。
+ {
+ tag: huks.HuksTag.HUKS_TAG_USER_AUTH_TYPE,
+ value: huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_PIN
+ },
+ // 指定密钥安全授权的类型(失效类型):新录入生物特征(PIN)后无效。
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_ACCESS_TYPE,
+ value: huks.HuksAuthAccessType.HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD
+ },
+ // 指定挑战值的类型:默认类型。
+ {
+ tag: huks.HuksTag.HUKS_TAG_CHALLENGE_TYPE,
+ value: huks.HuksChallengeType.HUKS_CHALLENGE_TYPE_NORMAL
+ }];
+
+let generateHuksOptions: huks.HuksOptions = {
+ properties: generateProperties,
+ inData: new Uint8Array([])
+}
+
+/*
+ * 生成密钥
+ */
+
+function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.generateKeyItem(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise generateKeyItem`);
+ let throwObject: ThrowObject = { isThrow: true };
+ try {
+ await generateKeyItem(keyAlias, huksOptions, throwObject)
+ .then((data) => {
+ console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ console.error(`promise: generateKeyItem failed, ` + JSON.stringify(error));
+ throw (error as Error);
+ } else {
+ }
+ });
+ } catch (error) {
+ console.error(`promise: generateKeyItem input arg invalid, ` + JSON.stringify(error));
+ throw (error as Error);
+ }
+}
+
+async function testGenKeyForFingerprintAccessControl() {
+ await publicGenKeyFunc(keyAlias, generateHuksOptions);
+}
+
+/* 集成生成密钥参数集 & 加密参数集 */
+let initProperties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_SM4,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_CBC,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_NONE,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_IV,
+ value: stringToUint8Array(IV),
+}];
+
+let initHuksOptions: huks.HuksOptions = {
+ properties: initProperties,
+ inData: new Uint8Array([])
+}
+
+function stringToUint8Array(str: string) {
+ let arr: number[] = [];
+ for (let i = 0, j = str.length; i < j; ++i) {
+ arr.push(str.charCodeAt(i));
+ }
+ return new Uint8Array(arr);
+}
+
+function initSession(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.initSession(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+/* 初始化HUKS中的会话,获取挑战值 */
+async function publicInitFunc(keyAlias: string, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise doInit`);
+ let throwObject: ThrowObject = { isThrow: true };
+ try {
+ await initSession(keyAlias, huksOptions, throwObject)
+ .then((data) => {
+ console.info(`promise: doInit success, data = ${JSON.stringify(data)}`);
+ handle = data.handle;
+ challenge = data.challenge as Uint8Array;
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: doInit failed, ` + JSON.stringify(error));
+ }
+ });
+ } catch (error) {
+ console.error(`promise: doInit input arg invalid, ` + JSON.stringify(error));
+ throw (error as Error);
+ }
+}
+
+/* 调用UserIAM拉起认证,触发HUKS的访问控制流程 */
+function userIAMAuthFinger(huksChallenge: Uint8Array) {
+ // 获取认证对象。
+ let authTypeList: userAuth.UserAuthType[] = [authType];
+ const authParam: userAuth.AuthParam = {
+ challenge: huksChallenge,
+ authType: authTypeList,
+ authTrustLevel: authTrustLevel
+ };
+ const widgetParam: userAuth.WidgetParam = {
+ title: 'PIN',
+ };
+ let auth: userAuth.UserAuthInstance;
+ try {
+ auth = userAuth.getUserAuthInstance(authParam, widgetParam);
+ console.info('get auth instance success');
+ } catch (error) {
+ console.error('get auth instance failed' + JSON.stringify(error));
+ throw (error as Error);
+ }
+ // 订阅认证结果。
+ try {
+ auth.on('result', {
+ onResult(result) {
+ console.info('[HUKS] -> [IAM] userAuthInstance callback result = ' + JSON.stringify(result));
+ fingerAuthToken = result.token;
+ testSm4Cipher();
+ }
+ });
+ console.log('subscribe authentication event success');
+ } catch (error) {
+ console.error('subscribe authentication event failed, ' + JSON.stringify(error));
+ throw (error as Error);
+ }
+ // 开始认证。
+ try {
+ auth.start();
+ console.info('authV9 start auth success');
+ } catch (error) {
+ console.error('authV9 start auth failed, error = ' + JSON.stringify(error));
+ throw (error as Error);
+ }
+}
+
+async function testInitAndAuthFinger() {
+ /* 初始化密钥会话获取挑战值 */
+ await publicInitFunc(keyAlias, initHuksOptions);
+ /* 调用userIAM进行身份认证 */
+ console.log('challenge value: ' + challenge.toString());
+ userIAMAuthFinger(challenge);
+}
+
+/* 集成生成密钥参数集 & 加密参数集 */
+class PropertyEncryptType {
+ public tag: huks.HuksTag = huks.HuksTag.HUKS_TAG_ALGORITHM;
+ public value: huks.HuksKeyAlg | huks.HuksKeyPurpose | huks.HuksKeySize | huks.HuksKeyPadding | huks.HuksCipherMode
+ | Uint8Array = huks.HuksKeyAlg.HUKS_ALG_SM4;
+}
+
+let propertiesEncrypt: PropertyEncryptType[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_SM4,
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT,
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_SM4_KEY_SIZE_128,
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_NONE,
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_CBC,
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_IV,
+ value: stringToUint8Array(IV),
+ }
+]
+let encryptOptions: huks.HuksOptions = {
+ properties: propertiesEncrypt,
+ inData: new Uint8Array([])
+}
+
+function updateSession(handle: number, huksOptions: huks.HuksOptions, token: Uint8Array, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.updateSession(handle, huksOptions, token, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicUpdateFunc(handle: number, token: Uint8Array, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise doUpdate`);
+ let throwObject: ThrowObject = { isThrow: true };
+ console.log('token value[publicUpdateFunc]:' + token)
+ try {
+ await updateSession(handle, huksOptions, token, throwObject)
+ .then((data) => {
+ console.info(`promise: doUpdate success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: doUpdate failed, ` + JSON.stringify(error));
+ }
+ });
+ } catch (error) {
+ console.error(`promise: doUpdate input arg invalid, ` + JSON.stringify(error));
+ throw (error as Error);
+ }
+}
+
+function finishSession(handle: number, huksOptions: huks.HuksOptions, token: Uint8Array, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.finishSession(handle, huksOptions, token, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicFinishFunc(handle: number, token: Uint8Array, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise doFinish`);
+ let throwObject: ThrowObject = { isThrow: false };
+ console.log('token value[publicFinishFunc]:' + token)
+ try {
+ await finishSession(handle, huksOptions, token, throwObject)
+ .then((data) => {
+ finishOutData = data.outData as Uint8Array;
+ console.info(`promise: doFinish success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: doFinish failed, ` + JSON.stringify(error));
+ }
+ });
+ } catch (error) {
+ console.error(`promise: doFinish input arg invalid, ` + JSON.stringify(error));
+ throw (error as Error);
+ }
+}
+
+async function testSm4Cipher() {
+ encryptOptions.inData = stringToUint8Array(cipherInData);
+ /* 传入认证令牌 */
+ await publicUpdateFunc(handle, fingerAuthToken, encryptOptions);
+ /* 传入认证令牌 */
+ console.log('continue publicFinishFunc');
+ await publicFinishFunc(handle, fingerAuthToken, encryptOptions);
+ console.log('end publicFinishFunc');
+ if (finishOutData === stringToUint8Array(cipherInData)) {
+ console.error('test finish encrypt error');
+ } else {
+ console.info('test finish encrypt success');
+ }
+}
+// [End user_authentication_and_access_control_guide]
+async function main() {
+ await testGenKeyForFingerprintAccessControl();
+ await testInitAndAuthFinger();
+}
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'UserIdentityAuthentication';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message).fontSize(20)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.user_identity_authentication'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ try {
+ await main();
+ this.message = 'Call Result: Success';
+ } catch (error) {
+ this.message = 'Call Result: Failed';
+ }
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/module.json5 b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..9a475d7e2c0f3d598e37b05c4de61e5c61efd9df
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/module.json5
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.ACCESS_BIOMETRIC"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/color.json b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/float.json b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/float.json
new file mode 100644
index 0000000000000000000000000000000000000000..a0a93dd91fd48f08f3a9532c76e9b26e68d4c034
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/float.json
@@ -0,0 +1,8 @@
+{
+ "float": [
+ {
+ "name": "page_text_font_size",
+ "value": "50fp"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/string.json b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..dd4d93181a69ec9a45ffbef5c4d09aae705eb103
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,24 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "AccessControl"
+ },
+ {
+ "name": "fine_grained_user_identity_authentication_call",
+ "value": "Call"
+ },
+ {
+ "name": "user_identity_authentication",
+ "value": "Call"
+ }
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/background.png b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/background.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/foreground.png b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/foreground.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/layered_image.json b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/startIcon.png b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/profile/backup_config.json b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/profile/main_pages.json b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..49a1be3eb9f9a717fe1c9c59a70414595a21cb96
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,7 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/FineGrainedUserIdentityAuthentication",
+ "pages/UserIdentityAuthentication"
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/dark/element/color.json b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/dark/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/resources/dark/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#000000"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/Ability.test.ets b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/AccessControl.test.ets b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/AccessControl.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..55cf08dbcd934777a0c72520116ea5f29f987b56
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/AccessControl.test.ets
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, it, expect, beforeAll } from '@ohos/hypium';
+// 导入测试依赖kit
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+let want: Want;
+
+export default function accessControlTest() {
+ describe('accessControlTest', () => {
+ /**
+ * 打开应用
+ */
+ beforeAll(async () => {
+ want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ await driver.delayMs(1000);
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ })
+
+ /**
+ * 点击按钮,用户身份认证访问控制
+ */
+ it('testAccessControl001', 0, async () => {
+ console.info('uitest: testAccessControl001 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('UserIdentityAuthentication'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(5000);
+ const button2 = await driver.findComponent(ON.text('Call'));
+ await button2.click();
+ await driver.delayMs(10000);
+ await driver.assertComponentExist(ON.text('Call Result: Success'));
+ console.info('uitest: testAccessControl001 end');
+ await driver.pressBack();
+ })
+
+ /**
+ * 点击按钮,细粒度用户身份认证访问控制
+ */
+ it('testAccessControl002', 0, async () => {
+ console.info('uitest: testAccessControl002 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('FineGrainedUserIdentityAuthentication'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('Call'));
+ await button2.click();
+ await driver.delayMs(10000);
+ await driver.assertComponentExist(ON.text('Call Result: Success'));
+ console.info('uitest: testAccessControl002 end');
+ await driver.pressBack();
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/List.test.ets b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..d923f98577a9bdd74c848705553d310aef1d143b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 accessControlTest from './AccessControl.test';
+
+export default function testsuite() {
+ accessControlTest();
+}
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/module.json5 b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/hvigor/hvigor-config.json5 b/UniversalKeystoreKit/KeyUsage/AccessControl/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..d584c19c247db9a7caee4b606bb931aa9279c637
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/hvigorfile.ts b/UniversalKeystoreKit/KeyUsage/AccessControl/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/oh-package.json5 b/UniversalKeystoreKit/KeyUsage/AccessControl/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e41bae026aab3b50d0abb42fece08ba43b4a772b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/ohosTest.md b/UniversalKeystoreKit/KeyUsage/AccessControl/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..c32f4adb8f3c485df8d4df0f1a21038a45521ef9
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/AccessControl/ohosTest.md
@@ -0,0 +1,9 @@
+# 访问控制测试用例归档
+
+## 用例表
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------------------------- | ------------ | ---- | ---------------- | -------- | -------- |
+| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass |
+| 点击按钮, 用户身份认证访问控制 | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass |
+| 点击按钮, 细粒度用户身份认证访问控制 | 成功拉起应用 | | 成功新增输出日志 | 是 | Pass |
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/FineGrainedUserIdentityAuthentication_1.png b/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/FineGrainedUserIdentityAuthentication_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..9d4191509b5ebb1f3a3608d9e5dc9743686029c3
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/FineGrainedUserIdentityAuthentication_1.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/FineGrainedUserIdentityAuthentication_2.png b/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/FineGrainedUserIdentityAuthentication_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..ef7b57701e0bcc3d9349fe37ffe6289b3607d2b4
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/FineGrainedUserIdentityAuthentication_2.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/UserIdentityAuthentication_1.png b/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/UserIdentityAuthentication_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..dc49a06c134a735065183555d2e42a1198de6968
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/UserIdentityAuthentication_1.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/UserIdentityAuthentication_2.png b/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/UserIdentityAuthentication_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..822396a2128a8f3e682ecb7e75785840946fe3d7
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/AccessControl/screenshots/UserIdentityAuthentication_2.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/.gitignore b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/AppScope/app.json5 b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..ad9bc7f08ab6ca06bac9378776be927ff6c9f375
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.encryptiondecryption",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/AppScope/resources/base/element/string.json b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..3e3fade23715f562a60093d1ac694b18eae2f045
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "EncryptionDecryption"
+ }
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/AppScope/resources/base/media/app_icon.png b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/AppScope/resources/base/media/app_icon.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/README.md b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..863528d8f7c878d0d636a0306d8c080c46f7a01a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/README.md
@@ -0,0 +1,160 @@
+## 加解密(ArkTS)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-encryption-decryption-arkts.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### AES/CBC/PKCS7
+
+##### 介绍
+
+1. 本示例主要介绍使用AES算法加密,用例中选取的分组模式为CBC、填充模式为PKCS7时,必须要填参数IV。
+
+##### 效果预览
+
+| 主页 | 删除 |
+| ---------------------------------------------------------- | ---------------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击AES/CBC/PKCS7按钮生成密钥,加密数据并解密数据,删除密钥。
+
+#### AES/GCM/NoPadding
+
+##### 介绍
+
+1. 本示例主要介绍使用AES算法加密,用例中选取的分组模式为GCM时,必须要填参数NONCE,AAD可选。
+
+##### 效果预览
+
+| 主页 | 删除 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+|
|
|
+
+使用说明
+
+1. 点击AES/GCM/NoPadding按钮生成密钥,加密数据并解密数据,删除密钥。
+
+#### RSA/ECB/PKCS1_V1_5
+
+##### 介绍
+
+1. 本示例主要介绍使用RSA算法加密,需要选择其对应分组模式以及填充模式和摘要算法DIGEST。
+
+##### 效果预览
+
+| 主页 | 删除 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+|
|
|
+
+使用说明
+
+1. 点击RSA/ECB/PKCS1_V1_5按钮生成密钥,加密数据并解密数据,删除密钥。
+
+#### RSA/ECB/OAEP/SHA256
+
+##### 介绍
+
+1. 本示例主要介绍使用RSA算法加密,需要选择其对应分组模式以及填充模式和摘要算法DIGEST。
+
+##### 效果预览
+
+| 主页 | 删除 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+|
|
|
+
+使用说明
+
+1. 点击RSA/ECB/OAEP/SHA256按钮生成密钥,加密数据并解密数据,删除密钥。
+
+#### SM2
+
+##### 介绍
+
+1. 本示例主要介绍使用SM2算法加密,摘要算法DIGEST需要指定为SM3。
+
+##### 效果预览
+
+| 主页 | 删除 |
+| -------------------------------------------------- | -------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击SM2按钮生成密钥,加密数据并解密数据,删除密钥。
+
+## 加解密(C/C++)
+
+### 介绍
+
+1. 本工程实现了对以下 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-encryption-decryption-ndk.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### Call C/C++
+
+##### 介绍
+
+1. 本示例主要介绍加解密,以AES 256密钥为例,完成加解密。
+
+##### 效果预览
+
+| 主页 | |
+| -------------------------------------------------- | -------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击Call C/C++按钮生成密钥,加密数据并解密数据,删除密钥。
+
+## 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---AESCBCPKCS7.ets
+|---|---|---AESGCMNoPadding.ets
+|---|---|---Index.ets // 首页
+|---|---|---RSAECBOAEPSHA256.ets
+|---|---|---RSAECBPKCS1_V1_5.ets
+|---|---|---SM2.ets
+|---cpp
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---EncryptionDecryption.test.ets // 自动化测试用例
+```
+
+
+## 相关权限
+
+无。
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo UniversalKeystoreKit/KeyUsage/EncryptionDecryption > .git/info/sparse-checkout
+git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/build-profile.json5 b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..fb5a1ab654ae6715a0ab69a31900ad26dcf2487f
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/build-profile.json5
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ "buildOption": {
+ "strictMode": {
+ "caseSensitiveCheck": true,
+ "useNormalizedOHMUrl": true
+ }
+ }
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/code-linter.json5 b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/.gitignore b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/build-profile.json5 b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2d8b081b615348a99aa197f90186f3d8891b7dc1
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/build-profile.json5
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ "externalNativeOptions": {
+ "path": "./src/main/cpp/CMakeLists.txt",
+ "arguments": "",
+ "cppFlags": "",
+ "abiFilters": [
+ "arm64-v8a",
+ "x86_64"
+ ]
+ }
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ },
+ "nativeLib": {
+ "debugSymbol": {
+ "strip": true,
+ "exclude": []
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/hvigorfile.ts b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/oh-package.json5 b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..118bdd4fe7699368a010e04c24f5bfc887cf1298
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/oh-package.json5
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {
+ "libentry.so": "file:./src/main/cpp/types/libentry"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/CMakeLists.txt b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..870045a54ae1426a9af5261da9ccf3f702039589
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,15 @@
+# the minimum version of CMake.
+cmake_minimum_required(VERSION 3.5.0)
+project(EncryptionDecryption)
+
+set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+if(DEFINED PACKAGE_FIND_FILE)
+ include(${PACKAGE_FIND_FILE})
+endif()
+
+include_directories(${NATIVERENDER_ROOT_PATH}
+ ${NATIVERENDER_ROOT_PATH}/include)
+
+add_library(entry SHARED napi_init.cpp)
+target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so)
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/napi_init.cpp b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/napi_init.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c4f84a6bc7b86998f3aeae9aee62f9605cc0ce9f
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/napi_init.cpp
@@ -0,0 +1,229 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+// [Start encrypt_and_decrypt]
+#include "huks/native_huks_api.h"
+#include "huks/native_huks_param.h"
+#include "napi/native_api.h"
+#include
+
+OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params,
+ uint32_t paramCount)
+{
+ OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_AddParams(*paramSet, params, paramCount);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ ret = OH_Huks_BuildParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ return ret;
+}
+
+static const uint32_t IV_SIZE = 16;
+static uint8_t IV[IV_SIZE] = {0}; // this is a test value, for real use the iv should be different every time
+static struct OH_Huks_Param g_genEncDecParams[] = {
+ {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT | OH_HUKS_KEY_PURPOSE_DECRYPT},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256},
+ {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE},
+ {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_CBC}};
+
+static struct OH_Huks_Param g_encryptParams[] = {
+ {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256},
+ {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE},
+ {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_CBC},
+ {.tag = OH_HUKS_TAG_IV,
+ .blob = {
+ .size = IV_SIZE,
+ .data = (uint8_t *)IV // this is a test value, for real use the iv should be different every time
+ }}};
+
+static struct OH_Huks_Param g_decryptParams[] = {
+ {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_DECRYPT},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256},
+ {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE},
+ {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_CBC},
+ {.tag = OH_HUKS_TAG_IV,
+ .blob = {
+ .size = IV_SIZE,
+ .data = (uint8_t *)IV // this is a test value, for real use the iv should be different every time
+ }}};
+
+static const uint32_t AES_COMMON_SIZE = 1024;
+OH_Huks_Result HksAesCipherTestEncrypt(const struct OH_Huks_Blob *keyAlias,
+ const struct OH_Huks_ParamSet *encryptParamSet,
+ const struct OH_Huks_Blob *inData, struct OH_Huks_Blob *cipherText)
+{
+ uint8_t handleE[sizeof(uint64_t)] = {0};
+ struct OH_Huks_Blob handleEncrypt = {sizeof(uint64_t), handleE};
+ OH_Huks_Result ret = OH_Huks_InitSession(keyAlias, encryptParamSet, &handleEncrypt, nullptr);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_FinishSession(&handleEncrypt, encryptParamSet, inData, cipherText);
+ return ret;
+}
+
+OH_Huks_Result HksAesCipherTestDecrypt(const struct OH_Huks_Blob *keyAlias,
+ const struct OH_Huks_ParamSet *decryptParamSet,
+ const struct OH_Huks_Blob *cipherText, struct OH_Huks_Blob *plainText,
+ const struct OH_Huks_Blob *inData)
+{
+ uint8_t handleD[sizeof(uint64_t)] = {0};
+ struct OH_Huks_Blob handleDecrypt = {sizeof(uint64_t), handleD};
+ OH_Huks_Result ret = OH_Huks_InitSession(keyAlias, decryptParamSet, &handleDecrypt, nullptr);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_FinishSession(&handleDecrypt, decryptParamSet, cipherText, plainText);
+ return ret;
+}
+
+static napi_value EncDecKey(napi_env env, napi_callback_info info)
+{
+ char tmpKeyAlias[] = "test_enc_dec";
+ struct OH_Huks_Blob keyAlias = {(uint32_t)strlen(tmpKeyAlias), (uint8_t *)tmpKeyAlias};
+ struct OH_Huks_ParamSet *genParamSet = nullptr;
+ struct OH_Huks_ParamSet *encryptParamSet = nullptr;
+ struct OH_Huks_ParamSet *decryptParamSet = nullptr;
+ OH_Huks_Result ohResult;
+ do {
+ /* 1. Generate Key */
+ /*
+ * 模拟生成密钥场景
+ * 1.1. 确定密钥别名
+ */
+ /*
+ * 1.2. 获取生成密钥算法参数配置
+ */
+ ohResult = InitParamSet(&genParamSet, g_genEncDecParams, sizeof(g_genEncDecParams) / sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ /*
+ * 1.3. 调用generateKeyItem
+ */
+ ohResult = OH_Huks_GenerateKeyItem(&keyAlias, genParamSet, nullptr);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ /* 2. Encrypt */
+ /*
+ * 模拟加密场景
+ * 2.1. 获取密钥别名
+ */
+ /*
+ * 2.2. 获取待加密的数据
+ */
+ /*
+ * 2.3. 获取加密算法参数配置
+ */
+ ohResult = InitParamSet(&encryptParamSet, g_encryptParams, sizeof(g_encryptParams) / sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ char tmpInData[] = "AES_ECB_INDATA_1";
+ struct OH_Huks_Blob inData = {(uint32_t)strlen(tmpInData), (uint8_t *)tmpInData};
+ uint8_t cipher[AES_COMMON_SIZE] = {0};
+ struct OH_Huks_Blob cipherText = {AES_COMMON_SIZE, cipher};
+ /*
+ * 2.4. 调用initSession获取handle
+ */
+ /*
+ * 2.5. 调用finishSession获取加密后的密文
+ */
+ ohResult = HksAesCipherTestEncrypt(&keyAlias, encryptParamSet, &inData, &cipherText);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ /* 3. Decrypt */
+ /*
+ * 模拟解密场景
+ * 3.1. 获取密钥别名
+ */
+ /*
+ * 3.2. 获取待解密的密文
+ */
+ /*
+ * 3.3. 获取解密算法参数配置
+ */
+ ohResult = InitParamSet(&decryptParamSet, g_decryptParams, sizeof(g_decryptParams) / sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ uint8_t plain[AES_COMMON_SIZE] = {0};
+ struct OH_Huks_Blob plainText = {AES_COMMON_SIZE, plain};
+ /*
+ * 3.4. 调用initSession获取handle
+ */
+ /*
+ * 3.5. 调用finishSession获取解密后的数据
+ */
+ ohResult = HksAesCipherTestDecrypt(&keyAlias, decryptParamSet, &cipherText, &plainText, &inData);
+ } while (0);
+ /* 4. Delete Key */
+ /*
+ * 模拟删除密钥场景
+ * 4.1. 获取密钥别名
+ */
+ /*
+ * 4.2. 调用deleteKeyItem删除密钥
+ */
+ (void)OH_Huks_DeleteKeyItem(&keyAlias, genParamSet);
+
+ OH_Huks_FreeParamSet(&genParamSet);
+ OH_Huks_FreeParamSet(&encryptParamSet);
+ OH_Huks_FreeParamSet(&decryptParamSet);
+
+ napi_value ret;
+ napi_create_int32(env, ohResult.errorCode, &ret);
+ return ret;
+}
+
+
+// [End encrypt_and_decrypt]
+
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports)
+{
+ napi_property_descriptor desc[] = {
+ {"encDecKey", nullptr, EncDecKey, nullptr, nullptr, nullptr, napi_default, nullptr}};
+ napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "entry",
+ .nm_priv = ((void *)0),
+ .reserved = {0},
+};
+
+extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); }
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/types/libentry/index.d.ts b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/types/libentry/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..49fa4d09e13c12fe0e241bdd320d5a832ded6ea6
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/types/libentry/index.d.ts
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2025 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 const encDecKey: () => number;
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/types/libentry/oh-package.json5 b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/types/libentry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2826cc7d6bd199c1008bb51d898dffa922201e6c
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/types/libentry/oh-package.json5
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "libentry.so",
+ "types": "./index.d.ts",
+ "version": "1.0.0",
+ "description": "Please describe the basic information."
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/entryability/EntryAbility.ets b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..edc2839f203ba057c186e19b0cbbbf80c8faa8b3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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 { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESCBCPKCS7.ets b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESCBCPKCS7.ets
new file mode 100644
index 0000000000000000000000000000000000000000..9d0ac6f76889281c8a168ee1f47ee39a09f7a5aa
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESCBCPKCS7.ets
@@ -0,0 +1,264 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start encrypt_and_decrypt_AESCBCPKCS7]
+/*
+ * 以下以AES/CBC/PKCS7的Promise操作使用为例
+ */
+import { huks } from '@kit.UniversalKeystoreKit';
+
+let aesKeyAlias = 'test_aesKeyAlias';
+let handle: number;
+let plainText = '123456';
+let IV = '001122334455';
+let cipherData: Uint8Array;
+
+function stringToUint8Array(str: String) {
+ let arr: number[] = [];
+ for (let i = 0, j = str.length; i < j; ++i) {
+ arr.push(str.charCodeAt(i));
+ }
+ return new Uint8Array(arr);
+}
+
+function uint8ArrayToString(fileData: Uint8Array) {
+ let dataString = '';
+ for (let i = 0; i < fileData.length; i++) {
+ dataString += String.fromCharCode(fileData[i]);
+ }
+ return dataString;
+}
+
+function getAesGenerateProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_AES
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT |
+ huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
+ }];
+ return properties;
+}
+
+function getAesEncryptProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_AES
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_PKCS7
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_CBC
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_IV,
+ value: stringToUint8Array(IV)
+ }];
+ return properties;
+}
+
+function getAesDecryptProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_AES
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_PKCS7
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_CBC
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_IV,
+ value: stringToUint8Array(IV)
+ }];
+ return properties;
+}
+
+async function generateAesKey() {
+ /*
+ * 模拟生成密钥场景
+ * 1. 确定密钥别名
+ */
+ /*
+ * 2. 获取生成密钥算法参数配置
+ */
+ let genProperties = getAesGenerateProperties();
+ let options: huks.HuksOptions = {
+ properties: genProperties
+ }
+ /*
+ * 3. 调用generateKeyItem
+ */
+ await huks.generateKeyItem(aesKeyAlias, options)
+ .then((data) => {
+ console.info(`promise: generate AES Key success, data = ${JSON.stringify(data)}`);
+ }).catch((error: Error) => {
+ console.error(`promise: generate AES Key failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+}
+
+async function encryptData() {
+ /*
+ * 模拟加密场景
+ * 1. 获取密钥别名
+ */
+ /*
+ * 2. 获取待加密的数据
+ */
+ /*
+ * 3. 获取加密算法参数配置
+ */
+ let encryptProperties = getAesEncryptProperties();
+ let options: huks.HuksOptions = {
+ properties: encryptProperties,
+ inData: stringToUint8Array(plainText)
+ }
+ /*
+ * 4. 调用initSession获取handle
+ */
+ await huks.initSession(aesKeyAlias, options)
+ .then((data) => {
+ handle = data.handle;
+ }).catch((error: Error) => {
+ console.error(`promise: init EncryptData failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+ /*
+ * 5. 调用finishSession获取加密后的密文
+ */
+ await huks.finishSession(handle, options)
+ .then((data) => {
+ console.info(`promise: encrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ cipherData = data.outData as Uint8Array;
+ }).catch((error: Error) => {
+ console.error(`promise: encrypt data failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+}
+
+async function decryptData() {
+ /*
+ * 模拟解密场景
+ * 1. 获取密钥别名
+ */
+ /*
+ * 2. 获取待解密的密文
+ */
+ /*
+ * 3. 获取解密算法参数配置
+ */
+ let decryptOptions = getAesDecryptProperties()
+ let options: huks.HuksOptions = {
+ properties: decryptOptions,
+ inData: cipherData
+ }
+ /*
+ * 4. 调用initSession获取handle
+ */
+ await huks.initSession(aesKeyAlias, options)
+ .then((data) => {
+ handle = data.handle;
+ }).catch((error: Error) => {
+ console.error(`promise: init DecryptData failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+ /*
+ * 5. 调用finishSession获取解密后的数据
+ */
+ await huks.finishSession(handle, options)
+ .then((data) => {
+ console.info(`promise: decrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ }).catch((error: Error) => {
+ console.error(`promise: decrypt data failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+}
+
+async function deleteKey() {
+ /*
+ * 模拟删除密钥场景
+ * 1. 获取密钥别名
+ */
+ let emptyOptions: huks.HuksOptions = {
+ properties: []
+ }
+ /*
+ * 2. 调用deleteKeyItem删除密钥
+ */
+ await huks.deleteKeyItem(aesKeyAlias, emptyOptions)
+ .then((data) => {
+ console.info(`promise: delete data success`);
+ }).catch((error: Error) => {
+ console.error(`promise: delete data failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+}
+
+
+// [End encrypt_and_decrypt_AESCBCPKCS7]
+
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'AES/CBC/PKCS7';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.aes_cbc_pkcs7'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ try {
+ await generateAesKey();
+ await encryptData();
+ await decryptData();
+ await deleteKey();
+ this.message = 'AES/CBC/PKCS7 Result: Success';
+ } catch {
+ this.message = 'AES/CBC/PKCS7 Result: Failed';
+ }
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESGCMNoPadding.ets b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESGCMNoPadding.ets
new file mode 100644
index 0000000000000000000000000000000000000000..ea053a5c6d1981fbceb875328547d4d030d1aaee
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESGCMNoPadding.ets
@@ -0,0 +1,272 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start encrypt_and_decrypt_AESGCMNoPadding]
+/*
+ * 以下以AES/GCM/NoPadding的Promise操作使用为例
+ */
+import { huks } from '@kit.UniversalKeystoreKit';
+
+let aesKeyAlias = 'test_aesKeyAlias';
+let handle: number;
+let plainText = '123456';
+let cipherData: Uint8Array;
+let AAD = '1234567890123456';
+let NONCE = '001122334455';
+
+function stringToUint8Array(str: String) {
+ let arr: number[] = [];
+ for (let i = 0, j = str.length; i < j; ++i) {
+ arr.push(str.charCodeAt(i));
+ }
+ return new Uint8Array(arr);
+}
+
+function uint8ArrayToString(fileData: Uint8Array) {
+ let dataString = '';
+ for (let i = 0; i < fileData.length; i++) {
+ dataString += String.fromCharCode(fileData[i]);
+ }
+ return dataString;
+}
+
+function getAesGenerateProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_AES
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT |
+ huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
+ }];
+ return properties;
+}
+
+function getAesGcmEncryptProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_AES
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_NONE
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_GCM
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_NONCE,
+ value: stringToUint8Array(NONCE)
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_ASSOCIATED_DATA,
+ value: stringToUint8Array(AAD)
+ }];
+ return properties;
+}
+
+function getAesGcmDecryptProperties(cipherData: Uint8Array) {
+ let properties: huks.HuksParam[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_AES
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_NONE
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_GCM
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_NONCE,
+ value: stringToUint8Array(NONCE)
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_ASSOCIATED_DATA,
+ value: stringToUint8Array(AAD)
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_AE_TAG,
+ value: cipherData.slice(cipherData.length - 16)
+ }];
+ return properties;
+}
+
+async function generateAesKey() {
+ /*
+ * 模拟生成密钥场景
+ * 1. 确定密钥别名
+ */
+ /*
+ * 2. 获取生成密钥算法参数配置
+ */
+ let genProperties = getAesGenerateProperties();
+ let options: huks.HuksOptions = {
+ properties: genProperties
+ }
+ /*
+ * 3. 调用generateKeyItem
+ */
+ await huks.generateKeyItem(aesKeyAlias, options)
+ .then((data) => {
+ console.info(`promise: generate AES Key success, data = ${JSON.stringify(data)}`);
+ }).catch((error: Error) => {
+ console.error(`promise: generate AES Key failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+}
+
+async function encryptData() {
+ /*
+ * 模拟加密场景
+ * 1. 获取密钥别名
+ */
+ /*
+ * 2. 获取待加密的数据
+ */
+ /*
+ * 3. 获取加密算法参数配置
+ */
+ let encryptProperties = getAesGcmEncryptProperties();
+ let options: huks.HuksOptions = {
+ properties: encryptProperties,
+ inData: stringToUint8Array(plainText)
+ }
+ /*
+ * 4. 调用initSession获取handle
+ */
+ await huks.initSession(aesKeyAlias, options)
+ .then((data) => {
+ handle = data.handle;
+ }).catch((error: Error) => {
+ console.error(`promise: init EncryptDataGcm failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+ /*
+ * 5. 调用finishSession获取加密后的密文
+ */
+ await huks.finishSession(handle, options)
+ .then((data) => {
+ console.info(`promise: encrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ cipherData = data.outData as Uint8Array;
+ }).catch((error: Error) => {
+ console.error(`promise: encrypt data failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+}
+
+async function decryptData() {
+ /*
+ * 模拟解密场景
+ * 1. 获取密钥别名
+ */
+ /*
+ * 2. 获取待解密的密文
+ */
+ /*
+ * 3. 获取解密算法参数配置
+ */
+ let decryptOptions = getAesGcmDecryptProperties(cipherData)
+ let options: huks.HuksOptions = {
+ properties: decryptOptions,
+ inData: cipherData.slice(0, cipherData.length - 16)
+ }
+ /*
+ * 4. 调用initSession获取handle
+ */
+ await huks.initSession(aesKeyAlias, options)
+ .then((data) => {
+ handle = data.handle;
+ }).catch((error: Error) => {
+ console.error(`promise: init DecryptDataGcm failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+ /*
+ * 5. 调用finishSession获取解密后的数据
+ */
+ await huks.finishSession(handle, options)
+ .then((data) => {
+ console.info(`promise: decrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ }).catch((error: Error) => {
+ console.error(`promise: decrypt data failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+}
+
+async function deleteKey() {
+ /*
+ * 模拟删除密钥场景
+ * 1. 获取密钥别名
+ */
+ let emptyOptions: huks.HuksOptions = {
+ properties: []
+ }
+ /*
+ * 2. 调用deleteKeyItem删除密钥
+ */
+ await huks.deleteKeyItem(aesKeyAlias, emptyOptions)
+ .then((data) => {
+ console.info(`promise: delete data success`);
+ }).catch((error: Error) => {
+ console.error(`promise: delete data failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+}
+
+// [End encrypt_and_decrypt_AESGCMNoPadding]
+@Entry
+@Component
+struct Index {
+ @State message: string = 'AES/GCM/NoPadding';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.aes_gcm_nopadding'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ try {
+ await generateAesKey();
+ await encryptData();
+ await decryptData();
+ await deleteKey();
+ this.message = 'AES/GCM/NoPadding Result: Success';
+ } catch {
+ this.message = 'AES/GCM/NoPadding Result: Failed';
+ }
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/DESCBCNoPadding.ets b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/DESCBCNoPadding.ets
new file mode 100644
index 0000000000000000000000000000000000000000..fbf1add09e5800b86e0549627eb06a559fd4828c
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/DESCBCNoPadding.ets
@@ -0,0 +1,257 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start encrypt_and_decrypt_DESCBCNoPadding]
+/*
+ * 以下以DES/CBC/NoPadding的Promise操作使用为例
+ */
+import { huks } from '@kit.UniversalKeystoreKit';
+
+let desKeyAlias = 'test_desKeyAlias';
+let handle: number;
+let plainText = '12345678';
+let IV = '12345678'; // 此处为样例代码,实际使用需采用随机值。
+let cipherData: Uint8Array;
+
+function stringToUint8Array(str: String) {
+ let arr: number[] = [];
+ for (let i = 0, j = str.length; i < j; ++i) {
+ arr.push(str.charCodeAt(i));
+ }
+ return new Uint8Array(arr);
+}
+
+function uint8ArrayToString(fileData: Uint8Array) {
+ let dataString = '';
+ for (let i = 0; i < fileData.length; i++) {
+ dataString += String.fromCharCode(fileData[i]);
+ }
+ return dataString;
+}
+
+function getDesGenerateProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_DES
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_DES_KEY_SIZE_64
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT |
+ huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
+ }];
+ return properties;
+}
+
+function getDesEncryptProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_DES
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_DES_KEY_SIZE_64
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_NONE
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_CBC
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_IV,
+ value: stringToUint8Array(IV)
+ }];
+ return properties;
+}
+
+function getDesDecryptProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_DES
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_DES_KEY_SIZE_64
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_NONE
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_CBC
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_IV,
+ value: stringToUint8Array(IV)
+ }];
+ return properties;
+}
+
+async function generateDesKey() {
+ /*
+ * 模拟生成密钥场景
+ * 1. 确定密钥别名
+ */
+ /*
+ * 2. 获取生成密钥算法参数配置
+ */
+ let genProperties = getDesGenerateProperties();
+ let options: huks.HuksOptions = {
+ properties: genProperties
+ }
+ /*
+ * 3. 调用generateKeyItem
+ */
+ await huks.generateKeyItem(desKeyAlias, options)
+ .then((data) => {
+ console.info(`promise: generate DES Key success, data = ${JSON.stringify(data)}`);
+ }).catch((error: Error) => {
+ console.error(`promise: generate DES Key failed, ${JSON.stringify(error)}`);
+ })
+}
+
+async function encryptData() {
+ /*
+ * 模拟加密场景
+ * 1. 获取密钥别名
+ */
+ /*
+ * 2. 获取待加密的数据
+ */
+ /*
+ * 3. 获取加密算法参数配置
+ */
+ let encryptProperties = getDesEncryptProperties();
+ let options: huks.HuksOptions = {
+ properties: encryptProperties,
+ inData: stringToUint8Array(plainText)
+ }
+ /*
+ * 4. 调用initSession获取handle
+ */
+ await huks.initSession(desKeyAlias, options)
+ .then((data) => {
+ handle = data.handle;
+ }).catch((error: Error) => {
+ console.error(`promise: init EncryptData failed, ${JSON.stringify(error)}`);
+ })
+ /*
+ * 5. 调用finishSession获取加密后的密文
+ */
+ await huks.finishSession(handle, options)
+ .then((data) => {
+ console.info(`promise: encrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ cipherData = data.outData as Uint8Array;
+ }).catch((error: Error) => {
+ console.error(`promise: encrypt data failed, ${JSON.stringify(error)}`);
+ })
+}
+
+async function decryptData() {
+ /*
+ * 模拟解密场景
+ * 1. 获取密钥别名
+ */
+ /*
+ * 2. 获取待解密的密文
+ */
+ /*
+ * 3. 获取解密算法参数配置
+ */
+ let decryptOptions = getDesDecryptProperties()
+ let options: huks.HuksOptions = {
+ properties: decryptOptions,
+ inData: cipherData
+ }
+ /*
+ * 4. 调用initSession获取handle
+ */
+ await huks.initSession(desKeyAlias, options)
+ .then((data) => {
+ handle = data.handle;
+ }).catch((error: Error) => {
+ console.error(`promise: init DecryptData failed, ${JSON.stringify(error)}`);
+ })
+ /*
+ * 5. 调用finishSession获取解密后的数据
+ */
+ await huks.finishSession(handle, options)
+ .then((data) => {
+ console.info(`promise: decrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ }).catch((error: Error) => {
+ console.error(`promise: decrypt data failed, ${JSON.stringify(error)}`);
+ })
+}
+
+async function deleteKey() {
+ /*
+ * 模拟删除密钥场景
+ * 1. 获取密钥别名
+ */
+ let emptyOptions: huks.HuksOptions = {
+ properties: []
+ }
+ /*
+ * 2. 调用deleteKeyItem删除密钥
+ */
+ await huks.deleteKeyItem(desKeyAlias, emptyOptions)
+ .then((data) => {
+ console.info(`promise: delete data success`);
+ }).catch((error: Error) => {
+ console.error(`promise: delete data failed, ${JSON.stringify(error)}`);
+ })
+}
+
+
+// [End encrypt_and_decrypt_DESCBCNoPadding]
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'DES/CBC/NoPadding';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.des_cbc_nopadding'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ try {
+ await generateDesKey();
+ await encryptData();
+ await decryptData();
+ await deleteKey();
+ this.message = 'DES/CBC/NoPadding Result: Success';
+ } catch {
+ this.message = 'DES/CBC/NoPadding Result: Failed';
+ }
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/Index.ets b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..4a8ef939c05bc643e6c753e9b4d5da1b9cfb9a33
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2025 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 { router } from '@kit.ArkUI';
+import testNapi from 'libentry.so';
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'EncryptionDecryptionArkTS';
+
+ goToSample(url: string): void {
+ router.pushUrl({
+ url: url,
+ }, router.RouterMode.Single, (err) => {
+ if (err) {
+ console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
+ return;
+ }
+ console.info('pushUrl success');
+ })
+ }
+
+ build() {
+ Column({ space: 5 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.enc_aes_cbc_pkcs7'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/AESCBCPKCS7')
+ })
+ Button($r('app.string.enc_aes_gcm_nopadding'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/AESGCMNoPadding')
+ })
+ Button($r('app.string.enc_rsa_ecb_pkcs1_v1_5'))
+ .width('70%')
+ .onClick(() => {
+ this.goToSample('pages/RSAECBPKCS1_V1_5')
+ })
+ Button($r('app.string.enc_rsa_ecb_oaep_sha256'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/RSAECBOAEPSHA256')
+ })
+ Button($r('app.string.enc_sm2'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/SM2')
+ })
+ Button($r('app.string.enc_des_cbc_nopadding'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/DESCBCNoPadding')
+ })
+ Button($r('app.string.call_cpp_enc_dec'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ let ret: number = testNapi.encDecKey();
+ this.message = 'Call C/C++ Result: ' + ret.toString();
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBOAEPSHA256.ets b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBOAEPSHA256.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7945f06ccbcf6e9a8227f76168a922231f212ddb
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBOAEPSHA256.ets
@@ -0,0 +1,261 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start encrypt_and_decrypt_RSAECBOAEPSHA256]
+/*
+ * 以下以RSA/ECB/OAEP/SHA256模式的Promise操作使用为例
+ */
+import { huks } from '@kit.UniversalKeystoreKit';
+
+let rsaKeyAlias = 'test_rsaKeyAlias';
+let handle: number;
+let plainText = '123456';
+let cipherData: Uint8Array;
+
+function stringToUint8Array(str: String) {
+ let arr: number[] = [];
+ for (let i = 0, j = str.length; i < j; ++i) {
+ arr.push(str.charCodeAt(i));
+ }
+ return new Uint8Array(arr);
+}
+
+function uint8ArrayToString(fileData: Uint8Array) {
+ let dataString = '';
+ for (let i = 0; i < fileData.length; i++) {
+ dataString += String.fromCharCode(fileData[i]);
+ }
+ return dataString;
+}
+
+function getRsaGenerateProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_RSA
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT |
+ huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
+ }];
+ return properties;
+}
+
+function getRsaEncryptProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_RSA
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_OAEP
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_ECB
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256
+ }];
+ return properties;
+}
+
+function getRsaDecryptProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_RSA
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_OAEP
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_ECB
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256
+ }];
+ return properties;
+}
+
+async function generateRsaKey() {
+ /*
+ * 模拟生成密钥场景
+ * 1. 确定密钥别名
+ */
+ /*
+ * 2. 获取生成密钥算法参数配置
+ */
+ let genProperties = getRsaGenerateProperties();
+ let options: huks.HuksOptions = {
+ properties: genProperties
+ }
+ /*
+ * 3. 调用generateKeyItem
+ */
+ await huks.generateKeyItem(rsaKeyAlias, options)
+ .then((data) => {
+ console.info(`promise: generate RSA Key success, data = ${JSON.stringify(data)}`);
+ }).catch((error: Error) => {
+ console.error(`promise: generate RSA Key failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+}
+
+async function encryptData() {
+ /*
+ * 模拟加密场景
+ * 1. 获取密钥别名
+ */
+ /*
+ * 2. 获取待加密的数据
+ */
+ /*
+ * 3. 获取加密算法参数配置
+ */
+ let encryptProperties = getRsaEncryptProperties();
+ let options: huks.HuksOptions = {
+ properties: encryptProperties,
+ inData: stringToUint8Array(plainText)
+ }
+ /*
+ * 4. 调用initSession获取handle
+ */
+ await huks.initSession(rsaKeyAlias, options)
+ .then((data) => {
+ handle = data.handle;
+ }).catch((error: Error) => {
+ console.error(`promise: init EncryptDataRsa failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+ /*
+ * 5. 调用finishSession获取加密后的密文
+ */
+ await huks.finishSession(handle, options)
+ .then((data) => {
+ console.info(`promise: encrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ cipherData = data.outData as Uint8Array;
+ }).catch((error: Error) => {
+ console.error(`promise: encrypt data failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+}
+
+async function decryptData() {
+ /*
+ * 模拟解密场景
+ * 1. 获取密钥别名
+ */
+ /*
+ * 2. 获取待解密的密文
+ */
+ /*
+ * 3. 获取解密算法参数配置
+ */
+ let decryptOptions = getRsaDecryptProperties()
+ let options: huks.HuksOptions = {
+ properties: decryptOptions,
+ inData: cipherData
+ }
+ /*
+ * 4. 调用initSession获取handle
+ */
+ await huks.initSession(rsaKeyAlias, options)
+ .then((data) => {
+ handle = data.handle;
+ }).catch((error: Error) => {
+ console.error(`promise: init DecryptDataRsa failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+ /*
+ * 5. 调用finishSession获取解密后的数据
+ */
+ await huks.finishSession(handle, options)
+ .then((data) => {
+ console.info(`promise: decrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ }).catch((error: Error) => {
+ console.error(`promise: decrypt data failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+}
+
+async function deleteKey() {
+ /*
+ * 模拟删除密钥场景
+ * 1. 获取密钥别名
+ */
+ let emptyOptions: huks.HuksOptions = {
+ properties: []
+ }
+ /*
+ * 2. 调用deleteKeyItem删除密钥
+ */
+ await huks.deleteKeyItem(rsaKeyAlias, emptyOptions)
+ .then((data) => {
+ console.info(`promise: delete data success`);
+ }).catch((error: Error) => {
+ console.error(`promise: delete data failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+}
+
+
+// [End encrypt_and_decrypt_RSAECBOAEPSHA256]
+@Entry
+@Component
+struct Index {
+ @State message: string = 'RSA/ECB/OAEP/SHA256';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message).fontSize(20)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.rsa_ecb_oaep_sha256'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ try {
+ await generateRsaKey();
+ await encryptData();
+ await decryptData();
+ await deleteKey();
+ this.message = 'RSA/ECB/OAEP/SHA256 Result: Success';
+ } catch {
+ this.message = 'RSA/ECB/OAEP/SHA256 Result: Failed';
+ }
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBPKCS1_V1_5.ets b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBPKCS1_V1_5.ets
new file mode 100644
index 0000000000000000000000000000000000000000..ebb254d4221eec277ae1d08202b59a28ca71dba1
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBPKCS1_V1_5.ets
@@ -0,0 +1,262 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start encrypt_and_decrypt_RSAECBPKCS1_V1_5]
+/*
+ * 以下以RSA/ECB/PKCS1_V1_5模式的Promise操作使用为例
+ */
+import { huks } from '@kit.UniversalKeystoreKit';
+
+let rsaKeyAlias = 'test_rsaKeyAlias';
+let handle: number;
+let plainText = '123456';
+let cipherData: Uint8Array;
+
+function stringToUint8Array(str: String) {
+ let arr: number[] = [];
+ for (let i = 0, j = str.length; i < j; ++i) {
+ arr.push(str.charCodeAt(i));
+ }
+ return new Uint8Array(arr);
+}
+
+function uint8ArrayToString(fileData: Uint8Array) {
+ let dataString = '';
+ for (let i = 0; i < fileData.length; i++) {
+ dataString += String.fromCharCode(fileData[i]);
+ }
+ return dataString;
+}
+
+function getRsaGenerateProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_RSA
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT |
+ huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
+ }];
+ return properties;
+}
+
+function getRsaEncryptProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_RSA
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_ECB
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_NONE
+ }];
+ return properties;
+}
+
+function getRsaDecryptProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_RSA
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_ECB
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_NONE
+ }];
+ return properties;
+}
+
+async function generateRsaKey() {
+ /*
+ * 模拟生成密钥场景
+ * 1. 确定密钥别名
+ */
+ /*
+ * 2. 获取生成密钥算法参数配置
+ */
+ let genProperties = getRsaGenerateProperties();
+ let options: huks.HuksOptions = {
+ properties: genProperties
+ }
+ /*
+ * 3. 调用generateKeyItem
+ */
+ await huks.generateKeyItem(rsaKeyAlias, options)
+ .then((data) => {
+ console.info(`promise: generate RSA Key success, data = ${JSON.stringify(data)}`);
+ }).catch((error: Error) => {
+ console.error(`promise: generate RSA Key failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+}
+
+async function encryptData() {
+ /*
+ * 模拟加密场景
+ * 1. 获取密钥别名
+ */
+ /*
+ * 2. 获取待加密的数据
+ */
+ /*
+ * 3. 获取加密算法参数配置
+ */
+ let encryptProperties = getRsaEncryptProperties();
+ let options: huks.HuksOptions = {
+ properties: encryptProperties,
+ inData: stringToUint8Array(plainText)
+ }
+ /*
+ * 4. 调用initSession获取handle
+ */
+ await huks.initSession(rsaKeyAlias, options)
+ .then((data) => {
+ handle = data.handle;
+ }).catch((error: Error) => {
+ console.error(`promise: init EncryptDataRsa failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+ /*
+ * 5. 调用finishSession获取加密后的密文
+ */
+ await huks.finishSession(handle, options)
+ .then((data) => {
+ console.info(`promise: encrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ cipherData = data.outData as Uint8Array;
+ }).catch((error: Error) => {
+ console.error(`promise: encrypt data failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+}
+
+async function decryptData() {
+ /*
+ * 模拟解密场景
+ * 1. 获取密钥别名
+ */
+ /*
+ * 2. 获取待解密的密文
+ */
+ /*
+ * 3. 获取解密算法参数配置
+ */
+ let decryptOptions = getRsaDecryptProperties()
+ let options: huks.HuksOptions = {
+ properties: decryptOptions,
+ inData: cipherData
+ }
+ /*
+ * 4. 调用initSession获取handle
+ */
+ await huks.initSession(rsaKeyAlias, options)
+ .then((data) => {
+ handle = data.handle;
+ }).catch((error: Error) => {
+ console.error(`promise: init DecryptDataRsa failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+ /*
+ * 5. 调用finishSession获取解密后的数据
+ */
+ await huks.finishSession(handle, options)
+ .then((data) => {
+ console.info(`promise: decrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ }).catch((error: Error) => {
+ console.error(`promise: decrypt data failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+}
+
+async function deleteKey() {
+ /*
+ * 模拟删除密钥场景
+ * 1. 获取密钥别名
+ */
+ let emptyOptions: huks.HuksOptions = {
+ properties: []
+ }
+ /*
+ * 2. 调用deleteKeyItem删除密钥
+ */
+ await huks.deleteKeyItem(rsaKeyAlias, emptyOptions)
+ .then((data) => {
+ console.info(`promise: delete data success`);
+ }).catch((error: Error) => {
+ console.error(`promise: delete data failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+}
+
+
+
+// [End encrypt_and_decrypt_RSAECBPKCS1_V1_5]
+@Entry
+@Component
+struct Index {
+ @State message: string = 'RSA/ECB/PKCS1_V1_5';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.rsa_ecb_pkcs1_v1_5'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ try {
+ await generateRsaKey();
+ await encryptData();
+ await decryptData();
+ let ret = await deleteKey();
+ this.message = 'RSA/ECB/PKCS1_V1_5 Result: Success';
+ } catch {
+ this.message = 'RSA/ECB/PKCS1_V1_5 Result: Failed';
+ }
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/SM2.ets b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/SM2.ets
new file mode 100644
index 0000000000000000000000000000000000000000..22aa2786362cc50b1f82b68a87c71d34e1a6c604
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/SM2.ets
@@ -0,0 +1,250 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start encrypt_and_decrypt_SM2]
+/*
+ * 以下以SM2模式的Promise操作使用为例
+ */
+import { huks } from '@kit.UniversalKeystoreKit';
+
+let sm2KeyAlias = 'test_sm2KeyAlias';
+let handle: number;
+let plainText = '123456';
+let cipherData: Uint8Array;
+
+function stringToUint8Array(str: String) {
+ let arr: number[] = [];
+ for (let i = 0, j = str.length; i < j; ++i) {
+ arr.push(str.charCodeAt(i));
+ }
+ return new Uint8Array(arr);
+}
+
+function uint8ArrayToString(fileData: Uint8Array) {
+ let dataString = '';
+ for (let i = 0; i < fileData.length; i++) {
+ dataString += String.fromCharCode(fileData[i]);
+ }
+ return dataString;
+}
+
+function getSm2GenerateProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_SM2
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_SM2_KEY_SIZE_256
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT |
+ huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
+ }];
+ return properties;
+}
+
+function getSm2EncryptProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_SM2
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_SM2_KEY_SIZE_256
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SM3
+ }];
+ return properties;
+}
+
+function getSm2DecryptProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_SM2
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_SM2_KEY_SIZE_256
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SM3
+ }];
+ return properties;
+}
+
+async function generateSm2Key() {
+ /*
+ * 模拟生成密钥场景
+ * 1. 确定密钥别名
+ */
+ /*
+ * 2. 获取生成密钥算法参数配置
+ */
+ let genProperties = getSm2GenerateProperties();
+ let options: huks.HuksOptions = {
+ properties: genProperties
+ }
+ /*
+ * 3. 调用generateKeyItem
+ */
+ await huks.generateKeyItem(sm2KeyAlias, options)
+ .then((data) => {
+ console.info(`promise: generate SM2 Key success, data = ${JSON.stringify(data)}`);
+ }).catch((error: Error) => {
+ console.error(`promise: generate SM2 Key failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+}
+
+async function encryptDataSm2() {
+ /*
+ * 模拟加密场景
+ * 1. 获取密钥别名
+ */
+ /*
+ * 2. 获取待加密的数据
+ */
+ /*
+ * 3. 获取加密算法参数配置
+ */
+ let encryptProperties = getSm2EncryptProperties();
+ let options: huks.HuksOptions = {
+ properties: encryptProperties,
+ inData: stringToUint8Array(plainText)
+ }
+ /*
+ * 4. 调用initSession获取handle
+ */
+ await huks.initSession(sm2KeyAlias, options)
+ .then((data) => {
+ handle = data.handle;
+ }).catch((error: Error) => {
+ console.error(`promise: init EncryptDataSm2 failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+ /*
+ * 5. 调用finishSession获取加密后的密文
+ */
+ await huks.finishSession(handle, options)
+ .then((data) => {
+ console.info(`promise: encrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ cipherData = data.outData as Uint8Array;
+ }).catch((error: Error) => {
+ console.error(`promise: encrypt data failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+}
+
+async function decryptDataSm2() {
+ /*
+ * 模拟解密场景
+ * 1. 获取密钥别名
+ */
+ /*
+ * 2. 获取待解密的密文
+ */
+ /*
+ * 3. 获取解密算法参数配置
+ */
+ let decryptOptions = getSm2DecryptProperties()
+ let options: huks.HuksOptions = {
+ properties: decryptOptions,
+ inData: cipherData
+ }
+ /*
+ * 4. 调用initSession获取handle
+ */
+ await huks.initSession(sm2KeyAlias, options)
+ .then((data) => {
+ handle = data.handle;
+ }).catch((error: Error) => {
+ console.error(`promise: init DecryptDataSm2 failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+ /*
+ * 5. 调用finishSession获取解密后的数据
+ */
+ await huks.finishSession(handle, options)
+ .then((data) => {
+ console.info(`promise: decrypt data success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ }).catch((error: Error) => {
+ console.error(`promise: decrypt data failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+}
+
+async function deleteKey() {
+ /*
+ * 模拟删除密钥场景
+ * 1. 获取密钥别名
+ */
+ let emptyOptions: huks.HuksOptions = {
+ properties: []
+ }
+ /*
+ * 2. 调用deleteKeyItem删除密钥
+ */
+ await huks.deleteKeyItem(sm2KeyAlias, emptyOptions)
+ .then((data) => {
+ console.info(`promise: delete data success`);
+ }).catch((error: Error) => {
+ console.error(`promise: delete data failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+}
+
+
+// [End encrypt_and_decrypt_SM2]
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'SM2';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.sm2'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ try {
+ await generateSm2Key();
+ await encryptDataSm2();
+ await decryptDataSm2();
+ await deleteKey();
+ this.message = 'SM2 Result: Success';
+ } catch {
+ this.message = 'SM2 Result: Failed';
+ }
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/module.json5 b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..4144486d1af4c03b0d767cce1cda86fc0d697f91
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/module.json5
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/element/color.json b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/element/string.json b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..f018573ea7152f5132ab29eeb117282cc591af07
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,72 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "EncryptionDecryption"
+ },
+ {
+ "name": "aes_cbc_pkcs7",
+ "value": "Call AES/CBC/PKCS7"
+ },
+ {
+ "name": "aes_gcm_nopadding",
+ "value": "Call AES/GCM/NoPadding"
+ },
+ {
+ "name": "rsa_ecb_pkcs1_v1_5",
+ "value": "Call RSA/ECB/PKCS1_V1_5"
+ },
+ {
+ "name": "rsa_ecb_oaep_sha256",
+ "value": "Call RSA/ECB/OAEP/SHA256"
+ },
+ {
+ "name": "sm2",
+ "value": "Call SM2"
+ },
+ {
+ "name": "des_cbc_nopadding",
+ "value": "Call DES/CBC/NoPadding"
+ },
+ {
+ "name": "call_cpp",
+ "value": "Call C/C++"
+ },
+ {
+ "name": "enc_aes_cbc_pkcs7",
+ "value": "AES/CBC/PKCS7"
+ },
+ {
+ "name": "enc_aes_gcm_nopadding",
+ "value": "AES/GCM/NoPadding"
+ },
+ {
+ "name": "enc_rsa_ecb_pkcs1_v1_5",
+ "value": "RSA/ECB/PKCS1_V1_5"
+ },
+ {
+ "name": "enc_rsa_ecb_oaep_sha256",
+ "value": "RSA/ECB/OAEP/SHA256"
+ },
+ {
+ "name": "enc_sm2",
+ "value": "SM2"
+ },
+ {
+ "name": "enc_des_cbc_nopadding",
+ "value": "DES/CBC/NoPadding"
+ },
+ {
+ "name": "call_cpp_enc_dec",
+ "value": "Call C/C++"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/background.png b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/background.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/foreground.png b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/foreground.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/layered_image.json b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/startIcon.png b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/profile/backup_config.json b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/profile/main_pages.json b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..1045fc56e65ca66ff74d80ada1114bbeda1ef8d4
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,11 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/AESCBCPKCS7",
+ "pages/AESGCMNoPadding",
+ "pages/RSAECBOAEPSHA256",
+ "pages/RSAECBPKCS1_V1_5",
+ "pages/DESCBCNoPadding",
+ "pages/SM2"
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/dark/element/color.json b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/dark/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/resources/dark/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#000000"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/ets/test/Ability.test.ets b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/ets/test/EncryptionDecryption.test.ets b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/ets/test/EncryptionDecryption.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..e68e966f2e116972c88657890735a3987e84c7d8
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/ets/test/EncryptionDecryption.test.ets
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, it, expect, beforeAll } from '@ohos/hypium';
+// 导入测试依赖kit
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+let want: Want;
+
+export default function encryptionDecryptionTest() {
+ describe('encryptionDecryptionTest', () => {
+ /**
+ * 打开应用
+ */
+ beforeAll(async () => {
+ want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ await driver.delayMs(1000);
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ })
+
+ /**
+ * 点击按钮,加解密AES/CBC/PKCS7
+ */
+ it('testEncryptionDecryption001', 0, async () => {
+ console.info('uitest: testEncryptionDecryption001 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('AES/CBC/PKCS7'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('Call AES/CBC/PKCS7'));
+ await button2.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('AES/CBC/PKCS7 Result: Success'));
+ console.info('uitest: testEncryptionDecryption001 end');
+ await driver.pressBack();
+ })
+
+ /**
+ * 点击按钮,加解密AES/GCM/NoPadding
+ */
+ it('testEncryptionDecryption002', 0, async () => {
+ console.info('uitest: testEncryptionDecryption002 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('AES/GCM/NoPadding'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('Call AES/GCM/NoPadding'));
+ await button2.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('AES/GCM/NoPadding Result: Success'));
+ console.info('uitest: testEncryptionDecryption002 end');
+ await driver.pressBack();
+ })
+
+ /**
+ * 点击按钮,加解密RSA/ECB/PKCS1_V1_5
+ */
+ it('testEncryptionDecryption003', 0, async () => {
+ console.info('uitest: testEncryptionDecryption003 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('RSA/ECB/PKCS1_V1_5'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('Call RSA/ECB/PKCS1_V1_5'));
+ await button2.click();
+ await driver.delayMs(3500);
+ await driver.assertComponentExist(ON.text('RSA/ECB/PKCS1_V1_5 Result: Success'));
+ console.info('uitest: testEncryptionDecryption003 end');
+ await driver.pressBack();
+ })
+
+ /**
+ * 点击按钮,加解密RSA/ECB/OAEP/SHA256
+ */
+ it('testEncryptionDecryption004', 0, async () => {
+ console.info('uitest: testEncryptionDecryption004 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('RSA/ECB/OAEP/SHA256'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('Call RSA/ECB/OAEP/SHA256'));
+ await button2.click();
+ await driver.delayMs(3500);
+ await driver.assertComponentExist(ON.text('RSA/ECB/OAEP/SHA256 Result: Success'));
+ console.info('uitest: testEncryptionDecryption004 end');
+ await driver.pressBack();
+ })
+
+ /**
+ * 点击按钮,加解密SM2
+ */
+ it('testEncryptionDecryption005', 0, async () => {
+ console.info('uitest: testEncryptionDecryption005 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('SM2'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('Call SM2'));
+ await button2.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('SM2 Result: Success'));
+ console.info('uitest: testEncryptionDecryption005 end');
+ await driver.pressBack();
+ })
+
+ /**
+ * 点击按钮,加解密C/C++
+ */
+ it('testEncryptionDecryption006', 0, async () => {
+ console.info('uitest: testEncryptionDecryption006 begin');
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('Call C/C++'));
+ await button2.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('Call C/C++ Result: 0'));
+ console.info('uitest: testEncryptionDecryption006 end');
+ })
+
+ /**
+ * 点击按钮,加解密DES/CBC/NoPadding
+ */
+ it('testEncryptionDecryption007', 0, async () => {
+ console.info('uitest: testEncryptionDecryption007 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('DES/CBC/NoPadding'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('Call DES/CBC/NoPadding'));
+ await button2.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('DES/CBC/NoPadding Result: Success'));
+ console.info('uitest: testEncryptionDecryption007 end');
+ await driver.pressBack();
+ await driver.pressBack();
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/ets/test/List.test.ets b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..ffb74246d27b90bd3125360211d229aede2ed555
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 abilityTest from './Ability.test';
+import encryptionDecryptionTest from './EncryptionDecryption.test';
+
+export default function testsuite() {
+ encryptionDecryptionTest();
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/module.json5 b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/test/List.test.ets b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/test/LocalUnit.test.ets b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/hvigor/hvigor-config.json5 b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..d584c19c247db9a7caee4b606bb931aa9279c637
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/hvigorfile.ts b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/oh-package.json5 b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e41bae026aab3b50d0abb42fece08ba43b4a772b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/ohosTest.md b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..f638f4014234ff0551ec918ff0a0d12e27899d1a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/ohosTest.md
@@ -0,0 +1,13 @@
+# 密钥加解密测试用例归档
+
+## 用例表
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ----------------------------------- | ------------ | ---- | ------------------ | -------- | -------- |
+| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass |
+| 点击按钮,加解密AES/CBC/PKCS7 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
+| 点击按钮,加解密AES/GCM/NoPadding | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
+| 点击按钮,加解密RSA/ECB/PKCS1_V1_5 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
+| 点击按钮,加解密RSA/ECB/OAEP/SHA256 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
+| 点击按钮,加解密SM2 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
+| 点击按钮,加解密C/C++ | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESCBCPKCS7_1.png b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESCBCPKCS7_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..246c5b8f16be0e6d97dfee2d384f24e3143bd5be
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESCBCPKCS7_1.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESCBCPKCS7_2.png b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESCBCPKCS7_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..3640f34e6f4373080601b02ba3eb2dc35866d4be
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESCBCPKCS7_2.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESGCMNoPadding_1.png b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESGCMNoPadding_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..152f860d96646936ca22ebaf4d4f9986278f2336
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESGCMNoPadding_1.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESGCMNoPadding_2.png b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESGCMNoPadding_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..d3f6a60adef2dd3caafd319ffebdec6659727f27
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/AESGCMNoPadding_2.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/Cpp_1.png b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/Cpp_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..19b0ad040ca40700788b4447ff3e981932ca31f6
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/Cpp_1.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/Cpp_2.png b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/Cpp_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..638ef2fe573d2e0ccd63dba647f6bfc9431c5784
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/Cpp_2.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBOAEPSHA256_1.png b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBOAEPSHA256_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..a68b26374dc631b6bab85fd6a823a1994d334b91
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBOAEPSHA256_1.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBOAEPSHA256_2.png b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBOAEPSHA256_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..845c38cba5fbb00a26576a156714491e14c605de
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBOAEPSHA256_2.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBPKCS1_V1_5_1.png b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBPKCS1_V1_5_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..caebc665383bf9dc1c235481776738d9d92440e3
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBPKCS1_V1_5_1.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBPKCS1_V1_5_2.png b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBPKCS1_V1_5_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..c943250700a8ca4541272d00ad60d548c8f408dd
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/RSAECBPKCS1_V1_5_2.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/SM2_1.png b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/SM2_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..cdfbfb8501ccb925d34c0ccf19bfc7a6986ea202
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/SM2_1.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/SM2_2.png b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/SM2_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..365f3085a7e53b22fc2368af8f4633914d2d4ffe
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/screenshots/SM2_2.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/.gitignore b/UniversalKeystoreKit/KeyUsage/HMAC/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/AppScope/app.json5 b/UniversalKeystoreKit/KeyUsage/HMAC/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..007435cf8c28359cb1e59eff3c6b247549df35ca
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.hmac",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/AppScope/resources/base/element/string.json b/UniversalKeystoreKit/KeyUsage/HMAC/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..029ee36507cfbae7faf39e9d91238ab70189bf55
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "HMAC"
+ }
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/AppScope/resources/base/media/app_icon.png b/UniversalKeystoreKit/KeyUsage/HMAC/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/HMAC/AppScope/resources/base/media/app_icon.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/README.md b/UniversalKeystoreKit/KeyUsage/HMAC/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..120e57156740123d02a3f9d37818202efc84436b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/README.md
@@ -0,0 +1,91 @@
+## HMAC(ArkTS)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-hmac-arkts.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### HMAC
+
+##### 介绍
+
+1. 本示例主要介绍HMAC,HMAC是密钥相关的哈希运算消息认证码(Hash-based Message Authentication Code),是一种基于Hash函数和密钥进行消息认证的方法。
+
+##### 效果预览
+
+| 主页 | 删除 |
+| --------------------------------------------------- | --------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击Call HMAC按钮确定密钥别名生成密钥并获取密钥别名和待哈希数据,获取 HMAC 算法参数配置。
+
+## HMAC(C/C++)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-hmac-ndk.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### Call C/C++
+
+##### 介绍
+
+1. 本示例主要介绍HMAC,HMAC是密钥相关的哈希运算消息认证码(Hash-based Message Authentication Code),是一种基于Hash函数和密钥进行消息认证的方法。
+
+##### 效果预览
+
+| 主页 | |
+| -------------------------------------------------- | -------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击Call C/C++按钮确定密钥别名生成密钥并获取密钥别名和待哈希数据,获取 HMAC 算法参数配置。
+
+## 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---HWAC.ets
+|---|---|---Index.ets // 首页
+|---cpp
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---HMAC.test.ets // 自动化测试用例
+```
+
+## 相关权限
+
+无。
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo UniversalKeystoreKit/KeyUsage/HMAC > .git/info/sparse-checkout
+git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git
+git pull origin master
+```
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/build-profile.json5 b/UniversalKeystoreKit/KeyUsage/HMAC/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..7dff2433b63be15bfc69a62ef9c59f2530684dbe
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/build-profile.json5
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ "buildOption": {
+ "strictMode": {
+ "caseSensitiveCheck": true,
+ "useNormalizedOHMUrl": true
+ }
+ }
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/code-linter.json5 b/UniversalKeystoreKit/KeyUsage/HMAC/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/.gitignore b/UniversalKeystoreKit/KeyUsage/HMAC/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/build-profile.json5 b/UniversalKeystoreKit/KeyUsage/HMAC/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2d8b081b615348a99aa197f90186f3d8891b7dc1
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/build-profile.json5
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ "externalNativeOptions": {
+ "path": "./src/main/cpp/CMakeLists.txt",
+ "arguments": "",
+ "cppFlags": "",
+ "abiFilters": [
+ "arm64-v8a",
+ "x86_64"
+ ]
+ }
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ },
+ "nativeLib": {
+ "debugSymbol": {
+ "strip": true,
+ "exclude": []
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/hvigorfile.ts b/UniversalKeystoreKit/KeyUsage/HMAC/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/oh-package.json5 b/UniversalKeystoreKit/KeyUsage/HMAC/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..118bdd4fe7699368a010e04c24f5bfc887cf1298
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/oh-package.json5
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {
+ "libentry.so": "file:./src/main/cpp/types/libentry"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/CMakeLists.txt b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..4b42dae94126fb56900e47244f760770ba8ec0c0
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,15 @@
+# the minimum version of CMake.
+cmake_minimum_required(VERSION 3.5.0)
+project(HMAC)
+
+set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+if(DEFINED PACKAGE_FIND_FILE)
+ include(${PACKAGE_FIND_FILE})
+endif()
+
+include_directories(${NATIVERENDER_ROOT_PATH}
+ ${NATIVERENDER_ROOT_PATH}/include)
+
+add_library(entry SHARED napi_init.cpp)
+target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so)
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/napi_init.cpp b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/napi_init.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..88bc17699fb8271ebc105f80a19bbcb1cdda6f70
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/napi_init.cpp
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start hmac]
+#include "huks/native_huks_api.h"
+#include "huks/native_huks_param.h"
+#include "napi/native_api.h"
+#include
+
+OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params,
+ uint32_t paramCount)
+{
+ OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_AddParams(*paramSet, params, paramCount);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ ret = OH_Huks_BuildParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ return ret;
+}
+
+static struct OH_Huks_Param g_genHmacParams[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_HMAC},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_MAC},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256},
+ {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA384}};
+
+static const uint32_t HMAC_COMMON_SIZE = 1024;
+OH_Huks_Result HksHmacTest(const struct OH_Huks_Blob *keyAlias, const struct OH_Huks_ParamSet *hmacParamSet,
+ const struct OH_Huks_Blob *inData, struct OH_Huks_Blob *hashText)
+{
+ uint8_t handleE[sizeof(uint64_t)] = {0};
+ struct OH_Huks_Blob handle = {sizeof(uint64_t), handleE};
+ OH_Huks_Result ret = OH_Huks_InitSession(keyAlias, hmacParamSet, &handle, nullptr);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_FinishSession(&handle, hmacParamSet, inData, hashText);
+ return ret;
+}
+
+static napi_value HmacKey(napi_env env, napi_callback_info info)
+{
+ /* 1. Generate Key */
+ /*
+ * 模拟生成密钥场景
+ * 1.1. 确定密钥别名
+ */
+ char tmpKeyAlias[] = "test_hmac";
+ struct OH_Huks_Blob keyAlias = {(uint32_t)strlen(tmpKeyAlias), (uint8_t *)tmpKeyAlias};
+ struct OH_Huks_ParamSet *hmacParamSet = nullptr;
+ OH_Huks_Result ohResult;
+ do {
+ /*
+ * 1.2. 获取生成密钥算法参数配置
+ */
+ ohResult = InitParamSet(&hmacParamSet, g_genHmacParams, sizeof(g_genHmacParams) / sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ /*
+ * 1.3. 调用generateKeyItem
+ */
+ ohResult = OH_Huks_GenerateKeyItem(&keyAlias, hmacParamSet, nullptr);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ /* 2. Hmac */
+ /*
+ * 模拟哈希场景
+ * 2.1. 获取密钥别名
+ */
+ /*
+ * 2.2. 获取待哈希的数据
+ */
+ char tmpInData[] = "HMAC_MAC_INDATA_1";
+ struct OH_Huks_Blob inData = {(uint32_t)strlen(tmpInData), (uint8_t *)tmpInData};
+ uint8_t cipher[HMAC_COMMON_SIZE] = {0};
+ struct OH_Huks_Blob hashText = {HMAC_COMMON_SIZE, cipher};
+ /*
+ * 2.3. 调用initSession获取handle
+ */
+ /*
+ * 2.4. 调用finishSession获取哈希后的内容
+ */
+ ohResult = HksHmacTest(&keyAlias, hmacParamSet, &inData, &hashText);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ } while (0);
+ OH_Huks_FreeParamSet(&hmacParamSet);
+ napi_value ret;
+ napi_create_int32(env, ohResult.errorCode, &ret);
+ return ret;
+}
+// [End hmac]
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports)
+{
+ napi_property_descriptor desc[] = {{"hmacKey", nullptr, HmacKey, nullptr, nullptr, nullptr, napi_default, nullptr}};
+ napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "entry",
+ .nm_priv = ((void *)0),
+ .reserved = {0},
+};
+
+extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); }
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/types/libentry/index.d.ts b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/types/libentry/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..97f8716a9af8a08f358e360f048a42982f04eac2
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/types/libentry/index.d.ts
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2025 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 const hmacKey: () => number;
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/types/libentry/oh-package.json5 b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/types/libentry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2826cc7d6bd199c1008bb51d898dffa922201e6c
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/types/libentry/oh-package.json5
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "libentry.so",
+ "types": "./index.d.ts",
+ "version": "1.0.0",
+ "description": "Please describe the basic information."
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/entryability/EntryAbility.ets b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..edc2839f203ba057c186e19b0cbbbf80c8faa8b3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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 { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/pages/HMAC.ets b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/pages/HMAC.ets
new file mode 100644
index 0000000000000000000000000000000000000000..edb3b5637bde20fe3ad559b166b615341d8ac63a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/pages/HMAC.ets
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start hmac_to]
+/*
+ * 以下以HMAC密钥的Promise操作使用为例
+ */
+import { huks } from '@kit.UniversalKeystoreKit';
+
+let hmacKeyAlias = 'test_HMAC';
+let handle: number;
+let plainText = '123456';
+let hashData: Uint8Array;
+
+function stringToUint8Array(str: String) {
+ let arr: number[] = [];
+ for (let i = 0, j = str.length; i < j; ++i) {
+ arr.push(str.charCodeAt(i));
+ }
+ return new Uint8Array(arr);
+}
+
+function uint8ArrayToString(fileData: Uint8Array) {
+ let dataString = '';
+ for (let i = 0; i < fileData.length; i++) {
+ dataString += String.fromCharCode(fileData[i]);
+ }
+ return dataString;
+}
+
+function getHMACProperties() {
+ const properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_HMAC
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_MAC
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SHA384,
+ }];
+ return properties;
+}
+
+async function generateHMACKey() {
+ /*
+ * 模拟生成密钥场景
+ * 1. 确定密钥别名
+ */
+ /*
+ * 2. 获取生成密钥算法参数配置
+ */
+ let genProperties = getHMACProperties();
+ let options: huks.HuksOptions = {
+ properties: genProperties
+ }
+ /*
+ * 3. 调用generateKeyItem
+ */
+ await huks.generateKeyItem(hmacKeyAlias, options)
+ .then((data) => {
+ console.info(`promise: generate HMAC Key success`);
+ }).catch((error: Error) => {
+ console.error(`promise: generate HMAC Key failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+}
+
+async function hMACData() {
+ /*
+ * 模拟HMAC场景
+ * 1. 获取密钥别名
+ */
+ /*
+ * 2. 获取待哈希的数据
+ */
+ /*
+ * 3. 获取HMAC算法参数配置
+ */
+ let hmacProperties = getHMACProperties();
+ let options: huks.HuksOptions = {
+ properties: hmacProperties,
+ inData: stringToUint8Array(plainText)
+ }
+ /*
+ * 4. 调用initSession获取handle
+ */
+ await huks.initSession(hmacKeyAlias, options)
+ .then((data) => {
+ handle = data.handle;
+ }).catch((error: Error) => {
+ console.error(`promise: init EncryptData failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+ /*
+ * 5. 调用finishSession获取HMAC的结果
+ */
+ await huks.finishSession(handle, options)
+ .then((data) => {
+ console.info(`promise: HMAC data success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ hashData = data.outData as Uint8Array;
+ }).catch((error: Error) => {
+ console.error(`promise: HMAC data failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ })
+}
+// [End hmac_to]
+@Entry
+@Component
+struct Index {
+ @State message: string = 'HMAC';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.call_hmac'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ try {
+ await generateHMACKey();
+ await hMACData();
+ this.message = 'HMAC Result: Success';
+ } catch (error) {
+ this.message = 'HMAC Result: ' + error.message;
+ }
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/pages/Index.ets b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..4cddde7d4baba7a00c26fccfa97bd30c562d4524
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2025 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 { router } from '@kit.ArkUI';
+import testNapi from 'libentry.so';
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'HMAC';
+
+ goToSample(url: string): void {
+ router.pushUrl({
+ url: url,
+ }, router.RouterMode.Single, (err) => {
+ if (err) {
+ console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
+ return;
+ }
+ console.info('pushUrl success');
+ })
+ }
+
+ build() {
+ Column({ space: 5 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.hmac'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/HMAC')
+ })
+ Button($r('app.string.call_cpp_hmac_key'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ let ret: number = testNapi.hmacKey();
+ this.message = 'Call C/C++ Result: ' + ret.toString();
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/module.json5 b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..4144486d1af4c03b0d767cce1cda86fc0d697f91
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/module.json5
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/element/color.json b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/element/string.json b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..a5a12a28d475bb307a69a1223f838f6e1819c075
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,28 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "HMAC"
+ },
+ {
+ "name": "hmac",
+ "value": "HMAC"
+ },
+ {
+ "name": "call_cpp_hmac_key",
+ "value": "Call C/C++"
+ },
+ {
+ "name": "call_hmac",
+ "value": "Call HMAC"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/background.png b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/background.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/foreground.png b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/foreground.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/layered_image.json b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/startIcon.png b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/profile/backup_config.json b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/profile/main_pages.json b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..55d301c016cc6423db194a05b50c05e3502fb16a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,6 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/HMAC"
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/dark/element/color.json b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/dark/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/resources/dark/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#000000"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/Ability.test.ets b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/HMAC.test.ets b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/HMAC.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..9555cd908701b39a6e15eaeb1edf669e8ac1dbc6
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/HMAC.test.ets
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, it, expect, beforeAll } from '@ohos/hypium';
+// 导入测试依赖kit
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+let want: Want;
+
+export default function hMACTest() {
+ describe('hMACTest', () => {
+
+ /**
+ * 打开应用
+ */
+ beforeAll(async () => {
+ want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ await driver.delayMs(1000);
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ })
+
+ /**
+ * 点击按钮,HMAC(ArkTS)
+ */
+ it('testHMAC001', 0, async () => {
+ console.info('uitest: testHMAC001 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('HMAC').type('Button'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('Call HMAC'));
+ await button2.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('HMAC Result: Success'));
+ console.info('uitest: testHMAC001 end');
+ await driver.pressBack();
+ })
+
+ /**
+ * 点击按钮,HMAC(C/C++)
+ */
+ it('testHMAC002', 0, async () => {
+ console.info('uitest: testHMAC002 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('Call C/C++'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(2000);
+ await driver.assertComponentExist(ON.text('Call C/C++ Result: 0'));
+ console.info('uitest: testHMAC002 end');
+ })
+ })
+}
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/List.test.ets b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..c054467fd688e71bf4b2a13ee0bef72b1bb4758c
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 hMACTest from './HMAC.test';
+
+export default function testsuite() {
+ hMACTest();
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/module.json5 b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/hvigor/hvigor-config.json5 b/UniversalKeystoreKit/KeyUsage/HMAC/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..d584c19c247db9a7caee4b606bb931aa9279c637
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/hvigorfile.ts b/UniversalKeystoreKit/KeyUsage/HMAC/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/oh-package.json5 b/UniversalKeystoreKit/KeyUsage/HMAC/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e41bae026aab3b50d0abb42fece08ba43b4a772b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/ohosTest.md b/UniversalKeystoreKit/KeyUsage/HMAC/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..4568f24cfecf4149b1315b844928427be60b10d9
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/HMAC/ohosTest.md
@@ -0,0 +1,9 @@
+# 密钥HMAC测试用例归档
+
+## 用例表
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| --------------------- | ------------ | ---- | ------------------ | -------- | -------- |
+| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass |
+| 点击按钮,HMAC(ArkTS) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
+| 点击按钮,HMAC(C/C++) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/HMAC_1.png b/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/HMAC_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..b99219740bd854a79df551a579ef4158131439a1
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/HMAC_1.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/HMAC_2.png b/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/HMAC_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..dc35b3f4d45c7b607dc0c6909ad1b172d37846a6
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/HMAC_2.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/cpp_1.png b/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/cpp_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..02946ae8e5a6994f7b7aef32b4604e96b8eac905
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/cpp_1.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/cpp_2.png b/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/cpp_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..d969cfd0c3f0cc56a028e56d31243cb30bb0a47c
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/HMAC/screenshots/cpp_2.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/.gitignore b/UniversalKeystoreKit/KeyUsage/KeyDerivation/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/AppScope/app.json5 b/UniversalKeystoreKit/KeyUsage/KeyDerivation/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..6defc46afc5484f3455686d18b743db44c6ffc47
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.keyderivation",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/AppScope/resources/base/element/string.json b/UniversalKeystoreKit/KeyUsage/KeyDerivation/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..96cf25cee263ecee3a2e7f67bfd7c32600f65090
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "KeyDerivation"
+ }
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/AppScope/resources/base/media/app_icon.png b/UniversalKeystoreKit/KeyUsage/KeyDerivation/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/KeyDerivation/AppScope/resources/base/media/app_icon.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/README.md b/UniversalKeystoreKit/KeyUsage/KeyDerivation/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..66dfd3ae5c1dfee0aade8969be216437ba89df2c
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/README.md
@@ -0,0 +1,109 @@
+## 密钥派生(ArkTS)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-key-derivation-arkts.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### HKDF
+
+##### 介绍
+
+1. 本示例主要介绍密钥派生,以HKDF为例,完成密钥派生。
+
+##### 效果预览
+
+| 主页 | 执行结果 |
+| --------------------------------------------------- | --------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击HKDF按钮生成密钥并派生密钥,删除密钥。
+
+#### PBKDF2
+
+##### 介绍
+
+1. 本示例主要介绍密钥派生,以PBKDF为例,完成密钥派生。
+
+##### 效果预览
+
+| 主页 | 执行结果 |
+| ----------------------------------------------------- | ----------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击PBKDF2按钮生成密钥并派生密钥,删除密钥。
+
+## 密钥派生(C/C++)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-key-derivation-ndk.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### Call C/C++
+
+##### 介绍
+
+1. 本示例主要介绍密钥派生,以HKDF256密钥为例,完成密钥派生。
+
+##### 效果预览
+
+| 主页 | 执行结果 |
+| -------------------------------------------------- | -------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击Call C/C++按钮生成密钥并派生密钥,删除密钥。
+
+## 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---HKDF.ets
+|---|---|---PBKDF2.ets
+|---|---|---Index.ets // 首页
+|---cpp
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---KeyDerivation.test.ets // 自动化测试用例
+```
+
+
+## 相关权限
+
+无。
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo UniversalKeystoreKit/KeyUsage/KeyDerivation > .git/info/sparse-checkout
+git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/build-profile.json5 b/UniversalKeystoreKit/KeyUsage/KeyDerivation/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..fb5a1ab654ae6715a0ab69a31900ad26dcf2487f
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/build-profile.json5
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ "buildOption": {
+ "strictMode": {
+ "caseSensitiveCheck": true,
+ "useNormalizedOHMUrl": true
+ }
+ }
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/code-linter.json5 b/UniversalKeystoreKit/KeyUsage/KeyDerivation/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/.gitignore b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/build-profile.json5 b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2d8b081b615348a99aa197f90186f3d8891b7dc1
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/build-profile.json5
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ "externalNativeOptions": {
+ "path": "./src/main/cpp/CMakeLists.txt",
+ "arguments": "",
+ "cppFlags": "",
+ "abiFilters": [
+ "arm64-v8a",
+ "x86_64"
+ ]
+ }
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ },
+ "nativeLib": {
+ "debugSymbol": {
+ "strip": true,
+ "exclude": []
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/hvigorfile.ts b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/oh-package.json5 b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..118bdd4fe7699368a010e04c24f5bfc887cf1298
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/oh-package.json5
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {
+ "libentry.so": "file:./src/main/cpp/types/libentry"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/CMakeLists.txt b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..183f2308d472e51823c051c79ee98f55f159f479
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,15 @@
+# the minimum version of CMake.
+cmake_minimum_required(VERSION 3.5.0)
+project(KeyDerivation)
+
+set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+if(DEFINED PACKAGE_FIND_FILE)
+ include(${PACKAGE_FIND_FILE})
+endif()
+
+include_directories(${NATIVERENDER_ROOT_PATH}
+ ${NATIVERENDER_ROOT_PATH}/include)
+
+add_library(entry SHARED napi_init.cpp)
+target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so)
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/napi_init.cpp b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/napi_init.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..40a395dfd01c48188515ec539ae4089daad1faef
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/napi_init.cpp
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start key_derivation]
+#include "huks/native_huks_api.h"
+#include "huks/native_huks_param.h"
+#include "napi/native_api.h"
+#include
+
+OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params,
+ uint32_t paramCount)
+{
+ OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_AddParams(*paramSet, params, paramCount);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ ret = OH_Huks_BuildParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ return ret;
+}
+static const uint32_t DERIVE_KEY_SIZE_32 = 32;
+static const uint32_t DERIVE_KEY_SIZE_256 = 256;
+static struct OH_Huks_Blob g_deriveKeyAlias = {(uint32_t)strlen("test_derive"), (uint8_t *)"test_derive"};
+static struct OH_Huks_Param g_genDeriveParams[] = {
+ {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_DERIVE},
+ {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA256},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256}};
+static struct OH_Huks_Param g_hkdfParams[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_HKDF},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_DERIVE},
+ {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA256},
+ {.tag = OH_HUKS_TAG_DERIVE_KEY_SIZE, .uint32Param = DERIVE_KEY_SIZE_32}};
+static struct OH_Huks_Param g_hkdfFinishParams[] = {
+ {.tag = OH_HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, .uint32Param = OH_HUKS_STORAGE_ONLY_USED_IN_HUKS},
+ {.tag = OH_HUKS_TAG_KEY_ALIAS, .blob = g_deriveKeyAlias},
+ {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = DERIVE_KEY_SIZE_256},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_DERIVE},
+ {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA256}};
+static const uint32_t COMMON_SIZE = 2048;
+static const char *G_DERIVE_IN_DATA = "Hks_HKDF_Derive_Test_00000000000000000000000000000000000000000000000000000000000"
+ "00000000000000000000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000000000000_string";
+static napi_value DeriveKey(napi_env env, napi_callback_info info)
+{
+ struct OH_Huks_Blob genAlias = {(uint32_t)strlen("test_signVerify"), (uint8_t *)"test_signVerify"};
+ struct OH_Huks_Blob inData = {(uint32_t)strlen(G_DERIVE_IN_DATA), (uint8_t *)G_DERIVE_IN_DATA};
+ struct OH_Huks_ParamSet *genParamSet = nullptr;
+ struct OH_Huks_ParamSet *hkdfParamSet = nullptr;
+ struct OH_Huks_ParamSet *hkdfFinishParamSet = nullptr;
+ OH_Huks_Result ohResult;
+ do {
+ ohResult = InitParamSet(&genParamSet, g_genDeriveParams, sizeof(g_genDeriveParams) /
+ sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+
+ ohResult = InitParamSet(&hkdfParamSet, g_hkdfParams, sizeof(g_hkdfParams) /
+ sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+
+ // finish paramset
+ ohResult =
+ InitParamSet(&hkdfFinishParamSet, g_hkdfFinishParams, sizeof(g_hkdfFinishParams) /
+ sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+
+ /* 1. Generate Key */
+ ohResult = OH_Huks_GenerateKeyItem(&genAlias, genParamSet, nullptr);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ /* 2. Derive */
+ // Init
+ uint8_t handleD[sizeof(uint64_t)] = {0};
+ struct OH_Huks_Blob handleDerive = {sizeof(uint64_t), handleD};
+ ohResult = OH_Huks_InitSession(&genAlias, hkdfParamSet, &handleDerive, nullptr);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ // Update
+ uint8_t tmpOut[COMMON_SIZE] = {0};
+ struct OH_Huks_Blob outData = {COMMON_SIZE, tmpOut};
+ ohResult = OH_Huks_UpdateSession(&handleDerive, hkdfParamSet, &inData, &outData);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ // Finish
+ uint8_t outDataD[COMMON_SIZE] = {0};
+ struct OH_Huks_Blob outDataDerive = {COMMON_SIZE, outDataD};
+ ohResult = OH_Huks_FinishSession(&handleDerive, hkdfFinishParamSet, &inData, &outDataDerive);
+ } while (0);
+ (void)OH_Huks_DeleteKeyItem(&genAlias, nullptr);
+ (void)OH_Huks_DeleteKeyItem(&g_deriveKeyAlias, nullptr);
+ OH_Huks_FreeParamSet(&genParamSet);
+ OH_Huks_FreeParamSet(&hkdfParamSet);
+ OH_Huks_FreeParamSet(&hkdfFinishParamSet);
+
+ napi_value ret;
+ napi_create_int32(env, ohResult.errorCode, &ret);
+ return ret;
+}
+// [End key_derivation]
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports)
+{
+ napi_property_descriptor desc[] = {
+ {"deriveKey", nullptr, DeriveKey, nullptr, nullptr, nullptr, napi_default, nullptr}};
+ napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "entry",
+ .nm_priv = ((void *)0),
+ .reserved = {0},
+};
+
+extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); }
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/types/libentry/index.d.ts b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/types/libentry/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..a15baf5bd241f5b2657003a4e76d66de97097c3d
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/types/libentry/index.d.ts
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2025 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 const deriveKey: () => number;
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/types/libentry/oh-package.json5 b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/types/libentry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2826cc7d6bd199c1008bb51d898dffa922201e6c
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/types/libentry/oh-package.json5
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "libentry.so",
+ "types": "./index.d.ts",
+ "version": "1.0.0",
+ "description": "Please describe the basic information."
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/entryability/EntryAbility.ets b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..edc2839f203ba057c186e19b0cbbbf80c8faa8b3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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 { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/HKDF.ets b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/HKDF.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0481900ea5964efd83363c3ed5698b4274d01371
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/HKDF.ets
@@ -0,0 +1,362 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+
+// [Start the_key_is_derived_from_hkdf]
+/*
+ * 以下以HKDF密钥的Promise操作使用为例
+ */
+import { huks } from '@kit.UniversalKeystoreKit';
+
+/*
+ * 确定密钥别名和封装密钥属性参数集
+ */
+let srcKeyAlias = 'hkdf_Key';
+let deriveHkdfInData = 'deriveHkdfTestIndata';
+let handle: number;
+let finishOutData: Uint8Array;
+let huksKeyDeriveKeySize = 32;
+/* 集成生成密钥参数集 */
+let properties: huks.HuksParam[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_AES,
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_128,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG,
+ value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS,
+}];
+
+let huksOptions: huks.HuksOptions = {
+ properties: properties,
+ inData: new Uint8Array([])
+}
+/* 集成init时密钥参数集 */
+let initProperties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_HKDF,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_DERIVE_KEY_SIZE,
+ value: huksKeyDeriveKeySize,
+}];
+
+let initOptions: huks.HuksOptions = {
+ properties: initProperties,
+ inData: new Uint8Array([])
+}
+/* 集成finish时密钥参数集 */
+let finishProperties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG,
+ value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_IS_KEY_ALIAS,
+ value: true,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_AES,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value:
+ huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT |
+ huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_NONE,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_ALIAS,
+ value: stringToUint8Array(srcKeyAlias),
+}, {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_NONE,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_ECB,
+}];
+let finishOptions: huks.HuksOptions = {
+ properties: finishProperties,
+ inData: new Uint8Array([])
+}
+
+function stringToUint8Array(str: String) {
+ let arr: number[] = [];
+ for (let i = 0, j = str.length; i < j; ++i) {
+ arr.push(str.charCodeAt(i));
+ }
+ return new Uint8Array(arr);
+}
+
+class ThrowObject {
+ public isThrow = false;
+}
+
+function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.generateKeyItem(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise generateKeyItem`);
+ let throwObject: ThrowObject = { isThrow: false };
+ try {
+ await generateKeyItem(keyAlias, huksOptions, throwObject)
+ .then((data) => {
+ console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+ });
+ } catch (error) {
+ console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+}
+
+function initSession(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.initSession(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicInitFunc(keyAlias: string, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise doInit`);
+ let throwObject: ThrowObject = { isThrow: false };
+ try {
+ await initSession(keyAlias, huksOptions, throwObject)
+ .then((data) => {
+ console.info(`promise: doInit success, data = ${JSON.stringify(data)}`);
+ handle = data.handle;
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: doInit failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+ });
+ } catch (error) {
+ console.error(`promise: doInit input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+}
+
+function updateSession(handle: number, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.updateSession(handle, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicUpdateFunc(handle: number, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise doUpdate`);
+ let throwObject: ThrowObject = { isThrow: false };
+ try {
+ await updateSession(handle, huksOptions, throwObject)
+ .then((data) => {
+ console.info(`promise: doUpdate success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: doUpdate failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+ });
+ } catch (error) {
+ console.error(`promise: doUpdate input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+}
+
+function finishSession(handle: number, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.finishSession(handle, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicFinishFunc(handle: number, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise doFinish`);
+ let throwObject: ThrowObject = { isThrow: false };
+ try {
+ await finishSession(handle, huksOptions, throwObject)
+ .then((data) => {
+ finishOutData = data.outData as Uint8Array;
+ console.info(`promise: doFinish success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: doFinish failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+ });
+ } catch (error) {
+ console.error(`promise: doFinish input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+}
+
+function deleteKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.deleteKeyItem(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicDeleteKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise deleteKeyItem`);
+ let throwObject: ThrowObject = { isThrow: false };
+ try {
+ await deleteKeyItem(keyAlias, huksOptions, throwObject)
+ .then((data) => {
+ console.info(`promise: deleteKeyItem key success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: deleteKeyItem failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+ });
+ } catch (error) {
+ console.error(`promise: deleteKeyItem input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+}
+
+async function testDerive() {
+ /* 生成密钥 */
+ await publicGenKeyFunc(srcKeyAlias, huksOptions);
+ /* 进行派生操作 */
+ await publicInitFunc(srcKeyAlias, initOptions);
+ initOptions.inData = stringToUint8Array(deriveHkdfInData);
+ await publicUpdateFunc(handle, initOptions);
+ await publicFinishFunc(handle, finishOptions);
+ await publicDeleteKeyFunc(srcKeyAlias, huksOptions);
+}
+// [End the_key_is_derived_from_hkdf]
+@Entry
+@Component
+struct Index {
+ @State message: string = 'HKDF';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message).fontSize(20)
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.call_hkdf'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ try {
+ let ret = await testDerive();
+ this.message = 'HKDF Result: Success';
+ } catch {
+ this.message = 'HKDF Result: Failed';
+ }
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/Index.ets b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..d7a06e9379a87cfc5a419c1bd65f620947356372
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2025 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 { router } from '@kit.ArkUI';
+import testNapi from 'libentry.so';
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'KeyDerivation';
+
+ goToSample(url: string): void {
+ router.pushUrl({
+ url: url,
+ }, router.RouterMode.Single, (err) => {
+ if (err) {
+ console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
+ return;
+ }
+ console.info('pushUrl success');
+ })
+ }
+
+ build() {
+ Column({ space: 5 }) {
+ Text(this.message)
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.hkdf'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/HKDF')
+ })
+ Button($r('app.string.pbkdf2'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/PBKDF2')
+ })
+ Button($r('app.string.call_cpp_derive_key'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ let ret: number = testNapi.deriveKey();
+ this.message = 'Call C/C++ Result: ' + ret.toString();
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/PBKDF2.ets b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/PBKDF2.ets
new file mode 100644
index 0000000000000000000000000000000000000000..8dfd360cd89b36121e13308bb79a5b8f055dfa51
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/PBKDF2.ets
@@ -0,0 +1,373 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start the_key_is_derived_from_pbkdf2]
+/*
+ * 以下以PBKDF2密钥的Promise操作使用为例
+ */
+import { huks } from '@kit.UniversalKeystoreKit';
+
+/*
+ * 确定密钥别名和封装密钥属性参数集
+ */
+let srcKeyAlias = 'pbkdf2_Key';
+let salt = 'mySalt';
+let iterationCount = 10000;
+let derivedKeySize = 32;
+let handle: number;
+let finishOutData: Uint8Array;
+
+/* 集成生成密钥参数集 */
+let properties: huks.HuksParam[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_AES,
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG,
+ value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS,
+}
+];
+
+let huksOptions: huks.HuksOptions = {
+ properties: properties,
+ inData: new Uint8Array([])
+}
+
+/* 集成init时密钥参数集 */
+let initProperties: huks.HuksParam[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_PBKDF2,
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DERIVE,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_DERIVE_KEY_SIZE,
+ value: derivedKeySize,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_ITERATION,
+ value: iterationCount,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_SALT,
+ value: stringToUint8Array(salt),
+}
+];
+
+let initOptions: huks.HuksOptions = {
+ properties: initProperties,
+ inData: new Uint8Array([])
+}
+
+/* 集成finish时密钥参数集 */
+let finishProperties: huks.HuksParam[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG,
+ value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS,
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_IS_KEY_ALIAS,
+ value: true,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_AES,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_NONE,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_ALIAS,
+ value: stringToUint8Array(srcKeyAlias),
+}, {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_NONE,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_ECB,
+}
+];
+
+let finishOptions: huks.HuksOptions = {
+ properties: finishProperties,
+ inData: new Uint8Array([])
+}
+
+function stringToUint8Array(str: String) {
+ let arr: number[] = [];
+ for (let i = 0, j = str.length; i < j; ++i) {
+ arr.push(str.charCodeAt(i));
+ }
+ return new Uint8Array(arr);
+}
+
+class ThrowObject {
+ public isThrow = false;
+}
+
+function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.generateKeyItem(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise generateKeyItem`);
+ let throwObject: ThrowObject = { isThrow: false };
+ try {
+ await generateKeyItem(keyAlias, huksOptions, throwObject)
+ .then((data) => {
+ console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+ });
+ } catch (error) {
+ console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+}
+
+function initSession(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.initSession(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicInitFunc(keyAlias: string, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise doInit`);
+ let throwObject: ThrowObject = { isThrow: false };
+ try {
+ await initSession(keyAlias, huksOptions, throwObject)
+ .then((data) => {
+ console.info(`promise: doInit success, data = ${JSON.stringify(data)}`);
+ handle = data.handle;
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: doInit failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+ });
+ } catch (error) {
+ console.error(`promise: doInit input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+}
+
+function updateSession(handle: number, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.updateSession(handle, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicUpdateFunc(handle: number, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise doUpdate`);
+ let throwObject: ThrowObject = { isThrow: false };
+ try {
+ await updateSession(handle, huksOptions, throwObject)
+ .then((data) => {
+ console.info(`promise: doUpdate success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: doUpdate failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+ });
+ } catch (error) {
+ console.error(`promise: doUpdate input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+}
+
+function finishSession(handle: number, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.finishSession(handle, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicFinishFunc(handle: number, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise doFinish`);
+ let throwObject: ThrowObject = { isThrow: false };
+ try {
+ await finishSession(handle, huksOptions, throwObject)
+ .then((data) => {
+ finishOutData = data.outData as Uint8Array;
+ console.info(`promise: doFinish success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: doFinish failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+ });
+ } catch (error) {
+ console.error(`promise: doFinish input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+}
+
+function deleteKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.deleteKeyItem(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicDeleteKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise deleteKeyItem`);
+ let throwObject: ThrowObject = { isThrow: false };
+ try {
+ await deleteKeyItem(keyAlias, huksOptions, throwObject)
+ .then((data) => {
+ console.info(`promise: deleteKeyItem key success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: deleteKeyItem failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+ });
+ } catch (error) {
+ console.error(`promise: deleteKeyItem input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+}
+
+async function testDerive() {
+ /* 生成密钥 */
+ await publicGenKeyFunc(srcKeyAlias, huksOptions);
+ /* 进行派生操作 */
+ await publicInitFunc(srcKeyAlias, initOptions);
+ await publicUpdateFunc(handle, initOptions);
+ await publicFinishFunc(handle, finishOptions);
+ await publicDeleteKeyFunc(srcKeyAlias, huksOptions);
+}
+// [End the_key_is_derived_from_pbkdf2]
+@Entry
+@Component
+struct Index {
+ @State message: string = 'PBKDF2';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message)
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.call_pbkdf2'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ try {
+ let ret = await testDerive();
+ this.message = 'PBKDF2 Result: Success';
+ } catch {
+ this.message = 'PBKDF2 Result: Failed';
+ }
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/module.json5 b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..4144486d1af4c03b0d767cce1cda86fc0d697f91
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/module.json5
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/element/color.json b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/element/string.json b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..03a4ae7285ba810b0262394cee50824c31c90784
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,60 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "KeyDerivation"
+ },
+ {
+ "name": "key_derivation",
+ "value": "KeyDerivation"
+ },
+ {
+ "name": "hkdf",
+ "value": "HKDF"
+ },
+ {
+ "name": "pbkdf2",
+ "value": "PBKDF2"
+ },
+ {
+ "name": "call_cpp_derive_key",
+ "value": "Call C/C++"
+ },
+ {
+ "name": "call_cpp_result",
+ "value": "Call C/C++ Result: "
+ },
+ {
+ "name": "call_hkdf",
+ "value": "Call HKDF"
+ },
+ {
+ "name": "call_pbkdf2",
+ "value": "Call PBKDF2"
+ },
+ {
+ "name": "hkdf_result_success",
+ "value": "HKDF Result: Success"
+ },
+ {
+ "name": "hkdf_result_failed",
+ "value": "HKDF Result: Failed"
+ },
+ {
+ "name": "pbkdf2_result_success",
+ "value": "PBKDF2 Result: Success"
+ },
+ {
+ "name": "pbkdf2_result_failed",
+ "value": "PBKDF2 Result: Failed"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/background.png b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/background.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/foreground.png b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/foreground.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/layered_image.json b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/startIcon.png b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/profile/backup_config.json b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/profile/main_pages.json b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..f6423999cf3a834171b0cd8c9890a78cb6a0573f
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,7 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/HKDF",
+ "pages/PBKDF2"
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/dark/element/color.json b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/dark/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/resources/dark/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#000000"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/ets/test/Ability.test.ets b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/ets/test/KeyDerivation.test.ets b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/ets/test/KeyDerivation.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b7b4b3de0aa97d0fb8b8a623258407370a4b5bd9
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/ets/test/KeyDerivation.test.ets
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, it, expect, beforeAll } from '@ohos/hypium';
+// 导入测试依赖kit
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+let want: Want;
+
+export default function keyDerivationTest() {
+ describe('keyDerivationTest', () => {
+ /**
+ * 打开应用
+ */
+ beforeAll(async () => {
+ want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ await driver.delayMs(1000);
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ })
+
+ /**
+ * 点击按钮,密钥派生HKDF
+ */
+ it('testKeyDerivation001', 0, async () => {
+ console.info('uitest: testKeyDerivation001 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('HKDF'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('Call HKDF'));
+ await button2.click();
+ await driver.delayMs(2000);
+ await driver.assertComponentExist(ON.text('HKDF Result: Success'));
+ console.info('uitest: testKeyDerivation001 end');
+ await driver.pressBack();
+ })
+
+ /**
+ * 点击按钮,密钥派生PBKDF2
+ */
+ it('testKeyDerivation002', 0, async () => {
+ console.info('uitest: testKeyDerivation002 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('PBKDF2'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('Call PBKDF2'));
+ await button2.click();
+ await driver.delayMs(2000);
+ await driver.assertComponentExist(ON.text('PBKDF2 Result: Success'));
+ console.info('uitest: testKeyDerivation002 end');
+ await driver.pressBack();
+ })
+
+ /**
+ * 点击按钮,密钥派生HKDF256(C/C++)
+ */
+ it('testKeyDerivation003', 0, async () => {
+ console.info('uitest: testKeyDerivation003 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('Call C/C++'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('Call C/C++ Result: 0'));
+ console.info('uitest: testKeyDerivation003 end');
+ await driver.pressBack();
+ })
+ })
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/ets/test/List.test.ets b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..fc4ce843a8c832493ad9075bd3dcd80a4db279bf
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 keyDerivationTest from './KeyDerivation.test';
+
+export default function testsuite() {
+ keyDerivationTest();
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/module.json5 b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/test/List.test.ets b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/test/LocalUnit.test.ets b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/hvigor/hvigor-config.json5 b/UniversalKeystoreKit/KeyUsage/KeyDerivation/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..d584c19c247db9a7caee4b606bb931aa9279c637
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/hvigorfile.ts b/UniversalKeystoreKit/KeyUsage/KeyDerivation/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/oh-package.json5 b/UniversalKeystoreKit/KeyUsage/KeyDerivation/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e41bae026aab3b50d0abb42fece08ba43b4a772b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/ohosTest.md b/UniversalKeystoreKit/KeyUsage/KeyDerivation/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..ba4443dd88394f07c4face6c7d36b4efef66d21d
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyDerivation/ohosTest.md
@@ -0,0 +1,10 @@
+# 密钥派生测试用例归档
+
+## 用例表
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------------- | ------------ | ---- | ------------------ | -------- | -------- |
+| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass |
+| 点击按钮,密钥派生HKDF | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
+| 点击按钮,密钥派生PBKDF2 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
+| 点击按钮,密钥派生(C/C++) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/Cpp_1.png b/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/Cpp_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..9ccc75e166ce2184f5011af72756742cc717fedb
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/Cpp_1.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/Cpp_2.png b/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/Cpp_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..43762154b7c03d9b58e3a27fee239c6528b1a64a
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/Cpp_2.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/HKDF_1.png b/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/HKDF_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..bc576a1f42c5d57394fb85302a7547bd23b6325f
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/HKDF_1.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/HKDF_2.png b/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/HKDF_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..2e3d529959c83d5c637e484e2ff02ac7fbdce30a
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/HKDF_2.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/PBKDF2_1.png b/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/PBKDF2_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..5ca73e0caf7fbd6f9bc78f01c2fc525ce455fead
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/PBKDF2_1.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/PBKDF2_2.png b/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/PBKDF2_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..700c836fcdbdfb0162ff3eb7c8180e6d0156a050
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/KeyDerivation/screenshots/PBKDF2_2.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/.gitignore b/UniversalKeystoreKit/KeyUsage/KeyExchange/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/AppScope/app.json5 b/UniversalKeystoreKit/KeyUsage/KeyExchange/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..287ffdacf9ec7c9a1fc48456bcdcdef60ebeb12a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.keyexchange",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/AppScope/resources/base/element/string.json b/UniversalKeystoreKit/KeyUsage/KeyExchange/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..dc8e956b1ffc434990edb1694e538f161db709e8
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "KeyExchange"
+ }
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/AppScope/resources/base/media/app_icon.png b/UniversalKeystoreKit/KeyUsage/KeyExchange/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/KeyExchange/AppScope/resources/base/media/app_icon.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/README.md b/UniversalKeystoreKit/KeyUsage/KeyExchange/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..c3aa9f8b2f151ede0aa58415e553303f723c9031
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/README.md
@@ -0,0 +1,109 @@
+## 密钥协商(ArkTS)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-key-derivation-arkts.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### X25519
+
+##### 介绍
+
+1. 本示例主要介绍密钥协商,以协商密钥类型为X25519,并密钥仅在HUKS内使用为例,完成密钥协商。
+
+##### 效果预览
+
+| 主页 | 执行结果 |
+| ----------------------------------------------------- | ----------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击X25519按钮完成密钥协商。
+
+#### DH
+
+##### 介绍
+
+1. 本示例主要介绍密钥协商,以协商密钥类型为DH密钥,并密钥仅在HUKS内使用为例,完成密钥协商。
+
+##### 效果预览
+
+| 主页 | 执行结果 |
+| ------------------------------------------------- | ------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击DH按钮完成密钥协商。
+
+## 密钥协商(C/C++)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-key-derivation-ndk.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### Call C/C++
+
+##### 介绍
+
+1. 本示例主要介绍密钥协商,以ECDH密钥为例,完成密钥协商。
+
+##### 效果预览
+
+| 主页 | 执行结果 |
+| -------------------------------------------------- | -------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击Call C/C++按钮完成密钥协商。
+
+## 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---X25519.ets
+|---|---|---DH.ets
+|---|---|---Index.ets // 首页
+|---cpp
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---KeyExchange.test.ets // 自动化测试用例
+```
+
+
+## 相关权限
+
+无。
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo UniversalKeystoreKit/KeyUsage/KeyExchange > .git/info/sparse-checkout
+git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/build-profile.json5 b/UniversalKeystoreKit/KeyUsage/KeyExchange/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..fb5a1ab654ae6715a0ab69a31900ad26dcf2487f
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/build-profile.json5
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ "buildOption": {
+ "strictMode": {
+ "caseSensitiveCheck": true,
+ "useNormalizedOHMUrl": true
+ }
+ }
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/code-linter.json5 b/UniversalKeystoreKit/KeyUsage/KeyExchange/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/.gitignore b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/build-profile.json5 b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2d8b081b615348a99aa197f90186f3d8891b7dc1
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/build-profile.json5
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ "externalNativeOptions": {
+ "path": "./src/main/cpp/CMakeLists.txt",
+ "arguments": "",
+ "cppFlags": "",
+ "abiFilters": [
+ "arm64-v8a",
+ "x86_64"
+ ]
+ }
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ },
+ "nativeLib": {
+ "debugSymbol": {
+ "strip": true,
+ "exclude": []
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/hvigorfile.ts b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/oh-package.json5 b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..118bdd4fe7699368a010e04c24f5bfc887cf1298
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/oh-package.json5
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {
+ "libentry.so": "file:./src/main/cpp/types/libentry"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/CMakeLists.txt b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..9e0677bac15dc15913479dd0df1397426d9617a2
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,15 @@
+# the minimum version of CMake.
+cmake_minimum_required(VERSION 3.5.0)
+project(KeyExchange)
+
+set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+if(DEFINED PACKAGE_FIND_FILE)
+ include(${PACKAGE_FIND_FILE})
+endif()
+
+include_directories(${NATIVERENDER_ROOT_PATH}
+ ${NATIVERENDER_ROOT_PATH}/include)
+
+add_library(entry SHARED napi_init.cpp)
+target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so)
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/napi_init.cpp b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/napi_init.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f61e7301457006166fc2fe391b2edcd93bd32c98
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/napi_init.cpp
@@ -0,0 +1,265 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start key_agreement]
+#include "huks/native_huks_api.h"
+#include "huks/native_huks_param.h"
+#include "napi/native_api.h"
+#include
+
+/* 初始化参数 */
+OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params,
+ uint32_t paramCount)
+{
+ OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_AddParams(*paramSet, params, paramCount);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ ret = OH_Huks_BuildParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ return ret;
+}
+static const uint32_t IV_SIZE = 16;
+static uint8_t IV[IV_SIZE] = {0}; // this is a test value, for real use the iv should be different every time
+static struct OH_Huks_Blob g_keyAliasFinal1001 = {(uint32_t)strlen("HksECDHAgreeKeyAliasTest001_1_final"),
+ (uint8_t *)"HksECDHAgreeKeyAliasTest001_1_final"};
+/* 集成密钥参数集 */
+static struct OH_Huks_Param g_genAgreeParams[] = {
+ {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECC},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256},
+ {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}};
+static struct OH_Huks_Param g_agreeParamsInit01[] = {
+ {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECDH},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256}};
+static struct OH_Huks_Param g_agreeParamsFinish01[] = {
+ {.tag = OH_HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, .uint32Param = OH_HUKS_STORAGE_ONLY_USED_IN_HUKS},
+ {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE},
+ {.tag = OH_HUKS_TAG_KEY_ALIAS, .blob = g_keyAliasFinal1001},
+ {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE},
+ {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_CBC}};
+static struct OH_Huks_Blob g_keyAliasFinal2001 = {(uint32_t)strlen("HksECDHAgreeKeyAliasTest001_2_final"),
+ (uint8_t *)"HksECDHAgreeKeyAliasTest001_2_final"};
+static struct OH_Huks_Param g_agreeParamsInit02[] = {
+ {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECDH},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256}};
+static struct OH_Huks_Param g_agreeParamsFinish02[] = {
+ {.tag = OH_HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG, .uint32Param = OH_HUKS_STORAGE_ONLY_USED_IN_HUKS},
+ {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_AES},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_AES_KEY_SIZE_256},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE},
+ {.tag = OH_HUKS_TAG_KEY_ALIAS, .blob = g_keyAliasFinal2001},
+ {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_NONE},
+ {.tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_CBC}};
+static const uint32_t ECDH_COMMON_SIZE = 1024;
+static struct OH_Huks_Blob g_keyAlias01001 = {(uint32_t)strlen("HksECDHAgreeKeyAliasTest001_1"),
+ (uint8_t *)"HksECDHAgreeKeyAliasTest001_1"};
+static struct OH_Huks_Blob g_keyAlias02001 = {(uint32_t)strlen("HksECDHAgreeKeyAliasTest001_2"),
+ (uint8_t *)"HksECDHAgreeKeyAliasTest001_2"};
+
+OH_Huks_Result MallocAndCheckBlobData(struct OH_Huks_Blob *blob, const uint32_t blobSize)
+{
+ struct OH_Huks_Result ret;
+ ret.errorCode = OH_HUKS_SUCCESS;
+ if (blobSize == 0 || blobSize > ECDH_COMMON_SIZE) {
+ ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR;
+ return ret;
+ }
+ blob->data = (uint8_t *)malloc(blobSize);
+ if (blob->data == NULL) {
+ ret.errorCode = OH_HUKS_ERR_CODE_INTERNAL_ERROR;
+ }
+ return ret;
+}
+/* 导出密钥 */
+OH_Huks_Result HksEcdhAgreeExport(const struct OH_Huks_Blob *keyAlias1, const struct OH_Huks_Blob *keyAlias2,
+ struct OH_Huks_Blob *publicKey1, struct OH_Huks_Blob *publicKey2,
+ const struct OH_Huks_ParamSet *genParamSet)
+{
+ OH_Huks_Result ret = OH_Huks_ExportPublicKeyItem(keyAlias1, genParamSet, publicKey1);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_ExportPublicKeyItem(keyAlias2, genParamSet, publicKey2);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ return ret;
+}
+static const char *IN_DATA = "Hks_ECDH_Agree_Test_000000000000000000000000000000000000000000000000000000000000"
+ "00000000000000000000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000000000000_string";
+/* 协商密钥操作 */
+OH_Huks_Result HksEcdhAgreeFinish(const struct OH_Huks_Blob *keyAlias, const struct OH_Huks_Blob *publicKey,
+ const struct OH_Huks_ParamSet *initParamSet,
+ const struct OH_Huks_ParamSet *finishParamSet, struct OH_Huks_Blob *outData)
+{
+ struct OH_Huks_Blob inData = {(uint32_t)strlen(IN_DATA), (uint8_t *)IN_DATA};
+ uint8_t handleU[sizeof(uint64_t)] = {0};
+ struct OH_Huks_Blob handle = {sizeof(uint64_t), handleU};
+ OH_Huks_Result ret = OH_Huks_InitSession(keyAlias, initParamSet, &handle, nullptr);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ uint8_t outDataU[ECDH_COMMON_SIZE] = {0};
+ struct OH_Huks_Blob outDataUpdate = {ECDH_COMMON_SIZE, outDataU};
+ ret = OH_Huks_UpdateSession(&handle, initParamSet, publicKey, &outDataUpdate);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_FinishSession(&handle, finishParamSet, &inData, outData);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ return ret;
+}
+
+/* 协商密钥整体流程 */
+static napi_value AgreeKey(napi_env env, napi_callback_info info)
+{
+ struct OH_Huks_ParamSet *genParamSet = nullptr;
+ struct OH_Huks_ParamSet *initParamSet01 = nullptr;
+ struct OH_Huks_ParamSet *finishParamSet01 = nullptr;
+ struct OH_Huks_ParamSet *initParamSet02 = nullptr;
+ struct OH_Huks_ParamSet *finishParamSet02 = nullptr;
+ struct OH_Huks_Blob publicKey01 = {.size = OH_HUKS_ECC_KEY_SIZE_256, .data = nullptr};
+ struct OH_Huks_Blob publicKey02 = {.size = OH_HUKS_ECC_KEY_SIZE_256, .data = nullptr};
+ struct OH_Huks_Blob outData01 = {.size = ECDH_COMMON_SIZE, .data = nullptr};
+ struct OH_Huks_Blob outData02 = {.size = ECDH_COMMON_SIZE, .data = nullptr};
+ OH_Huks_Result ohResult;
+ do {
+ /* 1.确定密钥别名集成密钥参数集 */
+ ohResult = InitParamSet(&genParamSet, g_genAgreeParams, sizeof(g_genAgreeParams) /
+ sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ ohResult =
+ InitParamSet(&initParamSet01, g_agreeParamsInit01, sizeof(g_agreeParamsInit01) /
+ sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ ohResult = InitParamSet(&finishParamSet01, g_agreeParamsFinish01,
+ sizeof(g_agreeParamsFinish01) / sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ ohResult =
+ InitParamSet(&initParamSet02, g_agreeParamsInit02, sizeof(g_agreeParamsInit02) /
+ sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ ohResult = InitParamSet(&finishParamSet02, g_agreeParamsFinish02,
+ sizeof(g_agreeParamsFinish02) / sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ /* 2.设备A生成密钥 */
+ ohResult = OH_Huks_GenerateKeyItem(&g_keyAlias01001, genParamSet, nullptr);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ /* 3.设备B生成密钥 */
+ ohResult = OH_Huks_GenerateKeyItem(&g_keyAlias02001, genParamSet, nullptr);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ ohResult = MallocAndCheckBlobData(&publicKey01, publicKey01.size);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ ohResult = MallocAndCheckBlobData(&publicKey02, publicKey02.size);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ /* 4.设备A、B导出公钥 */
+ ohResult = HksEcdhAgreeExport(&g_keyAlias01001, &g_keyAlias02001, &publicKey01,
+ &publicKey02, genParamSet);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ ohResult = MallocAndCheckBlobData(&outData01, outData01.size);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ ohResult = MallocAndCheckBlobData(&outData02, outData02.size);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ /* 5.设备A协商密钥 */
+ ohResult = HksEcdhAgreeFinish(&g_keyAlias01001, &publicKey02, initParamSet01,
+ finishParamSet01, &outData01);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ /* 5.设备B协商密钥 */
+ ohResult = HksEcdhAgreeFinish(&g_keyAlias02001, &publicKey01, initParamSet02,
+ finishParamSet02, &outData02);
+ } while (0);
+ free(publicKey01.data);
+ free(publicKey02.data);
+ free(outData01.data);
+ free(outData02.data);
+ /* 6.设备A、B删除密钥 */
+ OH_Huks_DeleteKeyItem(&g_keyAlias01001, genParamSet);
+ OH_Huks_DeleteKeyItem(&g_keyAlias02001, genParamSet);
+ OH_Huks_DeleteKeyItem(&g_keyAliasFinal1001, NULL);
+ OH_Huks_DeleteKeyItem(&g_keyAliasFinal2001, NULL);
+ OH_Huks_FreeParamSet(&genParamSet);
+ OH_Huks_FreeParamSet(&initParamSet01);
+ OH_Huks_FreeParamSet(&finishParamSet01);
+ OH_Huks_FreeParamSet(&initParamSet02);
+ OH_Huks_FreeParamSet(&finishParamSet02);
+
+ napi_value ret;
+ napi_create_int32(env, ohResult.errorCode, &ret);
+ return ret;
+}
+
+// [End key_agreement]
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports)
+{
+ napi_property_descriptor desc[] = {
+ {"agreeKey", nullptr, AgreeKey, nullptr, nullptr, nullptr, napi_default, nullptr}};
+ napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "entry",
+ .nm_priv = ((void *)0),
+ .reserved = {0},
+};
+
+extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); }
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/types/libentry/index.d.ts b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/types/libentry/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..14e3b41480dbecb0511d4b9fe692b1e651fd14aa
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/types/libentry/index.d.ts
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2025 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 const agreeKey: () => number;
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/types/libentry/oh-package.json5 b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/types/libentry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2826cc7d6bd199c1008bb51d898dffa922201e6c
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/types/libentry/oh-package.json5
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "libentry.so",
+ "types": "./index.d.ts",
+ "version": "1.0.0",
+ "description": "Please describe the basic information."
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/entryability/EntryAbility.ets b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..edc2839f203ba057c186e19b0cbbbf80c8faa8b3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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 { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/DH.ets b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/DH.ets
new file mode 100644
index 0000000000000000000000000000000000000000..89e937336c241e1f8f3225f93f3a1ba8a21e6bf2
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/DH.ets
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start key_agreement_dh]
+/*
+*以下以 DH密钥的Promise操作使用为例
+*/
+import { huks } from '@kit.UniversalKeystoreKit';
+
+function stringToUint8Array(str: string) {
+ let arr: number[] = []
+ for (let i = 0, j = str.length; i < j; ++i) {
+ arr.push(str.charCodeAt(i));
+ }
+ return new Uint8Array(arr);
+}
+
+function uint8ArrayToBigInt(arr: Uint8Array): bigint {
+ let i = 0
+ const byteMax: bigint = BigInt('0x100')
+ let result: bigint = BigInt('0')
+ while (i < arr.length) {
+ result = result * byteMax
+ result = result + BigInt(arr[i])
+ i += 1
+ }
+ return result;
+}
+
+const dhAgree: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_DH,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE,
+}]
+const dh2048Agree: huks.HuksParam[] = [
+ ...dhAgree, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_DH_KEY_SIZE_2048,
+}]
+const dhGenOptions: huks.HuksOptions = {
+ properties: dh2048Agree,
+ inData: new Uint8Array([])
+}
+const emptyOptions: huks.HuksOptions = {
+ properties: [],
+ inData: new Uint8Array([])
+}
+
+async function huksDhAgreeExportKey(keyAlias: string,
+ peerPubKey: huks.HuksReturnResult): Promise {
+ const initHandle = await huks.initSession(keyAlias, dhGenOptions)
+ const dhAgreeUpdateBobPubKey: huks.HuksOptions = {
+ properties: [
+ ...dh2048Agree, {
+ tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG,
+ value: huks.HuksKeyStorageType.HUKS_STORAGE_KEY_EXPORT_ALLOWED,
+ }],
+ inData: peerPubKey.outData
+ }
+ await huks.updateSession(initHandle.handle, dhAgreeUpdateBobPubKey)
+ return await huks.finishSession(initHandle.handle, emptyOptions)
+}
+
+async function huksDhAgreeExportTest(
+ aliasA: string, aliasB: string,
+ pubKeyA: huks.HuksReturnResult, pubKeyB: huks.HuksReturnResult) {
+
+ const agreedKeyFromAlice = await huksDhAgreeExportKey(aliasA, pubKeyB);
+ console.info(`ok! agreedKeyFromAlice export is 0x${uint8ArrayToBigInt(agreedKeyFromAlice.outData).toString(16)}`);
+
+ const agreedKeyFromBob = await huksDhAgreeExportKey(aliasB, pubKeyA);
+ console.info(`ok! agreedKeyFromBob export is 0x${uint8ArrayToBigInt(agreedKeyFromBob.outData).toString(16)}`);
+}
+
+async function huksDhAgreeInHuks(keyAlias: string, peerPubKey: huks.HuksReturnResult,
+ aliasAgreedKey: string): Promise {
+ const onlyUsedInHuks: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_KEY_STORAGE_FLAG,
+ value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS,
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG,
+ value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS,
+ }]
+ const dhAgreeInit: huks.HuksOptions = {
+ properties: [
+ ...dhAgree,
+ { tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, },
+ ...onlyUsedInHuks],
+ inData: new Uint8Array([])
+ }
+ const dhAgreeFinishParams: huks.HuksParam[] = [
+ ...onlyUsedInHuks,
+ { tag: huks.HuksTag.HUKS_TAG_IS_KEY_ALIAS, value: true },
+ { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, value: huks.HuksKeyAlg.HUKS_ALG_AES },
+ { tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
+ }]
+
+ const handle = await huks.initSession(keyAlias, dhAgreeInit)
+ const dhAgreeUpdatePubKey: huks.HuksOptions = {
+ properties: [...dhAgree, ...onlyUsedInHuks],
+ inData: peerPubKey.outData
+ }
+ await huks.updateSession(handle.handle, dhAgreeUpdatePubKey)
+ const dhAgreeAliceFinnish: huks.HuksOptions = {
+ properties: [...dhAgreeFinishParams, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_ALIAS, value: stringToUint8Array(aliasAgreedKey)
+ }], inData: new Uint8Array([])
+ }
+ return await huks.finishSession(handle.handle, dhAgreeAliceFinnish);
+}
+
+async function huksDhAgreeInHuksTest(
+ aliasA: string, aliasB: string,
+ pubKeyA: huks.HuksReturnResult, pubKeyB: huks.HuksReturnResult,
+ aliasAgreedKeyFromA: string, aliasAgreedKeyFromB: string) {
+
+ const finishAliceResult = await huksDhAgreeInHuks(aliasA, pubKeyB, aliasAgreedKeyFromA);
+ console.info(`ok! finishAliceResult in huks is 0x${uint8ArrayToBigInt(finishAliceResult.outData).toString(16)}`);
+ const aliceAgreedExist = await huks.isKeyItemExist(aliasAgreedKeyFromA, emptyOptions);
+ console.info(`ok! aliceAgreedExist in huks is ${aliceAgreedExist}`);
+
+ const finishBobResult = await huksDhAgreeInHuks(aliasB, pubKeyA, aliasAgreedKeyFromB);
+ console.info(`ok! finishBobResult in huks is 0x${uint8ArrayToBigInt(finishBobResult.outData).toString(16)}`);
+ const bobAgreedExist = await huks.isKeyItemExist(aliasAgreedKeyFromB, emptyOptions);
+ console.info(`ok! bobAgreedExist in huks is ${bobAgreedExist}`);
+
+ await huks.deleteKeyItem(aliasAgreedKeyFromA, emptyOptions);
+ await huks.deleteKeyItem(aliasAgreedKeyFromB, emptyOptions);
+}
+
+export default async function huksDhAgreeTest() {
+ const aliasAlice = 'alice';
+ const aliasBob = 'bob';
+
+ /* 调用generateKeyItem生成别名为alice与bob的两个密钥 */
+ await huks.generateKeyItem(aliasAlice, dhGenOptions);
+ await huks.generateKeyItem(aliasBob, dhGenOptions);
+
+ /* 导出非对称密钥alice与bob的的公钥 */
+ const pubKeyAlice = await huks.exportKeyItem(aliasAlice, emptyOptions);
+ const pubKeyBob = await huks.exportKeyItem(aliasBob, emptyOptions);
+
+ /* 开始协商,协商生成的密钥返回给业务管理 */
+ await huksDhAgreeExportTest(aliasAlice, aliasBob, pubKeyAlice, pubKeyBob);
+
+ /* 开始协商,协商生成的密钥由HUKS管理 */
+ await huksDhAgreeInHuksTest(aliasAlice, aliasBob, pubKeyAlice, pubKeyBob, 'agreedKeyFromAlice', 'agreedKeyFromBob');
+
+ await huks.deleteKeyItem(aliasAlice, emptyOptions);
+ await huks.deleteKeyItem(aliasBob, emptyOptions);
+}
+
+
+// [End key_agreement_dh]
+@Entry
+@Component
+struct Index {
+ @State message: string = 'DH';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.dh'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ try {
+ await huksDhAgreeTest();
+ this.message = 'DH Result: Success';
+ } catch {
+ this.message = 'DH Result: Failed';
+ }
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/Index.ets b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..6a9d3d10503a001b7260869c9e24a86dde1e99cf
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2025 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 { router } from '@kit.ArkUI';
+import testNapi from 'libentry.so';
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'KeyExchange';
+
+ goToSample(url: string): void {
+ router.pushUrl({
+ url: url,
+ }, router.RouterMode.Single, (err) => {
+ if (err) {
+ console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
+ return;
+ }
+ console.info('pushUrl success');
+ })
+ }
+
+ build() {
+ Column({ space: 5 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.x25519'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/X25519')
+ })
+ Button($r('app.string.dh'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/DH')
+ })
+ Button($r('app.string.call_cpp_agree_key'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ let ret: number = testNapi.agreeKey();
+ this.message = 'Call C/C++ Result: ' + ret.toString();
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/X25519.ets b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/X25519.ets
new file mode 100644
index 0000000000000000000000000000000000000000..85af04b5632b2896865e43483cfdf4dc9ffbda1f
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/X25519.ets
@@ -0,0 +1,427 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start key_agreement_X25519]
+
+/*
+*以下以X25519密钥的Promise操作使用为例
+*/
+import { huks } from '@kit.UniversalKeystoreKit';
+
+/*
+* 确定密钥别名和封装密钥属性参数集
+*/
+let srcKeyAliasFirst = 'AgreeX25519KeyFirstAlias';
+let srcKeyAliasSecond = 'AgreeX25519KeySecondAlias';
+let agreeX25519InData = 'AgreeX25519TestIndata';
+let finishOutData: Uint8Array;
+let handle: number;
+let exportKey: Uint8Array;
+let exportKeyFirst: Uint8Array;
+let exportKeySecond: Uint8Array;
+/* 集成生成密钥参数集 */
+let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_X25519,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_NONE,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_NONE,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_CBC,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG,
+ value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS,
+}];
+let huksOptions: huks.HuksOptions = {
+ properties: properties,
+ inData: new Uint8Array([])
+}
+/* 集成第一个协商参数集 */
+const finishProperties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG,
+ value: huks.HuksKeyStorageType.HUKS_STORAGE_ONLY_USED_IN_HUKS,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_IS_KEY_ALIAS,
+ value: true
+}, {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_AES,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value:
+ huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT |
+ huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_NONE,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_NONE,
+}, {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_ECB,
+}];
+let finishOptionsFirst: huks.HuksOptions = {
+ properties: [
+ ...finishProperties, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_ALIAS,
+ value: stringToUint8Array(srcKeyAliasFirst + 'final'),
+ }],
+ inData: stringToUint8Array(agreeX25519InData)
+}
+/* 集成第二个协商参数集 */
+let finishOptionsSecond: huks.HuksOptions = {
+ properties: [
+ ...finishProperties, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_ALIAS,
+ value: stringToUint8Array(srcKeyAliasSecond + 'final'),
+ }],
+ inData: stringToUint8Array(agreeX25519InData)
+}
+
+function stringToUint8Array(str: string) {
+ let arr: number[] = [];
+ for (let i = 0, j = str.length; i < j; ++i) {
+ arr.push(str.charCodeAt(i));
+ }
+ return new Uint8Array(arr);
+}
+
+class ThrowObject {
+ public isThrow: boolean = false
+}
+
+/* 生成密钥 */
+function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.generateKeyItem(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+/* 调用generateKeyItem生成密钥 */
+async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise generateKeyItem`);
+ let throwObject: ThrowObject = { isThrow: false };
+ try {
+ await generateKeyItem(keyAlias, huksOptions, throwObject)
+ .then((data) => {
+ console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+ });
+ } catch (error) {
+ console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+}
+
+/*初始化密钥会话接口,并获取一个句柄(必选)和挑战值(可选)*/
+function initSession(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.initSession(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+/*调用initSession获取handle*/
+async function publicInitFunc(keyAlias: string, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise doInit`);
+ let throwObject: ThrowObject = { isThrow: false };
+ try {
+ await initSession(keyAlias, huksOptions, throwObject)
+ .then((data) => {
+ console.info(`promise: doInit success, data = ${JSON.stringify(data)}`);
+ handle = data.handle;
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: doInit failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+ });
+ } catch (error) {
+ console.error(`promise: doInit input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+}
+
+/* 分段添加密钥操作的数据并进行相应的密钥操作,输出处理数据 */
+function updateSession(handle: number, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.updateSession(handle, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+/* 调用updateSession进行协商操作 */
+async function publicUpdateFunc(handle: number, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise doUpdate`);
+ let throwObject: ThrowObject = { isThrow: false };
+ try {
+ await updateSession(handle, huksOptions, throwObject)
+ .then((data) => {
+ console.info(`promise: doUpdate success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: doUpdate failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+ });
+ } catch (error) {
+ console.error(`promise: doUpdate input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+}
+
+/* 结束密钥会话并进行相应的密钥操作,输出处理数据 */
+function finishSession(handle: number, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.finishSession(handle, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+/* 调用finishSession结束操作 */
+async function publicFinishFunc(handle: number, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise doFinish`);
+ let throwObject: ThrowObject = { isThrow: false };
+ try {
+ await finishSession(handle, huksOptions, throwObject)
+ .then((data) => {
+ finishOutData = data.outData as Uint8Array;
+ console.info(`promise: doFinish success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: doFinish failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+ });
+ } catch (error) {
+ console.error(`promise: doFinish input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+}
+
+/* 导出密钥 */
+function exportKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.exportKeyItem(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+/* 调用exportKeyItem导出公钥操作 */
+async function publicExportKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise export`);
+ let throwObject: ThrowObject = { isThrow: false };
+ try {
+ await exportKeyItem(keyAlias, huksOptions, throwObject)
+ .then((data) => {
+ console.info(`promise: exportKeyItem success, data = ${JSON.stringify(data)}`);
+ exportKey = data.outData as Uint8Array;
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: exportKeyItem failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+ });
+ } catch (error) {
+ console.error(`promise: exportKeyItem input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+}
+
+/* 删除密钥操作 */
+function deleteKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.deleteKeyItem(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throwObject.isThrow = true;
+ throw (error as Error);
+ }
+ });
+}
+
+/* 调用deleteKeyItem删除密钥操作 */
+async function publicDeleteKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) {
+ console.info(`enter promise deleteKeyItem`);
+ let throwObject: ThrowObject = { isThrow: false };
+ try {
+ await deleteKeyItem(keyAlias, huksOptions, throwObject)
+ .then((data) => {
+ console.info(`promise: deleteKeyItem key success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ if (throwObject.isThrow) {
+ throw (error as Error);
+ } else {
+ console.error(`promise: deleteKeyItem failed, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+ });
+ } catch (error) {
+ console.error(`promise: deleteKeyItem input arg invalid, ${JSON.stringify(error)}`);
+ throw (error as Error);
+ }
+}
+
+async function testAgree() {
+ /* 1.确定密钥别名并集成并集成要参数集 A设备:srcKeyAliasFirst B设备:srcKeyAliasSecond*/
+ /* 2.设备A生成密钥 */
+ await publicGenKeyFunc(srcKeyAliasFirst, huksOptions);
+ /* 3.设备B生成密钥 */
+ await publicGenKeyFunc(srcKeyAliasSecond, huksOptions);
+ /* 4.设备A、B导出非对称密钥的公钥 */
+ await publicExportKeyFunc(srcKeyAliasFirst, huksOptions);
+ exportKeyFirst = exportKey;
+ await publicExportKeyFunc(srcKeyAliasSecond, huksOptions);
+ exportKeySecond = exportKey;
+ /* 5.对第一个密钥进行协商(三段式)*/
+ await publicInitFunc(srcKeyAliasFirst, huksOptions);
+ huksOptions.inData = exportKeySecond;
+ await publicUpdateFunc(handle, huksOptions);
+ await publicFinishFunc(handle, finishOptionsFirst);
+ /* 5.对第二个密钥进行协商(三段式) */
+ await publicInitFunc(srcKeyAliasSecond, huksOptions);
+ huksOptions.inData = exportKeyFirst;
+ await publicUpdateFunc(handle, huksOptions);
+ await publicFinishFunc(handle, finishOptionsSecond);
+ /* 6.设备A、B删除密钥 */
+ await publicDeleteKeyFunc(srcKeyAliasFirst, huksOptions);
+ await publicDeleteKeyFunc(srcKeyAliasSecond, huksOptions);
+}
+
+
+// [End key_agreement_X25519]
+@Entry
+@Component
+struct Index {
+ @State message: string = 'X25519';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.x25519'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ try {
+ await testAgree();
+ this.message = 'X25519 Result: Success';
+ } catch {
+ this.message = 'X25519 Result: Failed';
+ }
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/module.json5 b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..4144486d1af4c03b0d767cce1cda86fc0d697f91
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/module.json5
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/element/color.json b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/element/string.json b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..9797923c2281cd553118ddf6a69115ec5b41a821
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,28 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "KeyExchange"
+ },
+ {
+ "name": "x25519",
+ "value": "X25519"
+ },
+ {
+ "name": "dh",
+ "value": "DH"
+ },
+ {
+ "name": "call_cpp_agree_key",
+ "value": "Call C/C++"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/background.png b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/background.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/foreground.png b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/foreground.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/layered_image.json b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/startIcon.png b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/profile/backup_config.json b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/profile/main_pages.json b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..46d06be3c79c1ceccacb3f21ffb1ff4d9f900d11
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,7 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/X25519",
+ "pages/DH"
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/dark/element/color.json b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/dark/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/resources/dark/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#000000"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/ets/test/Ability.test.ets b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/ets/test/KeyExchange.test.ets b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/ets/test/KeyExchange.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7219b914f0330a8d4943cc7828c27d34b39bf2b2
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/ets/test/KeyExchange.test.ets
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, it, expect, beforeAll } from '@ohos/hypium';
+// 导入测试依赖kit
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+let want: Want;
+
+export default function keyExchangeTest() {
+ describe('keyExchangeTest', () => {
+ /**
+ * 打开应用
+ */
+ beforeAll(async () => {
+ want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ await driver.delayMs(1000);
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ })
+
+ /**
+ * 点击按钮,X25519非对称密钥协商
+ */
+ it('testKeyExchange001', 0, async () => {
+ console.info('uitest: testKeyExchange001 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('X25519'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('X25519').type('Button'));
+ await button2.click();
+ await driver.delayMs(3500);
+ await driver.assertComponentExist(ON.text('X25519 Result: Success'));
+ console.info('uitest: testKeyExchange001 end');
+ await driver.pressBack();
+ })
+
+ /**
+ * 点击按钮,DH密钥协商
+ */
+ it('testKeyExchange002', 0, async () => {
+ console.info('uitest: testKeyExchange002 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('DH'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('DH').type('Button'));
+ await button2.click();
+ await driver.delayMs(3500);
+ await driver.assertComponentExist(ON.text('DH Result: Success'));
+ console.info('uitest: testKeyExchange002 end');
+ await driver.pressBack();
+ })
+
+ /**
+ * 点击按钮,密钥协商(C/C++)
+ */
+ it('testKeyExchange003', 0, async () => {
+ console.info('uitest: testKeyExchange003 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('Call C/C++'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('Call C/C++ Result: 0'));
+ console.info('uitest: testKeyExchange003 end');
+ await driver.pressBack();
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/ets/test/List.test.ets b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..efdb2ea69515d544622c533e36c6b52fce63adf4
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 abilityTest from './Ability.test';
+import keyExchangeTest from './KeyExchange.test';
+
+export default function testsuite() {
+ keyExchangeTest();
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/module.json5 b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/test/List.test.ets b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/test/LocalUnit.test.ets b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/hvigor/hvigor-config.json5 b/UniversalKeystoreKit/KeyUsage/KeyExchange/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..d584c19c247db9a7caee4b606bb931aa9279c637
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/hvigorfile.ts b/UniversalKeystoreKit/KeyUsage/KeyExchange/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/oh-package.json5 b/UniversalKeystoreKit/KeyUsage/KeyExchange/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e41bae026aab3b50d0abb42fece08ba43b4a772b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/ohosTest.md b/UniversalKeystoreKit/KeyUsage/KeyExchange/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..d4941cce1b22c08d507fda5ceb805dfe1876e2ae
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/KeyExchange/ohosTest.md
@@ -0,0 +1,10 @@
+# 密钥协商测试用例归档
+
+## 用例表
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------------------ | ------------ | ---- | ------------------ | -------- | -------- |
+| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass |
+| 点击按钮,X25519非对称密钥协商 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
+| 点击按钮,DH密钥协商 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
+| 点击按钮,密钥协商(C/C++) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/Cpp_1.png b/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/Cpp_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..18f8f0cc77d5cc0e0f5fa848226bcac77e39ff5f
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/Cpp_1.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/Cpp_2.png b/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/Cpp_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..bff5e66377234c8880df85f9d64a55ba32d5feb7
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/Cpp_2.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/DH_1.png b/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/DH_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..e174cf5a8059ce1938dc15fc19ba971ae64185d3
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/DH_1.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/DH_2.png b/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/DH_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..f59179b24fe4b9a2e4d13d3f0f6dcf92432c84d5
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/DH_2.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/X25519_1.png b/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/X25519_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..c4f5cbe9ed1d40788be87cfeef2e93e0caa2a214
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/X25519_1.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/X25519_2.png b/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/X25519_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..e48b3038e1eb853df8ba8c8cfec17387f8e8222f
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/KeyExchange/screenshots/X25519_2.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/.gitignore b/UniversalKeystoreKit/KeyUsage/SigningVerification/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/AppScope/app.json5 b/UniversalKeystoreKit/KeyUsage/SigningVerification/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..681c2bb041f6e055cb91dae41f51930505aec79e
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.signingverification",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/AppScope/resources/base/element/string.json b/UniversalKeystoreKit/KeyUsage/SigningVerification/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..5244c89a0e918b99d3caa2c1dbce5004bac05cb5
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "SigningVerification"
+ }
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/AppScope/resources/base/media/app_icon.png b/UniversalKeystoreKit/KeyUsage/SigningVerification/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/SigningVerification/AppScope/resources/base/media/app_icon.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/README.md b/UniversalKeystoreKit/KeyUsage/SigningVerification/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..ef759535f9a87a20014d2b580dadc47a3a652571
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/README.md
@@ -0,0 +1,143 @@
+## 签名/验签(ArkTS)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-signing-signature-verification-arkts.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### ECC256/SHA256
+
+##### 介绍
+
+1. 本示例主要介绍密钥签名验签,以密钥签名验签类型ECC256/SHA256为例。
+
+##### 效果预览
+
+| 主页 | 执行结果 |
+| ---------------------------------------------------- | ---------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击ECC256/SHA256按钮进行密钥签名验签。
+
+#### SM2/SM3
+
+##### 介绍
+
+1. 本示例主要介绍密钥签名验签,以密钥签名验签类型SM2/SM3为例。
+
+##### 效果预览
+
+| 主页 | 执行结果 |
+| ------------------------------------------------- | ------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击SM2/SM3按钮进行密钥签名验签。
+
+#### RSA/SHA256/PSS
+
+##### 介绍
+
+1. 本示例主要介绍密钥签名验签,以密钥签名验签类型RSA/SHA256/PSS为例。
+
+##### 效果预览
+
+| 主页 | 执行结果 |
+| ------------------------------------------------- | ------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击RSA/SHA256/PSS按钮进行密钥签名验签。
+
+#### RSA/SHA256/PKCS1_V1_5
+
+##### 介绍
+
+1. 本示例主要介绍密钥签名验签,以密钥签名验签类型RSA/SHA256/PKCS1_V1_5为例。
+
+##### 效果预览
+
+| 主页 | 执行结果 |
+| ---------------------------------------------------- | ---------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击RSA/SHA256/PKCS1_V1_5按钮进行密钥签名验签。
+
+## 签名/验签(C/C++)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-signing-signature-verification-ndk.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### Call C/C++
+
+##### 介绍
+
+1. 本示例主要介绍密钥签名验签,以密钥算法为RSA2048、摘要算法为SHA384、填充模式为PSS的密钥为例。
+
+##### 效果预览
+
+| 主页 | 执行结果 |
+| ------------------------------------------------- | ------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击Call C/C++按钮完成密钥签名验签。
+
+## 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---ECC256SHA256.ets
+|---|---|---RSASHA256PKCS1_V1_5.ets
+|---|---|---RSASHA256PSS.ets
+|---|---|---SM2SM3.ets
+|---|---|---Index.ets // 首页
+|---cpp
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---SigningVerification.test.ets // 自动化测试用例
+```
+
+
+## 相关权限
+
+无。
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo UniversalKeystoreKit/KeyUsage/SigningVerification > .git/info/sparse-checkout
+git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/build-profile.json5 b/UniversalKeystoreKit/KeyUsage/SigningVerification/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..fb5a1ab654ae6715a0ab69a31900ad26dcf2487f
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/build-profile.json5
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ "buildOption": {
+ "strictMode": {
+ "caseSensitiveCheck": true,
+ "useNormalizedOHMUrl": true
+ }
+ }
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/code-linter.json5 b/UniversalKeystoreKit/KeyUsage/SigningVerification/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/.gitignore b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/build-profile.json5 b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2d8b081b615348a99aa197f90186f3d8891b7dc1
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/build-profile.json5
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ "externalNativeOptions": {
+ "path": "./src/main/cpp/CMakeLists.txt",
+ "arguments": "",
+ "cppFlags": "",
+ "abiFilters": [
+ "arm64-v8a",
+ "x86_64"
+ ]
+ }
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ },
+ "nativeLib": {
+ "debugSymbol": {
+ "strip": true,
+ "exclude": []
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/hvigorfile.ts b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/oh-package.json5 b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..118bdd4fe7699368a010e04c24f5bfc887cf1298
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/oh-package.json5
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {
+ "libentry.so": "file:./src/main/cpp/types/libentry"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/CMakeLists.txt b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..376c5456c7f6e87e7a020b2db8a14dc8d9a14912
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,15 @@
+# the minimum version of CMake.
+cmake_minimum_required(VERSION 3.5.0)
+project(SigningVerification)
+
+set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+if(DEFINED PACKAGE_FIND_FILE)
+ include(${PACKAGE_FIND_FILE})
+endif()
+
+include_directories(${NATIVERENDER_ROOT_PATH}
+ ${NATIVERENDER_ROOT_PATH}/include)
+
+add_library(entry SHARED napi_init.cpp)
+target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so)
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/napi_init.cpp b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/napi_init.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..590b3d441767bcc1992ac123e532587da69c50b1
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/napi_init.cpp
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start signature_verification_supported_algorithms]
+#include "huks/native_huks_api.h"
+#include "huks/native_huks_param.h"
+#include "napi/native_api.h"
+#include
+
+OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params,
+ uint32_t paramCount)
+{
+ OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_AddParams(*paramSet, params, paramCount);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ ret = OH_Huks_BuildParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ return ret;
+}
+
+static struct OH_Huks_Param g_genSignVerifyParamsTest[] = {
+ {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_RSA},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_SIGN | OH_HUKS_KEY_PURPOSE_VERIFY},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_RSA_KEY_SIZE_2048},
+ {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_PSS},
+ {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA384},
+};
+
+static struct OH_Huks_Param g_signParamsTest[] = {
+ {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_RSA},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_SIGN},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_RSA_KEY_SIZE_2048},
+ {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_PSS},
+ {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA384}};
+
+static struct OH_Huks_Param g_verifyParamsTest[] = {
+ {.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_RSA},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_VERIFY},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_RSA_KEY_SIZE_2048},
+ {.tag = OH_HUKS_TAG_PADDING, .uint32Param = OH_HUKS_PADDING_PSS},
+ {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_SHA384}};
+
+static const uint32_t RSA_COMMON_SIZE = 1024;
+static const char *DATA_TO_SIGN = "Hks_RSA_Sign_Verify_Test_0000000000000000000000000000000000000000000000000000000"
+ "00000000000000000000000000000000000000000000000000000000000000000000000000000000"
+ "0000000000000000000000000000000000000000000000000000000000000000000000000_string";
+
+static napi_value SignVerifyKey(napi_env env, napi_callback_info info)
+{
+ struct OH_Huks_Blob g_keyAlias = {(uint32_t)strlen("test_signVerify"), (uint8_t *)"test_signVerify"};
+ struct OH_Huks_Blob inData = {(uint32_t)strlen(DATA_TO_SIGN), (uint8_t *)DATA_TO_SIGN};
+ struct OH_Huks_ParamSet *genParamSet = nullptr;
+ struct OH_Huks_ParamSet *signParamSet = nullptr;
+ struct OH_Huks_ParamSet *verifyParamSet = nullptr;
+ OH_Huks_Result ohResult;
+ do {
+ ohResult = InitParamSet(&genParamSet, g_genSignVerifyParamsTest,
+ sizeof(g_genSignVerifyParamsTest) / sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ ohResult = InitParamSet(&signParamSet, g_signParamsTest, sizeof(g_signParamsTest) /
+ sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ ohResult =
+ InitParamSet(&verifyParamSet, g_verifyParamsTest, sizeof(g_verifyParamsTest) /
+ sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ /* 1. Generate Key */
+ ohResult = OH_Huks_GenerateKeyItem(&g_keyAlias, genParamSet, nullptr);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ /* 2. Sign */
+ // Init
+ uint8_t handleS[sizeof(uint64_t)] = {0};
+ struct OH_Huks_Blob handleSign = {(uint32_t)sizeof(uint64_t), handleS};
+ ohResult = OH_Huks_InitSession(&g_keyAlias, signParamSet, &handleSign, nullptr);
+ // Update
+ uint8_t outDataS[RSA_COMMON_SIZE] = {0};
+ struct OH_Huks_Blob outDataSign = {RSA_COMMON_SIZE, outDataS};
+ ohResult = OH_Huks_UpdateSession(&handleSign, signParamSet, &inData, &outDataSign);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ // Finish
+ struct OH_Huks_Blob finishInData = {0, NULL};
+ ohResult = OH_Huks_FinishSession(&handleSign, signParamSet, &finishInData, &outDataSign);
+
+ /* 3. Verify */
+ // Init
+ uint8_t handleV[sizeof(uint64_t)] = {0};
+ struct OH_Huks_Blob handleVerify = {(uint32_t)sizeof(uint64_t), handleV};
+ ohResult = OH_Huks_InitSession(&g_keyAlias, verifyParamSet, &handleVerify, nullptr);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ // Update loop
+ uint8_t temp[] = "out";
+ struct OH_Huks_Blob verifyOut = {(uint32_t)sizeof(temp), temp};
+ ohResult = OH_Huks_UpdateSession(&handleVerify, verifyParamSet, &inData, &verifyOut);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ // Finish
+ ohResult = OH_Huks_FinishSession(&handleVerify, verifyParamSet, &outDataSign, &verifyOut);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ } while (0);
+ (void)OH_Huks_DeleteKeyItem(&g_keyAlias, genParamSet);
+ OH_Huks_FreeParamSet(&genParamSet);
+ OH_Huks_FreeParamSet(&signParamSet);
+ OH_Huks_FreeParamSet(&verifyParamSet);
+
+ napi_value ret;
+ napi_create_int32(env, ohResult.errorCode, &ret);
+ return ret;
+}
+
+
+// [End signature_verification_supported_algorithms]
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports)
+{
+ napi_property_descriptor desc[] = {
+ {"signVerifyKey", nullptr, SignVerifyKey, nullptr, nullptr, nullptr, napi_default, nullptr}};
+ napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "entry",
+ .nm_priv = ((void *)0),
+ .reserved = {0},
+};
+
+extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); }
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/types/libentry/index.d.ts b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/types/libentry/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..d5ab38249969b5a1fb1ba8f2fbc77c0348101bad
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/types/libentry/index.d.ts
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2025 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 const signVerifyKey: () => number;
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/types/libentry/oh-package.json5 b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/types/libentry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2826cc7d6bd199c1008bb51d898dffa922201e6c
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/types/libentry/oh-package.json5
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "libentry.so",
+ "types": "./index.d.ts",
+ "version": "1.0.0",
+ "description": "Please describe the basic information."
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/entryability/EntryAbility.ets b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..edc2839f203ba057c186e19b0cbbbf80c8faa8b3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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 { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/ECC256SHA256.ets b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/ECC256SHA256.ets
new file mode 100644
index 0000000000000000000000000000000000000000..3830abfe8d36a55de650d5a8fb815b0c67cbcc58
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/ECC256SHA256.ets
@@ -0,0 +1,215 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start key_algorithm_ECC256SHA256]
+/*
+ * 密钥算法为ECC256、摘要算法为SHA256
+ */
+import { huks } from '@kit.UniversalKeystoreKit';
+
+let keyAlias = 'test_eccKeyAlias';
+let handle: number;
+let plaintext = '123456';
+let signature: Uint8Array;
+
+function stringToUint8Array(str: String) {
+ let arr: number[] = [];
+ for (let i = 0, j = str.length; i < j; ++i) {
+ arr.push(str.charCodeAt(i));
+ }
+ return new Uint8Array(arr);
+}
+
+function uint8ArrayToString(fileData: Uint8Array) {
+ let dataString = '';
+ for (let i = 0; i < fileData.length; i++) {
+ dataString += String.fromCharCode(fileData[i]);
+ }
+ return dataString;
+}
+
+function getEccGenerateProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_ECC
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN |
+ huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256
+ }];
+ return properties;
+}
+
+function getEccSignProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_ECC
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256
+ }];
+ return properties;
+}
+
+function getEccVerifyProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_ECC
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256
+ }];
+ return properties;
+}
+
+async function generateEccKey(keyAlias: string) {
+ let genProperties = getEccGenerateProperties();
+ let options: huks.HuksOptions = {
+ properties: genProperties
+ }
+ await huks.generateKeyItem(keyAlias, options)
+ .then((data) => {
+ console.info(`promise: generate ECC Key success, data = ${JSON.stringify(data)}`);
+ }).catch((err: Error) => {
+ console.error(`promise: generate ECC Key failed, error: ` + JSON.stringify(err));
+ throw (err as Error);
+ })
+}
+
+async function sign(keyAlias: string, plaintext: string) {
+ let signProperties = getEccSignProperties();
+ let options: huks.HuksOptions = {
+ properties: signProperties,
+ inData: stringToUint8Array(plaintext)
+ }
+ await huks.initSession(keyAlias, options)
+ .then((data) => {
+ handle = data.handle;
+ }).catch((err: Error) => {
+ console.error(`promise: init sign failed, error: ` + JSON.stringify(err));
+ throw (err as Error);
+ })
+ await huks.finishSession(handle, options)
+ .then((data) => {
+ console.info(`promise: sign success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ signature = data.outData as Uint8Array;
+ }).catch((err: Error) => {
+ console.error(`promise: sign failed, error: ` + JSON.stringify(err));
+ throw (err as Error);
+ })
+}
+
+async function verify(keyAlias: string, plaintext: string, signature: Uint8Array) {
+ let verifyProperties = getEccVerifyProperties()
+ let options: huks.HuksOptions = {
+ properties: verifyProperties,
+ inData: stringToUint8Array(plaintext)
+ }
+ await huks.initSession(keyAlias, options)
+ .then((data) => {
+ handle = data.handle;
+ }).catch((err: Error) => {
+ console.error(`promise: init verify failed, error: ` + JSON.stringify(err));
+ throw (err as Error);
+ })
+ await huks.updateSession(handle, options)
+ .then((data) => {
+ console.info(`promise: update verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ }).catch((err: Error) => {
+ console.error(`promise: update verify failed, error: ` + JSON.stringify(err));
+ throw (err as Error);
+ })
+ options.inData = signature;
+ await huks.finishSession(handle, options)
+ .then((data) => {
+ console.info(`promise: verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ }).catch((err: Error) => {
+ console.error(`promise: verify failed, error: ` + JSON.stringify(err));
+ throw (err as Error);
+ })
+}
+
+async function deleteEccKey(keyAlias: string) {
+ let emptyOptions: huks.HuksOptions = {
+ properties: []
+ }
+ await huks.deleteKeyItem(keyAlias, emptyOptions)
+ .then((data) => {
+ console.info(`promise: delete data success`);
+ }).catch((err: Error) => {
+ console.error(`promise: delete data failed`);
+ throw (err as Error);
+ })
+}
+
+async function testSignVerify() {
+ await generateEccKey(keyAlias);
+ await sign(keyAlias, plaintext);
+ await verify(keyAlias, plaintext, signature);
+ await deleteEccKey(keyAlias);
+}
+
+
+// [End key_algorithm_ECC256SHA256]
+@Entry
+@Component
+struct Index {
+ @State message: string = 'ECC256/SHA256';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.ecc256_sha256'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ try {
+ await testSignVerify();
+ this.message = 'ECC256/SHA256 Result: Success';
+ } catch (error) {
+ this.message = 'ECC256/SHA256 Result: Failed';
+ }
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/Index.ets b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..69313ce5a58cf76ca73d6d07c941027cd1928c5c
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2025 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 { router } from '@kit.ArkUI';
+import testNapi from 'libentry.so';
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'SigningVerification';
+
+ goToSample(url: string): void {
+ router.pushUrl({
+ url: url,
+ }, router.RouterMode.Single, (err) => {
+ if (err) {
+ console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
+ return;
+ }
+ console.info('pushUrl success');
+ })
+ }
+
+ build() {
+ Column({ space: 5 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.ecc256_sha256'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/ECC256SHA256');
+ })
+ Button($r('app.string.sm2_sm3'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/SM2SM3');
+ })
+ Button($r('app.string.rsa_sha256_pss'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/RSASHA256PSS');
+ })
+ Button($r('app.string.rsa_sha256_pkcs1_v1_5'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/RSASHA256PKCS1_V1_5');
+ })
+ Button($r('app.string.call_cpp_sign_verify'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ let ret: number = testNapi.signVerifyKey();
+ this.message = 'Call C/C++ Result: ' + ret.toString();
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PKCS1_V1_5.ets b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PKCS1_V1_5.ets
new file mode 100644
index 0000000000000000000000000000000000000000..ef2f7a204375ec358f1cd2a6b11b5d534dd4523b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PKCS1_V1_5.ets
@@ -0,0 +1,219 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+// [Start key_algorithm_RSASHA256PKCS1_V1_5]
+/*
+ * 密钥算法为RSA,摘要算法为SHA256,填充模式为PKCS1_V1_5
+ */
+import { huks } from '@kit.UniversalKeystoreKit';
+
+let keyAlias = 'test_rsaKeyAlias';
+let handle: number;
+let plaintext = '123456';
+let signature: Uint8Array;
+
+function stringToUint8Array(str: String) {
+ let arr: number[] = [];
+ for (let i = 0, j = str.length; i < j; ++i) {
+ arr.push(str.charCodeAt(i));
+ }
+ return new Uint8Array(arr);
+}
+
+function uint8ArrayToString(fileData: Uint8Array) {
+ let dataString = '';
+ for (let i = 0; i < fileData.length; i++) {
+ dataString += String.fromCharCode(fileData[i]);
+ }
+ return dataString;
+}
+
+function getRsaGenerateProperties() {
+ let properties: huks.HuksParam[] = [
+ { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, value: huks.HuksKeyAlg.HUKS_ALG_RSA },
+ { tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY
+ },
+ { tag: huks.HuksTag.HUKS_TAG_PADDING, value: huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5 },
+ { tag: huks.HuksTag.HUKS_TAG_DIGEST, value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 }
+ ];
+ return properties;
+}
+
+function getRsaSignProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_RSA
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256
+ }];
+ return properties;
+}
+
+function getRsaVerifyProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_RSA
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_PKCS1_V1_5
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256
+ }];
+ return properties;
+}
+
+async function generateRsaKey(keyAlias: string) {
+ let genProperties = getRsaGenerateProperties();
+ let options: huks.HuksOptions = {
+ properties: genProperties
+ }
+ await huks.generateKeyItem(keyAlias, options)
+ .then((data) => {
+ console.info(`promise: generate RSA Key success, data = ${JSON.stringify(data)}`);
+ }).catch((err: Error) => {
+ console.error(`promise: generate RSA Key failed, error: ` + JSON.stringify(err));
+ throw (err as Error);
+ })
+}
+
+async function sign(keyAlias: string, plaintext: string) {
+ let signProperties = getRsaSignProperties();
+ let options: huks.HuksOptions = {
+ properties: signProperties,
+ inData: stringToUint8Array(plaintext)
+ }
+ await huks.initSession(keyAlias, options)
+ .then((data) => {
+ handle = data.handle;
+ }).catch((err: Error) => {
+ console.error(`promise: init sign failed, error: ` + JSON.stringify(err));
+ throw (err as Error);
+ })
+ await huks.finishSession(handle, options)
+ .then((data) => {
+ console.info(`promise: sign success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ signature = data.outData as Uint8Array;
+ }).catch((err: Error) => {
+ console.error(`promise: sign failed, error: ` + JSON.stringify(err));
+ throw (err as Error);
+ })
+}
+
+async function verify(keyAlias: string, plaintext: string, signature: Uint8Array) {
+ let verifyProperties = getRsaVerifyProperties()
+ let options: huks.HuksOptions = {
+ properties: verifyProperties,
+ inData: stringToUint8Array(plaintext)
+ }
+ await huks.initSession(keyAlias, options)
+ .then((data) => {
+ handle = data.handle;
+ }).catch((err: Error) => {
+ console.error(`promise: init verify failed, error: ` + JSON.stringify(err));
+ throw (err as Error);
+ })
+ await huks.updateSession(handle, options)
+ .then((data) => {
+ console.info(`promise: update verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ }).catch((err: Error) => {
+ console.error(`promise: update verify failed, error: ` + JSON.stringify(err));
+ throw (err as Error);
+ })
+ options.inData = signature;
+ await huks.finishSession(handle, options)
+ .then((data) => {
+ console.info(`promise: verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ }).catch((err: Error) => {
+ console.error(`promise: verify failed, error: ` + JSON.stringify(err));
+ throw (err as Error);
+ })
+}
+
+async function deleteRsaKey(keyAlias: string) {
+ let emptyOptions: huks.HuksOptions = {
+ properties: []
+ }
+ await huks.deleteKeyItem(keyAlias, emptyOptions)
+ .then((data) => {
+ console.info(`promise: delete data success`);
+ }).catch((err: Error) => {
+ console.error(`promise: delete data failed`);
+ throw (err as Error);
+ })
+}
+
+export async function testSignVerify() {
+ await generateRsaKey(keyAlias);
+ await sign(keyAlias, plaintext);
+ await verify(keyAlias, plaintext, signature);
+ await deleteRsaKey(keyAlias);
+}
+
+
+
+// [End key_algorithm_RSASHA256PKCS1_V1_5]
+@Entry
+@Component
+struct Index {
+ @State message: string = 'RSA/SHA256/PKCS1_V1_5';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.rsa_sha256_pkcs1_v1_5'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ try {
+ await testSignVerify();
+ this.message = 'RSA/SHA256/PKCS1_V1_5 Result: Success';
+ } catch (error) {
+ this.message = 'RSA/SHA256/PKCS1_V1_5 Result: Failed';
+ }
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PSS.ets b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PSS.ets
new file mode 100644
index 0000000000000000000000000000000000000000..eb1ae9e3c77fb880554f57ac5eacb24fa7faa34a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PSS.ets
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+//
+// [Start key_algorithm_RSASHA256PSS]
+/*
+ * 密钥算法为RSA,摘要算法为SHA256,填充模式为PSS
+ */
+import { huks } from '@kit.UniversalKeystoreKit';
+
+let keyAlias = 'test_rsaKeyAlias';
+let handle: number;
+let plaintext = '123456';
+let signature: Uint8Array;
+
+function stringToUint8Array(str: string) {
+ let arr: number[] = [];
+ for (let i = 0, j = str.length; i < j; ++i) {
+ arr.push(str.charCodeAt(i));
+ }
+ return new Uint8Array(arr);
+}
+
+function uint8ArrayToString(fileData: Uint8Array) {
+ let dataString = '';
+ for (let i = 0; i < fileData.length; i++) {
+ dataString += String.fromCharCode(fileData[i]);
+ }
+ return dataString;
+}
+
+function getRsaGenerateProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_RSA
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN |
+ huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_PSS
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256
+ }];
+ return properties;
+}
+
+function getRsaSignProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_RSA
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_PSS
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN
+ }];
+ return properties;
+}
+
+function getRsaVerifyProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_RSA
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PADDING,
+ value: huks.HuksKeyPadding.HUKS_PADDING_PSS
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY
+ }];
+ return properties;
+}
+
+async function generateRsaKey(keyAlias: string) {
+ let genProperties = getRsaGenerateProperties();
+ let options: huks.HuksOptions = {
+ properties: genProperties
+ };
+ await huks.generateKeyItem(keyAlias, options)
+ .then((data) => {
+ console.info(`promise: generate RSA Key success, data = ${JSON.stringify(data)}`);
+ }).catch((err: Error) => {
+ console.error(`promise: generate RSA Key failed, error: ` + JSON.stringify(err));
+ throw (err as Error);
+ });
+}
+
+async function sign(keyAlias: string, plaintext: string) {
+ let signProperties = getRsaSignProperties();
+ let options: huks.HuksOptions = {
+ properties: signProperties,
+ inData: stringToUint8Array(plaintext)
+ }
+ await huks.initSession(keyAlias, options)
+ .then((data) => {
+ handle = data.handle;
+ }).catch((err: Error) => {
+ console.error(`promise: init sign failed, error: ` + JSON.stringify(err));
+ return;
+ });
+
+ if (handle !== undefined) {
+ await huks.finishSession(handle, options)
+ .then((data) => {
+ console.info(`promise: sign success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ signature = data.outData as Uint8Array;
+ }).catch((err: Error) => {
+ console.error(`promise: sign failed, error: ` + JSON.stringify(err));
+ throw (err as Error);
+ });
+ }
+}
+
+async function verify(keyAlias: string, plaintext: string, signature: Uint8Array) {
+ let verifyProperties = getRsaVerifyProperties();
+ let options: huks.HuksOptions = {
+ properties: verifyProperties,
+ inData: stringToUint8Array(plaintext)
+ }
+ await huks.initSession(keyAlias, options)
+ .then((data) => {
+ handle = data.handle;
+ }).catch((err: Error) => {
+ console.error(`promise: init verify failed, error: ` + JSON.stringify(err));
+ return;
+ });
+
+ if (handle !== undefined) {
+ await huks.updateSession(handle, options)
+ .then((data) => {
+ console.info(`promise: update verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ }).catch((err: Error) => {
+ console.error(`promise: update verify failed, error: ` + JSON.stringify(err));
+ throw (err as Error);
+ });
+
+ options.inData = signature;
+ await huks.finishSession(handle, options)
+ .then((data) => {
+ console.info(`promise: verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ }).catch((err: Error) => {
+ console.error(`promise: verify failed, error: ` + JSON.stringify(err));
+ throw (err as Error);
+ });
+ }
+}
+
+async function deleteRsaKey(keyAlias: string) {
+ let emptyOptions: huks.HuksOptions = {
+ properties: []
+ }
+ await huks.deleteKeyItem(keyAlias, emptyOptions)
+ .then((data) => {
+ console.info(`promise: delete data success`);
+ }).catch((err: Error) => {
+ console.error(`promise: delete data failed`);
+ throw (err as Error);
+ });
+}
+
+export async function testSignVerify() {
+ await generateRsaKey(keyAlias);
+ await sign(keyAlias, plaintext);
+ await verify(keyAlias, plaintext, signature);
+ await deleteRsaKey(keyAlias);
+}
+
+
+// [End key_algorithm_RSASHA256PSS]
+@Entry
+@Component
+struct Index {
+ @State message: string = 'RSA/SHA256/PSS';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.rsa_sha256_pss'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ try {
+ await testSignVerify();
+ this.message = 'RSA/SHA256/PSS Result: Success';
+ }catch {
+ this.message = 'RSA/SHA256/PSS Result: Failed';
+ }
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/SM2SM3.ets b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/SM2SM3.ets
new file mode 100644
index 0000000000000000000000000000000000000000..aae9a24519ed9c9c62173e59acb3769e2cae07fd
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/SM2SM3.ets
@@ -0,0 +1,218 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start key_algorithm_SM2SM3]
+/*
+ * 密钥算法为SM2、摘要算法为SM3
+ */
+import { huks } from '@kit.UniversalKeystoreKit';
+
+let keyAlias = 'test_sm2KeyAlias';
+let handle: number;
+let plaintext = '123456';
+let signature: Uint8Array;
+
+
+function stringToUint8Array(str: String) {
+ let arr: number[] = [];
+ for (let i = 0, j = str.length; i < j; ++i) {
+ arr.push(str.charCodeAt(i));
+ }
+ return new Uint8Array(arr);
+}
+
+
+function uint8ArrayToString(fileData: Uint8Array) {
+ let dataString = '';
+ for (let i = 0; i < fileData.length; i++) {
+ dataString += String.fromCharCode(fileData[i]);
+ }
+ return dataString;
+}
+
+
+function getSm2GenerateProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_SM2
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN |
+ huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SM3
+ }];
+ return properties;
+}
+
+function getSm2SignProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_SM2
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SM3
+ }];
+ return properties;
+}
+
+function getSm2VerifyProperties() {
+ let properties: huks.HuksParam[] = [{
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_SM2
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY
+ }, {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SM3
+ }];
+ return properties;
+}
+
+async function generateSm2Key(keyAlias: string) {
+ let genProperties = getSm2GenerateProperties();
+ let options: huks.HuksOptions = {
+ properties: genProperties
+ }
+ await huks.generateKeyItem(keyAlias, options)
+ .then((data) => {
+ console.info(`promise: generate Sm2 Key success, data = ${JSON.stringify(data)}`);
+ }).catch((err: Error) => {
+ console.error(`promise: generate Sm2 Key failed, error: ` + JSON.stringify(err));
+ throw (err as Error);
+ })
+}
+
+async function sign(keyAlias: string, plaintext: string) {
+ let signProperties = getSm2SignProperties();
+ let options: huks.HuksOptions = {
+ properties: signProperties,
+ inData: stringToUint8Array(plaintext)
+ }
+ await huks.initSession(keyAlias, options)
+ .then((data) => {
+ handle = data.handle;
+ }).catch((err: Error) => {
+ console.error(`promise: init sign failed, error: ` + JSON.stringify(err));
+ throw (err as Error);
+ })
+ await huks.finishSession(handle, options)
+ .then((data) => {
+ console.info(`promise: sign success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ signature = data.outData as Uint8Array;
+ }).catch((err: Error) => {
+ console.error(`promise: sign failed, error: ` + JSON.stringify(err));
+ throw (err as Error);
+ })
+}
+
+async function verify(keyAlias: string, plaintext: string, signature: Uint8Array) {
+ let verifyProperties = getSm2VerifyProperties()
+ let options: huks.HuksOptions = {
+ properties: verifyProperties,
+ inData: stringToUint8Array(plaintext)
+ }
+ await huks.initSession(keyAlias, options)
+ .then((data) => {
+ handle = data.handle;
+ }).catch((err: Error) => {
+ console.error(`promise: init verify failed, error: ` + JSON.stringify(err));
+ throw (err as Error);
+ })
+ await huks.updateSession(handle, options)
+ .then((data) => {
+ console.info(`promise: update verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ }).catch((err: Error) => {
+ console.error(`promise: update verify failed, error: ` + JSON.stringify(err));
+ throw (err as Error);
+ })
+ options.inData = signature;
+ await huks.finishSession(handle, options)
+ .then((data) => {
+ console.info(`promise: verify success, data is ` + uint8ArrayToString(data.outData as Uint8Array));
+ }).catch((err: Error) => {
+ console.error(`promise: verify failed, error: ` + JSON.stringify(err));
+ throw (err as Error);
+ })
+}
+
+async function deleteSm2Key(keyAlias: string) {
+ let emptyOptions: huks.HuksOptions = {
+ properties: []
+ }
+ await huks.deleteKeyItem(keyAlias, emptyOptions)
+ .then((data) => {
+ console.info(`promise: delete data success`);
+ }).catch((err: Error) => {
+ console.error(`promise: delete data failed`);
+ throw (err as Error);
+ })
+}
+
+export async function testSignVerify() {
+ await generateSm2Key(keyAlias);
+ await sign(keyAlias, plaintext);
+ await verify(keyAlias, plaintext, signature);
+ await deleteSm2Key(keyAlias);
+}
+
+
+// [End key_algorithm_SM2SM3]
+@Entry
+@Component
+struct Index {
+ @State message: string = 'SM2/SM3';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.sm2_sm3'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ try {
+ let ret = await testSignVerify();
+ this.message = 'SM2/SM3 Result: Success';
+ } catch {
+ this.message = 'SM2/SM3 Result: Failed';
+ }
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/module.json5 b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..4144486d1af4c03b0d767cce1cda86fc0d697f91
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/module.json5
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/element/color.json b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/element/string.json b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..d5c398960a436206a084d05e065103b672f30300
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,68 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "SigningVerification"
+ },
+ {
+ "name": "ecc256_sha256",
+ "value": "ECC256/SHA256"
+ },
+ {
+ "name": "sm2_sm3",
+ "value": "SM2/SM3"
+ },
+ {
+ "name": "rsa_sha256_pss",
+ "value": "RSA/SHA256/PSS"
+ },
+ {
+ "name": "rsa_sha256_pkcs1_v1_5",
+ "value": "RSA/SHA256/PKCS1_V1_5"
+ },
+ {
+ "name": "call_cpp_sign_verify",
+ "value": "Call C/C++"
+ },
+ {
+ "name": "ecc256_sha256_result_success",
+ "value": "ECC256/SHA256 Result: Success"
+ },
+ {
+ "name": "ecc256_sha256_result_failed",
+ "value": "ECC256/SHA256 Result: Failed"
+ },
+ {
+ "name": "rsa_sha256_pkcs1_v1_5_result_success",
+ "value": "RSA/SHA256/PKCS1_V1_5 Result: Success"
+ },
+ {
+ "name": "rsa_sha256_pkcs1_v1_5_result_failed",
+ "value": "RSA/SHA256/PKCS1_V1_5 Result: Failed"
+ },
+ {
+ "name": "rsa_sha256_pss_result_success",
+ "value": "RSA/SHA256/PSS Result: Success"
+ },
+ {
+ "name": "rsa_sha256_pss_result_failed",
+ "value": "RSA/SHA256/PSS Result: Failed"
+ },
+ {
+ "name": "sm2_sm3_result_success",
+ "value": "SM2/SM3 Result: Success"
+ },
+ {
+ "name": "sm2_sm3_result_failed",
+ "value": "SM2/SM3 Result: Failed"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/background.png b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/background.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/foreground.png b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/foreground.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/layered_image.json b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/startIcon.png b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/profile/backup_config.json b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/profile/main_pages.json b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..65bc862e86437fbaecbdf5e757a52b88eb0a332d
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,9 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/ECC256SHA256",
+ "pages/RSASHA256PKCS1_V1_5",
+ "pages/RSASHA256PSS",
+ "pages/SM2SM3"
+ ]
+}
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/dark/element/color.json b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/dark/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/resources/dark/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#000000"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/ets/test/Ability.test.ets b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/ets/test/List.test.ets b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0c1f35da764583310a6ce1f3e86c5014b7507784
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2025 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 abilityTest from './Ability.test';
+import signingVerificationTest from './SigningVerification.test';
+
+export default function testsuite() {
+ abilityTest();
+ signingVerificationTest();
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/ets/test/SigningVerification.test.ets b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/ets/test/SigningVerification.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..d609d5490616eaeb5a30d07d6858f3ddb379a239
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/ets/test/SigningVerification.test.ets
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, it, expect, beforeAll } from '@ohos/hypium';
+// 导入测试依赖kit
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+let want: Want;
+
+export default function signingVerificationTest() {
+ describe('signingVerificationTest', () => {
+ /**
+ * 打开应用
+ */
+ beforeAll(async () => {
+ want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ await driver.delayMs(1000);
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ })
+
+ /**
+ * 点击按钮,签名/验签ECC256/SHA256
+ */
+ it('testSigningVerification001', 0, async () => {
+ console.info('uitest: testSigningVerification001 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('ECC256/SHA256'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('ECC256/SHA256').type('Button'));
+ await button2.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('ECC256/SHA256 Result: Success'));
+ console.info('uitest: testSigningVerification001 end');
+ await driver.pressBack();
+ })
+
+ /**
+ * 点击按钮,签名/验签SM2/SM3
+ */
+ it('testSigningVerification002', 0, async () => {
+ console.info('uitest: testSigningVerification002 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('SM2/SM3'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('SM2/SM3').type('Button'));
+ await button2.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('SM2/SM3 Result: Success'));
+ console.info('uitest: testSigningVerification002 end');
+ await driver.pressBack();
+ })
+
+ /**
+ * 点击按钮,签名/验签RSA/SHA256/PSS
+ */
+ it('testSigningVerification003', 0, async () => {
+ console.info('uitest: testSigningVerification003 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('RSA/SHA256/PSS'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('RSA/SHA256/PSS').type('Button'));
+ await button2.click();
+ await driver.delayMs(4000);
+ await driver.assertComponentExist(ON.text('RSA/SHA256/PSS Result: Success'));
+ console.info('uitest: testSigningVerification003 end');
+ await driver.pressBack();
+ })
+
+ /**
+ * 点击按钮,签名/验签RSA/SHA256/PKCS1_V1_5
+ */
+ it('testSigningVerification004', 0, async () => {
+ console.info('uitest: testSigningVerification004 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('RSA/SHA256/PKCS1_V1_5'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('RSA/SHA256/PKCS1_V1_5').type('Button'));
+ await button2.click();
+ await driver.delayMs(4000);
+ await driver.assertComponentExist(ON.text('RSA/SHA256/PKCS1_V1_5 Result: Success'));
+ console.info('uitest: testSigningVerification004 end');
+ await driver.pressBack();
+ })
+
+ /**
+ * 点击按钮,签名/验签C/C++
+ */
+ it('testSigningVerification005', 0, async () => {
+ console.info('uitest: testSigningVerification005 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('Call C/C++'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('Call C/C++ Result: 0'));
+ console.info('uitest: testSigningVerification005 end');
+ await driver.pressBack();
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/module.json5 b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/test/List.test.ets b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/test/LocalUnit.test.ets b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/hvigor/hvigor-config.json5 b/UniversalKeystoreKit/KeyUsage/SigningVerification/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..d584c19c247db9a7caee4b606bb931aa9279c637
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/hvigorfile.ts b/UniversalKeystoreKit/KeyUsage/SigningVerification/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/oh-package.json5 b/UniversalKeystoreKit/KeyUsage/SigningVerification/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e41bae026aab3b50d0abb42fece08ba43b4a772b
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/ohosTest.md b/UniversalKeystoreKit/KeyUsage/SigningVerification/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..8bd7bdea561b7fad69db096765bf34eb8c8111be
--- /dev/null
+++ b/UniversalKeystoreKit/KeyUsage/SigningVerification/ohosTest.md
@@ -0,0 +1,12 @@
+# 签名/验签测试用例归档
+
+## 用例表
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ---------------------------------------- | ------------ | ---- | ------------------ | -------- | -------- |
+| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass |
+| 点击按钮,签名/验签ECC256/SHA256 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
+| 点击按钮,签名/验签SM2/SM3 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
+| 点击按钮,签名/验签RSA/SHA256/PSS | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
+| 点击按钮,签名/验签RSA/SHA256/PKCS1_V1_5 | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
+| 点击按钮,签名/验签C/C++ | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
\ No newline at end of file
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/ECC2561.png b/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/ECC2561.png
new file mode 100644
index 0000000000000000000000000000000000000000..252dbabaa0cb3c28cc324f48b0d882db1e031452
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/ECC2561.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/ECC2562.png b/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/ECC2562.png
new file mode 100644
index 0000000000000000000000000000000000000000..400b4266c04b9dc66de5d8db110c2026ce4b0642
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/ECC2562.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/RSA1.png b/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/RSA1.png
new file mode 100644
index 0000000000000000000000000000000000000000..787f3e9a5e28f212e6cc5d7e6a984a6b1c19eadb
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/RSA1.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/RSA2.png b/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/RSA2.png
new file mode 100644
index 0000000000000000000000000000000000000000..ca98a807da703b0a1b707a953c12859b994c762a
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/RSA2.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SHA2561.png b/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SHA2561.png
new file mode 100644
index 0000000000000000000000000000000000000000..dcf0dcb073906586c4f7bd508eb0288a5e975efa
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SHA2561.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SHA2562.png b/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SHA2562.png
new file mode 100644
index 0000000000000000000000000000000000000000..37bb6090b538c66a63b9482691c01f11f2b1041f
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SHA2562.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SM21.png b/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SM21.png
new file mode 100644
index 0000000000000000000000000000000000000000..3f0c0d889707a562d93adc10e9c01c888363d54a
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SM21.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SM22.png b/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SM22.png
new file mode 100644
index 0000000000000000000000000000000000000000..f3a57749b3f76a70532e572423e2114bbf9c519a
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/SM22.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/cpp1.png b/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/cpp1.png
new file mode 100644
index 0000000000000000000000000000000000000000..0740f3ea8c9ba409ac2e42fce0b811ffd4c95022
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/cpp1.png differ
diff --git a/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/cpp2.png b/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/cpp2.png
new file mode 100644
index 0000000000000000000000000000000000000000..be6dff82a487ad3f8c29cb546897442dba166921
Binary files /dev/null and b/UniversalKeystoreKit/KeyUsage/SigningVerification/screenshots/cpp2.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/.gitignore b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/AppScope/app.json5 b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..70552995056a2f9c64bbe4113945a75b0c3eeed6
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.checkkeyexists",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/AppScope/resources/base/element/string.json b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..b52da87a06229d9c75fba2ecef8ac99052d55017
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "CheckKeyExists"
+ }
+ ]
+}
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/AppScope/resources/base/media/app_icon.png b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/AppScope/resources/base/media/app_icon.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/README.md b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..3cfe8f52e28dba623d91aafc531590cfe5fe4bc3
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/README.md
@@ -0,0 +1,92 @@
+## 查询密钥是否存在(ArkTS)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-check-key-arkts.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### CheckKeyExists
+
+##### 介绍
+
+1. 本示例主要介绍HUKS提供了接口供应用查询指定密钥是否存在。
+
+##### 效果预览
+
+| 主页 | 查询密钥 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+|
|
|
+
+使用说明
+
+1. 点击CheckKeyExists按钮调用接口hasKeyItem,查询密钥是否存在。
+
+## 查询密钥是否存在(C/C++)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-check-key-ndk.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### Call C/C++
+
+##### 介绍
+
+1. 本示例主要介绍HUKS提供了接口供应用查询指定密钥是否存在。
+
+##### 效果预览
+
+| 主页 | 查询密钥 |
+| -------------------------------------------------- | -------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击Call C/C++按钮调用接口OH_Huks_IsKeyItemExist,查询密钥是否存在。
+
+## 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---CheckKeyExists.ets
+|---|---|---Index.ets // 首页
+|---cpp
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---HMAC.test.ets // 自动化测试用例
+```
+
+
+## 相关权限
+
+无。
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo UniversalKeystoreKit/OtherOperations/CheckKeyExists > .git/info/sparse-checkout
+git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/build-profile.json5 b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..fb5a1ab654ae6715a0ab69a31900ad26dcf2487f
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/build-profile.json5
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ "buildOption": {
+ "strictMode": {
+ "caseSensitiveCheck": true,
+ "useNormalizedOHMUrl": true
+ }
+ }
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/code-linter.json5 b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/.gitignore b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/build-profile.json5 b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2d8b081b615348a99aa197f90186f3d8891b7dc1
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/build-profile.json5
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ "externalNativeOptions": {
+ "path": "./src/main/cpp/CMakeLists.txt",
+ "arguments": "",
+ "cppFlags": "",
+ "abiFilters": [
+ "arm64-v8a",
+ "x86_64"
+ ]
+ }
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ },
+ "nativeLib": {
+ "debugSymbol": {
+ "strip": true,
+ "exclude": []
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/hvigorfile.ts b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/oh-package.json5 b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..118bdd4fe7699368a010e04c24f5bfc887cf1298
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/oh-package.json5
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {
+ "libentry.so": "file:./src/main/cpp/types/libentry"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/CMakeLists.txt b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..1fa27ba437437c563ec5cf148d4d1c9e61f74437
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,15 @@
+# the minimum version of CMake.
+cmake_minimum_required(VERSION 3.5.0)
+project(CheckKeyExists)
+
+set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+if(DEFINED PACKAGE_FIND_FILE)
+ include(${PACKAGE_FIND_FILE})
+endif()
+
+include_directories(${NATIVERENDER_ROOT_PATH}
+ ${NATIVERENDER_ROOT_PATH}/include)
+
+add_library(entry SHARED napi_init.cpp)
+target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so)
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/napi_init.cpp b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/napi_init.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6abbe282e65e0acd86c7f00573d70fc3994eff99
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/napi_init.cpp
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start query_whether_the_key_exists]
+#include "huks/native_huks_api.h"
+#include "huks/native_huks_param.h"
+#include "napi/native_api.h"
+#include
+// [StartExclude query_whether_the_key_exists]
+/* 以下以生成ECC密钥为例 */
+OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params,
+ uint32_t paramCount)
+{
+ OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_AddParams(*paramSet, params, paramCount);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ ret = OH_Huks_BuildParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ return ret;
+}
+
+struct OH_Huks_Param g_testGenerateKeyParam[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECC},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256},
+ {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}};
+
+static OH_Huks_Result GenerateKeyHelper(const char *alias)
+{
+ struct OH_Huks_Blob aliasBlob = {.size = (uint32_t)strlen(alias), .data = (uint8_t *)alias};
+ struct OH_Huks_ParamSet *testGenerateKeyParamSet = nullptr;
+ struct OH_Huks_Result ohResult;
+ do {
+ /* 1.初始化密钥属性集 */
+ ohResult = InitParamSet(&testGenerateKeyParamSet, g_testGenerateKeyParam,
+ sizeof(g_testGenerateKeyParam) / sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ /* 2.生成密钥 */
+ ohResult = OH_Huks_GenerateKeyItem(&aliasBlob, testGenerateKeyParamSet, nullptr);
+ } while (0);
+ OH_Huks_FreeParamSet(&testGenerateKeyParamSet);
+ return ohResult;
+}
+// [EndExclude query_whether_the_key_exists]
+static napi_value IsKeyExist(napi_env env, napi_callback_info info)
+{
+ /* 1.获取密钥别名 */
+ const char *alias = "test_key";
+ struct OH_Huks_Blob keyAlias = {
+ (uint32_t)strlen(alias),
+ (uint8_t *)alias
+ };
+
+ /* 生成密钥 */
+ OH_Huks_Result genResult = GenerateKeyHelper(alias);
+ if (genResult.errorCode != OH_HUKS_SUCCESS) {
+ napi_value ret;
+ napi_create_int32(env, genResult.errorCode, &ret);
+ return ret;
+ }
+
+ /* 2.调用OH_Huks_IsKeyItemExist判断密钥是否存在 */
+ struct OH_Huks_Result ohResult = OH_Huks_IsKeyItemExist(&keyAlias, nullptr);
+ // OH_HUKS_SUCCESS表示存在, OH_HUKS_ERR_CODE_ITEM_NOT_EXIST表示不存在
+
+ napi_value ret;
+ napi_create_int32(env, ohResult.errorCode, &ret);
+ return ret;
+}
+// [End query_whether_the_key_exists]
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports)
+{
+ napi_property_descriptor desc[] = {
+ { "isKeyExist", nullptr, IsKeyExist, nullptr, nullptr, nullptr, napi_default, nullptr }
+ };
+ napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "entry",
+ .nm_priv = ((void*)0),
+ .reserved = { 0 },
+};
+
+extern "C" __attribute__((constructor)) void RegisterEntryModule(void)
+{
+ napi_module_register(&demoModule);
+}
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/types/libentry/index.d.ts b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/types/libentry/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..d13f949ed36ef22f9d5593606a56f77e2f773183
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/types/libentry/index.d.ts
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2025 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 const isKeyExist: () => number;
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/types/libentry/oh-package.json5 b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/types/libentry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2826cc7d6bd199c1008bb51d898dffa922201e6c
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/types/libentry/oh-package.json5
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "libentry.so",
+ "types": "./index.d.ts",
+ "version": "1.0.0",
+ "description": "Please describe the basic information."
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/entryability/EntryAbility.ets b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..edc2839f203ba057c186e19b0cbbbf80c8faa8b3
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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 { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/pages/CheckKeyExists.ets b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/pages/CheckKeyExists.ets
new file mode 100644
index 0000000000000000000000000000000000000000..9080f921ae6c68eb094ead356dcdb4c70f440d2d
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/pages/CheckKeyExists.ets
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+
+// [Start querying_the_existence_of_a_key]
+import { huks } from '@kit.UniversalKeystoreKit';
+
+/* 1.确定密钥别名 */
+let keyAlias = 'test_key';
+let isKeyExist: Boolean;
+/* 2.构造空对象 */
+let huksOptions: huks.HuksOptions = {
+ properties: []
+}
+// [StartExclude querying_the_existence_of_a_key]
+/* 3.初始化密钥属性集 */
+let generateProperties: huks.HuksParam[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_DH
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_DH_KEY_SIZE_2048
+ }
+];
+
+let generateHuksOptions: huks.HuksOptions = {
+ properties: generateProperties,
+ inData: new Uint8Array([])
+}
+
+/* 3.生成密钥 */
+function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.generateKeyItem(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions): Promise {
+ console.info(`enter promise generateKeyItem`);
+ try {
+ await generateKeyItem(keyAlias, huksOptions)
+ .then((data) => {
+ console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`);
+ });
+ return 'Success';
+ } catch (error) {
+ console.error(`promise: generateKeyItem input arg invalid, ` + JSON.stringify(error));
+ return 'Failed';
+ }
+}
+
+async function testGenKey(): Promise {
+ let ret = await publicGenKeyFunc(keyAlias, generateHuksOptions);
+ return ret;
+}
+
+function check(): string {
+// [EndExclude querying_the_existence_of_a_key]
+ try {
+ /* 1.生成密钥 */
+ testGenKey();
+ /* 2.判断密钥是否存在 */
+ huks.hasKeyItem(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ console.error(`callback: hasKeyItem failed, ` + JSON.stringify(error));
+ } else {
+ if (data !== null && data.valueOf() !== null) {
+ isKeyExist = data.valueOf();
+ console.info(`callback: hasKeyItem success, isKeyExist = ${isKeyExist}`);
+ }
+ }
+ });
+ return 'Success';
+ } catch (error) {
+ console.error(`callback: hasKeyItem input arg invalid, ` + JSON.stringify(error));
+ return 'Failed';
+ }
+// [End querying_the_existence_of_a_key]
+}
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'CheckKeyExists';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.call_check_key_exists'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ let ret: string = check();
+ this.message = 'CheckKeyExists Result: ' + ret;
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/pages/Index.ets b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..8a28863c44137870e3ef51d0f9de55855a617a15
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2025 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 { router } from '@kit.ArkUI';
+import testNapi from 'libentry.so';
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'CheckKeyExists';
+
+ goToSample(url: string): void {
+ router.pushUrl({
+ url: url,
+ }, router.RouterMode.Single, (err) => {
+ if (err) {
+ console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
+ return;
+ }
+ console.info('pushUrl success');
+ })
+ }
+
+ build() {
+ Column({ space: 5 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.check_key_exists'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/CheckKeyExists')
+ })
+ Button($r('app.string.call_cpp_is_key_exist'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ let ret: number = testNapi.isKeyExist();
+ this.message = 'Call C/C++ Result: ' + ret.toString();
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/module.json5 b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..4144486d1af4c03b0d767cce1cda86fc0d697f91
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/module.json5
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/element/color.json b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/element/string.json b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..dbe2a4fd41c4f55d128f21e149716176f3df6d5e
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,28 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "CheckKeyExists"
+ },
+ {
+ "name": "check_key_exists",
+ "value": "CheckKeyExists"
+ },
+ {
+ "name": "call_cpp_is_key_exist",
+ "value": "Call C/C++"
+ },
+ {
+ "name": "call_check_key_exists",
+ "value": "Call CheckKeyExists"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/background.png b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/background.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/foreground.png b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/foreground.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/layered_image.json b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/startIcon.png b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/profile/backup_config.json b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/profile/main_pages.json b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..fbba609f7524f2bbbb7fc6c2b1721b570c7b4407
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,6 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/CheckKeyExists"
+ ]
+}
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/dark/element/color.json b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/dark/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/resources/dark/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#000000"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/ets/test/Ability.test.ets b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/ets/test/CheckKeyExists.test.ets b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/ets/test/CheckKeyExists.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..a41b084cd3264659743e16fe4d5084effa8e7870
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/ets/test/CheckKeyExists.test.ets
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, it, expect, beforeAll } from '@ohos/hypium';
+// 导入测试依赖kit
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+let want: Want;
+
+export default function checkKeyExistsTest() {
+ describe('checkKeyExistsTest', () => {
+ /**
+ * 打开应用
+ */
+ beforeAll(async () => {
+ want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ await driver.delayMs(1000);
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ })
+
+ /**
+ * 点击按钮,查询密钥是否存在(ArkTS)
+ */
+ it('testCheckKeyExists001', 0, async () => {
+ console.info('uitest: testCheckKeyExists001 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('CheckKeyExists').type('Button'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('Call CheckKeyExists'));
+ await button2.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('CheckKeyExists Result: Success'));
+ console.info('uitest: testCheckKeyExists001 end');
+ await driver.pressBack();
+ })
+
+ /**
+ * 点击按钮,查询密钥是否存在(C/C++)
+ */
+ it('testCheckKeyExists002', 0, async () => {
+ console.info('uitest: testCheckKeyExists002 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('Call C/C++'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('Call C/C++ Result: 0'));
+ console.info('uitest: testCheckKeyExists002 end');
+ await driver.pressBack();
+ })
+ })
+}
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/ets/test/List.test.ets b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7efd05967067708fdec19920a75c610866c7a339
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 checkKeyExistsTest from './CheckKeyExists.test';
+
+export default function testsuite() {
+ checkKeyExistsTest();
+}
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/module.json5 b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/test/List.test.ets b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/test/LocalUnit.test.ets b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/hvigor/hvigor-config.json5 b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..d584c19c247db9a7caee4b606bb931aa9279c637
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/hvigorfile.ts b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/oh-package.json5 b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e41bae026aab3b50d0abb42fece08ba43b4a772b
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/ohosTest.md b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..e672dd2ab8813a2e1fbafc70a03aaefb7c7df2e4
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/ohosTest.md
@@ -0,0 +1,9 @@
+## 查询密钥是否存在测试用例归档
+
+## 用例表
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| --------------------------------- | ------------ | ---- | ------------------ | -------- | -------- |
+| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass |
+| 点击按钮,查询密钥是否存在(ArkTS) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
+| 点击按钮,查询密钥是否存在(C/C++) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/CheckKeyExists_1.png b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/CheckKeyExists_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..34e8c2d7ac640bcf34e1ec983f2984517a0f4b77
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/CheckKeyExists_1.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/CheckKeyExists_2.png b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/CheckKeyExists_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..f7cc0f331f6a0724fa0760d0ab53f8d04fed8c4b
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/CheckKeyExists_2.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/Cpp_1.png b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/Cpp_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..375b22fd7003d32387329c3da68543981257f8ab
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/Cpp_1.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/Cpp_2.png b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/Cpp_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..ea4b76851435ad9fb844015189dbfa467cba27fe
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/CheckKeyExists/screenshots/Cpp_2.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/.gitignore b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/AppScope/app.json5 b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..6827bed80198b0b7fe24863d996bafa9b4b45d61
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.getkeyattributes",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/AppScope/resources/base/element/string.json b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..c5f9a78ef244f536d43207ccfca07f51ba5df965
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "GetKeyAttributes"
+ }
+ ]
+}
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/AppScope/resources/base/media/app_icon.png b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/AppScope/resources/base/media/app_icon.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/README.md b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..9c429445bfb2344c6b2946e4c54369340c750f8d
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/README.md
@@ -0,0 +1,92 @@
+## 获取密钥属性(ArkTS)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-obtain-key-properties-arkts.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### GetKeyAttributes
+
+##### 介绍
+
+1. 本示例主要介绍获取密钥属性,HUKS提供了接口供业务获取指定密钥的相关属性。在获取指定密钥属性前,需要确保已在HUKS中生成或导入持久化存储的密钥。
+
+##### 效果预览
+
+| 主页 | 获取密钥属性 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+|
|
|
+
+使用说明
+
+1. 点击Call GetKeyAttributes按钮调用接口getKeyItemProperties,获取的属性集。
+
+## 获取密钥属性(C/C++)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-obtain-key-properties-ndk.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### Call C/C++
+
+##### 介绍
+
+1. 本示例主要介绍获取密钥属性,HUKS提供了接口供业务获取指定密钥的相关属性。在获取指定密钥属性前,需要确保已在HUKS中生成或导入持久化存储的密钥。
+
+##### 效果预览
+
+| 主页 | 获取密钥属性 |
+| -------------------------------------------------- | -------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击Call C/C++按钮调用接口OH_Huks_GetKeyItemParamSet,从参数集中读取需要的参数。
+
+## 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---GetKeyAttributes.ets
+|---|---|---Index.ets // 首页
+|---cpp
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---HMAC.test.ets // 自动化测试用例
+```
+
+
+## 相关权限
+
+无。
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo UniversalKeystoreKit/OtherOperations/GetKeyAttributes > .git/info/sparse-checkout
+git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/build-profile.json5 b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..fb5a1ab654ae6715a0ab69a31900ad26dcf2487f
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/build-profile.json5
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ "buildOption": {
+ "strictMode": {
+ "caseSensitiveCheck": true,
+ "useNormalizedOHMUrl": true
+ }
+ }
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/code-linter.json5 b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/.gitignore b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/build-profile.json5 b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2d8b081b615348a99aa197f90186f3d8891b7dc1
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/build-profile.json5
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ "externalNativeOptions": {
+ "path": "./src/main/cpp/CMakeLists.txt",
+ "arguments": "",
+ "cppFlags": "",
+ "abiFilters": [
+ "arm64-v8a",
+ "x86_64"
+ ]
+ }
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ },
+ "nativeLib": {
+ "debugSymbol": {
+ "strip": true,
+ "exclude": []
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/hvigorfile.ts b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/oh-package.json5 b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..118bdd4fe7699368a010e04c24f5bfc887cf1298
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/oh-package.json5
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {
+ "libentry.so": "file:./src/main/cpp/types/libentry"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/CMakeLists.txt b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..a411957596688e3191fffdc435b89ccefd5ea388
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,15 @@
+# the minimum version of CMake.
+cmake_minimum_required(VERSION 3.5.0)
+project(GetKeyAttributes)
+
+set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+if(DEFINED PACKAGE_FIND_FILE)
+ include(${PACKAGE_FIND_FILE})
+endif()
+
+include_directories(${NATIVERENDER_ROOT_PATH}
+ ${NATIVERENDER_ROOT_PATH}/include)
+
+add_library(entry SHARED napi_init.cpp)
+target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so)
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/napi_init.cpp b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/napi_init.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c69148a980cd41b702475462ed2fb447442ff2e3
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/napi_init.cpp
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+// [Start obtain_the_key_attributes]
+#include "huks/native_huks_api.h"
+#include "huks/native_huks_param.h"
+#include "napi/native_api.h"
+#include
+// [StartExclude obtain_the_key_attributes]
+OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params,
+ uint32_t paramCount)
+{
+ OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_AddParams(*paramSet, params, paramCount);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ ret = OH_Huks_BuildParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ return ret;
+}
+
+struct OH_Huks_Param g_testGenerateKeyParam[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECC},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256},
+ {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}};
+
+static OH_Huks_Result GenerateKeyHelper(const char *alias)
+{
+ struct OH_Huks_Blob aliasBlob = {.size = (uint32_t)strlen(alias), .data = (uint8_t *)alias};
+ struct OH_Huks_ParamSet *testGenerateKeyParamSet = nullptr;
+ struct OH_Huks_Result ohResult;
+ do {
+ /* 1.初始化密钥属性集 */
+ ohResult = InitParamSet(&testGenerateKeyParamSet, g_testGenerateKeyParam,
+ sizeof(g_testGenerateKeyParam) / sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ /* 1.生成密钥 */
+ ohResult = OH_Huks_GenerateKeyItem(&aliasBlob, testGenerateKeyParamSet, nullptr);
+ } while (0);
+ OH_Huks_FreeParamSet(&testGenerateKeyParamSet);
+ return ohResult;
+}
+// [EndExclude obtain_the_key_attributes]
+static napi_value GetKeyParamSet(napi_env env, napi_callback_info info)
+{
+ /* 1. 参数构造:确定密钥别名 */
+ const char *alias = "test_key";
+ struct OH_Huks_Blob aliasBlob = { .size = (uint32_t)strlen(alias), .data = (uint8_t *)alias };
+ // [StartExclude obtain_the_key_attributes]
+ /* 生成密钥 */
+ OH_Huks_Result genResult = GenerateKeyHelper(alias);
+ if (genResult.errorCode != OH_HUKS_SUCCESS) {
+ napi_value ret;
+ napi_create_int32(env, genResult.errorCode, &ret);
+ return ret;
+ }
+ // [EndExclude obtain_the_key_attributes]
+ const size_t paramSetSize = 512;
+ /* 构造参数:为参数集申请内存
+ * 请业务按实际情况评估大小进行申请
+ */
+ struct OH_Huks_ParamSet *outParamSet = static_cast(malloc(paramSetSize));
+ if (outParamSet == nullptr) {
+ return nullptr;
+ }
+ outParamSet->paramSetSize = paramSetSize;
+ struct OH_Huks_Result ohResult;
+ do {
+ /* 2. 获取密钥属性集 */
+ ohResult = OH_Huks_GetKeyItemParamSet(&aliasBlob, nullptr, outParamSet);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ /* 3. 从参数集中读取参数,以OH_HUKS_TAG_PURPOSE为例 */
+ OH_Huks_Param *purposeParam = nullptr; // 无需申请内存,获取后指针指向该参数在参数集中所处内存地址
+ ohResult = OH_Huks_GetParam(outParamSet, OH_HUKS_TAG_PURPOSE, &purposeParam);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ } while (0);
+ OH_Huks_FreeParamSet(&outParamSet);
+ napi_value ret;
+ napi_create_int32(env, ohResult.errorCode, &ret);
+ return ret;
+}
+// [End obtain_the_key_attributes]
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports)
+{
+ napi_property_descriptor desc[] = {
+ { "getKeyParamSet", nullptr, GetKeyParamSet, nullptr, nullptr, nullptr, napi_default, nullptr }
+ };
+ napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "entry",
+ .nm_priv = ((void*)0),
+ .reserved = { 0 },
+};
+
+extern "C" __attribute__((constructor)) void RegisterEntryModule(void)
+{
+ napi_module_register(&demoModule);
+}
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/types/libentry/index.d.ts b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/types/libentry/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..daea8fc76737836657d12c5451c00838339620a8
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/types/libentry/index.d.ts
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2025 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 const getKeyParamSet: () => number;
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/types/libentry/oh-package.json5 b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/types/libentry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2826cc7d6bd199c1008bb51d898dffa922201e6c
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/types/libentry/oh-package.json5
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "libentry.so",
+ "types": "./index.d.ts",
+ "version": "1.0.0",
+ "description": "Please describe the basic information."
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/entryability/EntryAbility.ets b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..edc2839f203ba057c186e19b0cbbbf80c8faa8b3
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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 { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/pages/GetKeyAttributes.ets b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/pages/GetKeyAttributes.ets
new file mode 100644
index 0000000000000000000000000000000000000000..c772140aced6a03583f219fcfa750888cf8e1a82
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/pages/GetKeyAttributes.ets
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+// [Start obtaining_key_attribute]
+import { huks } from '@kit.UniversalKeystoreKit';
+
+/* 1. 设置密钥别名 */
+let keyAlias = 'keyAlias';
+/* option对象传空 */
+let emptyOptions: huks.HuksOptions = {
+ properties: []
+};
+// [StartExclude obtaining_key_attribute]
+let properties1: huks.HuksParam[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_DH
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_DH_KEY_SIZE_2048
+ }
+];
+
+let huksOptions: huks.HuksOptions = {
+ properties: properties1,
+ inData: new Uint8Array([])
+}
+
+/* 3.生成密钥 */
+function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.generateKeyItem(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions): Promise {
+ console.info(`enter promise generateKeyItem`);
+ try {
+ await generateKeyItem(keyAlias, huksOptions)
+ .then((data) => {
+ console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`);
+ });
+ return 'Success';
+ } catch (error) {
+ console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`);
+ return 'Failed';
+ }
+}
+
+async function testGenKey(): Promise {
+ let ret = await publicGenKeyFunc(keyAlias, huksOptions);
+ return ret;
+}
+
+function check(): string {
+// [EndExclude obtaining_key_attribute]
+ try {
+ /* 1. 生成密钥 */
+ testGenKey();
+ /* 2. 获取密钥属性 */
+ huks.getKeyItemProperties(keyAlias, emptyOptions, (error, data) => {
+ if (error) {
+ console.error(`callback: getKeyItemProperties failed, ${JSON.stringify(error)}`);
+ } else {
+ console.info(`callback: getKeyItemProperties success, data = ${JSON.stringify(data)}`);
+ }
+ });
+ return 'Success';
+ } catch (error) {
+ console.error(`callback: getKeyItemProperties input arg invalid, ${JSON.stringify(error)}`);
+ return 'Failed';
+ }
+// [End obtaining_key_attribute]
+}
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'GetKeyAttributes';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.call_get_key_attributes'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ let ret: string = check();
+ this.message = 'GetKeyAttributes Result: ' + ret;
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/pages/Index.ets b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..9fac27982f7f159cf699dfbd032a5109952e2046
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2025 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 { router } from '@kit.ArkUI';
+import testNapi from 'libentry.so';
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'GetKeyAttributes';
+
+ goToSample(url: string): void {
+ router.pushUrl({
+ url: url,
+ }, router.RouterMode.Single, (err) => {
+ if (err) {
+ console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
+ return;
+ }
+ console.info('pushUrl success');
+ })
+ }
+
+ build() {
+ Column({ space: 5 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.get_key_attributes'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/GetKeyAttributes')
+ })
+ Button($r('app.string.call_cpp_get_key_param_set'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ let ret: number = testNapi.getKeyParamSet();
+ this.message = 'Call C/C++ Result: ' + ret.toString();
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/module.json5 b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..4144486d1af4c03b0d767cce1cda86fc0d697f91
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/module.json5
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/element/color.json b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/element/string.json b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..f9637aff4942abdd1df9a531dc1388ed81059f71
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,28 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "GetKeyAttributes"
+ },
+ {
+ "name": "get_key_attributes",
+ "value": "GetKeyAttributes"
+ },
+ {
+ "name": "call_cpp_get_key_param_set",
+ "value": "Call C/C++"
+ },
+ {
+ "name": "call_get_key_attributes",
+ "value": "Call GetKeyAttributes"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/background.png b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/background.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/foreground.png b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/foreground.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/layered_image.json b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/startIcon.png b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/profile/backup_config.json b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/profile/main_pages.json b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..da0faf7e64d88fa9864bfbe01560e50356f9b143
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,6 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/GetKeyAttributes"
+ ]
+}
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/dark/element/color.json b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/dark/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/resources/dark/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#000000"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/ets/test/Ability.test.ets b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/ets/test/GetKeyAttributes.test.ets b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/ets/test/GetKeyAttributes.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0b3b396fee0a3adfbb73224f5f5f9524dc1b4051
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/ets/test/GetKeyAttributes.test.ets
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, it, expect, beforeAll } from '@ohos/hypium';
+// 导入测试依赖kit
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+let want: Want;
+
+export default function getKeyAttributesTest() {
+ describe('getKeyAttributesTest', () => {
+ /**
+ * 打开应用
+ */
+ beforeAll(async () => {
+ want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ await driver.delayMs(1000);
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ })
+
+ /**
+ * 点击按钮,获取密钥属性(ArkTS)
+ */
+ it('testGetKeyAttributes001', 0, async () => {
+ console.info('uitest: testGetKeyAttributes001 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('GetKeyAttributes').type('Button'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('Call GetKeyAttributes'));
+ await button2.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('GetKeyAttributes Result: Success'));
+ console.info('uitest: testGetKeyAttributes001 end');
+ await driver.pressBack();
+ })
+
+ /**
+ * 点击按钮,获取密钥属性(C/C++)
+ */
+ it('testGetKeyAttributes002', 0, async () => {
+ console.info('uitest: testGetKeyAttributes002 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('Call C/C++'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('Call C/C++ Result: 0'));
+ console.info('uitest: testGetKeyAttributes002 end');
+ await driver.pressBack();
+ })
+ })
+}
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/ets/test/List.test.ets b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f2afe995927bea9451dffaf4adcffd073b137909
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 getKeyAttributesTest from './GetKeyAttributes.test';
+
+export default function testsuite() {
+ getKeyAttributesTest();
+}
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/module.json5 b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/test/List.test.ets b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/test/LocalUnit.test.ets b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/hvigor/hvigor-config.json5 b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..d584c19c247db9a7caee4b606bb931aa9279c637
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/hvigorfile.ts b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/oh-package.json5 b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e41bae026aab3b50d0abb42fece08ba43b4a772b
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/ohosTest.md b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..9ff789ae85df086bb1526ca9cfd26c07f9dd8cf8
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/ohosTest.md
@@ -0,0 +1,9 @@
+# 获取密钥属性测试用例归档
+
+## 用例表
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ----------------------------- | ------------ | ---- | ------------------ | -------- | -------- |
+| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass |
+| 获取密钥属性(ArkTS) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
+| 点击按钮,获取密钥属性(C/C++) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/Cpp_1.png b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/Cpp_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..5f33ade88f931531a26f89b188588912d642cd19
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/Cpp_1.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/Cpp_2.png b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/Cpp_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..cda8123becbbe45d6a13c3ee665c088af2c03998
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/Cpp_2.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/GetKeyAttributes_1.png b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/GetKeyAttributes_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..8556975ee86b61fab6386e8505c728295fc731e7
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/GetKeyAttributes_1.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/GetKeyAttributes_2.png b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/GetKeyAttributes_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..e3e70e9f2723c789f6baaec1d885294a4936fd42
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/screenshots/GetKeyAttributes_2.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/.gitignore b/UniversalKeystoreKit/OtherOperations/KeyExport/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/AppScope/app.json5 b/UniversalKeystoreKit/OtherOperations/KeyExport/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..4ee18eb53cdc1e92a3feaf8aa0372f4e473cc77d
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.keyexport",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/AppScope/resources/base/element/string.json b/UniversalKeystoreKit/OtherOperations/KeyExport/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..31f53443c81a19a32b55c841faa917f046e58704
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "KeyExport"
+ }
+ ]
+}
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/AppScope/resources/base/media/app_icon.png b/UniversalKeystoreKit/OtherOperations/KeyExport/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/KeyExport/AppScope/resources/base/media/app_icon.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/README.md b/UniversalKeystoreKit/OtherOperations/KeyExport/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..a31201f3a34cf66ceade44def22f9af1e698ee5d
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/README.md
@@ -0,0 +1,91 @@
+## 密钥导出(ArkTS)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-export-key-arkts.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### KeyExport
+
+##### 介绍
+
+1. 本示例主要介绍密钥导出,业务需要获取持久化存储的非对称密钥的公钥时使用,轻量级设备仅支持RSA公钥导出。
+
+##### 效果预览
+
+| 主页 | 公钥导出 |
+| -------------------------------------------------------- | -------------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击Call KeyExport按钮调用接口exportKeyItem,在outData字段中获取以标准的X.509规范的DER格式封装的公钥明文。
+
+## 密钥导出(C/C++)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-export-key-ndk.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### Call C/C++
+
+##### 介绍
+
+1. 本示例主要介绍密钥导出,业务需要获取持久化存储的非对称密钥的公钥时使用,轻量级设备仅支持RSA公钥导出。
+
+##### 效果预览
+
+| 主页 | 公钥导出 |
+| -------------------------------------------------- | -------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击Call C/C++按钮调用接口OH_Huks_GetKeyItemParamSet,从参数key中导出以标准的X.509规范的DER格式封装的公钥。
+
+## 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---KeyExport.ets
+|---|---|---Index.ets // 首页
+|---cpp
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---KeyExport.test.ets // 自动化测试用例
+```
+
+## 相关权限
+
+无。
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo UniversalKeystoreKit/OtherOperations/KeyExport > .git/info/sparse-checkout
+git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git
+git pull origin master
+```
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/build-profile.json5 b/UniversalKeystoreKit/OtherOperations/KeyExport/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..fb5a1ab654ae6715a0ab69a31900ad26dcf2487f
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/build-profile.json5
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ "buildOption": {
+ "strictMode": {
+ "caseSensitiveCheck": true,
+ "useNormalizedOHMUrl": true
+ }
+ }
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/code-linter.json5 b/UniversalKeystoreKit/OtherOperations/KeyExport/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/.gitignore b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/build-profile.json5 b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2d8b081b615348a99aa197f90186f3d8891b7dc1
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/build-profile.json5
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ "externalNativeOptions": {
+ "path": "./src/main/cpp/CMakeLists.txt",
+ "arguments": "",
+ "cppFlags": "",
+ "abiFilters": [
+ "arm64-v8a",
+ "x86_64"
+ ]
+ }
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ },
+ "nativeLib": {
+ "debugSymbol": {
+ "strip": true,
+ "exclude": []
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/hvigorfile.ts b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/oh-package.json5 b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..118bdd4fe7699368a010e04c24f5bfc887cf1298
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/oh-package.json5
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {
+ "libentry.so": "file:./src/main/cpp/types/libentry"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/CMakeLists.txt b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..5b291e7135972a0c84baf4d606e22fe2c45f9353
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,15 @@
+# the minimum version of CMake.
+cmake_minimum_required(VERSION 3.5.0)
+project(KeyExport)
+
+set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+if(DEFINED PACKAGE_FIND_FILE)
+ include(${PACKAGE_FIND_FILE})
+endif()
+
+include_directories(${NATIVERENDER_ROOT_PATH}
+ ${NATIVERENDER_ROOT_PATH}/include)
+
+add_library(entry SHARED napi_init.cpp)
+target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so)
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/napi_init.cpp b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/napi_init.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1e3f591993356ed1d26e6e2fd7c95eaafafba2cf
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/napi_init.cpp
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+// [Start get_persistent_storage_asymmetric_public_keys]
+#include "huks/native_huks_api.h"
+#include "huks/native_huks_param.h"
+#include "napi/native_api.h"
+#include
+// [StartExclude get_persistent_storage_asymmetric_public_keys]
+/* 以下以生成ECC密钥为例 */
+OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param *params,
+ uint32_t paramCount)
+{
+ OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_AddParams(*paramSet, params, paramCount);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ ret = OH_Huks_BuildParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ return ret;
+}
+
+struct OH_Huks_Param g_testGenerateKeyParam[] = {{.tag = OH_HUKS_TAG_ALGORITHM, .uint32Param = OH_HUKS_ALG_ECC},
+ {.tag = OH_HUKS_TAG_PURPOSE, .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE},
+ {.tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = OH_HUKS_ECC_KEY_SIZE_256},
+ {.tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE}};
+
+static OH_Huks_Result GenerateKeyHelper(const char *alias)
+{
+ struct OH_Huks_Blob aliasBlob = {.size = (uint32_t)strlen(alias), .data = (uint8_t *)alias};
+ struct OH_Huks_ParamSet *testGenerateKeyParamSet = nullptr;
+ struct OH_Huks_Result ohResult;
+ do {
+ /* 1.初始化密钥属性集 */
+ ohResult = InitParamSet(&testGenerateKeyParamSet, g_testGenerateKeyParam,
+ sizeof(g_testGenerateKeyParam) / sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ /* 2.生成密钥 */
+ ohResult = OH_Huks_GenerateKeyItem(&aliasBlob, testGenerateKeyParamSet, nullptr);
+ } while (0);
+ OH_Huks_FreeParamSet(&testGenerateKeyParamSet);
+ return ohResult;
+}
+// [EndExclude get_persistent_storage_asymmetric_public_keys]
+static napi_value ExportKey(napi_env env, napi_callback_info info)
+{
+ /* 1. 参数构造:确定密钥别名 */
+ const char *alias = "test_key";
+ struct OH_Huks_Blob aliasBlob = { .size = (uint32_t)strlen(alias), .data = (uint8_t *)alias };
+ // [StartExclude get_persistent_storage_asymmetric_public_keys]
+ /* 生成密钥 */
+ OH_Huks_Result genResult = GenerateKeyHelper(alias);
+ if (genResult.errorCode != OH_HUKS_SUCCESS) {
+ napi_value ret;
+ napi_create_int32(env, genResult.errorCode, &ret);
+ return ret;
+ }
+ // [EndExclude get_persistent_storage_asymmetric_public_keys]
+ /* 构造参数:为待导出公钥申请内存 */
+ uint8_t *pubKey = (uint8_t *)malloc(512); // 请业务按实际密钥大小评估申请
+ if (pubKey == nullptr) {
+ return nullptr;
+ }
+ struct OH_Huks_Blob keyBlob = { 256, pubKey };
+ struct OH_Huks_Result ohResult;
+ do {
+ ohResult = OH_Huks_ExportPublicKeyItem(&aliasBlob, nullptr, &keyBlob);
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ } while (0);
+ free(pubKey);
+ napi_value ret;
+ napi_create_int32(env, ohResult.errorCode, &ret);
+ return ret;
+}
+// [End get_persistent_storage_asymmetric_public_keys]
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports)
+{
+ napi_property_descriptor desc[] = {
+ { "exportKey", nullptr, ExportKey, nullptr, nullptr, nullptr, napi_default, nullptr }
+ };
+ napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "entry",
+ .nm_priv = ((void*)0),
+ .reserved = { 0 },
+};
+
+extern "C" __attribute__((constructor)) void RegisterEntryModule(void)
+{
+ napi_module_register(&demoModule);
+}
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/types/libentry/index.d.ts b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/types/libentry/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..a9a8bde79fb4162899309919dfa2331cb823290e
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/types/libentry/index.d.ts
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2025 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 const exportKey: () => number;
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/types/libentry/oh-package.json5 b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/types/libentry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2826cc7d6bd199c1008bb51d898dffa922201e6c
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/types/libentry/oh-package.json5
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "libentry.so",
+ "types": "./index.d.ts",
+ "version": "1.0.0",
+ "description": "Please describe the basic information."
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/entryability/EntryAbility.ets b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..edc2839f203ba057c186e19b0cbbbf80c8faa8b3
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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 { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/pages/Index.ets b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..799718ccc35c72c566c0c8ddbd60529c9e737491
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2025 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 { router } from '@kit.ArkUI';
+import testNapi from 'libentry.so';
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'KeyExport';
+
+ goToSample(url: string): void {
+ router.pushUrl({
+ url: url,
+ }, router.RouterMode.Single, (err) => {
+ if (err) {
+ console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
+ return;
+ }
+ console.info('pushUrl success');
+ })
+ }
+
+ build() {
+ Column({ space: 5 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button('KeyExport')
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/KeyExport');
+ })
+ Button('Call C/C++')
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ let ret: number = testNapi.exportKey();
+ this.message = 'Call C/C++ Result: ' + ret.toString();
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/pages/KeyExport.ets b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/pages/KeyExport.ets
new file mode 100644
index 0000000000000000000000000000000000000000..5c6f94e77c2fb98027caf8512d8188a5451f61bc
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/pages/KeyExport.ets
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+// [Start fetch_persistent_security_public_keys]
+import { huks } from '@kit.UniversalKeystoreKit';
+
+/* 1. 设置密钥别名 */
+let keyAlias = 'keyAlias';
+/* option对象传空 */
+let emptyOptions: huks.HuksOptions = {
+properties: []
+};
+// [StartExclude fetch_persistent_security_public_keys]
+let properties1: huks.HuksParam[] = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_DH
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_AGREE
+ },
+ {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_DH_KEY_SIZE_2048
+ }
+];
+
+let huksOptions: huks.HuksOptions = {
+ properties: properties1,
+ inData: new Uint8Array([])
+}
+
+/* 3.生成密钥 */
+function generateKeyItem(keyAlias: string, huksOptions: huks.HuksOptions) {
+ return new Promise((resolve, reject) => {
+ try {
+ huks.generateKeyItem(keyAlias, huksOptions, (error, data) => {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(data);
+ }
+ });
+ } catch (error) {
+ throw (error as Error);
+ }
+ });
+}
+
+async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions): Promise {
+ console.info(`enter promise generateKeyItem`);
+ try {
+ await generateKeyItem(keyAlias, huksOptions)
+ .then((data) => {
+ console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`);
+ })
+ .catch((error: Error) => {
+ console.error(`promise: generateKeyItem failed, ${JSON.stringify(error)}`);
+ });
+ return 'Success';
+ } catch (error) {
+ console.error(`promise: generateKeyItem input arg invalid, ${JSON.stringify(error)}`);
+ return 'Failed';
+ }
+}
+
+async function testGenKey(): Promise {
+ let ret = await publicGenKeyFunc(keyAlias, huksOptions);
+ return ret;
+}
+
+function check(): string {
+// [EndExclude fetch_persistent_security_public_keys]
+ try {
+ // [StartExclude fetch_persistent_security_public_keys]
+ /* 1. 生成密钥 */
+ testGenKey()
+ // [EndExclude fetch_persistent_security_public_keys]
+ /* 2. 导出密钥 */
+ huks.exportKeyItem(keyAlias, emptyOptions, (error, data) => {
+ if (error) {
+ console.error(`callback: exportKeyItem failed, ` + error);
+ } else {
+ console.info(`callback: exportKeyItem success, data = ${JSON.stringify(data)}`);
+ }
+ });
+ return 'Success';
+ } catch (error) {
+ console.error(`callback: exportKeyItem input arg invalid, ${JSON.stringify(error)}`);
+ return 'Failed';
+ }
+// [End fetch_persistent_security_public_keys]
+}
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'KeyExport';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.call_keyExport'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ let ret: string = check();
+ this.message = 'KeyExport Result: ' + ret;
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/module.json5 b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..4144486d1af4c03b0d767cce1cda86fc0d697f91
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/module.json5
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/element/color.json b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/element/string.json b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..988f20262f3d0014216be867c59f612409f27d8c
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,28 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "KeyExport"
+ },
+ {
+ "name": "call_keyExport",
+ "value": "Call KeyExport"
+ },
+ {
+ "name": "key_export",
+ "value": "KeyExport"
+ },
+ {
+ "name": "call_cpp",
+ "value": "Call C/C++"
+ }
+ ]
+}
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/background.png b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/background.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/foreground.png b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/foreground.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/layered_image.json b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/startIcon.png b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/profile/backup_config.json b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/profile/main_pages.json b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..9ae4a8cd630b1c33a08c0267c461661f6d38500d
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,6 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/KeyExport"
+ ]
+}
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/dark/element/color.json b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/dark/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/resources/dark/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#000000"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/ets/test/Ability.test.ets b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/ets/test/KeyExport.test.ets b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/ets/test/KeyExport.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..dd36f06100eac3e606a31c56121f931a59d9442d
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/ets/test/KeyExport.test.ets
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, it, expect, beforeAll } from '@ohos/hypium';
+// 导入测试依赖kit
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+let want: Want;
+
+export default function keyExportTest() {
+ describe('keyExportTest', () => {
+ /**
+ * 打开应用
+ */
+ beforeAll(async () => {
+ want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ await driver.delayMs(1000);
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ })
+
+ /**
+ * 点击按钮,密钥导出(ArkTS)
+ */
+ it('testKeyExport001', 0, async () => {
+ console.info('uitest: testKeyExport001 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('KeyExport').type('Button'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('Call KeyExport'));
+ await button2.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('KeyExport Result: Success'));
+ console.info('uitest: testKeyExport001 end');
+ await driver.pressBack();
+ })
+
+ /**
+ * 点击按钮,密钥导出(C/C++)
+ */
+ it('testKeyExport002', 0, async () => {
+ console.info('uitest: testKeyExport002 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('Call C/C++'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('Call C/C++ Result: 0'));
+ console.info('uitest: testKeyExport002 end');
+ await driver.pressBack();
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/ets/test/List.test.ets b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..d38e02e89e3f9185727f0b6e4dea59e28b87e399
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 keyExportTest from './KeyExport.test';
+
+export default function testsuite() {
+ keyExportTest();
+}
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/module.json5 b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/test/List.test.ets b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f1186b1f53c3a70930921c5dbd1417332bec56c9
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 localUnitTest from './LocalUnit.test';
+
+export default function testsuite() {
+ localUnitTest();
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/test/LocalUnit.test.ets b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/test/LocalUnit.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..7fc57c77dbf76d8df08a2b802a55b948e3fcf968
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/test/LocalUnit.test.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function localUnitTest() {
+ describe('localUnitTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ });
+ });
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/hvigor/hvigor-config.json5 b/UniversalKeystoreKit/OtherOperations/KeyExport/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..d584c19c247db9a7caee4b606bb931aa9279c637
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/hvigorfile.ts b/UniversalKeystoreKit/OtherOperations/KeyExport/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/oh-package.json5 b/UniversalKeystoreKit/OtherOperations/KeyExport/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e41bae026aab3b50d0abb42fece08ba43b4a772b
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/ohosTest.md b/UniversalKeystoreKit/OtherOperations/KeyExport/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..2f97b8c42f110059a18893aa733f1d6aae4f18f3
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/KeyExport/ohosTest.md
@@ -0,0 +1,9 @@
+# 密钥导出测试用例归档
+
+## 用例表
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------------- | ------------ | ---- | ------------------ | -------- | -------- |
+| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass |
+| 点击按钮,密钥导出(ArkTS) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
+| 点击按钮,密钥导出(C/C++) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/Cpp_1.png b/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/Cpp_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..f66b80458aa1f2031b6e9a805029061bf836c975
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/Cpp_1.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/Cpp_2.png b/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/Cpp_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..6108f98ba61625f95b547708e2a44035450e24f5
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/Cpp_2.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/KeyExport_1.png b/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/KeyExport_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..947d7bd61508771cceb07cd75335c3efed33f552
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/KeyExport_1.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/KeyExport_2.png b/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/KeyExport_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..2cd5c6a999664dc42c2fbf1ddeb057af9b9090a0
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/KeyExport/screenshots/KeyExport_2.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/.gitignore b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/.gitignore
@@ -0,0 +1,12 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+/.appanalyzer
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/AppScope/app.json5 b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..fcec0d4c2be0b57192364b3e850a861566d82d38
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/AppScope/app.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "bundleName": "com.samples.querykeyaliasset",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/AppScope/resources/base/element/string.json b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..f2323df2c8e58e53173b23023545b7c76f82023e
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "QueryKeyAliasSet"
+ }
+ ]
+}
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/AppScope/resources/base/media/app_icon.png b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/AppScope/resources/base/media/app_icon.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/README.md b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..96c7b1e948a4ec3081d6cd40ffd8cbad2462ddfd
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/README.md
@@ -0,0 +1,92 @@
+## 查询密钥别名集(ArkTS)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-list-aliases-arkts.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### QueryKeyAliasSet
+
+##### 介绍
+
+1. 本示例主要介绍查询密钥别名集,HUKS提供了接口供应用查询密钥别名集。
+
+##### 效果预览
+
+| 主页 | 查询密钥别名 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+|
|
|
+
+使用说明
+
+1. 点击Call ArkTS按钮调用接口listAliases,查询密钥别名集。
+
+## 查询密钥别名集(C/C++)
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/UniversalKeystoreKit/huks-list-aliases-ndk.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+#### Call C/C++
+
+##### 介绍
+
+1. 本示例主要介绍查询密钥别名集,HUKS提供了接口供应用查询密钥别名集。
+
+##### 效果预览
+
+| 主页 | 查询密钥别名 |
+| -------------------------------------------------- | -------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击Call C/C++按钮调用接口OH_Huks_ListAliases,查询密钥别名集。
+
+## 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---QueryKeyAliasSet.ets
+|---|---|---Index.ets // 首页
+|---cpp
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---QueryKeyAliasSet.test.ets // 自动化测试用例
+```
+
+
+## 相关权限
+
+无。
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 6.0.0及以上。
+
+3. DevEco Studio版本:DevEco Studio 6.0.0及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 6.0.0及以上。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet > .git/info/sparse-checkout
+git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/build-profile.json5 b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..dc72b7a85eadf2c81a9f1742d7675b22de0581f6
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/build-profile.json5
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "6.0.0(20)",
+ "targetSdkVersion": 6.0.0(20)",
+ "runtimeOS": "HarmonyOS",
+ "buildOption": {
+ "strictMode": {
+ "caseSensitiveCheck": true,
+ "useNormalizedOHMUrl": true
+ }
+ }
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug"
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/code-linter.json5 b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/.gitignore b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/build-profile.json5 b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..48a79133bba1361549b5b101c1e7c184d136654d
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/build-profile.json5
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ "externalNativeOptions": {
+ "path": "./src/main/cpp/CMakeLists.txt",
+ "arguments": "",
+ "cppFlags": "",
+ "abiFilters": [
+ "x86_64",
+ "arm64-v8a"
+ ]
+ }
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ },
+ "nativeLib": {
+ "debugSymbol": {
+ "strip": true,
+ "exclude": []
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/hvigorfile.ts b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/oh-package.json5 b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..118bdd4fe7699368a010e04c24f5bfc887cf1298
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/oh-package.json5
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {
+ "libentry.so": "file:./src/main/cpp/types/libentry"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/CMakeLists.txt b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..72428e44e638742cfc78d0fe2f041c8efd280d28
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,15 @@
+# the minimum version of CMake.
+cmake_minimum_required(VERSION 3.5.0)
+project(QueryKeyAliasSet)
+
+set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+if(DEFINED PACKAGE_FIND_FILE)
+ include(${PACKAGE_FIND_FILE})
+endif()
+
+include_directories(${NATIVERENDER_ROOT_PATH}
+ ${NATIVERENDER_ROOT_PATH}/include)
+
+add_library(entry SHARED napi_init.cpp)
+target_link_libraries(entry PUBLIC libace_napi.z.so libhuks_ndk.z.so)
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/napi_init.cpp b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/napi_init.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d6f218f2225cd5746a466cd2727a1770877609f9
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/napi_init.cpp
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+// [Start query_key_alias_set_cpp]
+/* 以下查询密钥别名集为例 */
+#include "huks/native_huks_api.h"
+#include "huks/native_huks_param.h"
+#include "napi/native_api.h"
+#include
+
+OH_Huks_Result InitParamSet(
+ struct OH_Huks_ParamSet **paramSet,
+ const struct OH_Huks_Param *params,
+ uint32_t paramCount)
+{
+ OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ return ret;
+ }
+ ret = OH_Huks_AddParams(*paramSet, params, paramCount);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ ret = OH_Huks_BuildParamSet(paramSet);
+ if (ret.errorCode != OH_HUKS_SUCCESS) {
+ OH_Huks_FreeParamSet(paramSet);
+ return ret;
+ }
+ return ret;
+}
+
+struct OH_Huks_Param g_testQueryParam[] = {
+ {
+ .tag = OH_HUKS_TAG_AUTH_STORAGE_LEVEL,
+ .uint32Param = OH_HUKS_AUTH_STORAGE_LEVEL_DE
+ },
+};
+
+static napi_value ListAliases(napi_env env, napi_callback_info info)
+{
+ struct OH_Huks_ParamSet *testQueryParamSet = nullptr;
+ struct OH_Huks_KeyAliasSet *outData = nullptr;
+ struct OH_Huks_Result ohResult;
+ do {
+ /* 1.初始化密钥属性集 */
+ ohResult = InitParamSet(&testQueryParamSet, g_testQueryParam,
+ sizeof(g_testQueryParam) / sizeof(OH_Huks_Param));
+ if (ohResult.errorCode != OH_HUKS_SUCCESS) {
+ break;
+ }
+ /* 2.查询密钥别名集 */
+ ohResult = OH_Huks_ListAliases(testQueryParamSet, &outData);
+ } while (0);
+
+ OH_Huks_FreeParamSet(&testQueryParamSet);
+ OH_Huks_FreeKeyAliasSet(outData);
+ napi_value ret;
+ napi_create_int32(env, ohResult.errorCode, &ret);
+ return ret;
+}
+// [Start query_key_alias_set_cpp]
+
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports)
+{
+ napi_property_descriptor desc[] = {
+ { "listAliases", nullptr, ListAliases, nullptr, nullptr, nullptr, napi_default, nullptr }
+ };
+ napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "entry",
+ .nm_priv = ((void*)0),
+ .reserved = { 0 },
+};
+
+extern "C" __attribute__((constructor)) void RegisterEntryModule(void)
+{
+ napi_module_register(&demoModule);
+}
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/types/libentry/index.d.ts b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/types/libentry/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..8f80a2ec4410e593042def44e9562543d4f68aac
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/types/libentry/index.d.ts
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2025 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 const listAliases: () => number;
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/types/libentry/oh-package.json5 b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/types/libentry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..2826cc7d6bd199c1008bb51d898dffa922201e6c
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/cpp/types/libentry/oh-package.json5
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "name": "libentry.so",
+ "types": "./index.d.ts",
+ "version": "1.0.0",
+ "description": "Please describe the basic information."
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/entryability/EntryAbility.ets b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..edc2839f203ba057c186e19b0cbbbf80c8faa8b3
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2025 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 { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/pages/Index.ets b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..d884aeb691eaad51ad64b3f81409791734e221ee
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2025 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 { router } from '@kit.ArkUI';
+import testNapi from 'libentry.so';
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'QueryKeyAliasSet';
+
+ goToSample(url: string): void {
+ router.pushUrl({
+ url: url,
+ }, router.RouterMode.Single, (err) => {
+ if (err) {
+ console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
+ return;
+ }
+ console.info('pushUrl success');
+ })
+ }
+
+ build() {
+ Column({ space: 5 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.query_keyAlias_set'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ this.goToSample('pages/QueryKeyAliasSet');
+ })
+ Button($r('app.string.call_cpp'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(() => {
+ let ret: number = testNapi.listAliases();
+ this.message = 'Call C/C++ Success Result: ' + ret.toString();
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/pages/QueryKeyAliasSet.ets b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/pages/QueryKeyAliasSet.ets
new file mode 100644
index 0000000000000000000000000000000000000000..53d742fe830f3fb64037b8961949d16cbdeb0240
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/ets/pages/QueryKeyAliasSet.ets
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+// [Start query_key_alias_set_arkts]
+/*
+ * 以下查询密钥别名集Promise操作使用为例
+ */
+import { huks } from '@kit.UniversalKeystoreKit'
+
+async function testListAliases() {
+ /* 1.初始化密钥属性集 */
+ let queryProperties: Array = [
+ {
+ tag: huks.HuksTag.HUKS_TAG_AUTH_STORAGE_LEVEL,
+ value: huks.HuksAuthStorageLevel.HUKS_AUTH_STORAGE_LEVEL_DE
+ }
+ ];
+ let queryOptions: huks.HuksOptions = {
+ properties: queryProperties
+ };
+
+ try {
+ /* 2.查询密钥别名集 */
+ let result: huks.HuksListAliasesReturnResult = await huks.listAliases(queryOptions);
+ console.info(`promise: listAliases success`);
+ } catch (error) {
+ console.error(`promise: listAliases fail`);
+ // [StartExclude query_key_alias_set_arkts]
+ throw (error as Error);
+ // [EndExclude query_key_alias_set_arkts]
+ }
+}
+// [End query_key_alias_set_arkts]
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'QueryKeyAliasSet';
+
+ build() {
+ Column({ space: 12 }) {
+ Text(this.message)
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r('sys.float.ohos_id_text_size_body1'))
+ .fontColor($r('sys.color.ohos_id_color_text_primary'))
+ .maxLines(Infinity)
+ .textAlign(TextAlign.Start)
+ Button($r('app.string.call_arkts'))
+ .padding('12vp')
+ .height('40vp')
+ .borderRadius($r('sys.float.ohos_id_corner_radius_button'))
+ .backgroundColor($r('sys.color.ohos_id_color_emphasize'))
+ .fontSize('14sp')
+ .fontColor('#ffffff')
+ .onClick(async () => {
+ try {
+ await testListAliases();
+ this.message = 'Call ArkTS Result: Success';
+ } catch (error) {
+ this.message = 'Call ArkTS Result: Failed';
+ }
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/module.json5 b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..4144486d1af4c03b0d767cce1cda86fc0d697f91
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/module.json5
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/element/color.json b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/element/string.json b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..779619fbc155da658523dcee09028a42793dcd94
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,28 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "QueryKeyAliasSet"
+ },
+ {
+ "name": "query_keyAlias_set",
+ "value": "QueryKeyAliasSet"
+ },
+ {
+ "name": "call_cpp",
+ "value": "Call C/C++"
+ },
+ {
+ "name": "call_arkts",
+ "value": "Call ArkTS"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/background.png b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/background.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/foreground.png b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/foreground.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/layered_image.json b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/startIcon.png b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/profile/backup_config.json b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/profile/main_pages.json b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..4a5c10c23295646bd55feb701189430d0fb8f678
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,6 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/QueryKeyAliasSet"
+ ]
+}
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/dark/element/color.json b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/dark/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/main/resources/dark/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#000000"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/ets/test/Ability.test.ets b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f8ce9a2c012f8fe36114cef65216ef0b6254f41
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
+import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
+
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ })
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ })
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ })
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ })
+ it('assertContain', 0, () => {
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
+ hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
+ let a = 'abc';
+ let b = 'b';
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
+ expect(a).assertContain(b);
+ expect(a).assertEqual(a);
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/ets/test/List.test.ets b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..98ebcd87e313cd3a33f20d87fbe87af997dee507
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/ets/test/List.test.ets
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025 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 queryKeyAliasSetTest from './QueryKeyAliasSet.test';
+
+export default function testsuite() {
+ queryKeyAliasSetTest();
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/ets/test/QueryKeyAliasSet.test.ets b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/ets/test/QueryKeyAliasSet.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b193e3b786305d7462f7c6185354a83d2913cdf0
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/ets/test/QueryKeyAliasSet.test.ets
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, it, expect, beforeAll } from '@ohos/hypium';
+// 导入测试依赖kit
+import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
+import { UIAbility, Want } from '@kit.AbilityKit';
+
+const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
+let want: Want;
+
+export default function queryKeyAliasSetTest() {
+ describe('queryKeyAliasSetTest', () => {
+ /**
+ * 打开应用
+ */
+ beforeAll(async () => {
+ want = {
+ bundleName: bundleName,
+ abilityName: 'EntryAbility'
+ };
+ await delegator.startAbility(want);
+ const driver = Driver.create();
+ await driver.delayMs(1000);
+ const ability: UIAbility = await delegator.getCurrentTopAbility();
+ console.info('get top ability');
+ await driver.delayMs(1000);
+ expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
+ })
+
+ /**
+ * 点击按钮,查询密钥别名集(ArkTS)
+ */
+ it('testQueryKeyAliasSet001', 0, async () => {
+ console.info('uitest: testQueryKeyAliasSet001 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('QueryKeyAliasSet').type('Button'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ const button2 = await driver.findComponent(ON.text('Call ArkTS'));
+ await button2.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('Call ArkTS Result: Success'));
+ console.info('uitest: testQueryKeyAliasSet001 end');
+ await driver.pressBack();
+ })
+
+ /**
+ * 点击按钮,查询密钥别名集(C/C++)
+ */
+ it('testQueryKeyAliasSet002', 0, async () => {
+ console.info('uitest: testQueryKeyAliasSet002 begin');
+ const driver = Driver.create();
+ const button1 = await driver.findComponent(ON.text('Call C/C++'));
+ await driver.delayMs(1000);
+ await button1.click();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('Call C/C++ Success Result: 0'));
+ console.info('uitest: testQueryKeyAliasSet002 end');
+ await driver.pressBack();
+ })
+ })
+}
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/module.json5 b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/entry/src/ohosTest/module.json5
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "module": {
+ "name": "entry_test",
+ "type": "feature",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false
+ }
+}
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/hvigor/hvigor-config.json5 b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/hvigor/hvigor-config.json5
new file mode 100644
index 0000000000000000000000000000000000000000..d584c19c247db9a7caee4b606bb931aa9279c637
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/hvigor/hvigor-config.json5
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "dependencies": {
+ },
+ "execution": {
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
+ },
+ "nodeOptions": {
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
+ }
+}
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/hvigorfile.ts b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/oh-package.json5 b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e41bae026aab3b50d0abb42fece08ba43b4a772b
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 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.
+ */
+
+{
+ "modelVersion": "5.0.1",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/ohosTest.md b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/ohosTest.md
new file mode 100644
index 0000000000000000000000000000000000000000..cef5b6856be2e5e9e5d3f7ee0ab2999d1e132e52
--- /dev/null
+++ b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/ohosTest.md
@@ -0,0 +1,9 @@
+# 查询密钥别名集测试用例归档
+
+## 用例表
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ------------------------------- | ------------ | ---- | ------------------ | -------- | -------- |
+| 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass |
+| 点击按钮,查询密钥别名集(ArkTS) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
+| 点击按钮,查询密钥别名集(C/C++) | 成功拉起应用 | | 成功执行,输出日志 | 是 | Pass |
\ No newline at end of file
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/screenshots/Cpp_1.png b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/screenshots/Cpp_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..bca0b108f790fbad891010aeea64826bf7a0782d
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/screenshots/Cpp_1.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/screenshots/Cpp_2.png b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/screenshots/Cpp_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..fb4db4dd96885136a8a591b5571c4bf45c2d354b
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/screenshots/Cpp_2.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/screenshots/QueryKeyAliasSet_1.png b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/screenshots/QueryKeyAliasSet_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..c55fb3eee594fb42fcca96b4185721258c53557c
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/screenshots/QueryKeyAliasSet_1.png differ
diff --git a/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/screenshots/QueryKeyAliasSet_2.png b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/screenshots/QueryKeyAliasSet_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..1eb00b8bedf888d50f92a1e75189decf34eaea49
Binary files /dev/null and b/UniversalKeystoreKit/OtherOperations/QueryKeyAliasSet/screenshots/QueryKeyAliasSet_2.png differ