diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitylifecyclecallback/AbilityLifecycleCallback.ets b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitylifecyclecallback/AbilityLifecycleCallback.ets index 430cc485375e48ef471e61dfe5e3b4bdf38b6953..bac9c2a34b4f038ceebcc642b82af62ad0fab24d 100644 --- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitylifecyclecallback/AbilityLifecycleCallback.ets +++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitylifecyclecallback/AbilityLifecycleCallback.ets @@ -21,6 +21,7 @@ import { hilog } from '@kit.PerformanceAnalysisKit'; const TAG: string = '[AbilityLifecycleCallback]'; const DOMAIN: number = 0xFF00; +// [Start get_sandbox_path_from_context_singleton] export class GlobalContext { private constructor() { } @@ -43,7 +44,7 @@ export class GlobalContext { this._objects.set(key, objectClass); } } - +// [End get_sandbox_path_from_context_singleton] // 声明ability生命周期回调,需配置所有回调后才可以在applicationContext注册 let abilityLifecycleCallback: AbilityLifecycleCallback = { onAbilityCreate(ability) { diff --git a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/ets/pages/Index.ets index 170cc62808fe146f1a0b47b2a6f851c78d1ee6d6..5e904676c4acbaa978d796dc71ce3ca78d084010 100755 --- a/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/ArkWeb/LifecycleWebComp/entry/src/main/ets/pages/Index.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start the_status_of_web_component_web_page_loading] import { webview } from '@kit.ArkWeb'; import { BusinessError } from '@kit.BasicServicesKit'; import { promptAction } from '@kit.ArkUI'; @@ -127,4 +127,5 @@ struct WebComponent { }) } } -} \ No newline at end of file +} +// [End the_status_of_web_component_web_page_loading] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/AddIntTrackPreventByPassList.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/AddIntTrackPreventByPassList.ets index 882c47fbaa9b8ef814e3d7de90ca14d02c109cdf..aa1655f7bbde61df1c1a081b565110487297ab79 100755 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/AddIntTrackPreventByPassList.ets +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/AddIntTrackPreventByPassList.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start set_domains_to_bypass_intelligent_tracking] import { webview } from '@kit.ArkWeb'; import { BusinessError } from '@kit.BasicServicesKit'; @@ -36,4 +36,5 @@ struct WebComponent { Web({ src: $r('app.string.web_path'), controller: this.controller }); } } -} \ No newline at end of file +} +// [End set_domains_to_bypass_intelligent_tracking] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/ClearIntTrackPreventByPassList.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/ClearIntTrackPreventByPassList.ets index cee0fd0d0ce30eb90c97f2eef1028e7a5b30b941..fc8f4c08468d7173ebf6f674576423ab92e227f2 100755 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/ClearIntTrackPreventByPassList.ets +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/ClearIntTrackPreventByPassList.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start clear_all_intelligent_tracking_prevention_bypasses] import { webview } from '@kit.ArkWeb'; @Entry @@ -30,3 +30,4 @@ struct WebComponent { } } } +// [End clear_all_intelligent_tracking_prevention_bypasses] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/CollectingAdsBlockingInformation.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/CollectingAdsBlockingInformation.ets index 283ced2f34ecd9a3bd96950f6d5c48e97b10042c..92dcff572ceeaa5db68902c51d8a55f5acfaf1b1 100755 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/CollectingAdsBlockingInformation.ets +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/CollectingAdsBlockingInformation.ets @@ -13,13 +13,16 @@ * limitations under the License. */ +// [Start collect_information_about_ad_filtering] import { webview } from '@kit.ArkWeb'; @Entry @Component struct WebComponent { @State totalAdsBlockCounts: number = 0; + // [StartExclude collect_information_about_ad_filtering] @State myString: string = 'onAdsBlocked'; + // [EndExclude collect_information_about_ad_filtering] controller: webview.WebviewController = new webview.WebviewController(); build() { @@ -36,3 +39,4 @@ struct WebComponent { } } } +// [End collect_information_about_ad_filtering] diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_one.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_one.ets index d903a58c48d351147b1b33283d9ddcf943849c25..e70fa2041e757cc4df8d921a1196adf059951219 100755 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_one.ets +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_one.ets @@ -12,13 +12,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start turn_off_ad_filtering_for_specific_domain_pages] import { webview } from '@kit.ArkWeb'; +// [StartExclude turn_off_ad_filtering_for_specific_domain_pages] function resourceToString(resource: Resource) { return getContext().resourceManager.getStringSync(resource); } - +// [EndExclude turn_off_ad_filtering_for_specific_domain_pages] @Entry @Component struct WebComponent { @@ -62,3 +63,4 @@ struct WebComponent { } } } +// [End turn_off_ad_filtering_for_specific_domain_pages] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_two.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_two.ets index fb11841153705f6707e2982a98fb1d098af29621..fe925a82e9cb552cb6c7c03275463b52c7c5fc23 100755 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_two.ets +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_two.ets @@ -12,13 +12,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start set_up_page_level_ad_filtering_switch] import { webview } from '@kit.ArkWeb'; +// [StartExclude set_up_page_level_ad_filtering_switch] function resourceToString(resource: Resource) { return getContext().resourceManager.getStringSync(resource); } - +// [EndExclude set_up_page_level_ad_filtering_switch] @Entry @Component struct WebComponent { @@ -63,3 +64,4 @@ struct WebComponent { } } } +// [End set_up_page_level_ad_filtering_switch] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/EnableIntTrackPrevent.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/EnableIntTrackPrevent.ets index 2abfd30abb9173efd02d23456f9af5d0aa6f7190..e317299ae711252bb84c330c82d3e00be2ee137b 100755 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/EnableIntTrackPrevent.ets +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/EnableIntTrackPrevent.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start enable_or_disable_web_component_anti_tracking] import { webview } from '@kit.ArkWeb'; import { BusinessError } from '@kit.BasicServicesKit'; @@ -36,4 +37,5 @@ struct WebComponent { Web({ src: $r('app.string.web_path'), controller: this.controller }); } } -} \ No newline at end of file +} +// [End enable_or_disable_web_component_anti_tracking] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/EnablingAdsBlocking.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/EnablingAdsBlocking.ets index 6f3479240ce6de1897bb49f1e42d136890ffe1d9..8eb4a81e2d203fc04af163a09aaf5601ef77c7c7 100755 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/EnablingAdsBlocking.ets +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/EnablingAdsBlocking.ets @@ -13,13 +13,15 @@ * limitations under the License. */ +// [Start app_select_list_rule_file_for_ad_filter] import { webview } from '@kit.ArkWeb'; import { picker, fileUri } from '@kit.CoreFileKit'; +// [StartExclude app_select_list_rule_file_for_ad_filter] function resourceToString(resource: Resource) { return getContext().resourceManager.getStringSync(resource); } - +// [EndExclude app_select_list_rule_file_for_ad_filter] @Entry @Component struct WebComponent { @@ -59,3 +61,4 @@ struct WebComponent { } } } +// [End app_select_list_rule_file_for_ad_filter] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/IsIntTrackPreventEnabled.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/IsIntTrackPreventEnabled.ets index cf899e8d3fd84841e969a12d2487d4ab8e392716..f35678435d85e62eb43ee5e6183a73f833604b85 100755 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/IsIntTrackPreventEnabled.ets +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/IsIntTrackPreventEnabled.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start check_if_web_component_anti_tracking_on] import { webview } from '@kit.ArkWeb'; import { BusinessError } from '@kit.BasicServicesKit'; @@ -37,3 +38,4 @@ struct WebComponent { } } } +// [End check_if_web_component_anti_tracking_on] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/OnIntTrackPreventResult.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/OnIntTrackPreventResult.ets index 6312ba16347037977791cf218c00665726a06434..86bb3887dba5ec4ce1dc1b4c449b4108f75835fc 100755 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/OnIntTrackPreventResult.ets +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/OnIntTrackPreventResult.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start retrieve_blocked_and_visited_domain_names] import { webview } from '@kit.ArkWeb'; import { BusinessError } from '@kit.BasicServicesKit'; @@ -40,4 +41,5 @@ struct WebComponent { }) } } -} \ No newline at end of file +} +// [End retrieve_blocked_and_visited_domain_names] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/RemoveIntTrackPreventByPassList.ets b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/RemoveIntTrackPreventByPassList.ets index 86a03f28a7406192364d036f6c8d1a08cb6a1bbe..504ff4f33c70bf7fd9face2a029d6b789b295ad1 100755 --- a/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/RemoveIntTrackPreventByPassList.ets +++ b/code/DocsSample/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/RemoveIntTrackPreventByPassList.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start partial_domain_name_list] import { webview } from '@kit.ArkWeb'; import { BusinessError } from '@kit.BasicServicesKit'; @@ -37,3 +37,4 @@ struct WebComponent { } } } +// [End partial_domain_name_list] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/pages/OnInterceptRequest_one.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/pages/OnInterceptRequest_one.ets index 88739dc3db0aef654af44ff590b2e0254f2790f1..99b4325373d0f329d3c81f87eb45df1fbd3bdbf6 100755 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/pages/OnInterceptRequest_one.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/pages/OnInterceptRequest_one.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start build_response_resources_to_implement_custom_page_response_scenarios] import { webview } from '@kit.ArkWeb'; function resourceToString(resource: Resource) { @@ -57,3 +57,4 @@ struct WebComponent { } } } +// [End build_response_resources_to_implement_custom_page_response_scenarios] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/pages/OnInterceptRequest_two.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/pages/OnInterceptRequest_two.ets index 4b3d0a5299f50c82cdd110eca8ed9fee2e47d153..bd06563ae79a431a6686eeccf645cc9e26eaabdd 100755 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/pages/OnInterceptRequest_two.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/CustomizePageResp/entry/src/main/ets/pages/OnInterceptRequest_two.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start build_response_resource_enable_gen] import { webview } from '@kit.ArkWeb'; function resourceToString(resource: Resource) { @@ -74,3 +75,4 @@ struct WebComponent { } } } +// [End build_response_resource_enable_gen] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_one.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_one.ets index a95b79c366950b1ca436c5f385f3b0b5ae8f7a1e..2545aea0f8d01f1109809950f9297ce42a92b682 100755 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_one.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_one.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start load_local_page_file_in_sandbox_path] import { webview } from '@kit.ArkWeb'; import { GlobalContext } from './GlobalContext'; @@ -31,3 +32,4 @@ struct WebComponent { } } } +// [End load_local_page_file_in_sandbox_path] diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_two.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_two.ets index c85ba6a2e277da624eb8d9260b84edd1debda016..7e78e47a0575fe6581b4534dd9a321a2daaa3a25 100755 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_two.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadLocalPageFileInSandboxPath_two.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start web_components_load_html_strings_by_data_url] import { webview } from '@kit.ArkWeb'; import { BusinessError } from '@kit.BasicServicesKit'; @@ -29,3 +29,4 @@ struct WebComponent { } } } +// [End web_components_load_html_strings_by_data_url] diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingHTMLRichTextData.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingHTMLRichTextData.ets index 826021cc5c3417b5ee5a622c349434e13e107d3d..ed142efe47f184b1ecf781055df3dd5075947329 100755 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingHTMLRichTextData.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingHTMLRichTextData.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start devs_load_page_fragments_for_quick_loading] import { webview } from '@kit.ArkWeb'; import { BusinessError } from '@kit.BasicServicesKit'; @@ -41,3 +41,4 @@ struct WebComponent { } } } +// [End devs_load_page_fragments_for_quick_loading] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingLocalPages.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingLocalPages.ets index aa7357bd6e6bb6297aef2ca2de635ba05461b7bf..a09d901e5a4cef6530958ef001c7721973f0784e 100755 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingLocalPages.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingLocalPages.ets @@ -13,6 +13,8 @@ * limitations under the License. */ + +// [Start after_load_complete_call_to_change_page] import { webview } from '@kit.ArkWeb'; import { BusinessError } from '@kit.BasicServicesKit'; @@ -36,4 +38,5 @@ struct WebComponent { Web({ src: $rawfile('local.html'), controller: this.controller }); } } -} \ No newline at end of file +} +// [End after_load_complete_call_to_change_page] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingWebPages.ets b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingWebPages.ets index 28abb21e0386a29a6c4c133ac28fc3536e8ca445..bd01e1ff1cb2a311b0a0a4bd3538a409c7b85584 100755 --- a/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingWebPages.ets +++ b/code/DocsSample/ArkWeb/ManageWebPageLoadBrowse/LoadPages/entry/src/main/ets/pages/LoadingWebPages.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start use_load_interface_to_show_web_changes] import { webview } from '@kit.ArkWeb'; import { BusinessError } from '@kit.BasicServicesKit'; @@ -36,4 +37,5 @@ struct WebComponent { Web({ src: 'www.example.com', controller: this.controller }); } } -} \ No newline at end of file +} +// [End use_load_interface_to_show_web_changes] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/CalcAdjustSafeArea.ets b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/CalcAdjustSafeArea.ets index f2e0e972c8c328d93ba38add78c67350b50c9986..ddce0c96a410e396c1f2ff0d722b95bc6c5dd62e 100755 --- a/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/CalcAdjustSafeArea.ets +++ b/code/DocsSample/ArkWeb/ProcessWebPageCont/entry/src/main/ets/pages/CalcAdjustSafeArea.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start use_expand_safe_area_to_enable_immersive_effect] import { webview } from '@kit.ArkWeb'; @Entry @@ -28,3 +28,4 @@ struct WebComponent { } } } +// [End use_expand_safe_area_to_enable_immersive_effect] diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/entryability/EntryAbility.ets index c3a1c8a89fcc4cc1dfb9ef6b5ff4627253d98e9c..e068627fdb8ccf3a802397acd80615974d1e4243 100755 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/entryability/EntryAbility.ets @@ -13,10 +13,12 @@ * limitations under the License. */ + +import { createNWeb } from "../pages/common"; import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { window } from '@kit.ArkUI'; -import { createNWeb } from "../pages/common"; + export default class EntryAbility extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { @@ -26,16 +28,17 @@ export default class EntryAbility extends UIAbility { onDestroy(): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); } - + // [Start entry_ability_window_stage_created_after_specified_page_loaded] onWindowStageCreate(windowStage: window.WindowStage): void { windowStage.loadContent('pages/Index', (err, data) => { - // 创建Web动态组件(需传入UIContext),loadContent之后的任意时机均可创建 - createNWeb('www.example.com', windowStage.getMainWindowSync().getUIContext()); + // 创建空的Web动态组件(需传入UIContext),loadContent之后的任意时机均可创建 + createNWeb("about:blank", windowStage.getMainWindowSync().getUIContext()); if (err.code) { return; } }); } + // [End entry_ability_window_stage_created_after_specified_page_loaded] onWindowStageDestroy(): void { // Main window is destroyed, release UI related resources diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/pages/Index.ets index c20b0ca45f214c883dceccc5ce7ba30adbae6a5b..05172de125ec81709abfc50f85fa99c9d6b794bf 100755 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/pages/Index.ets @@ -15,6 +15,7 @@ // 使用NodeController的Page页 // Index.ets +// [Start nodeContainer_bind_controller_to_show_dynamic_pages] import { getNWeb } from './common' @Entry @Component @@ -33,3 +34,5 @@ struct Index { .height('100%') } } +// [End nodeContainer_bind_controller_to_show_dynamic_pages] + diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/pages/common.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/pages/common.ets index e22c3cd336dec67549ce52b69cb2f0ca33bed47a..6c4e209e7d580ac2a3b1c4996ea63324f1a31177 100755 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/pages/common.ets +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry/src/main/ets/pages/common.ets @@ -13,8 +13,9 @@ * limitations under the License. */ + +// [Start manage_dynamic_webview_components_in_harmonyos_app] // 创建NodeController -// common.ets import { UIContext, NodeController, BuilderNode, Size, FrameNode } from '@kit.ArkUI'; import { webview } from '@kit.ArkWeb'; @@ -96,3 +97,4 @@ export const createNWeb = (url: ResourceStr, uiContext: UIContext) => { export const getNWeb = (url: ResourceStr) : MyNodeController | undefined => { return nodeMap.get(url); } +// [End manage_dynamic_webview_components_in_harmonyos_app] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/entry1ability/Entry1Ability.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/entry1ability/Entry1Ability.ets index 552e7abe0be2b36dae4a85f53b50f532b6e487e3..844f1ef14f1d64eee187fd2001a56d07b125def9 100755 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/entry1ability/Entry1Ability.ets +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/entry1ability/Entry1Ability.ets @@ -27,6 +27,7 @@ export default class Entry1Ability extends UIAbility { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); } + // [Start entry_ability_window_stage_created_after_page_loaded] onWindowStageCreate(windowStage: window.WindowStage): void { windowStage.loadContent('pages/Index', (err, data) => { // 创建空的Web动态组件(需传入UIContext),loadContent之后的任意时机均可创建 @@ -36,6 +37,7 @@ export default class Entry1Ability extends UIAbility { } }); } + // [End entry_ability_window_stage_created_after_page_loaded] onWindowStageDestroy(): void { // Main window is destroyed, release UI related resources diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/Index.ets index 9f0948d444e9663cc5fb98c226c178b5821452e9..ef124adf169069c2e98e8ddd3ca4de8efca7ad0e 100755 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/Index.ets +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/Index.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start navigate_to_web_page_pre_start_webview_load] import router from '@ohos.router'; import { webview } from '@kit.ArkWeb'; @@ -32,3 +33,4 @@ struct Index1 { } } } +// [End navigate_to_web_page_pre_start_webview_load] diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/common.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/common.ets index 999e9909b658c07ec2a2fbf3e3f8a47d4b79a31d..8aafa42d13cd439091297bc55dcebd92c0d60b81 100755 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/common.ets +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/common.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start manage_dynamic_webview_components_in_harmonyos] // 创建NodeController import { UIContext, NodeController, BuilderNode, Size, FrameNode } from '@kit.ArkUI'; import { webview } from '@kit.ArkWeb'; @@ -95,3 +95,4 @@ export const createNWeb = (url: ResourceStr, uiContext: UIContext) => { export const getNWeb = (url: ResourceStr) : MyNodeController | undefined => { return nodeMap.get(url); } +// [End manage_dynamic_webview_components_in_harmonyos] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/index2.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/index2.ets index 46b3ca95cbd8a28de2800255aa05a0aae127029a..61785eaeb4c341c8eefcbceb2d098e881e6b2f0e 100755 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/index2.ets +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry1/src/main/ets/pages/index2.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start nodeContainer_bind_controller_show_dynamic_pages] import web_webview from '@ohos.web.webview'; @Entry @@ -32,3 +32,4 @@ struct index2 { .height('100%') } } +// [End nodeContainer_bind_controller_show_dynamic_pages] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/ets/pages/common.ets b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/ets/pages/common.ets index 82c5f1fb98ff97fe063a39c14a5278b239f9b7e6..b424a64654a46ca42b5cc3c8f2bb96feec8cb46e 100755 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/ets/pages/common.ets +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/ets/pages/common.ets @@ -26,6 +26,7 @@ class Data{ } // 通过布尔变量shouldInactive控制网页在后台完成预渲染后停止渲染 let shouldInactive: boolean = true; +// [Start call_onActive_method_to_pre_render_offline_web_component] @Builder function webBuilder(data:Data) { Column() { @@ -34,6 +35,7 @@ function webBuilder(data:Data) { // 调用onActive,开启渲染 data.controller.onActive(); }) + // [StartExclude call_onActive_method_to_pre_render_offline_web_component] .onFirstMeaningfulPaint(() =>{ if (!shouldInactive) { return; @@ -42,10 +44,12 @@ function webBuilder(data:Data) { data.controller.onInactive(); shouldInactive = false; }) + // [EndExclude call_onActive_method_to_pre_render_offline_web_component] .width('100%') .height('100%') } } +// [End call_onActive_method_to_pre_render_offline_web_component] let wrap = wrapBuilder(webBuilder); // 用于控制和反馈对应的NodeContianer上的节点的行为,需要与NodeContainer一起使用 export class MyNodeController extends NodeController { diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/module.json5 b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/module.json5 index c795511fa6f3e59972d74471cb44c0b9a91f67af..d40d6d37db59942f8af3cc8f227100af64ae200a 100755 --- a/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/module.json5 +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/entry2/src/main/module.json5 @@ -42,6 +42,6 @@ { "name" : "ohos.permission.INTERNET" } - ] + ], } } \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UseOfflineWebComp/oh-package-lock.json5 b/code/DocsSample/ArkWeb/UseOfflineWebComp/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..205c6cfd4d8cc03127a8a61d9c533f230e8ad80b --- /dev/null +++ b/code/DocsSample/ArkWeb/UseOfflineWebComp/oh-package-lock.json5 @@ -0,0 +1,27 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.19": "@ohos/hypium@1.0.19" + }, + "packages": { + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.19": { + "name": "@ohos/hypium", + "version": "1.0.19", + "integrity": "sha512-cEjDgLFCm3cWZDeRXk7agBUkPqjWxUo6AQeiu0gEkb3J8ESqlduQLSIXeo3cCsm8U/asL7iKjF85ZyOuufAGSQ==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.19.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/ets/pages/Index.ets index d9f86c4892e289b89e1063b4ab3a82ffbd1d786c..b45e3d66fd7b5dde9c59b5a4ed3d769871ef8aa1 100755 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry/src/main/ets/pages/Index.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start click_button_to_turn_on_camera_microphone] import { webview } from '@kit.ArkWeb'; import { BusinessError } from '@kit.BasicServicesKit'; import { abilityAccessCtrl } from '@kit.AbilityKit'; @@ -66,3 +66,4 @@ struct WebComponent { } } } +// [End click_button_to_turn_on_camera_microphone] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/entry2ability/Entry2Ability.ets b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/entry2ability/Entry2Ability.ets index 97f049833e8038360416009c62f83cdeb08cca19..413af92ba3a610c2332fae4f9ae6c45f8cefb2c0 100755 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/entry2ability/Entry2Ability.ets +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/entry2ability/Entry2Ability.ets @@ -12,12 +12,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { hilog } from '@kit.PerformanceAnalysisKit'; import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { hilog } from '@kit.PerformanceAnalysisKit'; +// [Start allow_subsequent_rendering_to_use_ui] import { window } from '@kit.ArkUI'; export default class Entry2Ability extends UIAbility { + // [StartExclude allow_subsequent_rendering_to_use_ui] onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); } @@ -25,7 +27,7 @@ export default class Entry2Ability extends UIAbility { onDestroy(): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); } - + // [EndExclude allow_subsequent_rendering_to_use_ui] onWindowStageCreate(windowStage: window.WindowStage): void { windowStage.loadContent('pages/Index', (err, data) => { if (err.code) { @@ -35,7 +37,7 @@ export default class Entry2Ability extends UIAbility { AppStorage.setOrCreate('UIContext', windowStage.getMainWindowSync().getUIContext()); }); } - + // [StartExclude allow_subsequent_rendering_to_use_ui] onWindowStageDestroy(): void { // Main window is destroyed, release UI related resources hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); @@ -50,4 +52,6 @@ export default class Entry2Ability extends UIAbility { // Ability has back to background hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); } + // [EndExclude allow_subsequent_rendering_to_use_ui] } +// [End allow_subsequent_rendering_to_use_ui] \ No newline at end of file diff --git a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/pages/Index.ets b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/pages/Index.ets index ef722e663e39bcbf1377d773c4e023d0670d738a..778738e0706c4c442912054d962bba8ed41935cb 100755 --- a/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/pages/Index.ets +++ b/code/DocsSample/ArkWeb/UsingWebMultimedia/entry2/src/main/ets/pages/Index.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start video_hosting_usage] import { webview } from '@kit.ArkWeb'; import { BuilderNode, FrameNode, NodeController, NodeRenderType, UIContext } from '@kit.ArkUI'; import { AVPlayerDemo, AVPlayerListener } from './PlayerDemo'; @@ -465,3 +465,4 @@ struct WebComponent { return this.nativePlayerInfoList.find((item)=> item.embedId == embedId); } } +// [End video_hosting_usage] \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Await.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Await.ets index 827b06c68efe94ec79bb53d1713dd50a8375a5f3..0f99919369f5aaef39759b937f8bfe7e45854a59 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Await.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Await.ets @@ -13,6 +13,8 @@ * limitations under the License. */ +// [Start use_hkdf_for_key_derivation_await] + import { cryptoFramework } from '@kit.CryptoArchitectureKit'; import { buffer } from '@kit.ArkTS'; @@ -31,7 +33,7 @@ async function kdfAwait() { let secret = await kdf.generateSecret(spec); console.info('key derivation output is ' + secret.data); } - +// [End use_hkdf_for_key_derivation_await] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Promise.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Promise.ets index d4222fbff82e780cfebb6b97a0e61496c826f9d8..59080c5cb328cba784c6c704caac3416dbf28c17 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Promise.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Promise.ets @@ -13,6 +13,8 @@ * limitations under the License. */ +// [Start use_hkdf_for_key_derivation_promise] + import { cryptoFramework } from '@kit.CryptoArchitectureKit'; import { BusinessError } from '@kit.BasicServicesKit'; import { buffer } from '@kit.ArkTS'; @@ -37,6 +39,7 @@ function kdfPromise() { }); } +// [End use_hkdf_for_key_derivation_promise] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Sync.ets index 27285f67ce3491abf5762a314f6576081b403d70..87e344284cec6c344570a83b3fc95d6100cef249 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/HKDFDerivation/entry/src/main/ets/pages/Sync.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start use_hkdf_for_key_derivation_sync] import { cryptoFramework } from '@kit.CryptoArchitectureKit'; import { buffer } from '@kit.ArkTS'; @@ -32,6 +32,7 @@ function kdfSync() { console.info('[Sync]key derivation output is ' + secret.data); } +// [End use_hkdf_for_key_derivation_sync] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Await.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Await.ets index 043464ce92dc7b1ce171df8d3dcd57c0579f4ed8..4a23ae51e49cb46def42dcd45e9d543d03d1dcd0 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Await.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Await.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start use_pbkdf2_for_key_derivation_await] import { cryptoFramework } from '@kit.CryptoArchitectureKit'; async function kdfAwait() { @@ -28,6 +28,8 @@ async function kdfAwait() { console.info('key derivation output is ' + secret.data); } +// [End use_pbkdf2_for_key_derivation_await] + @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Promise.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Promise.ets index e41b03f51f82115b465aec7ff5a9b3d58c4aa40f..17b97190db12fbb2a853df93f75b74ad2c164fb9 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Promise.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Promise.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start use_pbkdf2_for_key_derivation_promise] import { cryptoFramework } from '@kit.CryptoArchitectureKit'; import { BusinessError } from '@kit.BasicServicesKit'; @@ -32,7 +32,7 @@ function kdfPromise() { console.error('key derivation error.'); }); } - +// [End use_pbkdf2_for_key_derivation_promise] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Sync.ets index eec7a22fb2565cad382fb9cdee63389e4c2eafe6..f259312c81dfd9ab1aa5efc1402bf15dda7f1ca0 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyDerivation/PBKDF2Derivation/entry/src/main/ets/pages/Sync.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start use_pbkdf2_for_key_derivation_sync] import { cryptoFramework } from '@kit.CryptoArchitectureKit'; function kdfSync() { @@ -28,6 +28,7 @@ function kdfSync() { console.info('[Sync]key derivation output is ' + secret.data); } +// [End use_pbkdf2_for_key_derivation_sync] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/DH/DHAsync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/DH/DHAsync.ets index ed556b1aaa51ac91215ab37d02970e5db63a26b9..efd5f7a3752cc49ea8a13cff2f3c5df9cfe02743 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/DH/DHAsync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/DH/DHAsync.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start use_dh_for_key_negotiation_async] import { cryptoFramework } from '@kit.CryptoArchitectureKit'; async function dhAwait() { @@ -34,6 +34,7 @@ async function dhAwait() { console.error('DH result is not equal'); } } +// [End use_dh_for_key_negotiation_async] @Entry @Component diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/DH/DHSync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/DH/DHSync.ets index adec491b67f0a96428baacfd355997d5da6558d6..1dad296c7279affb6cd964f28f26f174fda48177 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/DH/DHSync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/DH/DHSync.ets @@ -13,6 +13,8 @@ * limitations under the License. */ + +// [Start use_dh_for_key_negotiation_sync] import { cryptoFramework } from '@kit.CryptoArchitectureKit'; function dhAwait() { @@ -34,7 +36,7 @@ function dhAwait() { console.error('DH result is not equal'); } } - +// [End use_dh_for_key_negotiation_sync] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/ECDH/EDCHAsync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/ECDH/EDCHAsync.ets index 8667db5eb4e28b90b6749b88f6e62c061a9a4b48..5dc035ea5d36da6dba48608e3c4052471f631725 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/ECDH/EDCHAsync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/ECDH/EDCHAsync.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +/// [Start use_ecdh_for_key_negotiation_async] import { cryptoFramework } from '@kit.CryptoArchitectureKit'; async function ecdhAwait() { @@ -44,6 +44,7 @@ async function ecdhAwait() { } } +// [End use_ecdh_for_key_negotiation_async] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/ECDH/EDCHSync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/ECDH/EDCHSync.ets index ee3f00e7e17b324dabb5cacabe14847859924694..edf1a0f7d102e83988d5731ea81f5126f2c613ff 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/ECDH/EDCHSync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/ECDH/EDCHSync.ets @@ -13,6 +13,8 @@ * limitations under the License. */ +// [Start use_ecdh_for_key_negotiation_sync] + import { cryptoFramework } from '@kit.CryptoArchitectureKit'; function ecdhAwait() { @@ -44,6 +46,8 @@ function ecdhAwait() { } } +// [End use_ecdh_for_key_negotiation_sync] + @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/X25519/X25519Async.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/X25519/X25519Async.ets index 1be37d026c3936c0ef86851dedad4088baec9fa4..a320edc5a2446fcbb723f2a96c440fbf3c7af7c6 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/X25519/X25519Async.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/X25519/X25519Async.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start use_x25519a_for_key_negotiation_async] import { cryptoFramework } from '@kit.CryptoArchitectureKit'; async function x25519Await() { @@ -41,7 +41,7 @@ async function x25519Await() { console.error('x25519 result is not equal'); } } - +// [End use_x25519a_for_key_negotiation_async] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/X25519/X25519Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/X25519/X25519Sync.ets index 93b2d229b7084826e4178407b688e502f7ab4de0..953a34d8c2783a94df1014e8526a86de0fcfb91a 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/X25519/X25519Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/KeyNegotiation/entry/src/main/ets/pages/X25519/X25519Sync.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start use_x25519a_for_key_negotiation_sync] import { cryptoFramework } from '@kit.CryptoArchitectureKit'; function x25519Await() { @@ -41,7 +41,7 @@ function x25519Await() { console.error('x25519 result is not equal'); } } - +// [End use_x25519a_for_key_negotiation_sync] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSegmentation/Async.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSegmentation/Async.ets index 9b7ab53adb81e5666331e9c363be167fe20a0c9d..61b41b8f927206c5fb16a65b5c0c3276a308f195 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSegmentation/Async.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSegmentation/Async.ets @@ -13,6 +13,8 @@ * limitations under the License. */ +// [Start message_authentication_code_calculation_hmac_one_time_incoming] + import { cryptoFramework } from '@kit.CryptoArchitectureKit'; import { buffer } from '@kit.ArkTS'; @@ -40,6 +42,8 @@ async function doHmac() { console.info('HMAC len:' + macLen); } +// [End message_authentication_code_calculation_hmac_one_time_incoming] + @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSegmentation/Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSegmentation/Sync.ets index ea497d8f18d8dc3138c72f3dfbaeeab29b8b25ff..7fa0b1b7b499e951320ec72199868c5c1d1cf75f 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSegmentation/Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSegmentation/Sync.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start message_authentication_code_calculation_sync_one_time_incoming] import { cryptoFramework } from '@kit.CryptoArchitectureKit'; import { buffer } from '@kit.ArkTS'; @@ -40,6 +40,8 @@ function doHmacBySync() { console.info('HMAC len:' + macLen); } +// [End message_authentication_code_calculation_sync_one_time_incoming] + @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSingleTime/Async.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSingleTime/Async.ets index a9f73fa472fed6ddbc9907a645d3a35c51cdba72..b3f63e65121dd26945fac0b8a99eff40efd6bdec 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSingleTime/Async.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSingleTime/Async.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start message_authentication_code_calculated_as_fragmented_hmac_async] import { cryptoFramework } from '@kit.CryptoArchitectureKit'; import { buffer } from '@kit.ArkTS'; @@ -46,6 +46,8 @@ async function doLoopHmac() { console.info('HMAC len:' + macLen); } + +// [End message_authentication_code_calculated_as_fragmented_hmac_async] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSingleTime/Sync.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSingleTime/Sync.ets index 52260466acbe0ceb73ed153c236a98bad41e4bc4..45fe02cfc8be73f24a856100a83aa7a4500a2f26 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSingleTime/Sync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageAuthenticationCode/entry/src/main/ets/pages/HMACSingleTime/Sync.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start message_authentication_code_calculated_as_fragmented_hmac_sync] import { cryptoFramework } from '@kit.CryptoArchitectureKit'; import { buffer } from '@kit.ArkTS'; @@ -46,6 +46,8 @@ function doLoopHmacBySync() { console.info('HMAC len:' + macLen); } + +// [End message_authentication_code_calculated_as_fragmented_hmac_sync] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/segmentation.cpp b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/segmentation.cpp index 77528e2039ef292540bb433f5af407c37851619f..fe193cfc526782c729eac653140cbb60479567b4 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/segmentation.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/segmentation.cpp @@ -13,6 +13,8 @@ * limitations under the License. */ +// [Start message_digest_calculation_segmented_digest_algorithm] + #include #include "CryptoArchitectureKit/crypto_common.h" #include "CryptoArchitectureKit/crypto_digest.h" @@ -57,4 +59,6 @@ OH_Crypto_ErrCode doLoopMd() OH_Crypto_FreeDataBlob(&out); OH_DigestCrypto_Destroy(ctx); return ret; -} \ No newline at end of file +} + +// [End message_digest_calculation_segmented_digest_algorithm] \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/singleTime.cpp b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/singleTime.cpp index 7e3e7d1af9ee2e3f441b7bdd0de195f25f17c4d1..eafdeeb714ab16f466e7d499353c9ea74f5f7eb7 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/singleTime.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/cpp/types/project/singleTime.cpp @@ -13,6 +13,8 @@ * limitations under the License. */ +// [Start message_digest_calculation_digest_algorithm_one_time_incoming] + #include "CryptoArchitectureKit/crypto_common.h" #include "CryptoArchitectureKit/crypto_digest.h" #include @@ -44,4 +46,6 @@ OH_Crypto_ErrCode doTestMd() OH_Crypto_FreeDataBlob(&out); OH_DigestCrypto_Destroy(ctx); return ret; -} \ No newline at end of file +} + +// [End message_digest_calculation_digest_algorithm_one_time_incoming] \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/segmentation/SegmentationAsync.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/segmentation/SegmentationAsync.ets index d5d70502874245b556a02e2532585b2d4222e800..a4efb4f6785c7285cfeddcc7d382b68a04102e5f 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/segmentation/SegmentationAsync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/segmentation/SegmentationAsync.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start message_digest_calculation_segmented_digest_algorithm_async] import { cryptoFramework } from '@kit.CryptoArchitectureKit'; import { buffer } from '@kit.ArkTS'; @@ -34,6 +34,7 @@ async function doLoopMd() { console.info('md len: ' + mdLen); } +// [End message_digest_calculation_segmented_digest_algorithm_async] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/segmentation/SegmentationSync.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/segmentation/SegmentationSync.ets index cbb9e89b2929af12a4f3933a3b1dc862d155b4b0..5e9b58c59275beb3b0686d0ff4891fb1ec141ea2 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/segmentation/SegmentationSync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/segmentation/SegmentationSync.ets @@ -13,6 +13,8 @@ * limitations under the License. */ +// [Start message_digest_calculation_segmented_digest_algorithm_sync] + import { cryptoFramework } from '@kit.CryptoArchitectureKit'; import { buffer } from '@kit.ArkTS'; @@ -33,7 +35,7 @@ function doLoopMdBySync() { let mdLen = md.getMdLength(); console.info('md len: ' + mdLen); } - +// [End message_digest_calculation_segmented_digest_algorithm_sync] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/singleTime/SingleTimeAsync.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/singleTime/SingleTimeAsync.ets index 8c048faa380df661cc84de1fa44668ab7ce563fc..c39fc8f1e362c0100c2603fb0e2ad641ee63e1f8 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/singleTime/SingleTimeAsync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/singleTime/SingleTimeAsync.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start message_digest_calculation_digest_algorithm_one_time_incoming_async] import { cryptoFramework } from '@kit.CryptoArchitectureKit'; import { buffer } from '@kit.ArkTS'; @@ -28,6 +28,8 @@ async function doMd() { console.info('md len: ' + mdLen); } +// [End message_digest_calculation_digest_algorithm_one_time_incoming_async] + @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/singleTime/SingleTimeSync.ets b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/singleTime/SingleTimeSync.ets index f1841e3ee2a38029295be83210b9518b8d3766ca..1f60f9e33afea390835bf5489c76d20516e7fdd6 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/singleTime/SingleTimeSync.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/MessageDigestComputation/entry/src/main/ets/pages/singleTime/SingleTimeSync.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start message_digest_calculation_digest_algorithm_one_time_incoming_sync] import { cryptoFramework } from '@kit.CryptoArchitectureKit'; import { buffer } from '@kit.ArkTS'; @@ -27,7 +27,7 @@ function doMdBySync() { let mdLen = md.getMdLength(); console.info('md len: ' + mdLen); } - +// [End message_digest_calculation_digest_algorithm_one_time_incoming_sync] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/ets/pages/Index.ets index 56f37c9df1dcb325cea8a15793f9c5a38d3975e6..7bdacbcc1cbe564d9b4f5604f8589712a9020e35 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SecureRandomNumberGeneration/entry/src/main/ets/pages/Index.ets @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +// [Start secure_random_number_generation] import { cryptoFramework } from '@kit.CryptoArchitectureKit'; import { BusinessError } from '@kit.BasicServicesKit'; @@ -41,6 +42,8 @@ async function doRand() { console.info('rand output:' + randOutput.data); } +// [End secure_random_number_generation] + @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/ecdsa_signature_verification.cpp b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/ecdsa_signature_verification.cpp index 2eac147f35e13877318a4b3cc060772c50ddf075..d0ae1503c74b04b582272a5d42ee4d7d2688cd35 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/ecdsa_signature_verification.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/ecdsa_signature_verification.cpp @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start verify_signatures_with_ecdsa_keys_c] #include "signing_signature_verification.h" bool DoTestEcdsaSignature() @@ -77,3 +77,4 @@ bool DoTestEcdsaSignature() OH_CryptoKeyPair_Destroy(keyPair); return res; } +// [End verify_signatures_with_ecdsa_keys_c] \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/sm2_signature_verification.cpp b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/sm2_signature_verification.cpp index 425b5eddd2413bc718c17a5d5ddd3e8048b78741..c1e897b0de7b46f5131a868224d6ee0d9d1b545e 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/sm2_signature_verification.cpp +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerification/entry/src/main/cpp/types/project/sm2_signature_verification.cpp @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start verify_signatures_with_sm2_key_pair_c] #include "signing_signature_verification.h" bool DoTestSm2Signature() @@ -84,3 +84,5 @@ bool DoTestSm2Signature() OH_CryptoKeyPair_Destroy(keyPair); return res; } + +// [End verify_signatures_with_sm2_key_pair_c] \ No newline at end of file diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/ecdsa_signature_verification/ecdsa_signature_verification_asynchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/ecdsa_signature_verification/ecdsa_signature_verification_asynchronous.ets index f31a122cd317a42f02c098f61116e14bbc73e9e5..6e103ba1f19eacbd9fc1bd14f32694c64d13922d 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/ecdsa_signature_verification/ecdsa_signature_verification_asynchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/ecdsa_signature_verification/ecdsa_signature_verification_asynchronous.ets @@ -13,6 +13,8 @@ * limitations under the License. */ +// [Start signature_verification_with_ecdsa_key_pair_ark_async] + import { cryptoFramework } from '@kit.CryptoArchitectureKit'; import { buffer } from '@kit.ArkTS'; @@ -52,6 +54,7 @@ async function main() { } } +// [End signature_verification_with_ecdsa_key_pair_ark_async] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/ecdsa_signature_verification/ecdsa_signature_verification_synchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/ecdsa_signature_verification/ecdsa_signature_verification_synchronous.ets index 8c011ab9229bc63b4782711c21cc08bd3f641c8f..8288f2ce2437fb1fb89a719412835a78bc958ff8 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/ecdsa_signature_verification/ecdsa_signature_verification_synchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/ecdsa_signature_verification/ecdsa_signature_verification_synchronous.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start signature_verification_with_ecdsa_key_pair_ark_sync] import { cryptoFramework } from '@kit.CryptoArchitectureKit'; import { buffer } from '@kit.ArkTS'; @@ -52,6 +52,8 @@ function main() { } } + +// [End signature_verification_with_ecdsa_key_pair_ark_sync] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/sm2_signature_verification/sm2_signature_verification_asynchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/sm2_signature_verification/sm2_signature_verification_asynchronous.ets index ba4b7a569dddc4d6a6b96f04592e61cf60f1a0bb..5f612bc7e67300d8ebc37916832996c15e211c7e 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/sm2_signature_verification/sm2_signature_verification_asynchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/sm2_signature_verification/sm2_signature_verification_asynchronous.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start use_the_sm2_key_pair_to_sign_and_verify_async] import { cryptoFramework } from '@kit.CryptoArchitectureKit'; import { buffer } from '@kit.ArkTS'; @@ -52,6 +52,8 @@ async function main() { } } + +// [End use_the_sm2_key_pair_to_sign_and_verify_async] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/sm2_signature_verification/sm2_signature_verification_synchronous.ets b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/sm2_signature_verification/sm2_signature_verification_synchronous.ets index 62e71435109d9b09f0c81612c229751c710e6c0b..3957b3ac729e0d6b26d75dd0aac37fc6e0035593 100755 --- a/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/sm2_signature_verification/sm2_signature_verification_synchronous.ets +++ b/code/DocsSample/Security/CryptoArchitectureKit/SignatureVerification/SigningSignatureVerificationArkTs/entry/src/main/ets/pages/sm2_signature_verification/sm2_signature_verification_synchronous.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start use_the_sm2_key_pair_to_sign_and_verify_sync] import { cryptoFramework } from '@kit.CryptoArchitectureKit'; import { buffer } from '@kit.ArkTS'; @@ -52,6 +52,8 @@ function main() { } } +// [End use_the_sm2_key_pair_to_sign_and_verify_sync] + @Entry @Component struct Index { diff --git a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/ets/pages/Index.ets index b1d3fc7f39935b5987be6c263656d0a2deef0330..c7eb3bcab546d285802e39de2c060bc4c9c317ec 100755 --- a/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/Security/DataProtectionKit/DataProtection/entry/src/main/ets/pages/Index.ets @@ -13,6 +13,8 @@ * limitations under the License. */ +// [Start guidance_on_the_development_of_data_leakage_prevention_services] + import { dlpPermission } from '@kit.DataProtectionKit'; import { common, Want } from '@kit.AbilityKit'; import { fileIo } from '@kit.CoreFileKit'; @@ -187,6 +189,9 @@ dlpPermission.isDLPFeatureProvided().then((res) => { console.error('error', (err as BusinessError).code, (err as BusinessError).message); // 失败报错 }); + +// [End guidance_on_the_development_of_data_leakage_prevention_services] + @Entry @Component struct Index { diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateGetCertCrlObject.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateGetCertCrlObject.ets index c560f710edbf70c5184e06a129a51e3364e519ed..78139d93730138895fe7595f95358a65e10f358b 100755 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateGetCertCrlObject.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateGetCertCrlObject.ets @@ -13,6 +13,9 @@ * limitations under the License. */ + + +// [Start certificate_collection_and_certificate_revocation_list_collection_object_creation_and_acquisition] import { cert } from '@kit.DeviceCertificateKit'; import { BusinessError } from '@kit.BasicServicesKit'; import { util } from '@kit.ArkTS'; @@ -103,6 +106,8 @@ async function sample() { } } + +// [End certificate_collection_and_certificate_revocation_list_collection_object_creation_and_acquisition] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCertObject.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCertObject.ets index b782420c88a2aeb4ee3eb263ec2d24f81ce03c78..99b48021f1c4df36fa2c1500aa7ca1206daf11ca 100755 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCertObject.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCertObject.ets @@ -13,6 +13,8 @@ * limitations under the License. */ +// [Start certificate_object_creation_resolution_validation] + import { cert } from '@kit.DeviceCertificateKit'; import { BusinessError } from '@kit.BasicServicesKit'; import { util } from '@kit.ArkTS'; @@ -84,6 +86,8 @@ function certSample(): void { }); } + +// [End certificate_object_creation_resolution_validation] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCertextensionObject.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCertextensionObject.ets index 395b7256232cae553fb0ac5f06e591d1fc5a05de..10ae5d57719b9fbf2ef87901442da13a1f38f0c6 100755 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCertextensionObject.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCertextensionObject.ets @@ -13,6 +13,9 @@ * limitations under the License. */ + +// [Start create_parse_validate_certificate_extension_info_objects] + import { cert } from '@kit.DeviceCertificateKit'; import { BusinessError } from '@kit.BasicServicesKit'; import { util } from '@kit.ArkTS'; @@ -68,6 +71,7 @@ function certExtensionSample(): void { } +// [End create_parse_validate_certificate_extension_info_objects] @Entry @Component diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCrlObject.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCrlObject.ets index 51ec07c776883cba5911c7e00c9278d0d1bd239f..e43c16bd9c3b59fa5a1fd094aff7180f1cb5be5e 100755 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCrlObject.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateParseVerifyCrlObject.ets @@ -13,6 +13,9 @@ * limitations under the License. */ +// [Start create_parse_verify_certificate_revocation_list_objects] + + import { cert } from '@kit.DeviceCertificateKit'; import { cryptoFramework } from '@kit.CryptoArchitectureKit'; import { BusinessError } from '@kit.BasicServicesKit'; @@ -172,6 +175,9 @@ function crlSample(): void { }); } + +// [End create_parse_verify_certificate_revocation_list_objects] + @Entry @Component struct Index { diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateTrustanchorFromP12.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateTrustanchorFromP12.ets index 4cded231313c55578f03189d332cad10e16a2a1c..ba8d960ff92b9edc4a7c3e4fc69ca0588410d439 100755 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateTrustanchorFromP12.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateTrustanchorFromP12.ets @@ -13,6 +13,8 @@ * limitations under the License. */ + +// [Start trust_array_constructed_from_p12_file_during_validation] import { cert } from '@kit.DeviceCertificateKit'; import { BusinessError } from '@kit.BasicServicesKit'; @@ -130,6 +132,8 @@ function test() { } } + +// [End trust_array_constructed_from_p12_file_during_validation] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateVerifyCerchainvalidatorObject.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateVerifyCerchainvalidatorObject.ets index 6513b3b8c5b66bd80ba73d51bdc15212fa490fbc..1b87d7c7f6d33cbb03db0bb9cd0a9b0d054ccd65 100755 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateVerifyCerchainvalidatorObject.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateVerifyCerchainvalidatorObject.ets @@ -13,6 +13,9 @@ * limitations under the License. */ + + +// [Start certificate_chain_validator_object_creation_and_validation] import { cert } from '@kit.DeviceCertificateKit'; import { util } from '@kit.ArkTS'; @@ -122,6 +125,8 @@ function certChainValidatorSample(): void { }); } + +// [End certificate_chain_validator_object_creation_and_validation] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateVerifyCertchainObject.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateVerifyCertchainObject.ets index 75ab34393e3358d58a7820f61d6bbd6835ad635e..9081b2d61e9867b1cb8f3250a06c05968eab8628 100755 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateVerifyCertchainObject.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateAlgorithmLibrary/entry/src/main/ets/pages/CreateVerifyCertchainObject.ets @@ -13,6 +13,8 @@ * limitations under the License. */ +// [Start certificate_chain_object_creation_and_validation] + import { cert } from '@kit.DeviceCertificateKit'; import { BusinessError } from '@kit.BasicServicesKit'; import { util } from '@kit.ArkTS'; @@ -118,6 +120,8 @@ async function sample() { } } + +// [End certificate_chain_object_creation_and_validation] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerDialogGuidelines.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerDialogGuidelines.ets index dddba1b3a4bb66b415939a12bfbe09f872b2d8ea..20437368557c987a23e3bb6dfca2e0b7830b1ee4 100755 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerDialogGuidelines.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerDialogGuidelines.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start certificate_management_dialog_box_development_guide] import { certificateManagerDialog } from '@kit.DeviceCertificateKit'; import { BusinessError } from '@kit.BasicServicesKit'; import { common } from '@kit.AbilityKit'; @@ -34,6 +34,8 @@ async function certificateManagerDialogSample() { } } + +// [End certificate_management_dialog_box_development_guide] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerGuidelines.ets b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerGuidelines.ets index 09baa8cb5610f4e7a4abc0922de889e1a104e562..39f6cc11dbde61b1445f7dee3bc441c0c8801397 100755 --- a/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerGuidelines.ets +++ b/code/DocsSample/Security/DeviceCertificateKit/CertificateManagement/entry/src/main/ets/pages/CertManagerGuidelines.ets @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +// [Start certificate_management_development_guidance] import { certificateManager } from '@kit.DeviceCertificateKit'; import { BusinessError } from '@kit.BasicServicesKit'; @@ -272,6 +273,8 @@ async function certificateManagerSample() { } } +// [End certificate_management_development_guidance] + @Entry @Component struct Index { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/napi_init.cpp index 6c177236330e9bf0b399e94f0b7887b25a8a8423..3a5cdcb34ab31ae90406fa04712ad8ee9d686e4e 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/cpp/napi_init.cpp @@ -12,12 +12,12 @@ * 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) @@ -62,7 +62,7 @@ static OH_Huks_Result GenerateKeyHelper(const char *alias) OH_Huks_FreeParamSet(&testGenerateKeyParamSet); return ohResult; } - +// [EndExclude key_deletion] static napi_value DeleteKey(napi_env env, napi_callback_info info) { /* 1.获取密钥别名 */ @@ -71,7 +71,7 @@ static napi_value DeleteKey(napi_env env, napi_callback_info info) (uint32_t)strlen("test_key"), (uint8_t *)"test_key" }; - + // [StartExclude key_deletion] /* 生成密钥 */ OH_Huks_Result genResult = GenerateKeyHelper(alias); if (genResult.errorCode != OH_HUKS_SUCCESS) { @@ -79,6 +79,7 @@ static napi_value DeleteKey(napi_env env, napi_callback_info info) 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); @@ -87,7 +88,7 @@ static napi_value DeleteKey(napi_env env, napi_callback_info info) 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) { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/pages/KeyDeletion.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/pages/KeyDeletion.ets index 27e5addb80f01f353c93291fb926952ce6cff37c..a5cc677a2f854acd44c829d47a56dd3351d7c28c 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/pages/KeyDeletion.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyDeletion/entry/src/main/ets/pages/KeyDeletion.ets @@ -16,11 +16,12 @@ /* * 以下以HKDF256密钥的Promise操作使用为例 */ +// [Start key_deletions] import { huks } from '@kit.UniversalKeystoreKit'; /* 1.确定密钥别名 */ let keyAlias = 'test_Key'; - +// [StartExclude key_deletions] /* 2.初始化密钥属性集 */ let generateProperties: huks.HuksParam[] = [ { @@ -81,7 +82,7 @@ async function testGenKey(): Promise { return ret; } - +// [EndExclude key_deletions] /* 4.构造空对象 */ let deleteHuksOptions: huks.HuksOptions = { properties: [] @@ -138,7 +139,7 @@ async function testDerive(): Promise { let ret = await publicDeleteKeyFunc(keyAlias, deleteHuksOptions); return ret; } - +// [End key_deletions] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/napi_init.cpp index fd8f89141bdd2bef7e30921d66a9e32c6fb16761..a083b2faff8b2b63859f5cd264abf6b5cd84b28e 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/cpp/napi_init.cpp @@ -12,7 +12,7 @@ * 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" @@ -66,7 +66,7 @@ static napi_value GenerateKey(napi_env env, napi_callback_info info) 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) { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/pages/Index.ets index 2ce4dd0d3e7388189b86785f8ac7769bd42c44ae..0a421f42aa26e1974e22baa3dd73d08fb6339b39 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyGeneration/DevelopmentGuidelines/GenerateKey/entry/src/main/ets/pages/Index.ets @@ -13,6 +13,9 @@ * limitations under the License. */ + +// [Start generate_key_ar] + import { huks } from '@kit.UniversalKeystoreKit'; import testNapi from 'libentry.so'; @@ -78,6 +81,10 @@ async function testGenKey(): Promise { return ret; } + +// [End generate_key_ar] + + @Entry @Component struct Index { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/napi_init.cpp index 8535a23a75c9494a13be53614bd50992d3c1d065..de425742291cbb1cbdc9b771e943533925af4652 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/cpp/napi_init.cpp @@ -13,6 +13,8 @@ * 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" @@ -563,6 +565,11 @@ static napi_value NAPI_Global_importWrappedKey(napi_env env, napi_callback_info 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.指定密钥别名 */ @@ -578,6 +585,8 @@ static napi_value IsKeyExist(napi_env env, napi_callback_info info) return ret; } +// [End encryption_import_key_commissioning_and_verification] + EXTERN_C_START static napi_value Init(napi_env env, napi_value exports) { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/pages/ImportEncryptedKey.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/pages/ImportEncryptedKey.ets index 4a550cec4c2a0953f65d4286cc92444a37691eba..3868b6dfe2dc840c7c4451360ce33c334ad329b1 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/pages/ImportEncryptedKey.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportEncryptedKey/entry/src/main/ets/pages/ImportEncryptedKey.ets @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +// [Start encrypt_the_import_key] import { huks } from '@kit.UniversalKeystoreKit'; @@ -620,6 +621,10 @@ async function ImportWrappedKey() { await publicDeleteKeyItemFunc(callerKekAliasAes256, callerAgreeParams); } + +// [End encrypt_the_import_key] + +// [Start encrypt_the_import_key_to_verify_that_the_key_exists] /* * 确定密钥别名和封装密钥属性参数集 */ @@ -652,4 +657,5 @@ function Check() { } } +// [End encrypt_the_import_key_to_verify_that_the_key_exists] export { ImportWrappedKey, Check }; diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/napi_init.cpp index a1c3e6ff08a41ac6dacc920d770308c782741061..3043449a63b925cfcbdab4c6f798a5332bf04725 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/cpp/napi_init.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start import_keys_in_plaintext] /* 以下以明文导入AES密钥为例 */ #include "huks/native_huks_api.h" #include "huks/native_huks_param.h" @@ -76,6 +77,7 @@ static napi_value ImportKey(napi_env env, napi_callback_info info) return ret; } +// [End import_keys_in_plaintext] EXTERN_C_START static napi_value Init(napi_env env, napi_value exports) { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/AES256.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/AES256.ets index 20718d09e102ec3da9621a7bd2d6ae9d96768d69..05e997efba76e0feb341a6081cf389618c37db86 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/AES256.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/AES256.ets @@ -13,6 +13,8 @@ * limitations under the License. */ +// [Start import_keys_in_plaintext_AES256] + /* 以下以导入AES256密钥的Callback操作使用为例 */ import { huks } from '@kit.UniversalKeystoreKit' @@ -61,6 +63,8 @@ function importAES256() { } } +// [End import_keys_in_plaintext_AES256] + let isKeyExist = false; let keyProperties: huks.HuksParam[] = [ diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/RSA2048.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/RSA2048.ets index e522e1cc29df3c0288995213fa4260f3e6458b49..c21dacea9293686f277e8a5f69330e5baba6de5b 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/RSA2048.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/RSA2048.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start import_keys_in_plaintext_RSA2048] /* 以下以导入RSA2048密钥的Callback操作使用为例 */ import { huks } from '@kit.UniversalKeystoreKit' @@ -106,6 +107,9 @@ function importRSA2048() { } } + + +// [End import_keys_in_plaintext_RSA2048] let isKeyExist = false; let keyProperties: huks.HuksParam[] = [ diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/X25519.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/X25519.ets index 29794fbe2c6a40f92498c89eb4decf481628ec98..70a1720bfe5f1cd5bf1b8e48dc7292c95011e2c3 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/X25519.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyGenerationImport/KeyImport/DevelopmentGuidelines/ImportKeyPlainText/entry/src/main/ets/pages/X25519.ets @@ -12,7 +12,7 @@ * 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' @@ -68,6 +68,9 @@ function importX25519() { } } + +// [End import_keys_in_plaintext_X25519] + let isKeyExist = false; let keyProperties: huks.HuksParam[] = [ diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/napi_init.cpp index 3be42f279901310396a96153a7a58ae9abafe89f..70730d8b48c49461a0c6168fb9d83c03724b9bf4 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/cpp/napi_init.cpp @@ -12,7 +12,7 @@ * 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" @@ -133,7 +133,7 @@ static napi_value AnonAttestKey(napi_env env, napi_callback_info info) 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) { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/pages/AnonymousKeyProof.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/pages/AnonymousKeyProof.ets index 18a32ed19679a54a4e02317268a41eb2ab3a9581..5d1c616b4cf3aecfd9bbc1b06fbb98f36c13cdc1 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/pages/AnonymousKeyProof.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/pages/AnonymousKeyProof.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start anonymous_key_proof] /* * 以下以anonAttestKey的Promise接口操作验证为例 */ @@ -184,7 +184,7 @@ async function anonAttestKeyTest(): Promise { console.info('anon attest certChain data: ' + anonAttestCertChain) return ret; } - +// [End anonymous_key_proof] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/napi_init.cpp old mode 100755 new mode 100644 index ed25c4cf2fbf985a2db596c4774403931ee06496..ca39403298336db868f4e573734d88eae2702ece --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/napi_init.cpp @@ -1,156 +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. - */ - -#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; -} - -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); } +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/pages/NonAnonymousKeyProof.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/pages/NonAnonymousKeyProof.ets index ab44d65cc1c05fed9bc83da39478e39f7987397f..3509e335b4679ba2c4b69f10045ab423b6a90545 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/pages/NonAnonymousKeyProof.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/ets/pages/NonAnonymousKeyProof.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start Start non_anonymized_key_proof] /* * 以下以attestKey的Promise接口操作验证为例 */ @@ -184,7 +184,7 @@ async function attestKeyTest(): Promise { console.info('attest certChain data: ' + attestCertChain) return ret; } - +// [End Start non_anonymized_key_proof] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/FineGrainedUserIdentityAuthentication.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/FineGrainedUserIdentityAuthentication.ets index 0bc3920045029cfd4217e441dd2d9ce893c41533..9c727153c0c5bdb2626b3a66120b330e5a393b0b 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/FineGrainedUserIdentityAuthentication.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/FineGrainedUserIdentityAuthentication.ets @@ -13,11 +13,12 @@ * 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 keyAlias = 'test_sm4_key_alias'; + let cipherInData = 'Hks_SM4_Cipher_Test_101010101010101010110_string'; // 明文数据。 let IV = '1234567890123456'; let handle = 0; @@ -28,6 +29,7 @@ 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; } @@ -131,7 +133,7 @@ async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions) 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 @@ -401,6 +403,7 @@ async function testSm4CipherFinish() { } } +// [End fine_grained_user_auth_and_access_control_guide] async function main() { await testGenKeyForFingerprintAccessControl(); await testSm4Cipher(); diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/UserIdentityAuthentication.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/UserIdentityAuthentication.ets index a89e9303affd1137c13e9cd42919879dd349dbe8..20d5968174848a10b350785e31762d62126370d3 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/UserIdentityAuthentication.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/AccessControl/entry/src/main/ets/pages/UserIdentityAuthentication.ets @@ -13,6 +13,8 @@ * limitations under the License. */ + +// [Start user_authentication_and_access_control_guide] import { huks } from '@kit.UniversalKeystoreKit'; import { userAuth } from '@kit.UserAuthenticationKit'; @@ -374,7 +376,7 @@ async function testSm4Cipher() { console.info('test finish encrypt success'); } } - +// [End user_authentication_and_access_control_guide] async function main() { await testGenKeyForFingerprintAccessControl(); await testInitAndAuthFinger(); diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/napi_init.cpp index 8153f0a5121c38bf73092beacbcd653828cde7ca..e66ddc43e9e990ca0ad9272ad582c7298526fbcf 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/cpp/napi_init.cpp @@ -13,6 +13,7 @@ * 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" @@ -202,6 +203,9 @@ static napi_value EncDecKey(napi_env env, napi_callback_info info) return ret; } + +// [End encrypt_and_decrypt] + EXTERN_C_START static napi_value Init(napi_env env, napi_value exports) { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESCBCPKCS7.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESCBCPKCS7.ets index 73542193e2e83ce050b4245d8d8fd25417e012c1..38277bacb28316cb872ae90e34b62f1cb745738b 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESCBCPKCS7.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESCBCPKCS7.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start encrypt_and_decrypt_AESCBCPKCS7] /* * 以下以AES/CBC/PKCS7的Promise操作使用为例 */ @@ -222,6 +222,10 @@ async function deleteKey() { }) } + +// [End encrypt_and_decrypt_AESCBCPKCS7] + + @Entry @Component struct Index { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESGCMNoPadding.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESGCMNoPadding.ets index 733fea8a418d44f00d9bba79ff859ab0742d2f6c..dd8ba3875cef1ed440ce40b004da368ca968eab7 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESGCMNoPadding.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/AESGCMNoPadding.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start encrypt_and_decrypt_AESGCMNoPadding] /* * 以下以AES/GCM/NoPadding的Promise操作使用为例 */ @@ -233,6 +233,7 @@ async function deleteKey() { }) } +// [End encrypt_and_decrypt_AESGCMNoPadding] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBOAEPSHA256.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBOAEPSHA256.ets index d3b82510655d34a957affcdf329c745f7008553d..644000a15437a4dbaf6c33971b35c60a11a2e841 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBOAEPSHA256.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBOAEPSHA256.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start encrypt_and_decrypt_RSAECBOAEPSHA256] /* * 以下以RSA/ECB/OAEP/SHA256模式的Promise操作使用为例 */ @@ -221,6 +221,8 @@ async function deleteKey() { }) } + +// [End encrypt_and_decrypt_RSAECBOAEPSHA256] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBPKCS1_V1_5.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBPKCS1_V1_5.ets index 7f44648fceb793272e0d009b23f583b816e56d51..f071b9b8840c52e56c143fd92402725e609e0c84 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBPKCS1_V1_5.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/RSAECBPKCS1_V1_5.ets @@ -12,7 +12,7 @@ * 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操作使用为例 */ @@ -221,6 +221,9 @@ async function deleteKey() { }) } + + +// [End encrypt_and_decrypt_RSAECBPKCS1_V1_5] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/SM2.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/SM2.ets index 98a624ef39a0d82bbf05396d8dd7e7bfbc72e209..c4db56bcd4d7844f41c3267e9ae69f2fea7fed7e 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/SM2.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/EncryptionDecryption/entry/src/main/ets/pages/SM2.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start encrypt_and_decrypt_SM2] /* * 以下以SM2模式的Promise操作使用为例 */ @@ -209,6 +209,9 @@ async function deleteKey() { }) } + +// [End encrypt_and_decrypt_SM2] + @Entry @Component struct Index { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/napi_init.cpp index 781dc912304279fca5fa6c8ff4af2c1e99271da6..5e01b344f6d1607fe7bcfcf738763ae0ef8af1e6 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/cpp/napi_init.cpp @@ -12,7 +12,7 @@ * 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" @@ -111,7 +111,7 @@ static napi_value HmacKey(napi_env env, napi_callback_info info) napi_create_int32(env, ohResult.errorCode, &ret); return ret; } - +// [End hmac] EXTERN_C_START static napi_value Init(napi_env env, napi_value exports) { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/pages/HMAC.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/pages/HMAC.ets index 2382757540c0a7028dc581a0f7dbc15a81eafe09..925aa809b57ae5dbb1308aaf8eae15c9609699b3 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/pages/HMAC.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/HMAC/entry/src/main/ets/pages/HMAC.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start hmac_to] /* * 以下以HMAC密钥的Promise操作使用为例 */ @@ -118,7 +118,7 @@ async function hMACData() { throw (error as Error); }) } - +// [End hmac_to] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/napi_init.cpp index 0cfae37cb4c3cee38334695bc6efd9eb19b64f05..a7dc694bf6574f93266f62c088336383a7ee5c67 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/cpp/napi_init.cpp @@ -12,7 +12,7 @@ * 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" @@ -124,7 +124,7 @@ static napi_value DeriveKey(napi_env env, napi_callback_info info) 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) { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/HKDF.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/HKDF.ets index 5c8b2881e4d7253d31b2e7b700906ae93f6f8f4b..3fc903ac6d54db884a152e52022129c514ede578 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/HKDF.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/HKDF.ets @@ -13,6 +13,8 @@ * limitations under the License. */ + +// [Start the_key_is_derived_from_hkdf] /* * 以下以HKDF密钥的Promise操作使用为例 */ @@ -323,7 +325,7 @@ async function testDerive() { await publicFinishFunc(handle, finishOptions); await publicDeleteKeyFunc(srcKeyAlias, huksOptions); } - +// [End the_key_is_derived_from_hkdf] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/PBKDF2.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/PBKDF2.ets index e3e0ad78ff5c42f13d38a0432b597e06cce111e4..a79cab1f463e60d1442accd241c4c147e3a61ca4 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/PBKDF2.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyDerivation/entry/src/main/ets/pages/PBKDF2.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start the_key_is_derived_from_pbkdf2] /* * 以下以PBKDF2密钥的Promise操作使用为例 */ @@ -336,7 +336,7 @@ async function testDerive() { await publicFinishFunc(handle, finishOptions); await publicDeleteKeyFunc(srcKeyAlias, huksOptions); } - +// [End the_key_is_derived_from_pbkdf2] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/napi_init.cpp index 46554caae9513313f59ee579584015d78bc37ce6..fa6fb399255b212d96a7911c583794121a7fe906 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/cpp/napi_init.cpp @@ -12,7 +12,7 @@ * 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" @@ -241,6 +241,7 @@ static napi_value AgreeKey(napi_env env, napi_callback_info info) return ret; } +// [End key_agreement] EXTERN_C_START static napi_value Init(napi_env env, napi_value exports) { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/DH.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/DH.ets index 0732f58f99458e2a7ed8e7b86ca724ba7f8cb9b0..0b85ce3c4d9b138eecb281dd03e4644627a5a505 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/DH.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/DH.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start key_agreement_dh] /* *以下以 DH密钥的Promise操作使用为例 */ @@ -166,6 +166,8 @@ export default async function huksDhAgreeTest() { await huks.deleteKeyItem(aliasBob, emptyOptions); } + +// [End key_agreement_dh] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/X25519.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/X25519.ets index c02c8185551ba7f6928058a9b431448d6e6a3673..8f9ea4b9b09aec37518937d32457a2ad9c6f1ebb 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/X25519.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/KeyExchange/entry/src/main/ets/pages/X25519.ets @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +// [Start key_agreement_X25519] /* *以下以X25519密钥的Promise操作使用为例 @@ -389,6 +390,8 @@ async function testAgree() { await publicDeleteKeyFunc(srcKeyAliasSecond, huksOptions); } + +// [End key_agreement_X25519] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/napi_init.cpp index 59a744a829c667481037b88374f2af43f19c12af..ebef8418ebefda2667d22383a1fd09a198d2f649 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/cpp/napi_init.cpp @@ -12,7 +12,7 @@ * 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" @@ -142,6 +142,8 @@ static napi_value SignVerifyKey(napi_env env, napi_callback_info info) return ret; } + +// [End signature_verification_supported_algorithms] EXTERN_C_START static napi_value Init(napi_env env, napi_value exports) { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/ECC256SHA256.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/ECC256SHA256.ets index dcc3acc992c346680bf2e50ea3370af7c4236aa3..8e7e018ab21ead2b2bb7fd43fb51e2c23072a1c6 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/ECC256SHA256.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/ECC256SHA256.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start key_algorithm_ECC256SHA256] /* * 密钥算法为ECC256、摘要算法为SHA256 */ @@ -178,6 +178,8 @@ async function testSignVerify() { await deleteEccKey(keyAlias); } + +// [End key_algorithm_ECC256SHA256] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PKCS1_V1_5.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PKCS1_V1_5.ets index f0de12b0e575000da5e1e7cac5ec60af7f69bf07..8d9bd5897874fcb3988ba9672cb480670efda5db 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PKCS1_V1_5.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PKCS1_V1_5.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start key_algorithm_RSASHA256PKCS1_V1_5] /* * 密钥算法为RSA,摘要算法为SHA256,填充模式为PKCS1_V1_5 */ @@ -180,6 +181,9 @@ export async function testSignVerify() { await deleteRsaKey(keyAlias); } + + +// [End key_algorithm_RSASHA256PKCS1_V1_5] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PSS.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PSS.ets index 9aa3789686259015d97c754aaa16fbca5e404313..1f9a89692ca0329aec252454a6649e1f4c48b4dc 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PSS.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/RSASHA256PSS.ets @@ -12,7 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// +// [Start key_algorithm_RSASHA256PSS] /* * 密钥算法为RSA,摘要算法为SHA256,填充模式为PSS */ @@ -188,6 +189,8 @@ export async function testSignVerify() { await deleteRsaKey(keyAlias); } + +// [End key_algorithm_RSASHA256PSS] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/SM2SM3.ets b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/SM2SM3.ets index d8d926059142894deaff188cc096a3d51ed7d92a..575845c335c0cf2d39793a1b7f860c3a8bfc62db 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/SM2SM3.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/KeyUsage/SigningVerification/entry/src/main/ets/pages/SM2SM3.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// [Start key_algorithm_SM2SM3] /* * 密钥算法为SM2、摘要算法为SM3 */ @@ -181,6 +181,8 @@ export async function testSignVerify() { await deleteSm2Key(keyAlias); } + +// [End key_algorithm_SM2SM3] @Entry @Component struct Index { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/napi_init.cpp index 81b1ce5a0fd6cb37ac6566ba52e6d52330bb560d..a1d73761d5f955c7be413f0554f528126f8376e0 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/cpp/napi_init.cpp @@ -12,12 +12,12 @@ * 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) @@ -62,7 +62,7 @@ static OH_Huks_Result GenerateKeyHelper(const char *alias) OH_Huks_FreeParamSet(&testGenerateKeyParamSet); return ohResult; } - +// [EndExclude query_whether_the_key_exists] static napi_value IsKeyExist(napi_env env, napi_callback_info info) { /* 1.获取密钥别名 */ @@ -88,7 +88,7 @@ static napi_value IsKeyExist(napi_env env, napi_callback_info info) 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) { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/pages/CheckKeyExists.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/pages/CheckKeyExists.ets index b3dcfc0d85bedbe95d4bebe9302ab9a32fddac6f..485547b725cd9d35b0d318c780f6b601ca59e467 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/pages/CheckKeyExists.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/CheckKeyExists/entry/src/main/ets/pages/CheckKeyExists.ets @@ -13,6 +13,8 @@ * limitations under the License. */ + +// [Start querying_the_existence_of_a_key] import { huks } from '@kit.UniversalKeystoreKit'; /* 1.确定密钥别名 */ @@ -22,7 +24,7 @@ let isKeyExist: Boolean; let huksOptions: huks.HuksOptions = { properties: [] } - +// [StartExclude querying_the_existence_of_a_key] /* 3.初始化密钥属性集 */ let generateProperties: huks.HuksParam[] = [ { @@ -84,6 +86,7 @@ async function testGenKey(): Promise { } function check(): string { +// [EndExclude querying_the_existence_of_a_key] try { /* 1.生成密钥 */ testGenKey(); @@ -103,6 +106,7 @@ function check(): string { console.error(`callback: hasKeyItem input arg invalid, ` + JSON.stringify(error)); return 'Failed'; } +// [End querying_the_existence_of_a_key] } @Entry diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/napi_init.cpp index f12c2e5c701eab8484c5656c93f283c9b87102ab..8250ad5b27f006079f1c0a6d9d69e7178590997b 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/cpp/napi_init.cpp @@ -12,12 +12,12 @@ * 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) { @@ -61,12 +61,13 @@ static OH_Huks_Result GenerateKeyHelper(const char *alias) 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) { @@ -74,6 +75,7 @@ static napi_value GetKeyParamSet(napi_env env, napi_callback_info info) napi_create_int32(env, genResult.errorCode, &ret); return ret; } + // [EndExclude obtain_the_key_attributes] const size_t paramSetSize = 512; /* 构造参数:为参数集申请内存 * 请业务按实际情况评估大小进行申请 @@ -102,7 +104,7 @@ static napi_value GetKeyParamSet(napi_env env, napi_callback_info info) 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) { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/pages/GetKeyAttributes.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/pages/GetKeyAttributes.ets index 1ef4abdbbc87c62218f7793ab04a84e7199e72dd..9e8c6836c09e51fc4bfc87f10a26f925ea42d7ed 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/pages/GetKeyAttributes.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/GetKeyAttributes/entry/src/main/ets/pages/GetKeyAttributes.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start obtaining_key_attribute] import { huks } from '@kit.UniversalKeystoreKit'; /* 1. 设置密钥别名 */ @@ -21,7 +22,7 @@ let keyAlias = 'keyAlias'; let emptyOptions: huks.HuksOptions = { properties: [] }; - +// [StartExclude obtaining_key_attribute] let properties1: huks.HuksParam[] = [ { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, @@ -82,6 +83,7 @@ async function testGenKey(): Promise { } function check(): string { +// [EndExclude obtaining_key_attribute] try { /* 1. 生成密钥 */ testGenKey(); @@ -98,6 +100,7 @@ function check(): string { console.error(`callback: getKeyItemProperties input arg invalid, ${JSON.stringify(error)}`); return 'Failed'; } +// [End obtaining_key_attribute] } @Entry diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/napi_init.cpp b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/napi_init.cpp index 33abf36c07a3e2a4553f7e3771027c69162f76a7..7ba85656d95a72f8e1d62b57fb4165aa8065631d 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/napi_init.cpp +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/cpp/napi_init.cpp @@ -13,11 +13,12 @@ * 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) @@ -62,12 +63,13 @@ static OH_Huks_Result GenerateKeyHelper(const char *alias) 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) { @@ -75,6 +77,7 @@ static napi_value ExportKey(napi_env env, napi_callback_info info) 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) { @@ -93,7 +96,7 @@ static napi_value ExportKey(napi_env env, napi_callback_info info) 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) { diff --git a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/pages/KeyExport.ets b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/pages/KeyExport.ets index 8d01c74c1e9978e65e0d9fa9efd736f70d111074..d5ddb66593094ea82017ca5c0f55549b83859fd9 100755 --- a/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/pages/KeyExport.ets +++ b/code/DocsSample/Security/UniversalKeystoreKit/OtherOperations/KeyExport/entry/src/main/ets/pages/KeyExport.ets @@ -13,7 +13,8 @@ * limitations under the License. */ -import { huks } from '@kit.UniversalKeystoreKit'; +// [Start fetch_persistent_security_public_keys] + /* 1. 设置密钥别名 */ let keyAlias = 'keyAlias'; @@ -21,7 +22,8 @@ let keyAlias = 'keyAlias'; let emptyOptions: huks.HuksOptions = { properties: [] }; - +// [StartExclude fetch_persistent_security_public_keys] +import { huks } from '@kit.UniversalKeystoreKit'; let properties1: huks.HuksParam[] = [ { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, @@ -82,9 +84,12 @@ async function testGenKey(): Promise { } 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) { @@ -98,6 +103,7 @@ function check(): string { console.error(`callback: exportKeyItem input arg invalid, ${JSON.stringify(error)}`); return 'Failed'; } +// [End fetch_persistent_security_public_keys] } @Entry