diff --git a/en/application-dev/reference/apis-asset-store-kit/_asset___attr.md b/en/application-dev/reference/apis-asset-store-kit/_asset___attr.md new file mode 100644 index 0000000000000000000000000000000000000000..878df2fcd6b2067c8607975af0ce21e42a67fe14 --- /dev/null +++ b/en/application-dev/reference/apis-asset-store-kit/_asset___attr.md @@ -0,0 +1,45 @@ +# Asset_Attr + + +## Overview + +Defines an asset attribute, which consists of a tag and a value in the form of a key-value (KV) pair. + +**Since**: 11 + +**Related module**: [AssetType](_asset_type.md) + +**Header file**: [asset_type.h](asset__type_8h.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| uint32_t [tag](#tag) | Name of the asset attribute. The tag (the key in the KV pair) uniquely identifies an attribute. | +| [Asset_Value](union_asset___value.md) [value](#value) | Value of the asset attribute. | + + +## Member Variable Description + + +### tag + +``` +uint32_t Asset_Attr::tag +``` +**Description** +Defines the name of the asset attribute. + + +### value + +``` +Asset_Value Asset_Attr::value +``` +**Description** + +Defines the value of the asset attribute diff --git a/en/application-dev/reference/apis-asset-store-kit/_asset___blob.md b/en/application-dev/reference/apis-asset-store-kit/_asset___blob.md new file mode 100644 index 0000000000000000000000000000000000000000..56e57d103d02dade4ba6775a43655b2a9537db73 --- /dev/null +++ b/en/application-dev/reference/apis-asset-store-kit/_asset___blob.md @@ -0,0 +1,46 @@ +# Asset_Blob + + +## Overview + +Defines a binary array, that is, an array of bytes with variable length. + +**Since**: 11 + +**Related module**: [AssetType](_asset_type.md) + +**Header file**: [asset_type.h](asset__type_8h.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| uint32_t [size](#size) | Size of the byte array. | +| uint8_t \* [data](#data) | Pointer to the byte array. | + + +## Member Variable Description + + +### data + +``` +uint8_t* Asset_Blob::data +``` +**Description** +Defines the pointer to the byte array. + + +### size + +``` +uint32_t Asset_Blob::size +``` +**Description** + +Defines the size of the byte array. + diff --git a/en/application-dev/reference/apis-asset-store-kit/_asset___result.md b/en/application-dev/reference/apis-asset-store-kit/_asset___result.md new file mode 100644 index 0000000000000000000000000000000000000000..2d240a55046514917ea482c75048e841c627e343 --- /dev/null +++ b/en/application-dev/reference/apis-asset-store-kit/_asset___result.md @@ -0,0 +1,44 @@ +# Asset_Result + + +## Overview + +Defines the query result of an asset. + +**Since**: 11 + +**Related module**: [AssetType](_asset_type.md) + +**Header file**: [asset_type.h](asset__type_8h.md) + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| uint32_t [count](#count) | Number of asset attributes in the query result. | +| [Asset_Attr](_asset___attr.md) \* [attrs](#attrs) | Pointer to the array of the asset attributes. | + + +## Member Variable Description + + +### attrs + +``` +Asset_Attr* Asset_Result::attrs +``` +**Description** +Indicates the pointer to the array of the asset attributes. + + +### count + +``` +uint32_t Asset_Result::count +``` +**Description** + +Indicates the number of asset attributes in the query result. diff --git a/en/application-dev/reference/apis-asset-store-kit/_asset___result_set.md b/en/application-dev/reference/apis-asset-store-kit/_asset___result_set.md new file mode 100644 index 0000000000000000000000000000000000000000..c0451896435595f6385cfb4ba174beb8370ee62a --- /dev/null +++ b/en/application-dev/reference/apis-asset-store-kit/_asset___result_set.md @@ -0,0 +1,45 @@ +# Asset_ResultSet + + +## Overview + +Defines the query result of multiple assets. + +**Since**: 11 + +**Related module**: [AssetType](_asset_type.md) + +**Header file**: [asset_type.h](asset__type_8h.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| uint32_t [count](#count) | Number of assets in the query result. | +| [Asset_Result](_asset___result.md) \* [results](#results) | Pointer to the array of assets. | + + +## Member Variable Description + + +### count + +``` +uint32_t Asset_ResultSet::count +``` +**Description** +Indicates the number of assets in the query result. + + +### results + +``` +Asset_Result* Asset_ResultSet::results +``` +**Description** + +Indicates the pointer to the array of assets. diff --git a/en/application-dev/reference/apis-asset-store-kit/_asset_api.md b/en/application-dev/reference/apis-asset-store-kit/_asset_api.md new file mode 100644 index 0000000000000000000000000000000000000000..154ec2eefd9fe99916813f53ddea7a322bc82f82 --- /dev/null +++ b/en/application-dev/reference/apis-asset-store-kit/_asset_api.md @@ -0,0 +1,388 @@ +# 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](asset__api_8h.md) | Defines the functions for accessing assets. | + + +### Functions + +| Name| Description| +| -------- | -------- | +| int32_t [OH_Asset_Add](#oh_asset_add) (const [Asset_Attr](_asset___attr.md) \*attributes, uint32_t attrCnt) | Adds an asset.| +| int32_t [OH_Asset_Remove](#oh_asset_remove) (const [Asset_Attr](_asset___attr.md) \*query, uint32_t queryCnt) | Removes one or more assets. | +| int32_t [OH_Asset_Update](#oh_asset_update) (const [Asset_Attr](_asset___attr.md) \*query, uint32_t queryCnt, const [Asset_Attr](_asset___attr.md) \*attributesToUpdate, uint32_t updateCnt) | Updates an asset. | +| int32_t [OH_Asset_PreQuery](#oh_asset_prequery) (const [Asset_Attr](_asset___attr.md) \*query, uint32_t queryCnt, [Asset_Blob](_asset___blob.md) \*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](#oh_asset_query) (const [Asset_Attr](_asset___attr.md) \*query, uint32_t queryCnt, [Asset_ResultSet](_asset___result_set.md) \*resultSet) | Queries one or more assets. | +| int32_t [OH_Asset_PostQuery](#oh_asset_postquery) (const [Asset_Attr](_asset___attr.md) \*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](_asset___attr.md) \* [OH_Asset_ParseAttr](#oh_asset_parseattr) (const [Asset_Result](_asset___result.md) \*result, [Asset_Tag](_asset_type.md#asset_tag) tag) | Parses the query result and obtains the specified attribute. | +| void [OH_Asset_FreeBlob](#oh_asset_freeblob) ([Asset_Blob](_asset___blob.md) \*blob) | Releases the memory occupied by the challenge value. | +| void [OH_Asset_FreeResultSet](#oh_asset_freeresultset) ([Asset_ResultSet](_asset___result_set.md) \*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. + +To set [ASSET_TAG_IS_PERSISTENT](_asset_type.md#asset_tag), the application must have the ohos.permission.STORE_PERSISTENT_DATA permission. + +**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](_asset_type.md#asset_resultcode) if the operation is successful; returns an error code otherwise. + +0 - The operation is successful. + +201 - The caller does not have the required permission. + +401 - The parameter is invalid. + +24000001 - The asset store service is unavailable. + +24000003 - The asset already exists. + +24000005 - The lock screen status does not match. + +24000006 - The system memory is insufficient. + +24000007 - The asset is corrupted. + +24000008 - The database operation failed. + +24000009 - The cryptographic operation failed. + +24000010 - The IPC failed. + +24000011 - The Bundle Manager service is abnormal. + +24000012 - The Account service is abnormal. + +24000013 - The Access Token service is abnormal. + +24000014 - The file operation failed. + +24000015 - Failed to obtain the system time. + +### 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](_asset_type.md#asset_resultcode) if the operation is successful; returns an error code otherwise. + +0 - The operation is successful. + +401 - The parameter is invalid. + +24000001 - The asset store service is unavailable. + +24000006 - The system memory is insufficient. + +24000010 - The IPC failed. + +24000011 - The Bundle Manager service is abnormal. + +24000012 - The Account service is abnormal. + +24000013 - The Access Token service is abnormal. + +### 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](_asset_type.md#asset_resultcode) if the operation is successful; returns an error code otherwise. + +0 - The operation is successful. + +401 - The parameter is invalid. + +24000001 - The asset store service is unavailable. + +24000002 - The asset is not found. + +24000005 - The lock screen status does not match. + +24000006 - The system memory is insufficient. + +24000007 - The asset is corrupted. + +24000008 - The database operation failed. + +24000009 - The cryptographic operation failed. + +24000010 - The IPC failed. + +24000011 - The Bundle Manager service is abnormal. + +24000012 - The Account service is abnormal. + +24000013 - The Access Token service is abnormal. + +24000016 - The number of cached assets exceeds the limit. + +24000017 - The function is not supported. + +### 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](_asset_type.md#asset_resultcode) if the operation is successful; returns an error code otherwise. + +0 - The operation is successful. + +401 - The parameter is invalid. + +24000001 - The asset store service is unavailable. + +24000002 - The asset is not found. + +24000004 - The access to the asset is denied. + +24000005 - The lock screen status does not match. + +24000006 - The system memory is insufficient. + +24000007 - The asset is corrupted. + +24000008 - The database operation failed. + +24000009 - The cryptographic operation failed. + +24000010 - The IPC failed. + +24000011 - The Bundle Manager service is abnormal. + +24000012 - The Account service is abnormal. + +24000013 - The Access Token service is abnormal. + +24000017 - The function is not supported. + +### 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](_asset_type.md#asset_resultcode) if the operation is successful; returns an error code otherwise. + +0 - The operation is successful. + +401 - The parameter is invalid. + +24000001 - The asset store service is unavailable. + +24000002 - The asset is not found. + +24000006 - The system memory is insufficient. + +24000007 - The asset is corrupted. + +24000008 - The database operation failed. + +24000010 - The IPC failed. + +24000011 - The Bundle Manager service is abnormal. + +24000012 - The Account service is abnormal. + +24000013 - The Access Token service is abnormal. + +24000015 - Failed to obtain the system time. + +### 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](_asset_type.md#asset_resultcode) if the operation is successful; returns an error code otherwise. + +0 - The operation is successful. + +401 - The parameter is invalid. + +24000001 - The asset store service is unavailable. + +24000002 - The asset is not found. + +24000005 - The lock screen status does not match. + +24000006 - The system memory is insufficient. + +24000007 - The asset is corrupted. + +24000008 - The database operation failed. + +24000009 - The cryptographic operation failed. + +24000010 - The IPC failed. + +24000011 - The Bundle Manager service is abnormal. + +24000012 - The Account service is abnormal. + +24000013 - The Access Token service is abnormal. + +24000015 - Failed to obtain the system time. diff --git a/en/application-dev/reference/apis-asset-store-kit/_asset_type.md b/en/application-dev/reference/apis-asset-store-kit/_asset_type.md new file mode 100644 index 0000000000000000000000000000000000000000..579de226d92f4e822812b4868b4709386682ae04 --- /dev/null +++ b/en/application-dev/reference/apis-asset-store-kit/_asset_type.md @@ -0,0 +1,285 @@ +# AssetType + + +## Overview + +Defines the enums, structs, and error codes used in the asset store service. + +**System capability**: SystemCapability.Security.Asset + +**Since**: 11 + + +## Summary + + +### Files + +| Name| Description| +| -------- | -------- | +| [asset_type.h](asset__type_8h.md) | Defines the enums, structs, and error codes used in the asset store service.| + + +### Structs + +| Name| Description| +| -------- | -------- | +| struct [Asset_Blob](_asset___blob.md) | Defines a binary array, that is, an array of bytes with variable length.| +| union [Asset_Value](union_asset___value.md) | Represents the value of an asset attribute.| +| struct [Asset_Attr](_asset___attr.md) | Represents an asset attribute in the form of a key-value (KV) pair.| +| struct [Asset_Result](_asset___result.md) | Represents the query result of an asset.| +| struct [Asset_ResultSet](_asset___result_set.md) | Represents the query result of multiple assets.| + + +### Macros + +| Name| Description| +| -------- | -------- | +| [ASSET_TAG_TYPE_MASK](#asset_tag_type_mask) (0xF << 28) | Defines the mask used to obtain the key type of an asset attribute.| + + +### Enums + +| Name| Description| +| -------- | -------- | +| [Asset_TagType](#asset_tagtype) {
ASSET_TYPE_BOOL = 0x1 << 28,
ASSET_TYPE_NUMBER = 0x2 << 28,
ASSET_TYPE_BYTES = 0x3 << 28 } | Enumerates the types of the keys of asset attributes.| +| [Asset_Tag](#asset_tag) {
ASSET_TAG_SECRET = ASSET_TYPE_BYTES \| 0x01,
ASSET_TAG_ALIAS = ASSET_TYPE_BYTES \| 0x02,
ASSET_TAG_ACCESSIBILITY = ASSET_TYPE_NUMBER \| 0x03,
ASSET_TAG_REQUIRE_PASSWORD_SET = ASSET_TYPE_BOOL \| 0x04,
ASSET_TAG_AUTH_TYPE = ASSET_TYPE_NUMBER \| 0x05,
ASSET_TAG_AUTH_VALIDITY_PERIOD = ASSET_TYPE_NUMBER \| 0x06,
ASSET_TAG_AUTH_CHALLENGE = ASSET_TYPE_BYTES \| 0x07,
ASSET_TAG_AUTH_TOKEN = ASSET_TYPE_BYTES \| 0x08,
ASSET_TAG_SYNC_TYPE = ASSET_TYPE_NUMBER \| 0x10,
ASSET_TAG_IS_PERSISTENT = ASSET_TYPE_BOOL \| 0x11,
ASSET_TAG_DATA_LABEL_CRITICAL_1 = ASSET_TYPE_BYTES \| 0x20,
ASSET_TAG_DATA_LABEL_CRITICAL_2 = ASSET_TYPE_BYTES \| 0x21,
ASSET_TAG_DATA_LABEL_CRITICAL_3 = ASSET_TYPE_BYTES \| 0x22,
ASSET_TAG_DATA_LABEL_CRITICAL_4 = ASSET_TYPE_BYTES \| 0x23,
ASSET_TAG_DATA_LABEL_NORMAL_1 = ASSET_TYPE_BYTES \| 0x30,
ASSET_TAG_DATA_LABEL_NORMAL_2 = ASSET_TYPE_BYTES \| 0x31,
ASSET_TAG_DATA_LABEL_NORMAL_3 = ASSET_TYPE_BYTES \| 0x32,
ASSET_TAG_DATA_LABEL_NORMAL_4 = ASSET_TYPE_BYTES \| 0x33,
ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_112+ = ASSET_TYPE_BYTES \| 0x34,
ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_212+ = ASSET_TYPE_BYTES \| 0x35,
ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_312+ = ASSET_TYPE_BYTES \| 0x36,
ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_412+ = ASSET_TYPE_BYTES \| 0x37,
ASSET_TAG_RETURN_TYPE = ASSET_TYPE_NUMBER \| 0x40,
ASSET_TAG_RETURN_LIMIT = ASSET_TYPE_NUMBER \| 0x41,
ASSET_TAG_RETURN_OFFSET = ASSET_TYPE_NUMBER \| 0x42,
ASSET_TAG_RETURN_ORDERED_BY = ASSET_TYPE_NUMBER \| 0x43,
ASSET_TAG_CONFLICT_RESOLUTION = ASSET_TYPE_NUMBER \| 0x44,
ASSET_TAG_UPDATE_TIME12+ = ASSET_TYPE_BYTES \| 0x45,
ASSET_TAG_OPERATION_TYPE12+ = ASSET_TYPE_NUMBER \| 0x46,
ASSET_TAG_REQUIRE_ATTR_ENCRYPTED14+ = ASSET_TYPE_BOOL \| 0x47,
ASSET_TAG_GROUP_ID18+ = ASSET_TYPE_BYTES \| 0x48,
} | Enumerates the keys of asset attributes.| +| [Asset_ResultCode](#asset_resultcode) {
ASSET_SUCCESS = 0,
ASSET_PERMISSION_DENIED = 201,
ASSET_INVALID_ARGUMENT = 401,
ASSET_SERVICE_UNAVAILABLE = 24000001,
ASSET_NOT_FOUND = 24000002,
ASSET_DUPLICATED = 24000003,
ASSET_ACCESS_DENIED = 24000004,
ASSET_STATUS_MISMATCH = 24000005,
ASSET_OUT_OF_MEMORY = 24000006,
ASSET_DATA_CORRUPTED = 24000007,
ASSET_DATABASE_ERROR = 24000008,
ASSET_CRYPTO_ERROR = 24000009,
ASSET_IPC_ERROR = 24000010,
ASSET_BMS_ERROR = 24000011,
ASSET_ACCOUNT_ERROR = 24000012,
ASSET_ACCESS_TOKEN_ERROR = 24000013,
ASSET_FILE_OPERATION_ERROR = 24000014,
ASSET_GET_SYSTEM_TIME_ERROR = 24000015,
ASSET_LIMIT_EXCEEDED = 24000016,
ASSET_UNSUPPORTED = 24000017
} | Enumerates the result codes returned by ASSET functions.| +| [Asset_Accessibility](#asset_accessibility) {
ASSET_ACCESSIBILITY_DEVICE_POWERED_ON = 0,
ASSET_ACCESSIBILITY_DEVICE_FIRST_UNLOCKED = 1,
ASSET_ACCESSIBILITY_DEVICE_UNLOCKED = 2
} | Enumerates the types of access control based on the lock screen status.| +| [Asset_AuthType](#asset_authtype) { ASSET_AUTH_TYPE_NONE = 0x00,
ASSET_AUTH_TYPE_ANY = 0xFF } | Enumerates the user authentication types supported by assets.| +| [Asset_SyncType](#asset_synctype) {
ASSET_SYNC_TYPE_NEVER = 0,
ASSET_SYNC_TYPE_THIS_DEVICE = 1 << 0,
ASSET_SYNC_TYPE_TRUSTED_DEVICE = 1 << 1,
ASSET_SYNC_TYPE_TRUSTED_ACCOUNT12+ = 1 << 2
} | Enumerates the types of sync supported by assets.| +| [Asset_ConflictResolution](#asset_conflictresolution) {
ASSET_CONFLICT_OVERWRITE = 0,
ASSET_CONFLICT_THROW_ERROR = 1
} | Enumerates the policies for resolving the conflict (for example, a duplicate alias).| +| [Asset_ReturnType](#asset_returntype) {
ASSET_RETURN_ALL = 0,
ASSET_RETURN_ATTRIBUTES = 1
} | Enumerates the types of the asset query result to return.| +| [Asset_OperationType](#asset_operationtype) {
ASSET_NEED_SYNC = 0,
ASSET_NEED_LOGOUT = 1
} | Enumerates the additional asset operation types.| + + +## Macro Description + + +### ASSET_TAG_TYPE_MASK + +``` +#define ASSET_TAG_TYPE_MASK (0xF << 28) +``` + +**Description** + +Defines the mask used to obtain the key type of an asset attribute. + +**Since**: 11 + + +## Enum Description + + +### Asset_Accessibility + +``` +enum Asset_Accessibility +``` + +**Description** + +Enumerates the types of access control based on the lock screen status. + +**Since**: 11 + +| Value| Description| +| -------- | -------- | +| ASSET_ACCESSIBILITY_DEVICE_POWERED_ON | The asset can be accessed after the device is powered on.| +| ASSET_ACCESSIBILITY_DEVICE_FIRST_UNLOCKED | The asset can be accessed only after the device is unlocked for the first time.| +| ASSET_ACCESSIBILITY_DEVICE_UNLOCKED | The asset can be accessed only after the device is unlocked.| + + +### Asset_AuthType + +``` +enum Asset_AuthType +``` + +**Description** + +Enumerates the user authentication types supported by assets. + +**Since**: 11 + +| Value| Description| +| -------- | -------- | +| ASSET_AUTH_TYPE_NONE | No user authentication is required before the asset is accessed.| +| ASSET_AUTH_TYPE_ANY | The asset can be accessed if any user authentication (such as PIN, facial, or fingerprint authentication) is successful.| + + +### Asset_ConflictResolution + +``` +enum Asset_ConflictResolution +``` + +**Description** + +Enumerates the policies for resolving the conflict (for example, a duplicate alias). + +**Since**: 11 + +| Value| Description| +| -------- | -------- | +| ASSET_CONFLICT_OVERWRITE | Overwrite the original asset.| +| ASSET_CONFLICT_THROW_ERROR | Throw an exception for the service to perform subsequent processing.| + + +### Asset_ResultCode + +``` +enum Asset_ResultCode +``` + +**Description** + +Enumerates the result codes returned by ASSET functions. + +**Since**: 11 + +| Value| Description| +| -------- | -------- | +| ASSET_SUCCESS | The operation is successful.| +| ASSET_PERMISSION_DENIED | The caller does not have the required permission.| +| ASSET_INVALID_ARGUMENT | The parameter is invalid.| +| ASSET_SERVICE_UNAVAILABLE | The asset store service is unavailable.| +| ASSET_NOT_FOUND | The asset is not found.| +| ASSET_DUPLICATED | The asset already exists.| +| ASSET_ACCESS_DENIED | The access to the asset is denied.| +| ASSET_STATUS_MISMATCH | The lock screen status does not match.| +| ASSET_OUT_OF_MEMORY | The system memory is insufficient.| +| ASSET_DATA_CORRUPTED | The asset is corrupted.| +| ASSET_DATABASE_ERROR | The database operation failed.| +| ASSET_CRYPTO_ERROR | The cryptographic operation failed.| +| ASSET_IPC_ERROR | The IPC failed.| +| ASSET_BMS_ERROR | The Bundle Manager service is abnormal.| +| ASSET_ACCOUNT_ERROR | The Account service is abnormal.| +| ASSET_ACCESS_TOKEN_ERROR | The Access Token service is abnormal.| +| ASSET_FILE_OPERATION_ERROR | The file operation failed.| +| ASSET_GET_SYSTEM_TIME_ERROR | Failed to obtain the system time.| +| ASSET_LIMIT_EXCEEDED | The number of cached assets exceeds the limit.| +| ASSET_UNSUPPORTED | The function is not supported.| + + +### Asset_ReturnType + +``` +enum Asset_ReturnType +``` + +**Description** + +Enumerates the types of the asset query result to return. + +**Since**: 11 + +| Value| Description| +| -------- | -------- | +| ASSET_RETURN_ALL | The query result contains the asset plaintext and its attributes.| +| ASSET_RETURN_ATTRIBUTES | The query result contains only the asset attributes.| + + +### Asset_SyncType + +``` +enum Asset_SyncType +``` + +**Description** + +Enumerates the types of sync supported by assets. + +**Since**: 11 + +| Value| Description| +| -------- | -------- | +| ASSET_SYNC_TYPE_NEVER | Asset sync is not allowed.| +| ASSET_SYNC_TYPE_THIS_DEVICE | Asset sync is allowed only on the local device, for example, in data restore on the local device.| +| ASSET_SYNC_TYPE_TRUSTED_DEVICE | Asset sync is allowed only between trusted devices, for example, in the case of cloning.| +| ASSET_SYNC_TYPE_TRUSTED_ACCOUNT | Asset sync is allowed only between the devices that are logged in with trusted accounts, for example, in cloud sync scenarios.
**Since**: 12| + + +### Asset_Tag + +``` +enum Asset_Tag +``` + +**Description** + +Enumerates the keys of asset attributes. + +**Since**: 11 + +| Value| Description| +| -------- | -------- | +| ASSET_TAG_SECRET | Sensitive user data in the form of bytes, such as passwords and tokens.| +| ASSET_TAG_ALIAS | Asset alias (identifier) in the form of bytes.| +| ASSET_TAG_ACCESSIBILITY | Access control based on the lock screen status. The value is of the uint32 type, which is a 32-bit unsigned integer.| +| ASSET_TAG_REQUIRE_PASSWORD_SET | Whether the asset is available only after a lock screen password is set.| +| ASSET_TAG_AUTH_TYPE | User authentication type for the asset. The value is of the uint32 type.| +| ASSET_TAG_AUTH_VALIDITY_PERIOD | Validity period of the user authentication, in seconds. The value is of the uint32 type, in seconds.| +| ASSET_TAG_AUTH_CHALLENGE | Challenge value, in the form of bytes, used for anti-replay during the authentication.| +| ASSET_TAG_AUTH_TOKEN | Authentication token, in the form of bytes, obtained after a successful user authentication.| +| ASSET_TAG_SYNC_TYPE | Asset sync type. The value is of the uint32 type.| +| ASSET_TAG_IS_PERSISTENT | Whether the asset needs to be stored persistently.| +| ASSET_TAG_DATA_LABEL_CRITICAL_1 | Custom data, which is of the bytes type and cannot be changed.| +| ASSET_TAG_DATA_LABEL_CRITICAL_2 | Custom data, which is of the bytes type and cannot be changed.| +| ASSET_TAG_DATA_LABEL_CRITICAL_3 | Custom data, which is of the bytes type and cannot be changed.| +| ASSET_TAG_DATA_LABEL_CRITICAL_4 | Custom data, which is of the bytes type and cannot be changed.| +| ASSET_TAG_DATA_LABEL_NORMAL_1 | Custom data, which is of the bytes type and can be changed.| +| ASSET_TAG_DATA_LABEL_NORMAL_2 | Custom data, which is of the bytes type and can be changed.| +| ASSET_TAG_DATA_LABEL_NORMAL_3 | Custom data, which is of the bytes type and can be changed.| +| ASSET_TAG_DATA_LABEL_NORMAL_4 | Custom data, which is of the bytes type and can be changed.| +| ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_1 | Custom data, which is of the bytes type, can be changed, but cannot be synced.
**Since**: 12| +| ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_2 | Custom data, which is of the bytes type, can be changed, but cannot be synced.
**Since**: 12| +| ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_3 | Custom data, which is of the bytes type, can be changed, but cannot be synced.
**Since**: 12| +| ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_4 | Custom data, which is of the bytes type, can be changed, but cannot be synced.
**Since**: 12| +| ASSET_TAG_RETURN_TYPE | Type of asset information to return. The value is of the uint32 type.| +| ASSET_TAG_RETURN_LIMIT | Maximum number of assets that can be returned in a query operation. The value is of the uint32 type.| +| ASSET_TAG_RETURN_OFFSET | Offset of the returned assets in a batch query. The value is of the uint32 type.| +| ASSET_TAG_RETURN_ORDERED_BY | Sorting order of the assets in the query result. The value is of the uint32 type.| +| ASSET_TAG_CONFLICT_RESOLUTION | Policy for resolving the conflict when an asset is added. The value is of the uint32_t type.| +| ASSET_TAG_UPDATE_TIME | Asset update time, in timestamp format. The value is of the bytes type.
**Since**: 12| +| ASSET_TAG_OPERATION_TYPE | Additional operation type. The value is of the uint32_t type.
**Since**: 12| +| ASSET_TAG_REQUIRE_ATTR_ENCRYPTED | Whether to encrypt the additional information customized by the service. The value is of the Boolean type.
**Since**: 14| +| ASSET_TAG_GROUP_ID | Group to which the asset belongs. The value is of the bytes type.
**Since**: 18| + + +### Asset_TagType + +``` +enum Asset_TagType +``` + +**Description** + +Enumerates the types of the keys of asset attributes. + +**Since**: 11 + +| Value| Description| +| -------- | -------- | +| ASSET_TYPE_BOOL | Boolean.| +| ASSET_TYPE_NUMBER | uint32_t.| +| ASSET_TYPE_BYTES | Bytes.| + + +### Asset_OperationType + +``` +enum Asset_OperationType +``` + +**Description** + +Enumerates the additional asset operation types. + +**Since**: 12 + +| Value| Description| +| -------- | -------- | +| ASSET_NEED_SYNC | Sync.| +| ASSET_NEED_LOGOUT | Log out.| diff --git a/en/application-dev/reference/apis-asset-store-kit/asset__api_8h.md b/en/application-dev/reference/apis-asset-store-kit/asset__api_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..cd314d65a364c23e71c047e56deaa44a4d8bdeb3 --- /dev/null +++ b/en/application-dev/reference/apis-asset-store-kit/asset__api_8h.md @@ -0,0 +1,32 @@ +# asset_api.h + + +## Overview + +Defines the functions for accessing assets. + +**Library**: libasset_ndk.z.so + +**System capability**: SystemCapability.Security.Asset + +**Since**: 11 + +**Related module**: [AssetApi](_asset_api.md) + + +## Summary + + +### Functions + +| Name| Description| +| -------- | -------- | +| int32_t [OH_Asset_Add](_asset_api.md#oh_asset_add) (const [Asset_Attr](_asset___attr.md) \*attributes, uint32_t attrCnt) | Adds an asset.| +| int32_t [OH_Asset_Remove](_asset_api.md#oh_asset_remove) (const [Asset_Attr](_asset___attr.md) \*query, uint32_t queryCnt) | Removes one or more assets.| +| int32_t [OH_Asset_Update](_asset_api.md#oh_asset_update) (const [Asset_Attr](_asset___attr.md) \*query, uint32_t queryCnt, const [Asset_Attr](_asset___attr.md) \*attributesToUpdate, uint32_t updateCnt) | Updates an asset.| +| int32_t [OH_Asset_PreQuery](_asset_api.md#oh_asset_prequery) (const [Asset_Attr](_asset___attr.md) \*query, uint32_t queryCnt, [Asset_Blob](_asset___blob.md) \*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](_asset_api.md#oh_asset_query) (const [Asset_Attr](_asset___attr.md) \*query, uint32_t queryCnt, [Asset_ResultSet](_asset___result_set.md) \*resultSet) | Queries one or more assets.| +| int32_t [OH_Asset_PostQuery](_asset_api.md#oh_asset_postquery) (const [Asset_Attr](_asset___attr.md) \*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](_asset___attr.md) \* [OH_Asset_ParseAttr](_asset_api.md#oh_asset_parseattr) (const [Asset_Result](_asset___result.md) \*result, [Asset_Tag](_asset_type.md#asset_tag) tag) | Parses the query result and obtains the specified attribute. | +| void [OH_Asset_FreeBlob](_asset_api.md#oh_asset_freeblob) ([Asset_Blob](_asset___blob.md) \*blob) | Releases the memory occupied by the challenge value.| +| void [OH_Asset_FreeResultSet](_asset_api.md#oh_asset_freeresultset) ([Asset_ResultSet](_asset___result_set.md) \*resultSet) | Releases the memory occupied by the query result.| diff --git a/en/application-dev/reference/apis-asset-store-kit/asset__type_8h.md b/en/application-dev/reference/apis-asset-store-kit/asset__type_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..187aab7b6535346bd9bc59eb17113bf332324f04 --- /dev/null +++ b/en/application-dev/reference/apis-asset-store-kit/asset__type_8h.md @@ -0,0 +1,50 @@ +# asset_type.h + + +## Overview + +Defines the enums, structs, and error codes used in the asset store service (ASSET). + +**Library**: libasset_ndk.z.so + +**System capability**: SystemCapability.Security.Asset + +**Since**: 11 + +**Related module**: [AssetType](_asset_type.md) + + +## Summary + + +### Structs + +| Name| Description| +| -------- | -------- | +| struct [Asset_Blob](_asset___blob.md) | Defines a binary array, that is, an array of bytes with variable length.| +| union [Asset_Value](union_asset___value.md) | Represents the value of an asset attribute.| +| struct [Asset_Attr](_asset___attr.md) | Represents an asset attribute in the form of a key-value (KV) pair.| +| struct [Asset_Result](_asset___result.md) | Represents the query result of an asset.| +| struct [Asset_ResultSet](_asset___result_set.md) | Represents the query result of multiple assets.| + + +### Macros + +| Name| Description| +| -------- | -------- | +| [ASSET_TAG_TYPE_MASK](_asset_type.md#asset_tag_type_mask) (0xF << 28) | Defines the mask used to obtain the key type of an asset attribute.| + + +### Enums + +| Name| Description| +| -------- | -------- | +| [Asset_TagType](_asset_type.md#asset_tagtype) {
ASSET_TYPE_BOOL = 0x1 << 28,
ASSET_TYPE_NUMBER = 0x2 << 28,
ASSET_TYPE_BYTES = 0x3 << 28 } | Enumerates the tag types of asset attributes. | +| [Asset_Tag](_asset_type.md#asset_tag) {
ASSET_TAG_SECRET = ASSET_TYPE_BYTES \| 0x01,
ASSET_TAG_ALIAS = ASSET_TYPE_BYTES \| 0x02,
ASSET_TAG_ACCESSIBILITY = ASSET_TYPE_NUMBER \| 0x03,
ASSET_TAG_REQUIRE_PASSWORD_SET = ASSET_TYPE_BOOL \| 0x04,
ASSET_TAG_AUTH_TYPE = ASSET_TYPE_NUMBER \| 0x05,
ASSET_TAG_AUTH_VALIDITY_PERIOD = ASSET_TYPE_NUMBER \| 0x06,
ASSET_TAG_AUTH_CHALLENGE = ASSET_TYPE_BYTES \| 0x07,
ASSET_TAG_AUTH_TOKEN = ASSET_TYPE_BYTES \| 0x08,
ASSET_TAG_SYNC_TYPE = ASSET_TYPE_NUMBER \| 0x10,
ASSET_TAG_IS_PERSISTENT = ASSET_TYPE_BOOL \| 0x11,
ASSET_TAG_DATA_LABEL_CRITICAL_1 = ASSET_TYPE_BYTES \| 0x20,
ASSET_TAG_DATA_LABEL_CRITICAL_2 = ASSET_TYPE_BYTES \| 0x21,
ASSET_TAG_DATA_LABEL_CRITICAL_3 = ASSET_TYPE_BYTES \| 0x22,
ASSET_TAG_DATA_LABEL_CRITICAL_4 = ASSET_TYPE_BYTES \| 0x23,
ASSET_TAG_DATA_LABEL_NORMAL_1 = ASSET_TYPE_BYTES \| 0x30,
ASSET_TAG_DATA_LABEL_NORMAL_2 = ASSET_TYPE_BYTES \| 0x31,
ASSET_TAG_DATA_LABEL_NORMAL_3 = ASSET_TYPE_BYTES \| 0x32,
ASSET_TAG_DATA_LABEL_NORMAL_4 = ASSET_TYPE_BYTES \| 0x33,
ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_112+ = ASSET_TYPE_BYTES \| 0x34,
ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_212+ = ASSET_TYPE_BYTES \| 0x35,
ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_312+ = ASSET_TYPE_BYTES \| 0x36,
ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_412+ = ASSET_TYPE_BYTES \| 0x37,
ASSET_TAG_RETURN_TYPE = ASSET_TYPE_NUMBER \| 0x40,
ASSET_TAG_RETURN_LIMIT = ASSET_TYPE_NUMBER \| 0x41,
ASSET_TAG_RETURN_OFFSET = ASSET_TYPE_NUMBER \| 0x42,
ASSET_TAG_RETURN_ORDERED_BY = ASSET_TYPE_NUMBER \| 0x43,
ASSET_TAG_CONFLICT_RESOLUTION = ASSET_TYPE_NUMBER \| 0x44,
ASSET_TAG_UPDATE_TIME12+ = ASSET_TYPE_BYTES \| 0x45,
ASSET_TAG_OPERATION_TYPE12+ = ASSET_TYPE_NUMBER \| 0x46,
ASSET_TAG_REQUIRE_ATTR_ENCRYPTED14+ = ASSET_TYPE_BOOL \| 0x47,
ASSET_TAG_GROUP_ID18+ = ASSET_TYPE_BYTES \| 0x48,
} | Enumerates the tags of asset attributes.| +| [Asset_ResultCode](_asset_type.md#asset_resultcode) {
ASSET_SUCCESS = 0,
ASSET_PERMISSION_DENIED = 201,
ASSET_INVALID_ARGUMENT = 401,
ASSET_SERVICE_UNAVAILABLE = 24000001,
ASSET_NOT_FOUND = 24000002,
ASSET_DUPLICATED = 24000003,
ASSET_ACCESS_DENIED = 24000004,
ASSET_STATUS_MISMATCH = 24000005,
ASSET_OUT_OF_MEMORY = 24000006,
ASSET_DATA_CORRUPTED = 24000007,
ASSET_DATABASE_ERROR = 24000008,
ASSET_CRYPTO_ERROR = 24000009,
ASSET_IPC_ERROR = 24000010,
ASSET_BMS_ERROR = 24000011,
ASSET_ACCOUNT_ERROR = 24000012,
ASSET_ACCESS_TOKEN_ERROR = 24000013,
ASSET_FILE_OPERATION_ERROR = 24000014,
ASSET_GET_SYSTEM_TIME_ERROR = 24000015,
ASSET_LIMIT_EXCEEDED = 24000016,
ASSET_UNSUPPORTED = 24000017
} | Enumerates the result codes returned by ASSET functions.| +| [Asset_Accessibility](_asset_type.md#asset_accessibility) {
ASSET_ACCESSIBILITY_DEVICE_POWERED_ON = 0,
ASSET_ACCESSIBILITY_DEVICE_FIRST_UNLOCKED = 1,
ASSET_ACCESSIBILITY_DEVICE_UNLOCKED = 2
} | Enumerates the types of access control based on the lock screen status.| +| [Asset_AuthType](_asset_type.md#asset_authtype) { ASSET_AUTH_TYPE_NONE = 0x00,
ASSET_AUTH_TYPE_ANY = 0xFF } | Enumerates the user authentication types supported by assets.| +| [Asset_SyncType](_asset_type.md#asset_synctype) {
ASSET_SYNC_TYPE_NEVER = 0,
ASSET_SYNC_TYPE_THIS_DEVICE = 1 << 0,
ASSET_SYNC_TYPE_TRUSTED_DEVICE = 1 << 1,
ASSET_SYNC_TYPE_TRUSTED_ACCOUNT12+ = 1 << 2
} | Enumerates the sync types supported by assets.| +| [Asset_ConflictResolution](_asset_type.md#asset_conflictresolution) {
ASSET_CONFLICT_OVERWRITE = 0,
ASSET_CONFLICT_THROW_ERROR = 1
} | Enumerates the policies for resolving the conflict (for example, a duplicate alias).| +| [Asset_ReturnType](_asset_type.md#asset_returntype) {
ASSET_RETURN_ALL = 0,
ASSET_RETURN_ATTRIBUTES = 1
} | Enumerates the types of the asset query result to return.| +| [Asset_OperationType](_asset_type.md#asset_operationtype)12+ {
ASSET_NEED_SYNC = 0,
ASSET_NEED_LOGOUT = 1
} | Enumerates the additional asset operation types.| diff --git a/en/application-dev/reference/apis-asset-store-kit/union_asset___value.md b/en/application-dev/reference/apis-asset-store-kit/union_asset___value.md new file mode 100644 index 0000000000000000000000000000000000000000..cb3ca50b3db74bda5011b2c476e0e0c92c6cc377 --- /dev/null +++ b/en/application-dev/reference/apis-asset-store-kit/union_asset___value.md @@ -0,0 +1,54 @@ +# Asset_Value + + +## Overview + +Defines the value of an asset attribute, which is in the form of a key-value (KV) pair. + +**Since**: 11 + +**Related module**: [AssetType](_asset_type.md) + +**Header file**: [asset_type.h](asset__type_8h.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| bool [boolean](#boolean) | Asset attribute value of the Boolean type. | +| uint32_t [u32](#u32) | Asset attribute value of the uint32_t type. | +| [Asset_Blob](_asset___blob.md) [blob](#blob) | Asset attribute value in an array of bytes. | + + +## Member Variable Description + + +### blob + +``` +Asset_Blob Asset_Value::blob +``` +**Description** +Represents an asset attribute value in an array of bytes. + + +### boolean + +``` +bool Asset_Value::boolean +``` +**Description** +Represents an asset attribute value of the Boolean type. + + +### u32 + +``` +uint32_t Asset_Value::u32 +``` +**Description** +Represents an asset attribute value of the uint32_t type. diff --git a/en/application-dev/reference/apis-crypto-architecture-kit/_crypto___data_blob.md b/en/application-dev/reference/apis-crypto-architecture-kit/_crypto___data_blob.md new file mode 100644 index 0000000000000000000000000000000000000000..62e920a7301a39fa84861732e247c6407f64cc34 --- /dev/null +++ b/en/application-dev/reference/apis-crypto-architecture-kit/_crypto___data_blob.md @@ -0,0 +1,46 @@ +# Crypto_DataBlob + + +## Overview + +Defines the data used for encryption and decryption. + +**Since**: 12 + +**Related module**: [CryptoCommonApi](_crypto_common_api.md) + +**Header file**: [crypto_common.h](crypto__common_8h.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| uint8_t \* [data](#data) | Pointer to the data. | +| size_t [len](#len) | Length of the data. | + + +## Member Variable Description + + +### data + +``` +uint8_t* Crypto_DataBlob::data +``` +**Description** + +Pointer to the data. + + +### len + +``` +size_t Crypto_DataBlob::len +``` +**Description** + +Length of the data. diff --git a/en/application-dev/reference/apis-crypto-architecture-kit/_crypto_asym_key_api.md b/en/application-dev/reference/apis-crypto-architecture-kit/_crypto_asym_key_api.md new file mode 100644 index 0000000000000000000000000000000000000000..15e0cd4c624e1cbef183162b1b4c490f40eb27aa --- /dev/null +++ b/en/application-dev/reference/apis-crypto-architecture-kit/_crypto_asym_key_api.md @@ -0,0 +1,422 @@ +# CryptoAsymKeyApi + + +## Overview + +Provides APIs for asymmetric keys. + +**Since**: 12 + + +## Summary + + +### Files + +| Name | Description | +| -------- | -------- | +| [crypto_asym_key.h](crypto__asym__key_8h.md) | Defines APIs for asymmetric keys. | + + +### Types + +| Name | Description | +| -------- | -------- | +| typedef struct [OH_CryptoKeyPair](#oh_cryptokeypair) [OH_CryptoKeyPair](#oh_cryptokeypair) | Defines a struct for an asymmetric key pair. | +| typedef struct [OH_CryptoPubKey](#oh_cryptopubkey) [OH_CryptoPubKey](#oh_cryptopubkey) | Defines a struct for the public key in an asymmetric key pair. | +| typedef struct [OH_CryptoAsymKeyGenerator](#oh_cryptoasymkeygenerator) [OH_CryptoAsymKeyGenerator](#oh_cryptoasymkeygenerator) | Defines a struct for an asymmetric key generator. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [CryptoAsymKey_ParamType](#cryptoasymkey_paramtype) {
CRYPTO_DSA_P_DATABLOB = 101, CRYPTO_DSA_Q_DATABLOB = 102,
CRYPTO_DSA_G_DATABLOB = 103, CRYPTO_DSA_SK_DATABLOB = 104,
CRYPTO_DSA_PK_DATABLOB = 105, CRYPTO_ECC_FP_P_DATABLOB = 201,
CRYPTO_ECC_A_DATABLOB = 202, CRYPTO_ECC_B_DATABLOB = 203,
CRYPTO_ECC_G_X_DATABLOB = 204, CRYPTO_ECC_G_Y_DATABLOB = 205,
CRYPTO_ECC_N_DATABLOB = 206, CRYPTO_ECC_H_INT = 207,
CRYPTO_ECC_SK_DATABLOB = 208, CRYPTO_ECC_PK_X_DATABLOB = 209,
CRYPTO_ECC_PK_Y_DATABLOB = 210, CRYPTO_ECC_FIELD_TYPE_STR = 211,
CRYPTO_ECC_FIELD_SIZE_INT = 212, CRYPTO_ECC_CURVE_NAME_STR = 213,
CRYPTO_RSA_N_DATABLOB = 301, CRYPTO_RSA_D_DATABLOB = 302,
CRYPTO_RSA_E_DATABLOB = 303, CRYPTO_DH_P_DATABLOB = 401,
CRYPTO_DH_G_DATABLOB = 402, CRYPTO_DH_L_NUM = 403,
CRYPTO_DH_SK_DATABLOB = 404, CRYPTO_DH_PK_DATABLOB = 405,
CRYPTO_ED25519_SK_DATABLOB = 501, CRYPTO_ED25519_PK_DATABLOB = 502,
CRYPTO_X25519_SK_DATABLOB = 601, CRYPTO_X25519_PK_DATABLOB = 602
} | Enumerates the types of the asymmetric key parameters. | +| [Crypto_EncodingType](#crypto_encodingtype) { CRYPTO_PEM = 0, CRYPTO_DER = 1 } | Enumerates the encoding types. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoAsymKeyGenerator_Create](#oh_cryptoasymkeygenerator_create) (const char \*algoName, [OH_CryptoAsymKeyGenerator](#oh_cryptoasymkeygenerator) \*\*ctx) | Creates an asymmetric key generator instance based on the specified algorithm. | +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoAsymKeyGenerator_Generate](#oh_cryptoasymkeygenerator_generate) ([OH_CryptoAsymKeyGenerator](#oh_cryptoasymkeygenerator) \*ctx, [OH_CryptoKeyPair](#oh_cryptokeypair) \*\*keyCtx) | Randomly generates an asymmetric key pair. | +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoAsymKeyGenerator_Convert](#oh_cryptoasymkeygenerator_convert) ([OH_CryptoAsymKeyGenerator](#oh_cryptoasymkeygenerator) \*ctx, [Crypto_EncodingType](#crypto_encodingtype) type, [Crypto_DataBlob](_crypto___data_blob.md) \*pubKeyData, [Crypto_DataBlob](_crypto___data_blob.md) \*priKeyData, [OH_CryptoKeyPair](#oh_cryptokeypair) \*\*keyCtx) | Converts asymmetric key data into a key pair. | +| const char \* [OH_CryptoAsymKeyGenerator_GetAlgoName](#oh_cryptoasymkeygenerator_getalgoname) ([OH_CryptoAsymKeyGenerator](#oh_cryptoasymkeygenerator) \*ctx) | Obtains the asymmetric key algorithm. | +| void [OH_CryptoAsymKeyGenerator_Destroy](#oh_cryptoasymkeygenerator_destroy) ([OH_CryptoAsymKeyGenerator](#oh_cryptoasymkeygenerator) \*ctx) | Destroys an asymmetric key generator instance. | +| void [OH_CryptoKeyPair_Destroy](#oh_cryptokeypair_destroy) ([OH_CryptoKeyPair](#oh_cryptokeypair) \*keyCtx) | Destroys an asymmetric key pair instance. | +| [OH_CryptoPubKey](#oh_cryptopubkey) \* [OH_CryptoKeyPair_GetPubKey](#oh_cryptokeypair_getpubkey) ([OH_CryptoKeyPair](#oh_cryptokeypair) \*keyCtx) | Obtains the public key instance from a key pair. | +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoPubKey_Encode](#oh_cryptopubkey_encode) ([OH_CryptoPubKey](#oh_cryptopubkey) \*key, [Crypto_EncodingType](#crypto_encodingtype) type, const char \*encodingStandard, [Crypto_DataBlob](_crypto___data_blob.md) \*out) | Encodes the public key data in the specified format. | +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoPubKey_GetParam](#oh_cryptopubkey_getparam) ([OH_CryptoPubKey](#oh_cryptopubkey) \*key, [CryptoAsymKey_ParamType](#cryptoasymkey_paramtype) item, [Crypto_DataBlob](_crypto___data_blob.md) \*value) | Obtains the specified parameter from a public key instance. | + + +## Type Description + + +### OH_CryptoAsymKeyGenerator + +``` +typedef struct OH_CryptoAsymKeyGenerator OH_CryptoAsymKeyGenerator +``` + +**Description** + +Defines a struct for an asymmetric key generator. + +**Since**: 12 + + +### OH_CryptoKeyPair + +``` +typedef struct OH_CryptoKeyPair OH_CryptoKeyPair +``` + +**Description** + +Defines a struct for an asymmetric key pair. + +**Since**: 12 + + +### OH_CryptoPubKey + +``` +typedef struct OH_CryptoPubKey OH_CryptoPubKey +``` + +**Description** + +Defines a struct for the public key in an asymmetric key pair. + +**Since**: 12 + + +## Enum Description + + +### Crypto_EncodingType + +``` +enum Crypto_EncodingType +``` + +**Description** + +Enumerates the encoding types. + +**Since**: 12 + +| Enum | Description | +| -------- | -------- | +| CRYPTO_PEM | PEM. | +| CRYPTO_DER | DER. | + + +### CryptoAsymKey_ParamType + +``` +enum CryptoAsymKey_ParamType +``` + +**Description** + +Enumerates the types of the asymmetric key parameters. + +**Since**: 12 + +| Enum | Description | +| -------- | -------- | +| CRYPTO_DSA_P_DATABLOB | Prime modulus **p** in the DSA algorithm. | +| CRYPTO_DSA_Q_DATABLOB | Parameter **q**, prime factor of (p – 1) in the DSA algorithm. | +| CRYPTO_DSA_G_DATABLOB | Parameter **g** in the DSA algorithm. | +| CRYPTO_DSA_SK_DATABLOB | Private key **sk** in the DSA algorithm. | +| CRYPTO_DSA_PK_DATABLOB | Public key **pk** in the DSA algorithm. | +| CRYPTO_ECC_FP_P_DATABLOB | Prime number **p** in the **Fp** field of the elliptic curve in the ECC algorithm. | +| CRYPTO_ECC_A_DATABLOB | First coefficient **a** of the elliptic curve in the ECC algorithm. | +| CRYPTO_ECC_B_DATABLOB | Second coefficient **b** of the elliptic curve in the ECC algorithm. | +| CRYPTO_ECC_G_X_DATABLOB | X coordinate of the base point **g** in the ECC algorithm. | +| CRYPTO_ECC_G_Y_DATABLOB | Y coordinate of the base point **g** in the ECC algorithm. | +| CRYPTO_ECC_N_DATABLOB | Order **n** of the base point **g** in the ECC algorithm. | +| CRYPTO_ECC_H_INT | Cofactor **h** in the ECC algorithm. | +| CRYPTO_ECC_SK_DATABLOB | Private key **sk** in the ECC algorithm. | +| CRYPTO_ECC_PK_X_DATABLOB | X coordinate of the public key **pk** (a point on the elliptic curve) in the ECC algorithm. | +| CRYPTO_ECC_PK_Y_DATABLOB | Y coordinate of the public key **pk** (a point on the elliptic curve) in the ECC algorithm. | +| CRYPTO_ECC_FIELD_TYPE_STR | Elliptic curve field type in the ECC algorithm. Currently, only the **Fp** field is supported. | +| CRYPTO_ECC_FIELD_SIZE_INT | Size of the field in the ECC algorithm, in bits.
**NOTE**: The size of the **Fp** field is the length of the prime **p**, in bits. | +| CRYPTO_ECC_CURVE_NAME_STR | Standards for Efficient Cryptography Group (SECG) curve name in the ECC algorithm. | +| CRYPTO_RSA_N_DATABLOB | Modulus **n** in the RSA algorithm. | +| CRYPTO_RSA_D_DATABLOB | Private key **sk** (private key exponent **d**) in the RSA algorithm. | +| CRYPTO_RSA_E_DATABLOB | Public key **pk** (public key exponent **e**) in the RSA algorithm. | +| CRYPTO_DH_P_DATABLOB | Prime **p** in the DH algorithm. | +| CRYPTO_DH_G_DATABLOB | Parameter **g** in the DH algorithm. | +| CRYPTO_DH_L_NUM | Length of the private key in the DH algorithm, in bits. | +| CRYPTO_DH_SK_DATABLOB | Private key **sk** in the DH algorithm. | +| CRYPTO_DH_PK_DATABLOB | Public key **pk** in the DH algorithm. | +| CRYPTO_ED25519_SK_DATABLOB | Private key **sk** in the Ed25519 algorithm. | +| CRYPTO_ED25519_PK_DATABLOB | Public key **pk** in the Ed25519 algorithm. | +| CRYPTO_X25519_SK_DATABLOB | Private key **sk** in the X25519 algorithm. | +| CRYPTO_X25519_PK_DATABLOB | Public key **pk** in the X25519 algorithm. | + + +## Function Description + + +### OH_CryptoAsymKeyGenerator_Convert() + +``` +OH_Crypto_ErrCode OH_CryptoAsymKeyGenerator_Convert (OH_CryptoAsymKeyGenerator *ctx, Crypto_EncodingType type, Crypto_DataBlob *pubKeyData, Crypto_DataBlob *priKeyData, OH_CryptoKeyPair **keyCtx ) +``` + +**Description** + +Converts binary data into an asymmetric key pair. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| ctx | Pointer to the asymmetric key generator instance. | +| type | Encoding type. | +| pubKeyData | Pointer to the public key data to convert. | +| priKeyData | Pointer to the private key data to convert. | +| keyCtx | Pointer to the asymmetric key pair instance. | + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + + +### OH_CryptoAsymKeyGenerator_Create() + +``` +OH_Crypto_ErrCode OH_CryptoAsymKeyGenerator_Create (const char *algoName, OH_CryptoAsymKeyGenerator **ctx ) +``` + +**Description** + +Creates an asymmetric key generator instance based on the specified algorithm. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| algoName | Pointer to the algorithm used to create the asymmetric key generator instance. For example, **'RSA1024\|PRIMES_2'**. | +| ctx | Pointer to the asymmetric key generator instance created. | + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + + +### OH_CryptoAsymKeyGenerator_Destroy() + +``` +void OH_CryptoAsymKeyGenerator_Destroy (OH_CryptoAsymKeyGenerator *ctx) +``` + +**Description** + +Destroys an asymmetric key generator instance. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| ctx | Pointer to the asymmetric key generator instance to destroy. | + + +### OH_CryptoAsymKeyGenerator_Generate() + +``` +OH_Crypto_ErrCode OH_CryptoAsymKeyGenerator_Generate (OH_CryptoAsymKeyGenerator *ctx, OH_CryptoKeyPair **keyCtx ) +``` + +**Description** + +Randomly generates an asymmetric key pair. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| ctx | Pointer to the asymmetric key generator instance. | +| keyCtx | Pointer to the asymmetric key pair instance created. | + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + + +### OH_CryptoAsymKeyGenerator_GetAlgoName() + +``` +const char* OH_CryptoAsymKeyGenerator_GetAlgoName (OH_CryptoAsymKeyGenerator *ctx) +``` + +**Description** + +Obtains the asymmetric key algorithm. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| ctx | Pointer to the asymmetric key generator instance. | + +**Returns** + +Name of the asymmetric key algorithm obtained. + + +### OH_CryptoKeyPair_Destroy() + +``` +void OH_CryptoKeyPair_Destroy (OH_CryptoKeyPair *keyCtx) +``` + +**Description** + +Destroys an asymmetric key pair instance. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| keyCtx | Pointer to the asymmetric key pair instance to destroy. | + + +### OH_CryptoKeyPair_GetPubKey() + +``` +OH_CryptoPubKey* OH_CryptoKeyPair_GetPubKey (OH_CryptoKeyPair *keyCtx) +``` + +**Description** + +Obtains the public key from a key pair. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| keyCtx | Pointer to the key pair instance. | + +**Returns** + +Public key obtained. + + +### OH_CryptoPubKey_Encode() + +``` +OH_Crypto_ErrCode OH_CryptoPubKey_Encode (OH_CryptoPubKey *key, Crypto_EncodingType type, const char *encodingStandard, Crypto_DataBlob *out ) +``` + +**Description** + +Encodes the public key data in the specified format. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| key | Ponter to the public key data. | +| type | Encoding type. | +| encodingStandard | Encoding format. | +| out | Pointer to the public key encoded in the specified format. | + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + + +### OH_CryptoPubKey_GetParam() + +``` +OH_Crypto_ErrCode OH_CryptoPubKey_GetParam (OH_CryptoPubKey *key, CryptoAsymKey_ParamType item, Crypto_DataBlob *value ) +``` + +**Description** + +Obtains the specified parameter from a public key instance. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| key | Ponter to the public key data. | +| item | Type of the asymmetric key parameter to obtain. | +| value | Pointer to the parameter value obtained. | + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. diff --git a/en/application-dev/reference/apis-crypto-architecture-kit/_crypto_common_api.md b/en/application-dev/reference/apis-crypto-architecture-kit/_crypto_common_api.md new file mode 100644 index 0000000000000000000000000000000000000000..dcfe3d0aeaf7fdcdc387a9dd45d17235b39b6e2e --- /dev/null +++ b/en/application-dev/reference/apis-crypto-architecture-kit/_crypto_common_api.md @@ -0,0 +1,127 @@ +# CryptoCommonApi + + +## Overview + +Provides common APIs for cryptographic operations. + +**Since**: 12 + + +## Summary + + +### Files + +| Name | Description | +| -------- | -------- | +| [crypto_common.h](crypto__common_8h.md) | Defines common APIs for cryptographic operations. | + + +### Structs + +| Name | Description | +| -------- | -------- | +| struct [Crypto_DataBlob](_crypto___data_blob.md) | Defines the data used for encryption and decryption. | + + +### Types + +| Name | Description | +| -------- | -------- | +| typedef struct [Crypto_DataBlob](_crypto___data_blob.md) [Crypto_DataBlob](#crypto_datablob) | Defines a struct for the data used for encryption and decryption. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [OH_Crypto_ErrCode](#oh_crypto_errcode) {
CRYPTO_SUCCESS = 0, CRYPTO_INVALID_PARAMS = 401,
CRYPTO_NOT_SUPPORT = 801, CRYPTO_MEMORY_ERROR = 17620001,
CRYPTO_OPERTION_ERROR = 17630001
} | Enumerates the encryption and decryption error codes. | +| [Crypto_CipherMode](#crypto_ciphermode) {
CRYPTO_ENCRYPT_MODE = 0,
CRYPTO_DECRYPT_MODE = 1
} | Enumerates the cryptographic operation types. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| void [OH_Crypto_FreeDataBlob](#oh_crypto_freedatablob) ([Crypto_DataBlob](_crypto___data_blob.md) \*dataBlob) | Releases a **dataBlob** instance. | + + +## Type Description + + +### Crypto_DataBlob + +``` +typedef struct Crypto_DataBlob Crypto_DataBlob +``` + +**Description** + +Defines a struct for the data used for encryption and decryption. + +**Since**: 12 + + +## Enum Description + + +### Crypto_CipherMode + +``` +enum Crypto_CipherMode +``` + +**Description** + +Enumerates the cryptographic operation types. + +**Since**: 12 + +| Enum | Description | +| -------- | -------- | +| CRYPTO_ENCRYPT_MODE | Encrypt data. | +| CRYPTO_DECRYPT_MODE | Decrypt data. | + + +### OH_Crypto_ErrCode + +``` +enum OH_Crypto_ErrCode +``` + +**Description** + +Enumerates the encryption and decryption error codes. + +**Since**: 12 + +| Enum | Description | +| -------- | -------- | +| CRYPTO_SUCCESS | The operation is successful. | +| CRYPTO_INVALID_PARAMS | Invalid parameters are detected. | +| CRYPTO_NOT_SUPPORT | The function or algorithm is not supported. | +| CRYPTO_MEMORY_ERROR | A memory error occurred. | +| CRYPTO_OPERTION_ERROR | The encryption or decryption operation fails. | + + +## Function Description + + +### OH_Crypto_FreeDataBlob() + +``` +void OH_Crypto_FreeDataBlob (Crypto_DataBlob *dataBlob) +``` + +**Description** + +Releases a **dataBlob** instance. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| dataBlob | Pointer to the **dataBlob** instance to release. | diff --git a/en/application-dev/reference/apis-crypto-architecture-kit/_crypto_digest_api.md b/en/application-dev/reference/apis-crypto-architecture-kit/_crypto_digest_api.md new file mode 100644 index 0000000000000000000000000000000000000000..149c43a22a780ee7397c14b12ed515b6985f9d97 --- /dev/null +++ b/en/application-dev/reference/apis-crypto-architecture-kit/_crypto_digest_api.md @@ -0,0 +1,255 @@ +# CryptoDigestApi + + +## Overview + +Provides APIs for message digest (MD) algorithms. + +**Since**: 12 + + +## Summary + + +### Files + +| Name | Description | +| -------- | -------- | +| [crypto_digest.h](crypto__digest_8h.md) | Defines APIs for MD algorithms. | + + +### Types + +| Name | Description | +| -------- | -------- | +| typedef struct [OH_CryptoDigest](#oh_cryptodigest) [OH_CryptoDigest](#oh_cryptodigest) | Defines an MD. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoDigest_Create](#oh_cryptodigest_create) (const char \*algoName, [OH_CryptoDigest](#oh_cryptodigest) \*\*ctx) | Creates an MD instance based on the given algorithm name. | +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoDigest_Update](#oh_cryptodigest_update) ([OH_CryptoDigest](#oh_cryptodigest) \*ctx, [Crypto_DataBlob](_crypto___data_blob.md) \*in) | Updates the data used for generating an MD. | +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoDigest_Final](#oh_cryptodigest_final) ([OH_CryptoDigest](#oh_cryptodigest) \*ctx, [Crypto_DataBlob](_crypto___data_blob.md) \*out) | Generates an MD. | +| uint32_t [OH_CryptoDigest_GetLength](#oh_cryptodigest_getlength) ([OH_CryptoDigest](#oh_cryptodigest) \*ctx) | Obtains the length of an MD. | +| const char \* [OH_CryptoDigest_GetAlgoName](#oh_cryptodigest_getalgoname) ([OH_CryptoDigest](#oh_cryptodigest) \*ctx) | Obtains the digest algorithm. | +| void [OH_DigestCrypto_Destroy](#oh_digestcrypto_destroy) ([OH_CryptoDigest](#oh_cryptodigest) \*ctx) | Destroys an MD instance. | + + +## Type Description + + +### OH_CryptoDigest + +``` +typedef struct OH_CryptoDigestOH_CryptoDigest +``` + +**Description** + +Defines an MD. + +**Since**: 12 + + +## Function Description + + +### OH_CryptoDigest_Create() + +``` +OH_Crypto_ErrCode OH_CryptoDigest_Create (const char *algoName, OH_CryptoDigest **ctx ) +``` + +**Description** + +Creates an MD instance based on the given algorithm name. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| algoName | Pointer to the algorithm used to generate the MD instance. For example, **'SHA256'**. | +| ctx | Pointer to the MD instance created. | + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + + +### OH_CryptoDigest_Final() + +``` +OH_Crypto_ErrCode OH_CryptoDigest_Final (OH_CryptoDigest *ctx, Crypto_DataBlob *out ) +``` + +**Description** + +Generates an MD. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| ctx | Pointer to the MD instance. | +| out | Pointer to the MD generated. | + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + +**See** + +[OH_CryptoDigest_Update](#oh_cryptodigest_update) + + +### OH_CryptoDigest_GetAlgoName() + +``` +const char* OH_CryptoDigest_GetAlgoName (OH_CryptoDigest *ctx) +``` + +**Description** + +Obtains the digest algorithm. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| ctx | Pointer to the MD instance. | + +**Returns** + +MD algorithm obtained. + + +### OH_CryptoDigest_GetLength() + +``` +uint32_t OH_CryptoDigest_GetLength (OH_CryptoDigest *ctx) +``` + +**Description** + +Obtains the length of an MD. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| ctx | Pointer to the MD instance. | + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + + +### OH_CryptoDigest_Update() + +``` +OH_Crypto_ErrCode OH_CryptoDigest_Update (OH_CryptoDigest *ctx, Crypto_DataBlob *in ) +``` + +**Description** + +Updates the data used for generating an MD. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| ctx | Pointer to the MD instance. | +| in | Pointer to the data to pass in. | + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + +**See** + +[OH_CryptoDigest_Final](#oh_cryptodigest_final) + + +### OH_DigestCrypto_Destroy() + +``` +void OH_DigestCrypto_Destroy (OH_CryptoDigest *ctx) +``` + +**Description** + +Destroys an MD instance. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| ctx | Pointer to the MD instance. | + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. diff --git a/en/application-dev/reference/apis-crypto-architecture-kit/_crypto_signature_api.md b/en/application-dev/reference/apis-crypto-architecture-kit/_crypto_signature_api.md new file mode 100644 index 0000000000000000000000000000000000000000..73dce10bfaead363f6c0b73dde40ce89b50ea280 --- /dev/null +++ b/en/application-dev/reference/apis-crypto-architecture-kit/_crypto_signature_api.md @@ -0,0 +1,383 @@ +# CryptoSignatureApi + + +## Overview + +Provides APIs for signature verification. + +**Since**: 12 + + +## Summary + + +### Files + +| Name| Description| +| -------- | -------- | +| [crypto_signature.h](crypto__signature_8h.md) | Defines APIs for signature verification.| + + +### Types + +| Name| Description| +| -------- | -------- | +| typedef struct [OH_CryptoVerify](#oh_cryptoverify) [OH_CryptoVerify](#oh_cryptoverify) | Defines the data used for signature verification.| + + +### Enums + +| Name| Description| +| -------- | -------- | +| [CryptoSignature_ParamType](#cryptosignature_paramtype) {
CRYPTO_PSS_MD_NAME_STR = 100, CRYPTO_PSS_MGF_NAME_STR = 101,
CRYPTO_PSS_MGF1_NAME_STR = 102, CRYPTO_PSS_SALT_LEN_INT = 103,
CRYPTO_PSS_TRAILER_FIELD_INT = 104, CRYPTO_SM2_USER_ID_DATABLOB = 105
} | Enumerates the types of signature verification parameters.| + + +### Functions + +| Name| Description| +| -------- | -------- | +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoVerify_Create](#oh_cryptoverify_create) (const char \*algoName, [OH_CryptoVerify](#oh_cryptoverify) \*\*verify) | Creates a **Verify** instance for signature verification.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoVerify_Init](#oh_cryptoverify_init) ([OH_CryptoVerify](#oh_cryptoverify) \*ctx, [OH_CryptoPubKey](_crypto_asym_key_api.md#oh_cryptopubkey) \*pubKey) | Initializes a **Verify** instance by using the public key.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoVerify_Update](#oh_cryptoverify_update) ([OH_CryptoVerify](#oh_cryptoverify) \*ctx, [Crypto_DataBlob](_crypto___data_blob.md) \*in) | Updates the data to be verified.| +| bool [OH_CryptoVerify_Final](#oh_cryptoverify_final) ([OH_CryptoVerify](#oh_cryptoverify) \*ctx, [Crypto_DataBlob](_crypto___data_blob.md) \*in, [Crypto_DataBlob](_crypto___data_blob.md) \*signData) | Verifies the signature of the data.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoVerify_Recover](#oh_cryptoverify_recover) ([OH_CryptoVerify](#oh_cryptoverify) \*ctx, [Crypto_DataBlob](_crypto___data_blob.md) \*signData, [Crypto_DataBlob](_crypto___data_blob.md) \*rawSignData) | Restores the raw signature data.| +| const char \* [OH_CryptoVerify_GetAlgoName](#oh_cryptoverify_getalgoname) ([OH_CryptoVerify](#oh_cryptoverify) \*ctx) | Obtains the signature verification algorithm.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoVerify_SetParam](#oh_cryptoverify_setparam) ([OH_CryptoVerify](#oh_cryptoverify) \*ctx, [CryptoSignature_ParamType](#cryptosignature_paramtype) type, [Crypto_DataBlob](_crypto___data_blob.md) \*value) | Sets a signature verification parameter.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoVerify_GetParam](#oh_cryptoverify_getparam) ([OH_CryptoVerify](#oh_cryptoverify) \*ctx, [CryptoSignature_ParamType](#cryptosignature_paramtype) type, [Crypto_DataBlob](_crypto___data_blob.md) \*value) | Obtains a signature verification parameter.| +| void [OH_CryptoVerify_Destroy](#oh_cryptoverify_destroy) ([OH_CryptoVerify](#oh_cryptoverify) \*ctx) | Destroys a **Verify** instance.| + + +## Type Description + + +### OH_CryptoVerify + +``` +typedef struct OH_CryptoVerifyOH_CryptoVerify +``` + +**Description** + +Defines the data used for signature verification. + +**Since**: 12 + + +## Enum Description + + +### CryptoSignature_ParamType + +``` +enum CryptoSignature_ParamType +``` + +**Description** + +Enumerates the types of signature verification parameters. + +**Since**: 12 + +| Enum| Description| +| -------- | -------- | +| CRYPTO_PSS_MD_NAME_STR | MD algorithm used with the PSS padding mode in RSA.| +| CRYPTO_PSS_MGF_NAME_STR | Mask generation algorithm used with the PSS padding mode in RSA. Currently, only MGF1 is supported.| +| CRYPTO_PSS_MGF1_NAME_STR | MD parameters for the MGF1 mask generation used with the PSS padding mode in RSA.| +| CRYPTO_PSS_SALT_LEN_INT | Length of the salt in bytes used with the PSS padding mode in RSA.| +| CRYPTO_PSS_TRAILER_FIELD_INT | Trailer field used in the encoding operation when PSS padding mode is used in RSA. The value is **1**.| +| CRYPTO_SM2_USER_ID_DATABLOB | User ID field in SM2.| + + +## Function Description + + +### OH_CryptoVerify_Create() + +``` +OH_Crypto_ErrCode OH_CryptoVerify_Create (const char *algoName, OH_CryptoVerify **verify ) +``` + +**Description** + +Creates a **Verify** instance for signature verification. + +**Since**: 12 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| algoName | Pointer to the algorithm used to generate the **Verify** instance. For example, **'RSA1024\|PKCS1\|SHA256'**.| | | +| verify | Pointer to the **Verify** instance created.| + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + + +### OH_CryptoVerify_Destroy() + +``` +void OH_CryptoVerify_Destroy (OH_CryptoVerify *ctx) +``` + +**Description** + +Destroys a **Verify** instance. + +**Since**: 12 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| ctx | Pointer to the **Verify** instance to destroy.| + + +### OH_CryptoVerify_Final() + +``` +bool OH_CryptoVerify_Final (OH_CryptoVerify *ctx, Crypto_DataBlob *in, Crypto_DataBlob *signData ) +``` + +**Description** + +Verifies the signature of the data. + +**Since**: 12 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| ctx | Pointer to the **Verify** instance.| +| in | Pointer to the data passed in.| +| out | Pointer to the signature data.| + +**Returns** + +Returns a boolean value, indicating whether the signature verification is successful. + +**See** + +[OH_CryptoVerify_Init](#oh_cryptoverify_init) + +[OH_CryptoVerify_Update](#oh_cryptoverify_update) + + +### OH_CryptoVerify_GetAlgoName() + +``` +const char* OH_CryptoVerify_GetAlgoName (OH_CryptoVerify *ctx) +``` + +**Description** + +Obtains the signature verification algorithm. + +**Since**: 12 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| ctx | Pointer to the **Verify** instance.| + +**Returns** + +Signature verification algorithm obtained. + + +### OH_CryptoVerify_GetParam() + +``` +OH_Crypto_ErrCode OH_CryptoVerify_GetParam (OH_CryptoVerify *ctx, CryptoSignature_ParamType type, Crypto_DataBlob *value ) +``` + +**Description** + +Obtains a signature verification parameter. + +**Since**: 12 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| ctx | Pointer to the **Verify** instance.| +| type | Name of the signature verification parameter to obtain.| +| value | Pointer to the parameter value obtained.| + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + + +### OH_CryptoVerify_Init() + +``` +OH_Crypto_ErrCode OH_CryptoVerify_Init (OH_CryptoVerify *ctx, OH_CryptoPubKey *pubKey ) +``` + +**Description** + +Initializes a **Verify** instance by using the public key. + +**Since**: 12 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| ctx | Pointer to the **Verify** instance.| +| pubKey | Pointer to the public key.| + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + +**See** + +[OH_CryptoVerify_Update](#oh_cryptoverify_update) + +[OH_CryptoVerify_Final](#oh_cryptoverify_final) + + +### OH_CryptoVerify_Recover() + +``` +OH_Crypto_ErrCode OH_CryptoVerify_Recover (OH_CryptoVerify *ctx, Crypto_DataBlob *signData, Crypto_DataBlob *rawSignData ) +``` + +**Description** + +Restores the signature data. + +**Since**: 12 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| ctx | Pointer to the **Verify** instance.| +| signData | Pointer to the signature data to be restored.| +| rawSignData | Pointer to the raw data restored.| + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + + +### OH_CryptoVerify_SetParam() + +``` +OH_Crypto_ErrCode OH_CryptoVerify_SetParam (OH_CryptoVerify *ctx, CryptoSignature_ParamType type, Crypto_DataBlob *value ) +``` + +**Description** + +Sets a signature verification parameter. + +**Since**: 12 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| ctx | Pointer to the **Verify** instance.| +| type | Name of the signature verification parameter to set.| +| value | Pointer to the value of the signature verification parameter to set.| + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + + +### OH_CryptoVerify_Update() + +``` +OH_Crypto_ErrCode OH_CryptoVerify_Update (OH_CryptoVerify *ctx, Crypto_DataBlob *in ) +``` + +**Description** + +Updates the data to be verified. + +**Since**: 12 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| ctx | Pointer to the **Verify** instance.| +| in | Pointer to the data to pass in.| + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + +**See** + +[OH_CryptoVerify_Init](#oh_cryptoverify_init) + +[OH_CryptoVerify_Final](#oh_cryptoverify_final) diff --git a/en/application-dev/reference/apis-crypto-architecture-kit/_crypto_sym_cipher_api.md b/en/application-dev/reference/apis-crypto-architecture-kit/_crypto_sym_cipher_api.md new file mode 100644 index 0000000000000000000000000000000000000000..539708fb51790aadaefe5caf6eae31414d106241 --- /dev/null +++ b/en/application-dev/reference/apis-crypto-architecture-kit/_crypto_sym_cipher_api.md @@ -0,0 +1,377 @@ +# CryptoSymCipherApi + + +## Overview + +Provides APIs for symmetric key encryption and decryption. + +**Since**: 12 + + +## Summary + + +### Files + +| Name| Description| +| -------- | -------- | +| [crypto_sym_cipher.h](crypto__sym__cipher_8h.md) | Defines APIs for symmetric encryption and decryption.| + + +### Types + +| Name| Description| +| -------- | -------- | +| typedef struct [OH_CryptoSymCipher](#oh_cryptosymcipher) [OH_CryptoSymCipher](#oh_cryptosymcipher) | Defines a symmetric encryption and decryption instance.| +| typedef struct [OH_CryptoSymCipherParams](#oh_cryptosymcipherparams) [OH_CryptoSymCipherParams](#oh_cryptosymcipherparams) | Defines symmetric encryption and decryption parameters.| + + +### Enums + +| Name| Description| +| -------- | -------- | +| [CryptoSymCipher_ParamsType](#cryptosymcipher_paramstype) {
CRYPTO_IV_DATABLOB = 100,
CRYPTO_AAD_DATABLOB = 101,
CRYPTO_TAG_DATABLOB = 102
} | Enumerates the types of symmetric encryption and decryption parameters.| + + +### Functions + +| Name| Description| +| -------- | -------- | +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoSymCipherParams_Create](#oh_cryptosymcipherparams_create) ([OH_CryptoSymCipherParams](#oh_cryptosymcipherparams) \*\*params) | Creates a symmetric encryption/decryption parameter instance.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoSymCipherParams_SetParam](#oh_cryptosymcipherparams_setparam) ([OH_CryptoSymCipherParams](#oh_cryptosymcipherparams) \*params, [CryptoSymCipher_ParamsType](#cryptosymcipher_paramstype) paramsType, [Crypto_DataBlob](_crypto___data_blob.md) \*value) | Sets a symmetric encryption/decryption parameter.| +| void [OH_CryptoSymCipherParams_Destroy](#oh_cryptosymcipherparams_destroy) ([OH_CryptoSymCipherParams](#oh_cryptosymcipherparams) \*params) | Destroys a symmetric encryption/decryption parameter instance.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoSymCipher_Create](#oh_cryptosymcipher_create) (const char \*algoName, [OH_CryptoSymCipher](#oh_cryptosymcipher) \*\*ctx) | Creates a symmetric cipher instance based on the given algorithm name.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoSymCipher_Init](#oh_cryptosymcipher_init) ([OH_CryptoSymCipher](#oh_cryptosymcipher) \*ctx, [Crypto_CipherMode](_crypto_common_api.md#crypto_ciphermode) mod, [OH_CryptoSymKey](_crypto_sym_key_api.md#oh_cryptosymkey) \*key, [OH_CryptoSymCipherParams](#oh_cryptosymcipherparams) \*params) | Initializes a symmetric cipher instance.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoSymCipher_Update](#oh_cryptosymcipher_update) ([OH_CryptoSymCipher](#oh_cryptosymcipher) \*ctx, [Crypto_DataBlob](_crypto___data_blob.md) \*in, [Crypto_DataBlob](_crypto___data_blob.md) \*out) | Updates the data to be encrypted or decrypted.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoSymCipher_Final](#oh_cryptosymcipher_final) ([OH_CryptoSymCipher](#oh_cryptosymcipher) \*ctx, [Crypto_DataBlob](_crypto___data_blob.md) \*in, [Crypto_DataBlob](_crypto___data_blob.md) \*out) | Outputs the remaining data (generated by the block cipher mode) and finishes the encryption or decryption operation.| +| const char \* [OH_CryptoSymCipher_GetAlgoName](#oh_cryptosymcipher_getalgoname) ([OH_CryptoSymCipher](#oh_cryptosymcipher) \*ctx) | Obtains the symmetric encryption/decryption algorithm.| +| void [OH_CryptoSymCipher_Destroy](#oh_cryptosymcipher_destroy) ([OH_CryptoSymCipher](#oh_cryptosymcipher) \*ctx) | Destroys a symmetric cipher instance.| + + +## Type Description + + +### OH_CryptoSymCipher + +``` +typedef struct OH_CryptoSymCipherOH_CryptoSymCipher +``` + +**Description** + +Defines a symmetric encryption and decryption instance. + +**Since**: 12 + + +### OH_CryptoSymCipherParams + +``` +typedef struct OH_CryptoSymCipherParamsOH_CryptoSymCipherParams +``` + +**Description** + +Defines symmetric encryption and decryption parameters. + +**Since**: 12 + + +## Enum Description + + +### CryptoSymCipher_ParamsType + +``` +enum CryptoSymCipher_ParamsType +``` + +**Description** + +Enumerates the types of symmetric encryption and decryption parameters. + +**Since**: 12 + +| Enum| Description| +| -------- | -------- | +| CRYPTO_IV_DATABLOB | Initialization vector (IV).| +| CRYPTO_AAD_DATABLOB | Additional authentication data (AAD).| +| CRYPTO_TAG_DATABLOB | authTag.| + + +## Function Description + + +### OH_CryptoSymCipher_Create() + +``` +OH_Crypto_ErrCode OH_CryptoSymCipher_Create (const char *algoName, OH_CryptoSymCipher **ctx ) +``` + +**Description** + +Creates a symmetric cipher instance based on the given algorithm name. + +**Since**: 12 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| algoName | Pointer to the algorithm used to create a symmetric cipher instance. For example, **'AES128\|GCM\|PKCS7'**.| | | +| ctx | Pointer to the symmetric cipher instance created.| + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + + +### OH_CryptoSymCipher_Destroy() + +``` +void OH_CryptoSymCipher_Destroy (OH_CryptoSymCipher *ctx) +``` + +**Description** + +Destroys a symmetric cipher instance. + +**Since**: 12 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| ctx | Pointer to the symmetric cipher instance to destroy.| + + +### OH_CryptoSymCipher_Final() + +``` +OH_Crypto_ErrCode OH_CryptoSymCipher_Final (OH_CryptoSymCipher *ctx, Crypto_DataBlob *in, Crypto_DataBlob *out ) +``` + +**Description** + +Outputs the remaining data (generated by the block cipher mode) and finishes the encryption or decryption operation. + +**Since**: 12 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| ctx | Pointer to the symmetric cipher instance.| +| in | Pointer to the data to be encrypted or decrypted.| +| out | Pointer to the remaining data encrypted or decrypted.| + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + +**See** + +[OH_CryptoSymCipher_Init](#oh_cryptosymcipher_init) + +[OH_CryptoSymCipher_Update](#oh_cryptosymcipher_update) + + +### OH_CryptoSymCipher_GetAlgoName() + +``` +const char* OH_CryptoSymCipher_GetAlgoName (OH_CryptoSymCipher *ctx) +``` + +**Description** + +Obtains the symmetric encryption/decryption algorithm. + +**Since**: 12 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| ctx | Pointer to the symmetric cipher instance.| + +**Returns** + +Symmetric encryption/decryption algorithm obtained. + + +### OH_CryptoSymCipher_Init() + +``` +OH_Crypto_ErrCode OH_CryptoSymCipher_Init (OH_CryptoSymCipher *ctx, Crypto_CipherMode mod, OH_CryptoSymKey *key, OH_CryptoSymCipherParams *params ) +``` + +**Description** + +Initializes a symmetric cipher instance. + +**Since**: 12 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| ctx | Pointer to the symmetric cipher instance.| +| mod | Operation to perform, encryption or decryption.| +| key | Pointer to the symmetric key.| +| params | Pointer to the parameters for encryption or decryption.| + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + + +### OH_CryptoSymCipher_Update() + +``` +OH_Crypto_ErrCode OH_CryptoSymCipher_Update (OH_CryptoSymCipher *ctx, Crypto_DataBlob *in, Crypto_DataBlob *out ) +``` + +**Description** + +Updates the data to be encrypted or decrypted. + +**Since**: 12 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| ctx | Pointer to the symmetric cipher instance.| +| in | Data to be encrypted or decrypted.| +| out | Pointer to the data updated.| + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + + +### OH_CryptoSymCipherParams_Create() + +``` +OH_Crypto_ErrCode OH_CryptoSymCipherParams_Create (OH_CryptoSymCipherParams **params) +``` + +**Description** + +Creates a symmetric encryption/decryption parameter instance. + +**Since**: 12 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| params | Pointer to the symmetric encryption/decryption parameter instance.| + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + + +### OH_CryptoSymCipherParams_Destroy() + +``` +void OH_CryptoSymCipherParams_Destroy (OH_CryptoSymCipherParams *params) +``` + +**Description** + +Destroys a symmetric encryption/decryption parameter instance. + +**Since**: 12 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| params | Pointer to the symmetric encryption/decryption parameter instance.| + + +### OH_CryptoSymCipherParams_SetParam() + +``` +OH_Crypto_ErrCode OH_CryptoSymCipherParams_SetParam (OH_CryptoSymCipherParams *params, CryptoSymCipher_ParamsType paramsType, Crypto_DataBlob *value ) +``` + +**Description** + +Sets a symmetric encryption/decryption parameter. + +**Since**: 12 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| params | Pointer to the symmetric encryption/decryption parameter instance.| +| paramsType | Name of the parameter to set.| +| value | Pointer to the parameter value set.| + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. diff --git a/en/application-dev/reference/apis-crypto-architecture-kit/_crypto_sym_key_api.md b/en/application-dev/reference/apis-crypto-architecture-kit/_crypto_sym_key_api.md new file mode 100644 index 0000000000000000000000000000000000000000..9461350668e1b150848032f2914aa451cbdcf036 --- /dev/null +++ b/en/application-dev/reference/apis-crypto-architecture-kit/_crypto_sym_key_api.md @@ -0,0 +1,293 @@ +# CryptoSymKeyApi + + +## Overview + +Provides APIs for symmetric key operations. + +**Since**: 12 + + +## Summary + + +### Files + +| Name | Description | +| -------- | -------- | +| [crypto_sym_key.h](crypto__sym__key_8h.md) | Defines APIs for symmetric key operations. | + + +### Types + +| Name | Description | +| -------- | -------- | +| typedef struct [OH_CryptoSymKey](#oh_cryptosymkey) [OH_CryptoSymKey](#oh_cryptosymkey) | Defines a struct for a symmetric key. | +| typedef struct [OH_CryptoSymKeyGenerator](#oh_cryptosymkeygenerator) [OH_CryptoSymKeyGenerator](#oh_cryptosymkeygenerator) | Defines a struct for a symmetric key generator. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoSymKeyGenerator_Create](#oh_cryptosymkeygenerator_create) (const char \*algoName, [OH_CryptoSymKeyGenerator](#oh_cryptosymkeygenerator) \*\*ctx) | Creates a symmetric key generator instance based on the given algorithm name. | +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoSymKeyGenerator_Generate](#oh_cryptosymkeygenerator_generate) ([OH_CryptoSymKeyGenerator](#oh_cryptosymkeygenerator) \*ctx, [OH_CryptoSymKey](#oh_cryptosymkey) \*\*keyCtx) | Randomly generates a symmetric key. | +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoSymKeyGenerator_Convert](#oh_cryptosymkeygenerator_convert) ([OH_CryptoSymKeyGenerator](#oh_cryptosymkeygenerator) \*ctx, const [Crypto_DataBlob](_crypto___data_blob.md) \*keyData, [OH_CryptoSymKey](#oh_cryptosymkey) \*\*keyCtx) | Converts binary data into a symmetric key. | +| const char \* [OH_CryptoSymKeyGenerator_GetAlgoName](#oh_cryptosymkeygenerator_getalgoname) ([OH_CryptoSymKeyGenerator](#oh_cryptosymkeygenerator) \*ctx) | Obtains the algorithm of a symmetric key generator instance. | +| void [OH_CryptoSymKeyGenerator_Destroy](#oh_cryptosymkeygenerator_destroy) ([OH_CryptoSymKeyGenerator](#oh_cryptosymkeygenerator) \*ctx) | Destroys a symmetric key generator instance. | +| const char \* [OH_CryptoSymKey_GetAlgoName](#oh_cryptosymkey_getalgoname) ([OH_CryptoSymKey](#oh_cryptosymkey) \*keyCtx) | Obtains the algorithm of a symmetric key. | +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoSymKey_GetKeyData](#oh_cryptosymkey_getkeydata) ([OH_CryptoSymKey](#oh_cryptosymkey) \*keyCtx, [Crypto_DataBlob](_crypto___data_blob.md) \*out) | Obtains symmetric key data from a key instance. | +| void [OH_CryptoSymKey_Destroy](#oh_cryptosymkey_destroy) ([OH_CryptoSymKey](#oh_cryptosymkey) \*keyCtx) | Destroys a symmetric key instance. | + + +## Type Description + + +### OH_CryptoSymKey + +``` +typedef struct OH_CryptoSymKeyOH_CryptoSymKey +``` + +**Description** + +Defines a struct for a symmetric key. + +**Since**: 12 + + +### OH_CryptoSymKeyGenerator + +``` +typedef struct OH_CryptoSymKeyGeneratorOH_CryptoSymKeyGenerator +``` + +**Description** + +Defines a struct for a symmetric key generator. + +**Since**: 12 + + +## Function Description + + +### OH_CryptoSymKey_Destroy() + +``` +void OH_CryptoSymKey_Destroy (OH_CryptoSymKey *keyCtx) +``` + +**Description** + +Destroys a symmetric key instance. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| keyCtx | Pointer to the symmetric key instance to destroy. | + + +### OH_CryptoSymKey_GetAlgoName() + +``` +const char* OH_CryptoSymKey_GetAlgoName (OH_CryptoSymKey *keyCtx) +``` + +**Description** + +Obtains the algorithm of a symmetric key. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| keyCtx | Pointer to the symmetric key instance. | + +**Returns** + +Symmetric key algorithm obtained. + + +### OH_CryptoSymKey_GetKeyData() + +``` +OH_Crypto_ErrCode OH_CryptoSymKey_GetKeyData (OH_CryptoSymKey *keyCtx, Crypto_DataBlob *out ) +``` + +**Description** + +Obtains symmetric key data from a key instance. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| keyCtx | Pointer to the symmetric key instance. | +| out | Pointer to the data obtained. | + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + + +### OH_CryptoSymKeyGenerator_Convert() + +``` +OH_Crypto_ErrCode OH_CryptoSymKeyGenerator_Convert (OH_CryptoSymKeyGenerator *ctx, const Crypto_DataBlob *keyData, OH_CryptoSymKey **keyCtx ) +``` + +**Description** + +Converts binary data into a symmetric key. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| ctx | Pointer to the symmetric key generator instance. | +| keyData | Pointer to the data to convert. | +| keyCtx | Pointer to the symmetric key obtained. | + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + + +### OH_CryptoSymKeyGenerator_Create() + +``` +OH_Crypto_ErrCode OH_CryptoSymKeyGenerator_Create (const char *algoName, OH_CryptoSymKeyGenerator **ctx ) +``` + +**Description** + +Creates a symmetric key generator instance based on the given algorithm name. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| algoName | Pointer to the algorithm used to generate the symmetric key. For example, **'AES256'**. | +| ctx | Double pointer to the symmetric key generator instance created. | + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + + +### OH_CryptoSymKeyGenerator_Destroy() + +``` +void OH_CryptoSymKeyGenerator_Destroy (OH_CryptoSymKeyGenerator *ctx) +``` + +**Description** + +Destroys a symmetric key generator instance. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| ctx | Pointer to the symmetric key generator instance to destroy. | + + +### OH_CryptoSymKeyGenerator_Generate() + +``` +OH_Crypto_ErrCode OH_CryptoSymKeyGenerator_Generate (OH_CryptoSymKeyGenerator *ctx, OH_CryptoSymKey **keyCtx ) +``` + +**Description** + +Randomly generates a symmetric key. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| ctx | Pointer to the symmetric key generator instance. | +| keyCtx | Pointer to the symmetric key created. | + +**Returns** + +[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): + +**0**: The operation is successful. + +**401**: Invalid parameters are detected. + +**801**: The operation is not supported. + +**17620001**: A memory error occurred. + +**17630001**: Failed to call an API of a third-party algorithm library. + + +### OH_CryptoSymKeyGenerator_GetAlgoName() + +``` +const char* OH_CryptoSymKeyGenerator_GetAlgoName (OH_CryptoSymKeyGenerator *ctx) +``` + +**Description** + +Obtains the algorithm of a symmetric key generator instance. + +**Since**: 12 + +**Parameters** + +| Name | Description | +| -------- | -------- | +| ctx | Pointer to the symmetric key generator instance. | + +**Returns** + +Symmetric key algorithm obtained. diff --git a/en/application-dev/reference/apis-crypto-architecture-kit/crypto__asym__key_8h.md b/en/application-dev/reference/apis-crypto-architecture-kit/crypto__asym__key_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..92203bddc49f79554239c8aae4de1eafaa68450c --- /dev/null +++ b/en/application-dev/reference/apis-crypto-architecture-kit/crypto__asym__key_8h.md @@ -0,0 +1,49 @@ +# crypto_asym_key.h + + +## Overview + +Provides APIs for asymmetric keys. + +**Library**: libohcrypto.so + +**System capability**: SystemCapability.Security.CryptoFramework + +**Since**: 12 + +**Related module**: [CryptoAsymKeyApi](_crypto_asym_key_api.md) + + +## Summary + + +### Types + +| Name| Description| +| -------- | -------- | +| typedef struct [OH_CryptoKeyPair](_crypto_asym_key_api.md#oh_cryptokeypair) [OH_CryptoKeyPair](_crypto_asym_key_api.md#oh_cryptokeypair) | Defines an asymmetric key pair.| +| typedef struct [OH_CryptoPubKey](_crypto_asym_key_api.md#oh_cryptopubkey) [OH_CryptoPubKey](_crypto_asym_key_api.md#oh_cryptopubkey) | Defines the public key in an asymmetric key pair.| +| typedef struct [OH_CryptoAsymKeyGenerator](_crypto_asym_key_api.md#oh_cryptoasymkeygenerator) [OH_CryptoAsymKeyGenerator](_crypto_asym_key_api.md#oh_cryptoasymkeygenerator) | Defines an asymmetric key generator.| + + +### Enums + +| Name| Description| +| -------- | -------- | +| [CryptoAsymKey_ParamType](_crypto_asym_key_api.md#cryptoasymkey_paramtype) {
CRYPTO_DSA_P_DATABLOB = 101, CRYPTO_DSA_Q_DATABLOB = 102,
CRYPTO_DSA_G_DATABLOB = 103, CRYPTO_DSA_SK_DATABLOB = 104,
CRYPTO_DSA_PK_DATABLOB = 105, CRYPTO_ECC_FP_P_DATABLOB = 201,
CRYPTO_ECC_A_DATABLOB = 202, CRYPTO_ECC_B_DATABLOB = 203,
CRYPTO_ECC_G_X_DATABLOB = 204, CRYPTO_ECC_G_Y_DATABLOB = 205,
CRYPTO_ECC_N_DATABLOB = 206, CRYPTO_ECC_H_INT = 207,
CRYPTO_ECC_SK_DATABLOB = 208, CRYPTO_ECC_PK_X_DATABLOB = 209,
CRYPTO_ECC_PK_Y_DATABLOB = 210, CRYPTO_ECC_FIELD_TYPE_STR = 211,
CRYPTO_ECC_FIELD_SIZE_INT = 212, CRYPTO_ECC_CURVE_NAME_STR = 213,
CRYPTO_RSA_N_DATABLOB = 301, CRYPTO_RSA_D_DATABLOB = 302,
CRYPTO_RSA_E_DATABLOB = 303, CRYPTO_DH_P_DATABLOB = 401,
CRYPTO_DH_G_DATABLOB = 402, CRYPTO_DH_L_NUM = 403,
CRYPTO_DH_SK_DATABLOB = 404, CRYPTO_DH_PK_DATABLOB = 405,
CRYPTO_ED25519_SK_DATABLOB = 501, CRYPTO_ED25519_PK_DATABLOB = 502,
CRYPTO_X25519_SK_DATABLOB = 601, CRYPTO_X25519_PK_DATABLOB = 602
} | Enumerates the types of the asymmetric key parameters.| +| [Crypto_EncodingType](_crypto_asym_key_api.md#crypto_encodingtype) { CRYPTO_PEM = 0, CRYPTO_DER = 1 } | Enumerates the encoding types.| + + +### Functions + +| Name| Description| +| -------- | -------- | +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoAsymKeyGenerator_Create](_crypto_asym_key_api.md#oh_cryptoasymkeygenerator_create) (const char \*algoName, [OH_CryptoAsymKeyGenerator](_crypto_asym_key_api.md#oh_cryptoasymkeygenerator) \*\*ctx) | Creates an asymmetric key generator instance based on the specified algorithm.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoAsymKeyGenerator_Generate](_crypto_asym_key_api.md#oh_cryptoasymkeygenerator_generate) ([OH_CryptoAsymKeyGenerator](_crypto_asym_key_api.md#oh_cryptoasymkeygenerator) \*ctx, [OH_CryptoKeyPair](_crypto_asym_key_api.md#oh_cryptokeypair) \*\*keyCtx) | Randomly generates an asymmetric key pair.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoAsymKeyGenerator_Convert](_crypto_asym_key_api.md#oh_cryptoasymkeygenerator_convert) ([OH_CryptoAsymKeyGenerator](_crypto_asym_key_api.md#oh_cryptoasymkeygenerator) \*ctx, [Crypto_EncodingType](_crypto_asym_key_api.md#crypto_encodingtype) type, [Crypto_DataBlob](_crypto___data_blob.md) \*pubKeyData, [Crypto_DataBlob](_crypto___data_blob.md) \*priKeyData, [OH_CryptoKeyPair](_crypto_asym_key_api.md#oh_cryptokeypair) \*\*keyCtx) | Converts asymmetric key data into a key pair.| +| const char \* [OH_CryptoAsymKeyGenerator_GetAlgoName](_crypto_asym_key_api.md#oh_cryptoasymkeygenerator_getalgoname) ([OH_CryptoAsymKeyGenerator](_crypto_asym_key_api.md#oh_cryptoasymkeygenerator) \*ctx) | Obtains the asymmetric key algorithm.| +| void [OH_CryptoAsymKeyGenerator_Destroy](_crypto_asym_key_api.md#oh_cryptoasymkeygenerator_destroy) ([OH_CryptoAsymKeyGenerator](_crypto_asym_key_api.md#oh_cryptoasymkeygenerator) \*ctx) | Destroys an asymmetric key generator instance.| +| void [OH_CryptoKeyPair_Destroy](_crypto_asym_key_api.md#oh_cryptokeypair_destroy) ([OH_CryptoKeyPair](_crypto_asym_key_api.md#oh_cryptokeypair) \*keyCtx) | Destroys an asymmetric key pair instance.| +| [OH_CryptoPubKey](_crypto_asym_key_api.md#oh_cryptopubkey) \* [OH_CryptoKeyPair_GetPubKey](_crypto_asym_key_api.md#oh_cryptokeypair_getpubkey) ([OH_CryptoKeyPair](_crypto_asym_key_api.md#oh_cryptokeypair) \*keyCtx) | Obtains the public key instance from a key pair.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoPubKey_Encode](_crypto_asym_key_api.md#oh_cryptopubkey_encode) ([OH_CryptoPubKey](_crypto_asym_key_api.md#oh_cryptopubkey) \*key, [Crypto_EncodingType](_crypto_asym_key_api.md#crypto_encodingtype) type, const char \*encodingStandard, [Crypto_DataBlob](_crypto___data_blob.md) \*out) | Obtains public key data in the specified encoding format.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoPubKey_GetParam](_crypto_asym_key_api.md#oh_cryptopubkey_getparam) ([OH_CryptoPubKey](_crypto_asym_key_api.md#oh_cryptopubkey) \*key, [CryptoAsymKey_ParamType](_crypto_asym_key_api.md#cryptoasymkey_paramtype) item, [Crypto_DataBlob](_crypto___data_blob.md) \*value) | Obtains the specified parameter from a public key instance.| diff --git a/en/application-dev/reference/apis-crypto-architecture-kit/crypto__common_8h.md b/en/application-dev/reference/apis-crypto-architecture-kit/crypto__common_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..94fd3878a1b8aae9dc7e8088970b07b57b14442a --- /dev/null +++ b/en/application-dev/reference/apis-crypto-architecture-kit/crypto__common_8h.md @@ -0,0 +1,46 @@ +# crypto_common.h + + +## Overview + +Provides common APIs for cryptographic operations. + +**Library**: libohcrypto.so + +**System capability**: SystemCapability.Security.CryptoFramework + +**Since**: 12 + +**Related module**: [CryptoCommonApi](_crypto_common_api.md) + + +## Summary + + +### Structs + +| Name| Description| +| -------- | -------- | +| struct [Crypto_DataBlob](_crypto___data_blob.md) | Defines the data used for encryption and decryption.| + + +### Types + +| Name| Description| +| -------- | -------- | +| typedef struct [Crypto_DataBlob](_crypto___data_blob.md) [Crypto_DataBlob](_crypto_common_api.md#crypto_datablob) | Defines a struct for the data used for encryption and decryption.| + + +### Enums + +| Name| Description| +| -------- | -------- | +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) {
CRYPTO_SUCCESS = 0, CRYPTO_INVALID_PARAMS = 401,
CRYPTO_NOT_SUPPORT = 801, CRYPTO_MEMORY_ERROR = 17620001,
CRYPTO_OPERTION_ERROR = 17630001
} | Enumerates the encryption and decryption error codes.| +| [Crypto_CipherMode](_crypto_common_api.md#crypto_ciphermode) {
CRYPTO_ENCRYPT_MODE = 0,
CRYPTO_DECRYPT_MODE = 1
} | Enumerates the cryptographic operation types.| + + +### Functions + +| Name| Description| +| -------- | -------- | +| void [OH_Crypto_FreeDataBlob](_crypto_common_api.md#oh_crypto_freedatablob) ([Crypto_DataBlob](_crypto___data_blob.md) \*dataBlob) | Releases a **dataBlob** instance.| diff --git a/en/application-dev/reference/apis-crypto-architecture-kit/crypto__digest_8h.md b/en/application-dev/reference/apis-crypto-architecture-kit/crypto__digest_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..55edd8f77d8357e55e3cdf9094c345ed88b1f73e --- /dev/null +++ b/en/application-dev/reference/apis-crypto-architecture-kit/crypto__digest_8h.md @@ -0,0 +1,36 @@ +# crypto_digest.h + + +## Overview + +Provides APIs for message digest (MD) algorithms. + +**Library**: libohcrypto.so + +**System capability**: SystemCapability.Security.CryptoFramework + +**Since**: 12 + +**Related module**: [CryptoDigestApi](_crypto_digest_api.md) + + +## Summary + + +### Types + +| Name| Description| +| -------- | -------- | +| typedef struct [OH_CryptoDigest](_crypto_digest_api.md#oh_cryptodigest) [OH_CryptoDigest](_crypto_digest_api.md#oh_cryptodigest) | Defines an MD.| + + +### Functions + +| Name| Description| +| -------- | -------- | +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoDigest_Create](_crypto_digest_api.md#oh_cryptodigest_create) (const char \*algoName, [OH_CryptoDigest](_crypto_digest_api.md#oh_cryptodigest) \*\*ctx) | Creates an MD instance based on the given algorithm name.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoDigest_Update](_crypto_digest_api.md#oh_cryptodigest_update) ([OH_CryptoDigest](_crypto_digest_api.md#oh_cryptodigest) \*ctx, [Crypto_DataBlob](_crypto___data_blob.md) \*in) | Updates the data used for generating an MD.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoDigest_Final](_crypto_digest_api.md#oh_cryptodigest_final) ([OH_CryptoDigest](_crypto_digest_api.md#oh_cryptodigest) \*ctx, [Crypto_DataBlob](_crypto___data_blob.md) \*out) | Generates an MD.| +| uint32_t [OH_CryptoDigest_GetLength](_crypto_digest_api.md#oh_cryptodigest_getlength) ([OH_CryptoDigest](_crypto_digest_api.md#oh_cryptodigest) \*ctx) | Obtains the length of an MD.| +| const char \* [OH_CryptoDigest_GetAlgoName](_crypto_digest_api.md#oh_cryptodigest_getalgoname) ([OH_CryptoDigest](_crypto_digest_api.md#oh_cryptodigest) \*ctx) | Obtains the digest algorithm.| +| void [OH_DigestCrypto_Destroy](_crypto_digest_api.md#oh_digestcrypto_destroy) ([OH_CryptoDigest](_crypto_digest_api.md#oh_cryptodigest) \*ctx) | Destroys an MD instance.| diff --git a/en/application-dev/reference/apis-crypto-architecture-kit/crypto__signature_8h.md b/en/application-dev/reference/apis-crypto-architecture-kit/crypto__signature_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..0b5bb487e9723511ad5200390678fae336f08b6b --- /dev/null +++ b/en/application-dev/reference/apis-crypto-architecture-kit/crypto__signature_8h.md @@ -0,0 +1,46 @@ +# crypto_signature.h + + +## Overview + +Provides APIs for signature verification. + +**Library**: libohcrypto.so + +**System capability**: SystemCapability.Security.CryptoFramework + +**Since**: 12 + +**Related module**: [CryptoSignatureApi](_crypto_signature_api.md) + + +## Summary + + +### Types + +| Name| Description| +| -------- | -------- | +| typedef struct [OH_CryptoVerify](_crypto_signature_api.md#oh_cryptoverify) [OH_CryptoVerify](_crypto_signature_api.md#oh_cryptoverify) | Defines the data used for signature verification.| + + +### Enums + +| Name| Description| +| -------- | -------- | +| [CryptoSignature_ParamType](_crypto_signature_api.md#cryptosignature_paramtype) {
CRYPTO_PSS_MD_NAME_STR = 100, CRYPTO_PSS_MGF_NAME_STR = 101,
CRYPTO_PSS_MGF1_NAME_STR = 102, CRYPTO_PSS_SALT_LEN_INT = 103,
CRYPTO_PSS_TRAILER_FIELD_INT = 104, CRYPTO_SM2_USER_ID_DATABLOB = 105
} | Enumerates the types of signature verification parameters.| + + +### Functions + +| Name| Description| +| -------- | -------- | +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoVerify_Create](_crypto_signature_api.md#oh_cryptoverify_create) (const char \*algoName, [OH_CryptoVerify](_crypto_signature_api.md#oh_cryptoverify) \*\*verify) | Creates a **Verify** instance for signature verification.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoVerify_Init](_crypto_signature_api.md#oh_cryptoverify_init) ([OH_CryptoVerify](_crypto_signature_api.md#oh_cryptoverify) \*ctx, [OH_CryptoPubKey](_crypto_asym_key_api.md#oh_cryptopubkey) \*pubKey) | Initializes a **Verify** instance by using the public key.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoVerify_Update](_crypto_signature_api.md#oh_cryptoverify_update) ([OH_CryptoVerify](_crypto_signature_api.md#oh_cryptoverify) \*ctx, [Crypto_DataBlob](_crypto___data_blob.md) \*in) | Updates the data to be verified.| +| bool [OH_CryptoVerify_Final](_crypto_signature_api.md#oh_cryptoverify_final) ([OH_CryptoVerify](_crypto_signature_api.md#oh_cryptoverify) \*ctx, [Crypto_DataBlob](_crypto___data_blob.md) \*in, [Crypto_DataBlob](_crypto___data_blob.md) \*signData) | Verifies the signature of the data.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoVerify_Recover](_crypto_signature_api.md#oh_cryptoverify_recover) ([OH_CryptoVerify](_crypto_signature_api.md#oh_cryptoverify) \*ctx, [Crypto_DataBlob](_crypto___data_blob.md) \*signData, [Crypto_DataBlob](_crypto___data_blob.md) \*rawSignData) | Restores the signature data.| +| const char \* [OH_CryptoVerify_GetAlgoName](_crypto_signature_api.md#oh_cryptoverify_getalgoname) ([OH_CryptoVerify](_crypto_signature_api.md#oh_cryptoverify) \*ctx) | Obtains the signature verification algorithm.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoVerify_SetParam](_crypto_signature_api.md#oh_cryptoverify_setparam) ([OH_CryptoVerify](_crypto_signature_api.md#oh_cryptoverify) \*ctx, [CryptoSignature_ParamType](_crypto_signature_api.md#cryptosignature_paramtype) type, [Crypto_DataBlob](_crypto___data_blob.md) \*value) | Sets signature verification parameters.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoVerify_GetParam](_crypto_signature_api.md#oh_cryptoverify_getparam) ([OH_CryptoVerify](_crypto_signature_api.md#oh_cryptoverify) \*ctx, [CryptoSignature_ParamType](_crypto_signature_api.md#cryptosignature_paramtype) type, [Crypto_DataBlob](_crypto___data_blob.md) \*value) | Obtains signature verification parameters.| +| void [OH_CryptoVerify_Destroy](_crypto_signature_api.md#oh_cryptoverify_destroy) ([OH_CryptoVerify](_crypto_signature_api.md#oh_cryptoverify) \*ctx) | Destroys a **Verify** instance.| diff --git a/en/application-dev/reference/apis-crypto-architecture-kit/crypto__sym__cipher_8h.md b/en/application-dev/reference/apis-crypto-architecture-kit/crypto__sym__cipher_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..847fee6e21464a1225b8e0964992fce11309a281 --- /dev/null +++ b/en/application-dev/reference/apis-crypto-architecture-kit/crypto__sym__cipher_8h.md @@ -0,0 +1,47 @@ +# crypto_sym_cipher.h + + +## Overview + +Provides APIs for symmetric encryption and decryption. + +**Library**: libohcrypto.so + +**System capability**: SystemCapability.Security.CryptoFramework + +**Since**: 12 + +**Related module**: [CryptoSymCipherApi](_crypto_sym_cipher_api.md) + + +## Summary + + +### Types + +| Name| Description| +| -------- | -------- | +| typedef struct [OH_CryptoSymCipher](_crypto_sym_cipher_api.md#oh_cryptosymcipher) [OH_CryptoSymCipher](_crypto_sym_cipher_api.md#oh_cryptosymcipher) | Defines a symmetric encryption and decryption instance.| +| typedef struct [OH_CryptoSymCipherParams](_crypto_sym_cipher_api.md#oh_cryptosymcipherparams) [OH_CryptoSymCipherParams](_crypto_sym_cipher_api.md#oh_cryptosymcipherparams) | Defines symmetric encryption and decryption parameters.| + + +### Enums + +| Name| Description| +| -------- | -------- | +| [CryptoSymCipher_ParamsType](_crypto_sym_cipher_api.md#cryptosymcipher_paramstype) {
CRYPTO_IV_DATABLOB = 100,
CRYPTO_AAD_DATABLOB = 101,
CRYPTO_TAG_DATABLOB = 102
} | Enumerates the types of symmetric encryption and decryption parameters.| + + +### Functions + +| Name| Description| +| -------- | -------- | +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoSymCipherParams_Create](_crypto_sym_cipher_api.md#oh_cryptosymcipherparams_create) ([OH_CryptoSymCipherParams](_crypto_sym_cipher_api.md#oh_cryptosymcipherparams) \*\*params) | Creates a symmetric encryption/decryption parameter instance.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoSymCipherParams_SetParam](_crypto_sym_cipher_api.md#oh_cryptosymcipherparams_setparam) ([OH_CryptoSymCipherParams](_crypto_sym_cipher_api.md#oh_cryptosymcipherparams) \*params, [CryptoSymCipher_ParamsType](_crypto_sym_cipher_api.md#cryptosymcipher_paramstype) paramsType, [Crypto_DataBlob](_crypto___data_blob.md) \*value) | Sets symmetric encryption/decryption parameters.| +| void [OH_CryptoSymCipherParams_Destroy](_crypto_sym_cipher_api.md#oh_cryptosymcipherparams_destroy) ([OH_CryptoSymCipherParams](_crypto_sym_cipher_api.md#oh_cryptosymcipherparams) \*params) | Destroys a symmetric encryption/decryption parameter instance.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoSymCipher_Create](_crypto_sym_cipher_api.md#oh_cryptosymcipher_create) (const char \*algoName, [OH_CryptoSymCipher](_crypto_sym_cipher_api.md#oh_cryptosymcipher) \*\*ctx) | Creates a symmetric encryption/decryption instance based on the given algorithm name.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoSymCipher_Init](_crypto_sym_cipher_api.md#oh_cryptosymcipher_init) ([OH_CryptoSymCipher](_crypto_sym_cipher_api.md#oh_cryptosymcipher) \*ctx, [Crypto_CipherMode](_crypto_common_api.md#crypto_ciphermode) mod, [OH_CryptoSymKey](_crypto_sym_key_api.md#oh_cryptosymkey) \*key, [OH_CryptoSymCipherParams](_crypto_sym_cipher_api.md#oh_cryptosymcipherparams) \*params) | Initializes a symmetric encryption/decryption instance.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoSymCipher_Update](_crypto_sym_cipher_api.md#oh_cryptosymcipher_update) ([OH_CryptoSymCipher](_crypto_sym_cipher_api.md#oh_cryptosymcipher) \*ctx, [Crypto_DataBlob](_crypto___data_blob.md) \*in, [Crypto_DataBlob](_crypto___data_blob.md) \*out) | Updates the data to be encrypted or decrypted.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoSymCipher_Final](_crypto_sym_cipher_api.md#oh_cryptosymcipher_final) ([OH_CryptoSymCipher](_crypto_sym_cipher_api.md#oh_cryptosymcipher) \*ctx, [Crypto_DataBlob](_crypto___data_blob.md) \*in, [Crypto_DataBlob](_crypto___data_blob.md) \*out) | Finishes the encryption or decryption operation.| +| const char \* [OH_CryptoSymCipher_GetAlgoName](_crypto_sym_cipher_api.md#oh_cryptosymcipher_getalgoname) ([OH_CryptoSymCipher](_crypto_sym_cipher_api.md#oh_cryptosymcipher) \*ctx) | Obtains the symmetric encryption/decryption algorithm.| +| void [OH_CryptoSymCipher_Destroy](_crypto_sym_cipher_api.md#oh_cryptosymcipher_destroy) ([OH_CryptoSymCipher](_crypto_sym_cipher_api.md#oh_cryptosymcipher) \*ctx) | Destroys a symmetric encryption/decryption instance.| diff --git a/en/application-dev/reference/apis-crypto-architecture-kit/crypto__sym__key_8h.md b/en/application-dev/reference/apis-crypto-architecture-kit/crypto__sym__key_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..45425d108e03fb8497cd93aac64e4e24f13b5475 --- /dev/null +++ b/en/application-dev/reference/apis-crypto-architecture-kit/crypto__sym__key_8h.md @@ -0,0 +1,39 @@ +# crypto_sym_key.h + + +## Overview + +Provides APIs for symmetric key operations. + +**Library**: libohcrypto.so + +**System capability**: SystemCapability.Security.CryptoFramework + +**Since**: 12 + +**Related module**: [CryptoSymKeyApi](_crypto_sym_key_api.md) + + +## Summary + + +### Types + +| Name| Description| +| -------- | -------- | +| typedef struct [OH_CryptoSymKey](_crypto_sym_key_api.md#oh_cryptosymkey) [OH_CryptoSymKey](_crypto_sym_key_api.md#oh_cryptosymkey) | Defines a struct for a symmetric key.| +| typedef struct [OH_CryptoSymKeyGenerator](_crypto_sym_key_api.md#oh_cryptosymkeygenerator) [OH_CryptoSymKeyGenerator](_crypto_sym_key_api.md#oh_cryptosymkeygenerator) | Defines a struct for a symmetric key generator.| + + +### Functions + +| Name| Description| +| -------- | -------- | +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoSymKeyGenerator_Create](_crypto_sym_key_api.md#oh_cryptosymkeygenerator_create) (const char \*algoName, [OH_CryptoSymKeyGenerator](_crypto_sym_key_api.md#oh_cryptosymkeygenerator) \*\*ctx) | Creates a symmetric key generator instance based on the given algorithm name.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoSymKeyGenerator_Generate](_crypto_sym_key_api.md#oh_cryptosymkeygenerator_generate) ([OH_CryptoSymKeyGenerator](_crypto_sym_key_api.md#oh_cryptosymkeygenerator) \*ctx, [OH_CryptoSymKey](_crypto_sym_key_api.md#oh_cryptosymkey) \*\*keyCtx) | Randomly generates a symmetric key.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoSymKeyGenerator_Convert](_crypto_sym_key_api.md#oh_cryptosymkeygenerator_convert) ([OH_CryptoSymKeyGenerator](_crypto_sym_key_api.md#oh_cryptosymkeygenerator) \*ctx, const [Crypto_DataBlob](_crypto___data_blob.md) \*keyData, [OH_CryptoSymKey](_crypto_sym_key_api.md#oh_cryptosymkey) \*\*keyCtx) | Converts binary data into a symmetric key.| +| const char \* [OH_CryptoSymKeyGenerator_GetAlgoName](_crypto_sym_key_api.md#oh_cryptosymkeygenerator_getalgoname) ([OH_CryptoSymKeyGenerator](_crypto_sym_key_api.md#oh_cryptosymkeygenerator) \*ctx) | Obtains the algorithm of a symmetric key generator instance.| +| void [OH_CryptoSymKeyGenerator_Destroy](_crypto_sym_key_api.md#oh_cryptosymkeygenerator_destroy) ([OH_CryptoSymKeyGenerator](_crypto_sym_key_api.md#oh_cryptosymkeygenerator) \*ctx) | Destroys a symmetric key generator instance.| +| const char \* [OH_CryptoSymKey_GetAlgoName](_crypto_sym_key_api.md#oh_cryptosymkey_getalgoname) ([OH_CryptoSymKey](_crypto_sym_key_api.md#oh_cryptosymkey) \*keyCtx) | Obtains the algorithm of a symmetric key.| +| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoSymKey_GetKeyData](_crypto_sym_key_api.md#oh_cryptosymkey_getkeydata) ([OH_CryptoSymKey](_crypto_sym_key_api.md#oh_cryptosymkey) \*keyCtx, [Crypto_DataBlob](_crypto___data_blob.md) \*out) | Obtains symmetric key data from a key instance.| +| void [OH_CryptoSymKey_Destroy](_crypto_sym_key_api.md#oh_cryptosymkey_destroy) ([OH_CryptoSymKey](_crypto_sym_key_api.md#oh_cryptosymkey) \*keyCtx) | Destroys a symmetric key instance.| diff --git a/en/application-dev/reference/apis-data-protection-kit/_dlp_permission_api.md b/en/application-dev/reference/apis-data-protection-kit/_dlp_permission_api.md new file mode 100644 index 0000000000000000000000000000000000000000..32af0d822aaf5748af9b065df83866695e69d648 --- /dev/null +++ b/en/application-dev/reference/apis-data-protection-kit/_dlp_permission_api.md @@ -0,0 +1,269 @@ +# DlpPermissionApi + + +## Overview + +Data loss prevention (DLP) is a system solution provided to prevent data disclosure. The **dlppermissionapi** file provides APIs for cross-device file access management, encrypted storage, and access authorization. + +**Since**: 14 + + +## Summary + + +### Files + +| Name| Description| +| -------- | -------- | +| [dlp_permission_api.h](dlp__permission__api_8h.md) | Defines the APIs for cross-device file access management, encrypted storage, and access authorization. | + + +### Enums + +| Name| Description| +| -------- | -------- | +| [DLP_ErrCode](#dlp_errcode) {
ERR_OH_SUCCESS = 0,
ERR_OH_INVALID_PARAMETER = 19100001,
ERR_OH_API_ONLY_FOR_SANDBOX = 19100006,
ERR_OH_API_NOT_FOR_SANDBOX = 19100007,
ERR_OH_SYSTEM_SERVICE_EXCEPTION = 19100011,
ERR_OH_OUT_OF_MEMORY = 19100012,
ERR_OH_APPLICATION_NOT_AUTHORIZED = 19100018
} | Enumerates the DLP error codes.| +| [DLP_FileAccess](#dlp_fileaccess) {
NO_PERMISSION = 0,
READ_ONLY = 1,
CONTENT_EDIT = 2,
FULL_CONTROL = 3
} | Enumerates the permissions on a DLP file.| + + +### Functions + +| Name| Description| +| -------- | -------- | +| [DLP_ErrCode](#dlp_errcode) [OH_DLP_GetDlpPermissionInfo](#oh_dlp_getdlppermissioninfo) ([DLP_FileAccess](#dlp_fileaccess) \*dlpFileAccess, uint32_t \*flags) | Obtains the permission information of this DLP file.| +| [DLP_ErrCode](#dlp_errcode) [OH_DLP_GetOriginalFileName](#oh_dlp_getoriginalfilename) (const char \*fileName, char \*\*originalFileName) | Obtains the original file name of a DLP file.| +| [DLP_ErrCode](#dlp_errcode) [OH_DLP_IsInSandbox](#oh_dlp_isinsandbox) (bool \*isInSandbox) | Checks whether this application is running in a DLP sandbox environment.| +| [DLP_ErrCode](#dlp_errcode) [OH_DLP_SetSandboxAppConfig](#oh_dlp_setsandboxappconfig) (const char \*configInfo) | Sets sandbox application configuration.| +| [DLP_ErrCode](#dlp_errcode) [OH_DLP_GetSandboxAppConfig](#oh_dlp_getsandboxappconfig) (char \*\*configInfo) | Obtains the sandbox application configuration.| +| [DLP_ErrCode](#dlp_errcode) [OH_DLP_CleanSandboxAppConfig](#oh_dlp_cleansandboxappconfig) () | Cleans the sandbox application configuration.| + + +## Enum Description + + +### DLP_ErrCode + +``` +enum DLP_ErrCode +``` + +**Description** + +Enumerates the DLP error codes. + +**Since**: 14 + +| Value| Description| +| -------- | -------- | +| ERR_OH_SUCCESS | The operation is successful.| +| ERR_OH_INVALID_PARAMETER | Invalid parameters are specified.| +| ERR_OH_API_ONLY_FOR_SANDBOX | The caller is not a DLP sandbox application.| +| ERR_OH_API_NOT_FOR_SANDBOX | The API is not available to a DLP sandbox application.| +| ERR_OH_SYSTEM_SERVICE_EXCEPTION | The system service is abnormal.| +| ERR_OH_OUT_OF_MEMORY | The memory allocation fails.| +| ERR_OH_APPLICATION_NOT_AUTHORIZED | The application is not authorized to perform the operation.| + + +### DLP_FileAccess + +``` +enum DLP_FileAccess +``` + +**Description** + +Enumerates the permissions on a DLP file. + +**Since**: 14 + +| Value| Description| +| -------- | -------- | +| NO_PERMISSION | No permission on the file.| +| READ_ONLY | Read-only permission.| +| CONTENT_EDIT | Edit permission.| +| FULL_CONTROL | Full control.| + + +## Function Description + + +### OH_DLP_GetDlpPermissionInfo() + +``` +DLP_ErrCode OH_DLP_GetDlpPermissionInfo(DLP_FileAccess *dlpFileAccess, uint32_t *flags) +``` + +**Description** + +Obtains the permission information of this DLP file. + +**Since**: 14 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| dlpFileAccess | Pointer to the authorization type of the DLP file for users. For details, see [DLP_FileAccess](#dlp_fileaccess).| +| flags | Pointer to the operation permissions allowed for the DLP file. The options are as follows:
**0x00000000** indicates no permission on the file.
**0x00000001** indicates the permission for viewing the file.
**0x00000002** indicates the permission for saving the file.
**0x00000004** indicates the permission for saving the file as another file.
**0x00000008** indicates the permission for editing the file.
**0x00000010** indicates the permission for capturing screenshots of the file.
**0x00000020** indicates the permission for sharing the screen, on which the file is open.
**0x00000040** indicates the permission for recording the screen, on which the file is open.
**0x00000080** indicates the permission for copying the file.
**0x00000100** indicates the permission for printing the file.
**0x00000200** indicates the permission for exporting the file.
**0x00000400** indicates the permission for modifying the permissions on the file.| + +**Returns** + +[DLP_ErrCode](#dlp_errcode): + +Returns **0** if the operation is successful. + +Returns **19100001** if invalid parameters are detected. + +Returns **19100006** when the access is denied for a non-DLP sandbox application. + +Returns **19100011** when the system service is abnormal. + +Returns **19100012** if the memory allocation fails. + + +### OH_DLP_GetOriginalFileName() + +``` +DLP_ErrCode OH_DLP_GetOriginalFileName(const char *fileName, char **originalFileName) +``` + +**Description** + +Obtains the original file name of a DLP file. + +**Since**: 14 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| fileName | Pointer to the target file whose original file name is to be obtained.| +| originalFileName | Double pointer to the original file name obtained.| + +**Returns** + +[DLP_ErrCode](#dlp_errcode): + +Returns **0** if the operation is successful. + +Returns **19100001** if invalid parameters are detected. + +Returns **19100012** if the memory allocation fails. + + +### OH_DLP_IsInSandbox() + +``` +DLP_ErrCode OH_DLP_IsInSandbox(bool *isInSandbox) +``` + +**Description** + +Checks whether this application is running in a DLP sandbox environment. + +**Since**: 14 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| isInSandbox | Pointer to the value indicating whether the application is running in a DLP sandbox environment.| + +**Returns** + +[DLP_ErrCode](#dlp_errcode): + +Returns **0** if the operation is successful. + +Returns **19100011** when the system service is abnormal. + +Returns **19100012** if the memory allocation fails. + + +### OH_DLP_SetSandboxAppConfig() + +``` +DLP_ErrCode OH_DLP_SetSandboxAppConfig(const char *configInfo) +``` + +**Description** + +Sets sandbox application configuration. + +**Since**: 14 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| configInfo | Pointer to the sandbox application configuration to set.| + +**Returns** + +[DLP_ErrCode](#dlp_errcode): + +Returns **0** if the operation is successful. + +Returns **19100001** if invalid parameters are detected. + +Returns **19100007** if the API cannot be called by a DLP sandbox application. + +Returns **19100011** when the system service is abnormal. + +Returns **19100018** if the application is unauthorized. + + +### OH_DLP_GetSandboxAppConfig() + +``` +DLP_ErrCode OH_DLP_GetSandboxAppConfig(char **configInfo) +``` + +**Description** + +Obtains the sandbox application configuration. + +**Since**: 14 + +**Parameters** + +| Name| Description| +| -------- | -------- | +| configInfo | Pointer to the sandbox application configuration obtained.| + +**Returns** + +[DLP_ErrCode](#dlp_errcode): + +Returns **0** if the operation is successful. + +Returns **19100011** when the system service is abnormal. + +Returns **19100012** if the memory allocation fails. + +Returns **19100018** if the application is unauthorized. + + +### OH_DLP_CleanSandboxAppConfig() + +``` +DLP_ErrCode OH_DLP_CleanSandboxAppConfig() +``` + +**Description** + +Cleans the sandbox application configuration. + +**Since**: 14 + +**Returns** + +[DLP_ErrCode](#dlp_errcode): + +Returns **0** if the operation is successful. + +Returns **19100007** if the API cannot be called by a DLP sandbox application. + +Returns **19100011** when the system service is abnormal. + +Returns **19100018** if the application is unauthorized. diff --git a/en/application-dev/reference/apis-data-protection-kit/dlp__permission__api_8h.md b/en/application-dev/reference/apis-data-protection-kit/dlp__permission__api_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..40b85abf9054844b5535251fed1c469c66b3f1d9 --- /dev/null +++ b/en/application-dev/reference/apis-data-protection-kit/dlp__permission__api_8h.md @@ -0,0 +1,37 @@ +# dlp_permission_api.h + + +## Overview + +Defines the APIs for cross-device file access management, encrypted storage, and access authorization. + +**Library**: libohdlp_permission.so + +**System capability**: SystemCapability.Security.DataLossPrevention + +**Since**: 14 + +**Related module**: [DlpPermissionApi](_dlp_permission_api.md) + + +## Summary + + +### Enums + +| Name| Description| +| -------- | -------- | +| [DLP_ErrCode](_dlp_permission_api.md#dlp_errcode) {
ERR_OH_SUCCESS = 0,
ERR_OH_INVALID_PARAMETER = 19100001,
ERR_OH_API_ONLY_FOR_SANDBOX = 19100006,
ERR_OH_API_NOT_FOR_SANDBOX = 19100007,
ERR_OH_SYSTEM_SERVICE_EXCEPTION = 19100011,
ERR_OH_OUT_OF_MEMORY = 19100012,
ERR_OH_APPLICATION_NOT_AUTHORIZED = 19100018
} | Enumerates the DLP error codes.| +| [DLP_FileAccess](_dlp_permission_api.md#dlp_fileaccess) {
NO_PERMISSION = 0,
READ_ONLY = 1,
CONTENT_EDIT = 2,
FULL_CONTROL = 3
} | Enumerates the permissions on a DLP file.| + + +### Functions + +| Name| Description| +| -------- | -------- | +| [DLP_ErrCode](_dlp_permission_api.md#dlp_errcode) [OH_DLP_GetDlpPermissionInfo](_dlp_permission_api.md#oh_dlp_getdlppermissioninfo) ([DLP_FileAccess](_dlp_permission_api.md#dlp_fileaccess ) \*dlpFileAccess, uint32_t \*flags) | Obtains the permission information of this DLP file.| +| [DLP_ErrCode](_dlp_permission_api.md#dlp_errcode) [OH_DLP_GetOriginalFileName](_dlp_permission_api.md#oh_dlp_getoriginalfilename) (const char \*fileName, char \*\*originalFileName) | Obtains the original file name of a DLP file.| +| [DLP_ErrCode](_dlp_permission_api.md#dlp_errcode) [OH_DLP_IsInSandbox](_dlp_permission_api.md#oh_dlp_isinsandbox) (bool \*isInSandbox) | Checks whether this application is running in a DLP sandbox environment.| +| [DLP_ErrCode](_dlp_permission_api.md#dlp_errcode) [OH_DLP_SetSandboxAppConfig](_dlp_permission_api.md#oh_dlp_setsandboxappconfig) (const char \*configInfo) | Sets sandbox application configuration.| +| [DLP_ErrCode](_dlp_permission_api.md#dlp_errcode) [OH_DLP_GetSandboxAppConfig](_dlp_permission_api.md#oh_dlp_getsandboxappconfig) (char \*\*configInfo) | Obtains the sandbox application configuration.| +| [DLP_ErrCode](_dlp_permission_api.md#dlp_errcode) [OH_DLP_CleanSandboxAppConfig](_dlp_permission_api.md#oh_dlp_cleansandboxappconfig) () | Cleans the sandbox application configuration.| diff --git a/en/application-dev/website.md b/en/application-dev/website.md index ee3f900bce021a4c5355d94b8ebf6929fd296c7e..ff8b276555ef6bbba4ac8b661c493fa4edcd837b 100644 --- a/en/application-dev/website.md +++ b/en/application-dev/website.md @@ -3248,17 +3248,17 @@ - C APIs - Modules - - [AssetApi](reference/apis-asset-store-kit/capi-assetapi.md) - - [AssetType](reference/apis-asset-store-kit/capi-assettype.md) + - [AssetApi](reference/apis-asset-store-kit/_asset_api.md) + - [AssetType](reference/apis-asset-store-kit/_asset_type.md) - Header Files - - [asset_api.h](reference/apis-asset-store-kit/capi-asset-api-h.md) - - [asset_type.h](reference/apis-asset-store-kit/capi-asset-type-h.md) + - [asset_api.h](reference/apis-asset-store-kit/asset__api_8h.md) + - [asset_type.h](reference/apis-asset-store-kit/asset__type_8h.md) - Structs - - [Asset_Blob](reference/apis-asset-store-kit/capi-asset-blob.md) - - [Asset_Value](reference/apis-asset-store-kit/capi-asset-value.md) - - [Asset_Attr](reference/apis-asset-store-kit/capi-asset-attr.md) - - [Asset_Result](reference/apis-asset-store-kit/capi-asset-result.md) - - [Asset_ResultSet](reference/apis-asset-store-kit/capi-asset-resultset.md) + - [Asset_Attr](reference/apis-asset-store-kit/_asset___attr.md) + - [Asset_Blob](reference/apis-asset-store-kit/_asset___blob.md) + - [Asset_Result](reference/apis-asset-store-kit/_asset___result.md) + - [Asset_ResultSet](reference/apis-asset-store-kit/_asset___result_set.md) + - [Asset_Value](reference/apis-asset-store-kit/union_asset___value.md) - Error Codes - [Asset Store Service Error Code](reference/apis-asset-store-kit/errorcode-asset.md) - Crypto Architecture Kit @@ -3268,32 +3268,21 @@ - [@system.cipher (Cipher Algorithm)](reference/apis-crypto-architecture-kit/js-apis-system-cipher.md) - C APIs - Modules - - [CryptoArchitectureKit](reference/apis-crypto-architecture-kit/capi-cryptoarchitecturekit.md) - - [CryptoAsymKeyApi](reference/apis-crypto-architecture-kit/capi-cryptoasymkeyapi.md) - - [CryptoCommonApi](reference/apis-crypto-architecture-kit/capi-cryptocommonapi.md) - - [CryptoDigestApi](reference/apis-crypto-architecture-kit/capi-cryptodigestapi.md) - - [CryptoSignatureApi](reference/apis-crypto-architecture-kit/capi-cryptosignatureapi.md) - - [CryptoSymCipherApi](reference/apis-crypto-architecture-kit/capi-cryptosymcipherapi.md) - - [CryptoSymKeyApi](reference/apis-crypto-architecture-kit/capi-cryptosymkeyapi.md) + - [CryptoAsymKeyApi](reference/apis-crypto-architecture-kit/_crypto_asym_key_api.md) + - [CryptoCommonApi](reference/apis-crypto-architecture-kit/_crypto_common_api.md) + - [CryptoDigestApi](reference/apis-crypto-architecture-kit/_crypto_digest_api.md) + - [CryptoSignatureApi](reference/apis-crypto-architecture-kit/_crypto_signature_api.md) + - [CryptoSymCipherApi](reference/apis-crypto-architecture-kit/_crypto_sym_cipher_api.md) + - [CryptoSymKeyApi](reference/apis-crypto-architecture-kit/_crypto_sym_key_api.md) - Header Files - - [crypto_architecture_kit.h](reference/apis-crypto-architecture-kit/capi-crypto-architecture-kit-h.md) - - [crypto_asym_key.h](reference/apis-crypto-architecture-kit/capi-crypto-asym-key-h.md) - - [crypto_common.h](reference/apis-crypto-architecture-kit/capi-crypto-common-h.md) - - [crypto_digest.h](reference/apis-crypto-architecture-kit/capi-crypto-digest-h.md) - - [crypto_signature.h](reference/apis-crypto-architecture-kit/capi-crypto-signature-h.md) - - [crypto_sym_cipher.h](reference/apis-crypto-architecture-kit/capi-crypto-sym-cipher-h.md) - - [crypto_sym_key.h](reference/apis-crypto-architecture-kit/capi-crypto-sym-key-h.md) + - [crypto_asym_key.h](reference/apis-crypto-architecture-kit/crypto__asym__key_8h.md) + - [crypto_common.h](reference/apis-crypto-architecture-kit/crypto__common_8h.md) + - [crypto_digest.h](reference/apis-crypto-architecture-kit/crypto__digest_8h.md) + - [crypto_signature.h](reference/apis-crypto-architecture-kit/crypto__signature_8h.md) + - [crypto_sym_cipher.h](reference/apis-crypto-architecture-kit/crypto__sym__cipher_8h.md) + - [crypto_sym_key.h](reference/apis-crypto-architecture-kit/crypto__sym__key_8h.md) - Structs - - [Crypto_DataBlob](reference/apis-crypto-architecture-kit/capi-crypto-datablob.md) - - [OH_CryptoKeyPair](reference/apis-crypto-architecture-kit/capi-oh-cryptokeypair.md) - - [OH_CryptoPubKey](reference/apis-crypto-architecture-kit/capi-oh-cryptopubkey.md) - - [OH_CryptoAsymKeyGenerator](reference/apis-crypto-architecture-kit/capi-oh-cryptoasymkeygenerator.md) - - [OH_CryptoDigest](reference/apis-crypto-architecture-kit/capi-oh-cryptodigest.md) - - [OH_CryptoVerify](reference/apis-crypto-architecture-kit/capi-oh-cryptoverify.md) - - [OH_CryptoSymCipher](reference/apis-crypto-architecture-kit/capi-oh-cryptosymcipher.md) - - [OH_CryptoSymCipherParams](reference/apis-crypto-architecture-kit/capi-oh-cryptosymcipherparams.md) - - [OH_CryptoSymKey](reference/apis-crypto-architecture-kit/capi-oh-cryptosymkey.md) - - [OH_CryptoSymKeyGenerator](reference/apis-crypto-architecture-kit/capi-oh-cryptosymkeygenerator.md) + - [Crypto_DataBlob](reference/apis-crypto-architecture-kit/_crypto___data_blob.md) - Error Codes - [Crypto Framework Error Codes](reference/apis-crypto-architecture-kit/errorcode-crypto-framework.md) - Data Protection Kit @@ -3304,9 +3293,9 @@ - C APIs - Modules - - [DlpPermissionApi](reference/apis-data-protection-kit/capi-dlppermissionapi.md) + - [DlpPermissionApi](reference/apis-data-protection-kit/_dlp_permission_api.md) - Header Files - - [dlp_permission_api.h](reference/apis-data-protection-kit/capi-dlp-permission-api-h.md) + - [dlp_permission_api.h](reference/apis-data-protection-kit/dlp__permission__api_8h.md) - Error Codes - [DLP Service Error Codes](reference/apis-data-protection-kit/errorcode-dlp.md) - Device Certificate Kit