harmony 鸿蒙CryptoSymCipherApi
CryptoSymCipherApi
Overview
Provides APIs for symmetric key encryption and decryption.
Since: 12
Summary
Files
Name | Description |
---|---|
crypto_sym_cipher.h | Defines APIs for symmetric encryption and decryption. |
Types
Name | Description |
---|---|
typedef struct OH_CryptoSymCipher OH_CryptoSymCipher | Defines a symmetric encryption and decryption instance. |
typedef struct OH_CryptoSymCipherParams OH_CryptoSymCipherParams | Defines symmetric encryption and decryption parameters. |
Enums
Name | Description |
---|---|
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 OH_CryptoSymCipherParams_Create (OH_CryptoSymCipherParams **params) | Creates a symmetric encryption/decryption parameter instance. |
OH_Crypto_ErrCode OH_CryptoSymCipherParams_SetParam (OH_CryptoSymCipherParams *params, CryptoSymCipher_ParamsType paramsType, Crypto_DataBlob *value) | Sets a symmetric encryption/decryption parameter. |
void OH_CryptoSymCipherParams_Destroy (OH_CryptoSymCipherParams *params) | Destroys a symmetric encryption/decryption parameter instance. |
OH_Crypto_ErrCode OH_CryptoSymCipher_Create (const char *algoName, OH_CryptoSymCipher **ctx) | Creates a symmetric cipher instance based on the given algorithm name. |
OH_Crypto_ErrCode OH_CryptoSymCipher_Init (OH_CryptoSymCipher *ctx, Crypto_CipherMode mod, OH_CryptoSymKey *key, OH_CryptoSymCipherParams *params) | Initializes a symmetric cipher instance. |
OH_Crypto_ErrCode OH_CryptoSymCipher_Update (OH_CryptoSymCipher *ctx, Crypto_DataBlob *in, Crypto_DataBlob *out) | Updates the data to be encrypted or decrypted. |
OH_Crypto_ErrCode OH_CryptoSymCipher_Final (OH_CryptoSymCipher *ctx, Crypto_DataBlob *in, Crypto_DataBlob *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 *ctx) | Obtains the symmetric encryption/decryption algorithm. |
void OH_CryptoSymCipher_Destroy (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
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
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_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
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
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
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
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.
你可能感兴趣的鸿蒙文章
harmony 鸿蒙Crypto Architecture Kit (Crypto Architecture Service)
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
7、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦