crypto_key_agreement.h
Overview
Defines key agreement APIs.
Header file: <CryptoArchitectureKit/crypto_key_agreement.h>
Library: libohcrypto.so
System capability: SystemCapability.Security.CryptoFramework
Since: 20
Related module: CryptoKeyAgreementApi
Summary
Structs
| Name | typedef Keyword | Description |
|---|---|---|
| OH_CryptoKeyAgreement | OH_CryptoKeyAgreement | Defines a struct for key agreement. |
Functions
| Name | Description |
|---|---|
| OH_Crypto_ErrCode OH_CryptoKeyAgreement_Create(const char *algoName, OH_CryptoKeyAgreement **ctx) | Creates a key agreement instance based on the given algorithm name. Note: The created resource must be destroyed by calling OH_CryptoKeyAgreement_Destroy. |
| OH_Crypto_ErrCode OH_CryptoKeyAgreement_GenerateSecret(OH_CryptoKeyAgreement *ctx, OH_CryptoPrivKey *privkey, OH_CryptoPubKey *pubkey, Crypto_DataBlob *secret) | Generates the secret value of key agreement. Note: After the use is complete, the memory for storing the secret parameter must be released by calling OH_Crypto_FreeDataBlob. |
| void OH_CryptoKeyAgreement_Destroy(OH_CryptoKeyAgreement *ctx) | Destroys a key agreement instance. |
Function Description
OH_CryptoKeyAgreement_Create()
OH_Crypto_ErrCode OH_CryptoKeyAgreement_Create(const char *algoName, OH_CryptoKeyAgreement **ctx)
Description
Creates a key agreement instance based on the given algorithm name.
Note: The created resource must be destroyed by calling OH_CryptoKeyAgreement_Destroy.
Since: 20
Parameters
| Name | Description |
|---|---|
| const char *algoName | Algorithm name of the key agreement instance to be created. For example, ECC or X25519. |
| OH_CryptoKeyAgreement **ctx | Key agreement instance. |
Returns
| Type | Description |
|---|---|
| OH_Crypto_ErrCode | CRYPTO_SUCCESS: The operation is successful. CRYPTO_NOT_SUPPORTED: The operation is not supported. CRYPTO_MEMORY_ERROR: A memory error occurs. CRYPTO_PARAMETER_CHECK_FAILED: The parameter check failed. CRYPTO_OPERTION_ERROR: Failed to call an API of a third-party algorithm library. |
OH_CryptoKeyAgreement_GenerateSecret()
OH_Crypto_ErrCode OH_CryptoKeyAgreement_GenerateSecret(OH_CryptoKeyAgreement *ctx, OH_CryptoPrivKey *privkey, OH_CryptoPubKey *pubkey, Crypto_DataBlob *secret)
Description
Generates the secret value of key agreement.
Note: After the use is complete, the memory for storing the secret parameter must be released by calling OH_Crypto_FreeDataBlob.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_CryptoKeyAgreement *ctx | Key agreement instance. |
| OH_CryptoPrivKey *privkey | Private key. |
| OH_CryptoPubKey *pubkey | Public key. |
| Crypto_DataBlob *secret | Secret value. |
Returns
| Type | Description |
|---|---|
| OH_Crypto_ErrCode | CRYPTO_SUCCESS: The operation is successful. CRYPTO_NOT_SUPPORTED: The operation is not supported. CRYPTO_MEMORY_ERROR: A memory error occurs. CRYPTO_PARAMETER_CHECK_FAILED: The parameter check failed. CRYPTO_OPERTION_ERROR: Failed to call an API of a third-party algorithm library. |
OH_CryptoKeyAgreement_Destroy()
void OH_CryptoKeyAgreement_Destroy(OH_CryptoKeyAgreement *ctx)
Description
Destroys a key agreement instance.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_CryptoKeyAgreement *ctx | Key agreement instance. |