AssetApi

Overview

Provides functions for adding, removing, updating, and querying sensitive data less than 1024 bytes in size, including passwords, app tokens, and other critical data (such as bank card numbers).

System capability: SystemCapability.Security.Asset

Since: 11

Summary

Files

Name Description
asset_api.h Defines the functions for accessing assets.

Functions

Name Description
int32_t OH_Asset_Add (const Asset_Attr *attributes, uint32_t attrCnt) Adds an asset.
int32_t OH_Asset_Remove (const Asset_Attr *query, uint32_t queryCnt) Removes one or more assets.
int32_t OH_Asset_Update (const Asset_Attr *query, uint32_t queryCnt, const Asset_Attr *attributesToUpdate, uint32_t updateCnt) Updates an asset.
int32_t OH_Asset_PreQuery (const Asset_Attr *query, uint32_t queryCnt, Asset_Blob *challenge) Performs preprocessing for the asset query. This function is used when user authentication is required for the access to the asset.
int32_t OH_Asset_Query (const Asset_Attr *query, uint32_t queryCnt, Asset_ResultSet *resultSet) Queries one or more assets.
int32_t OH_Asset_PostQuery (const Asset_Attr *handle, uint32_t handleCnt) Performs postprocessing for the asset query. This function is used when user authentication is required for the access to the asset.
Asset_Attr * OH_Asset_ParseAttr (const Asset_Result *result, Asset_Tag tag) Parses the query result and obtains the specified attribute.
void OH_Asset_FreeBlob (Asset_Blob *blob) Releases the memory occupied by the challenge value.
void OH_Asset_FreeResultSet (Asset_ResultSet *resultSet) Releases the memory occupied by the query result.

Function Description

OH_Asset_Add()

int32_t OH_Asset_Add (const Asset_Attr * attributes, uint32_t attrCnt )

Description Adds an asset.

Since: 11

Parameters

Name Description
attributes Attributes of the asset to add
attrCnt Number of attributes of the asset to add.

Returns

Returns ASSET_SUCCESS if the operation is successful; returns an error code otherwise.

OH_Asset_FreeBlob()

void OH_Asset_FreeBlob (Asset_Blob * blob)

Description Releases the memory occupied by the challenge value.

Since: 11

Parameters

Name Description
blob Challenge value returned by OH_Asset_PreQuery.

OH_Asset_FreeResultSet()

void OH_Asset_FreeResultSet (Asset_ResultSet * resultSet)

Description Releases the memory occupied by the query result.

Since: 11

Parameters

Name Description
resultSet Query result returned by OH_Asset_Query.

OH_Asset_ParseAttr()

Asset_Attr* OH_Asset_ParseAttr (const Asset_Result * result, Asset_Tag tag )

Description Parses the query result and obtains the specified attribute.

Since: 11

Parameters

Name Description
result Query result returned by OH_Asset_Query.
tag Key of the attribute to obtain.

Returns

Returns Asset_Attr obtained if the operation is successful; returns NULL otherwise. The attribute does not need to be released by the service.

OH_Asset_PostQuery()

int32_t OH_Asset_PostQuery (const Asset_Attr * handle, uint32_t handleCnt )

Description Performs postprocessing for the asset query. This API is used when user authentication is required for the access to the asset.

Since: 11

Parameters

Name Description
handle Handle of the query operation, including the challenge value returned by OH_Asset_PreQuery.
handleCnt Number of elements in the handle attribute set.

Returns

Returns ASSET_SUCCESS if the operation is successful; returns an error code otherwise.

OH_Asset_PreQuery()

int32_t OH_Asset_PreQuery (const Asset_Attr * query, uint32_t queryCnt, Asset_Blob * challenge )

Description Performs preprocessing for the asset query. This API is used when user authentication is required for the access to the asset.

Since: 11

Parameters

Name Description
query Attributes of the asset to query.
queryCnt Number of attributes.
challenge Challenge value, which is used when OH_Asset_Query is called.

Returns

Returns ASSET_SUCCESS if the operation is successful; returns an error code otherwise.

OH_Asset_Query()

int32_t OH_Asset_Query (const Asset_Attr * query, uint32_t queryCnt, Asset_ResultSet * resultSet )

Description Queries one or more assets.

Since: 11

Parameters

Name Description
query Attributes of the asset to query.
queryCnt Number of attributes.
resultSet Array of query results.

Returns

Returns ASSET_SUCCESS if the operation is successful; returns an error code otherwise.

OH_Asset_Remove()

int32_t OH_Asset_Remove (const Asset_Attr * query, uint32_t queryCnt )

Description Removes one or more assets.

Since: 11

Parameters

Name Description
query Attributes of the asset to remove.
queryCnt Number of Attributes.

Returns

Returns ASSET_SUCCESS if the operation is successful; returns an error code otherwise.

OH_Asset_Update()

int32_t OH_Asset_Update (const Asset_Attr * query, uint32_t queryCnt, const Asset_Attr * attributesToUpdate, uint32_t updateCnt )

Description Updates an asset.

Since: 11

Parameters

Name Description
query Attributes of the asset to update.
queryCnt Number of attributes to update.
attributesToUpdate New attributes of the asset.
updateCnt Number of new attributes.

Returns

Returns ASSET_SUCCESS if the operation is successful; returns an error code otherwise.