1# Querying Key Aliases (C/C++)
2
3
4This topic walks you through on how to query key aliases.
5>**NOTE**<br>
6> The mini-system devices do not support query of key aliases.
7
8## Add the dynamic library in the CMake script.
9```txt
10   target_link_libraries(entry PUBLIC libhuks_ndk.z.so)
11```
12
13## How to Develop
14
151. Initialize the key property set.
16   
17   Set the tag for querying the key aliases. The tag can only be [HUKS_TAG_AUTH_STORAGE_LEVEL](../../reference/apis-universal-keystore-kit/_huks_type_api.md#oh_huks_authstoragelevel).
18   
192. Use [OH_Huks_ListAliases](../../reference/apis-universal-keystore-kit/_huks_key_api.md#oh_huks_listaliases) to query key aliases.
20
21 ```c++
22/* Query key aliases. */
23#include "huks/native_huks_api.h"
24#include "huks/native_huks_param.h"
25#include <string.h>
26OH_Huks_Result InitParamSet(
27    struct OH_Huks_ParamSet **paramSet,
28    const struct OH_Huks_Param *params,
29    uint32_t paramCount)
30{
31    OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet);
32    if (ret.errorCode != OH_HUKS_SUCCESS) {
33        return ret;
34    }
35    ret = OH_Huks_AddParams(*paramSet, params, paramCount);
36    if (ret.errorCode != OH_HUKS_SUCCESS) {
37        OH_Huks_FreeParamSet(paramSet);
38        return ret;
39    }
40    ret = OH_Huks_BuildParamSet(paramSet);
41    if (ret.errorCode != OH_HUKS_SUCCESS) {
42        OH_Huks_FreeParamSet(paramSet);
43        return ret;
44    }
45    return ret;
46}
47struct OH_Huks_Param g_testQueryParam[] = {
48    {
49        .tag = OH_HUKS_TAG_AUTH_STORAGE_LEVEL,
50        .uint32Param = OH_HUKS_AUTH_STORAGE_LEVEL_DE
51    }, 
52};
53static napi_value ListAliases(napi_env env, napi_callback_info info)
54{
55    struct OH_Huks_ParamSet *testQueryParamSet = nullptr;
56    struct OH_Huks_KeyAliasSet *outData = nullptr;
57    struct OH_Huks_Result ohResult;
58    do {
59        /* 1. Initialize the key property set. */
60        ohResult = InitParamSet(&testQueryParamSet, g_testQueryParam,
61            sizeof(g_testQueryParam) / sizeof(OH_Huks_Param));
62        if (ohResult.errorCode != OH_HUKS_SUCCESS) {
63            break;
64        }
65        /* 2. Query key aliases. */
66        ohResult = OH_Huks_ListAliases(testQueryParamSet, &outData);
67    } while (0);
68
69    OH_Huks_FreeParamSet(&testQueryParamSet);
70    OH_Huks_FreeKeyAliasSet(outData);
71    napi_value ret;
72    napi_create_int32(env, ohResult.errorCode, &ret);
73    return ret;
74}
75 ```
76