From b39a5066230a8f776f25f643daa829e1b47e3cc8 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Tue, 29 Apr 2025 17:07:31 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BA=E4=BE=8B=E4=BB=A3=E7=A0=81=E6=A0=87?= =?UTF-8?q?=E6=B3=A813?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangweiyuan --- .../AbilityLifecycleCallback.ets | 3 +- .../entry/src/main/ets/pages/Index.ets | 5 +- .../pages/AddIntTrackPreventByPassList.ets | 5 +- .../pages/ClearIntTrackPreventByPassList.ets | 3 +- .../CollectingAdsBlockingInformation.ets | 4 + .../ets/pages/DisAdsBlockSpecDomPages_one.ets | 6 +- .../ets/pages/DisAdsBlockSpecDomPages_two.ets | 6 +- .../main/ets/pages/EnableIntTrackPrevent.ets | 4 +- .../main/ets/pages/EnablingAdsBlocking.ets | 5 +- .../ets/pages/IsIntTrackPreventEnabled.ets | 2 + .../ets/pages/OnIntTrackPreventResult.ets | 4 +- .../pages/RemoveIntTrackPreventByPassList.ets | 3 +- .../main/ets/pages/OnInterceptRequest_one.ets | 3 +- .../main/ets/pages/OnInterceptRequest_two.ets | 2 + .../LoadLocalPageFileInSandboxPath_one.ets | 2 + .../LoadLocalPageFileInSandboxPath_two.ets | 3 +- .../ets/pages/LoadingHTMLRichTextData.ets | 3 +- .../src/main/ets/pages/LoadingLocalPages.ets | 5 +- .../src/main/ets/pages/LoadingWebPages.ets | 4 +- .../src/main/ets/pages/CalcAdjustSafeArea.ets | 3 +- .../main/ets/entryability/EntryAbility.ets | 11 +- .../entry/src/main/ets/pages/Index.ets | 3 + .../entry/src/main/ets/pages/common.ets | 4 +- .../main/ets/entry1ability/Entry1Ability.ets | 2 + .../entry1/src/main/ets/pages/Index.ets | 2 + .../entry1/src/main/ets/pages/common.ets | 3 +- .../entry1/src/main/ets/pages/index2.ets | 3 +- .../entry2/src/main/ets/pages/common.ets | 4 + .../entry2/src/main/module.json5 | 2 +- .../UseOfflineWebComp/oh-package-lock.json5 | 27 ++ .../entry/src/main/ets/pages/Index.ets | 3 +- .../main/ets/entry2ability/Entry2Ability.ets | 10 +- .../entry2/src/main/ets/pages/Index.ets | 3 +- .../entry/src/main/ets/pages/Await.ets | 4 +- .../entry/src/main/ets/pages/Promise.ets | 3 + .../entry/src/main/ets/pages/Sync.ets | 3 +- .../entry/src/main/ets/pages/Await.ets | 4 +- .../entry/src/main/ets/pages/Promise.ets | 4 +- .../entry/src/main/ets/pages/Sync.ets | 3 +- .../entry/src/main/ets/pages/DH/DHAsync.ets | 3 +- .../entry/src/main/ets/pages/DH/DHSync.ets | 4 +- .../src/main/ets/pages/ECDH/EDCHAsync.ets | 3 +- .../src/main/ets/pages/ECDH/EDCHSync.ets | 4 + .../src/main/ets/pages/X25519/X25519Async.ets | 4 +- .../src/main/ets/pages/X25519/X25519Sync.ets | 4 +- .../main/ets/pages/HMACSegmentation/Async.ets | 4 + .../main/ets/pages/HMACSegmentation/Sync.ets | 4 +- .../main/ets/pages/HMACSingleTime/Async.ets | 4 +- .../main/ets/pages/HMACSingleTime/Sync.ets | 4 +- .../main/cpp/types/project/segmentation.cpp | 6 +- .../src/main/cpp/types/project/singleTime.cpp | 6 +- .../pages/segmentation/SegmentationAsync.ets | 3 +- .../pages/segmentation/SegmentationSync.ets | 4 +- .../ets/pages/singleTime/SingleTimeAsync.ets | 4 +- .../ets/pages/singleTime/SingleTimeSync.ets | 4 +- .../entry/src/main/ets/pages/Index.ets | 3 + .../project/ecdsa_signature_verification.cpp | 3 +- .../project/sm2_signature_verification.cpp | 4 +- ...sa_signature_verification_asynchronous.ets | 3 + ...dsa_signature_verification_synchronous.ets | 4 +- ...m2_signature_verification_asynchronous.ets | 4 +- ...sm2_signature_verification_synchronous.ets | 4 +- .../entry/src/main/ets/pages/Index.ets | 5 + .../main/ets/pages/CreateGetCertCrlObject.ets | 5 + .../ets/pages/CreateParseVerifyCertObject.ets | 4 + .../CreateParseVerifyCertextensionObject.ets | 4 + .../ets/pages/CreateParseVerifyCrlObject.ets | 6 + .../ets/pages/CreateTrustanchorFromP12.ets | 4 + .../CreateVerifyCerchainvalidatorObject.ets | 5 + .../ets/pages/CreateVerifyCertchainObject.ets | 4 + .../ets/pages/CertManagerDialogGuidelines.ets | 4 +- .../main/ets/pages/CertManagerGuidelines.ets | 3 + .../entry/src/main/cpp/napi_init.cpp | 11 +- .../entry/src/main/ets/pages/KeyDeletion.ets | 7 +- .../entry/src/main/cpp/napi_init.cpp | 4 +- .../entry/src/main/ets/pages/Index.ets | 7 + .../entry/src/main/cpp/napi_init.cpp | 9 + .../src/main/ets/pages/ImportEncryptedKey.ets | 6 + .../entry/src/main/cpp/napi_init.cpp | 2 + .../entry/src/main/ets/pages/AES256.ets | 4 + .../entry/src/main/ets/pages/RSA2048.ets | 4 + .../entry/src/main/ets/pages/X25519.ets | 5 +- .../entry/src/main/cpp/napi_init.cpp | 4 +- .../src/main/ets/pages/AnonymousKeyProof.ets | 4 +- .../entry/src/main/cpp/napi_init.cpp | 312 +++++++++--------- .../main/ets/pages/NonAnonymousKeyProof.ets | 4 +- .../FineGrainedUserIdentityAuthentication.ets | 7 +- .../ets/pages/UserIdentityAuthentication.ets | 4 +- .../entry/src/main/cpp/napi_init.cpp | 4 + .../entry/src/main/ets/pages/AESCBCPKCS7.ets | 6 +- .../src/main/ets/pages/AESGCMNoPadding.ets | 3 +- .../src/main/ets/pages/RSAECBOAEPSHA256.ets | 4 +- .../src/main/ets/pages/RSAECBPKCS1_V1_5.ets | 5 +- .../entry/src/main/ets/pages/SM2.ets | 5 +- .../HMAC/entry/src/main/cpp/napi_init.cpp | 4 +- .../HMAC/entry/src/main/ets/pages/HMAC.ets | 4 +- .../entry/src/main/cpp/napi_init.cpp | 4 +- .../entry/src/main/ets/pages/HKDF.ets | 4 +- .../entry/src/main/ets/pages/PBKDF2.ets | 4 +- .../entry/src/main/cpp/napi_init.cpp | 3 +- .../entry/src/main/ets/pages/DH.ets | 4 +- .../entry/src/main/ets/pages/X25519.ets | 3 + .../entry/src/main/cpp/napi_init.cpp | 4 +- .../entry/src/main/ets/pages/ECC256SHA256.ets | 4 +- .../main/ets/pages/RSASHA256PKCS1_V1_5.ets | 4 + .../entry/src/main/ets/pages/RSASHA256PSS.ets | 5 +- .../entry/src/main/ets/pages/SM2SM3.ets | 4 +- .../entry/src/main/cpp/napi_init.cpp | 8 +- .../src/main/ets/pages/CheckKeyExists.ets | 6 +- .../entry/src/main/cpp/napi_init.cpp | 10 +- .../src/main/ets/pages/GetKeyAttributes.ets | 5 +- .../entry/src/main/cpp/napi_init.cpp | 9 +- .../entry/src/main/ets/pages/KeyExport.ets | 10 +- 113 files changed, 554 insertions(+), 273 deletions(-) create mode 100644 code/DocsSample/ArkWeb/UseOfflineWebComp/oh-package-lock.json5 mode change 100755 => 100644 code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/NonanonymousKeyProof/entry/src/main/cpp/napi_init.cpp 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 430cc48537..bac9c2a34b 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 170cc62808..5e904676c4 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 882c47fbaa..aa1655f7bb 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 cee0fd0d0c..fc8f4c0846 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 283ced2f34..92dcff572c 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 d903a58c48..e70fa2041e 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 fb11841153..fe925a82e9 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 2abfd30abb..e317299ae7 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 6f3479240c..8eb4a81e2d 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 cf899e8d3f..f35678435d 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 6312ba1634..86bb3887db 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 86a03f28a7..504ff4f33c 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 88739dc3db..99b4325373 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 4b3d0a5299..bd06563ae7 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 a95b79c366..2545aea0f8 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 c85ba6a2e2..7e78e47a05 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 826021cc5c..ed142efe47 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 aa7357bd6e..a09d901e5a 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 28abb21e03..bd01e1ff1c 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 f2e0e972c8..ddce0c96a4 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 c3a1c8a89f..e068627fdb 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 c20b0ca45f..05172de125 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 e22c3cd336..6c4e209e7d 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 552e7abe0b..844f1ef14f 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 9f0948d444..ef124adf16 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 999e9909b6..8aafa42d13 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 46b3ca95cb..61785eaeb4 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 82c5f1fb98..b424a64654 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 c795511fa6..d40d6d37db 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 0000000000..205c6cfd4d --- /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 d9f86c4892..b45e3d66fd 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 97f049833e..413af92ba3 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 ef722e663e..778738e070 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 827b06c68e..0f99919369 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 d4222fbff8..59080c5cb3 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 27285f67ce..87e344284c 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 043464ce92..4a23ae51e4 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 e41b03f51f..17b97190db 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 eec7a22fb2..f259312c81 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 ed556b1aaa..efd5f7a375 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 adec491b67..1dad296c72 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 8667db5eb4..5dc035ea5d 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 ee3f00e7e1..edf1a0f7d1 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 1be37d026c..a320edc5a2 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 93b2d229b7..953a34d8c2 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 9b7ab53adb..61b41b8f92 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 ea497d8f18..7fa0b1b7b4 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 a9f73fa472..b3f63e6512 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 52260466ac..45fe02cfc8 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 77528e2039..fe193cfc52 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 7e3e7d1af9..eafdeeb714 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 d5d7050287..a4efb4f678 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 cbb9e89b29..5e9b58c592 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 8c048faa38..c39fc8f1e3 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 f1841e3ee2..1f60f9e33a 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 56f37c9df1..7bdacbcc1c 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 2eac147f35..d0ae1503c7 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 425b5eddd2..c1e897b0de 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 f31a122cd3..6e103ba1f1 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 8c011ab922..8288f2ce24 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 ba4b7a569d..5f612bc7e6 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 62e7143510..3957b3ac72 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 b1d3fc7f39..c7eb3bcab5 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 c560f710ed..78139d9373 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 b782420c88..99b48021f1 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 395b725623..10ae5d5771 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 51ec07c776..e43c16bd9c 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 4cded23131..ba8d960ff9 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 6513b3b8c5..1b87d7c7f6 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 75ab34393e..9081b2d61e 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 dddba1b3a4..2043736855 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 09baa8cb56..39f6cc11db 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 6c17723633..3a5cdcb34a 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 27e5addb80..a5cc677a2f 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 fd8f89141b..a083b2faff 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 2ce4dd0d3e..0a421f42aa 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 8535a23a75..de42574229 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 4a550cec4c..3868b6dfe2 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 a1c3e6ff08..3043449a63 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 20718d09e1..05e997efba 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 e522e1cc29..c21dacea92 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 29794fbe2c..70a1720bfe 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 3be42f2799..70730d8b48 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 18a32ed196..5d1c616b4c 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 ed25c4cf2f..ca39403298 --- 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 ab44d65cc1..3509e335b4 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 0bc3920045..9c727153c0 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 a89e9303af..20d5968174 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 8153f0a512..e66ddc43e9 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 73542193e2..38277bacb2 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 733fea8a41..dd8ba3875c 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 d3b8251065..644000a154 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 7f44648fce..f071b9b884 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 98a624ef39..c4db56bcd4 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 781dc91230..5e01b344f6 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 2382757540..925aa809b5 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 0cfae37cb4..a7dc694bf6 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 5c8b2881e4..3fc903ac6d 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 e3e0ad78ff..a79cab1f46 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 46554caae9..fa6fb39925 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 0732f58f99..0b85ce3c4d 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 c02c818555..8f9ea4b9b0 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 59a744a829..ebef8418eb 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 dcc3acc992..8e7e018ab2 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 f0de12b0e5..8d9bd58978 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 9aa3789686..1f9a89692c 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 d8d9260591..575845c335 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 81b1ce5a0f..a1d73761d5 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 b3dcfc0d85..485547b725 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 f12c2e5c70..8250ad5b27 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 1ef4abdbbc..9e8c6836c0 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 33abf36c07..7ba85656d9 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 8d01c74c1e..d5ddb66593 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 -- Gitee