Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.
HarmonyOS
Since version 6.1.1(24), the API for setting HDC authentication keys is available for security debugging on enterprise devices, enabling more robust device security.
This API sets HDC authentication keys for both upper and lower devices, ensuring that connections and debugging are permitted only when both parties belong to the same enterprise. This effectively prevents enterprise assets from being tampered with or disclosed.
For details about these APIs, please refer to the API Reference.
| API | Description |
|---|---|
| setHdcAuthenticationKey(devType: AuthenticateDeviceType, keyType: AuthenticateKeyType, key: Uint8Array): Promise<void> | Sets HDC authentication keys between the upper and lower devices using a promise. |
Generate a 3072-bit RSA key pair locally using OpenSSL.
Generate a private key using OpenSSL:
- openssl genpkey -algorithm RSA -out private_key_3072.pem -pkeyopt rsa_keygen_bits:3072
Generate a public key based on the private key:
- openssl rsa -in private_key_3072.pem -pubout -out public_key_3072.pem
Import the required modules.
- import { fileGuard } from '@kit.EnterpriseDataGuardKit';
Initialize the guard object of FileGuard and call the setHdcAuthenticationKey API to set the HDC authentication key between the upper and lower devices. The upper device must issue the private key, while the lower device issues the public key, enabling secure debugging of the lower device by the upper device.
- function testSetHdcAuthenticationKey() {
- let guard: fileGuard.FileGuard = new fileGuard.FileGuard();
- let devType: fileGuard.AuthenticateDeviceType = fileGuard.AuthenticateDeviceType.UPPER;
- let keyType: fileGuard.AuthenticateKeyType = fileGuard.AuthenticateKeyType.PUBLIC_KEY;
- // Convert the key into the Uint8Array type.
- let key: Uint8Array = new Uint8Array([0]);
-
- guard.setHdcAuthenticationKey(devType, keyType, key).then(() => {
- console.info(`Succeeded in setting the HDC authentication key.`);
- }).catch((error: BusinessError) => {
- console.error(`Failed to set the HDC authentication key. Code: ${error.code}, message: ${error.message}.`);
- })
- }
Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
Quick start
Helps you find desired resources with ease.