You can use the application attestation capability to verify requests from applications on your server, including whether the requests are from real applications and devices and whether the request content is tampered with.
To help you better understand the application scenarios of this feature and improve the access efficiency, the document is updated from Device Attestation to Application Attestation.
Application public/private key pair: an asymmetric key pair (including a public key and a private key), for example, an RSA or ECC key pair, for application request attestation.
Application public key ID: a unique ID generated for the application public key, which is used to identify your application server and query the public key.
Application ID: contains application identity information, such as the application package name and hash of the application signature key.
Key attestation certificate chain: a certificate chain issued by the Huawei server after verifying that the application public key is from a real device and a real application. The certificate chain contains the application public key and your application ID.
Your application can call Universal Keystore Kit APIs and complete corresponding verification on your server to verify the authenticity of application requests.

This document describes how to verify the authenticity of application requests on your application and application server.
Prerequisite: Create a key to establish a trusted credential.
The application calls the key generation API of Universal Keystore Kit to create a unique public/private key pair, which is stored in a hardware-based secure environment.
The application calls the key attestation API of Universal Keystore Kit to issue the key attestation certificate chain for the application public key and application ID.
The application server verifies the key attestation certificate chain and checks whether the application ID in the certificate chain is correct.
The application server stores the application public key in the key attestation certificate chain.
Service request authentication: Identify real requests through signature verification.
When processing key services (such as password-free payments and marketing activities), the application calls the signature API of Universal Keystore Kit to sign service requests using the application private key.
The application server uses the saved application public key to perform signature verification. If the verification is successful, the request is from a real device and a real application, and the content is not tampered with.
Starting from API version 26.0.0, the step of attesting key and application ID supports the offline key attestation API (anonAttestKeyItemOffline). This API features no service quota limitations while delivering identical functionality to the online counterpart (anonAttestKeyItem). It is highly recommended that your application prioritize adopting and integrating this offline API.
For applications that have integrated the online key attestation API, it is recommended that you switch to the offline key attestation API.
| Comparison Item | Offline Key Attestation API (Recommended) | Online Key Attestation API |
|---|---|---|
| Functions | Provides the capability of attesting the key and application ID. | Provides the capability of attesting the key and application ID. |
| Implementation | Uses the device's locally cached CA certificate to issue attestation. Network connection is required for updates only after the cached CA certificate expires (valid for 1 month). | Accesses the Huawei server for every request to issue attestation using the server's CA certificate. |
| Service Quota | Unlimited | 35 times/second/appliation |
This solution identifies non-authentic device scenarios, such as emulators, by verifying that the application public key originates from a genuine device and subsequently issuing a key attestation certificate chain.
The key attestation certificate chain contains application ID information such as the application package name, public key hash of the application signing certificate, and the application type (debug or release). The server verifies the information to determine whether the request is from a real application, effectively identifying non-real applications such as repackaged and spoofed applications.
The certificate chain also contains the application public key. The corresponding private key is stored in a hardware-based secure environment. You can use the private key to sign important service requests to identify attacks where application requests are tampered with or forged by packet capture.
This capability requires that the request comes from a real device. Therefore, it is not implemented on emulators. Specifically, when an application calls the key attestation API on an emulator, a simulated fixed certificate chain is returned, which cannot pass the root CA certificate verification by the Huawei server.
| API | Quota | Description |
|---|---|---|
| Key attestation API (online) | 35 times/second/appliation | By default, when an application calls the online key attestation API (anonAttestKeyItem/OH_Huks_AnonAttestKeyItem), the instantaneous traffic does not exceed 35 requests per second. If the actual number of calls exceeds the service quota, switch to the offline key attestation API. |
| Key attestation API (offline) | Unlimited | Unlimited |