openharmony 鸿蒙 capi-crypto-key-agreement-h

2026-08-25 浏览 (1)

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

Nametypedef KeywordDescription
OH_CryptoKeyAgreementOH_CryptoKeyAgreementDefines a struct for key agreement.

Functions

NameDescription
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

NameDescription
const char *algoNameAlgorithm name of the key agreement instance to be created.
For example, ECC or X25519.
OH_CryptoKeyAgreement **ctxKey agreement instance.

Returns

TypeDescription
OH_Crypto_ErrCodeCRYPTO_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

NameDescription
OH_CryptoKeyAgreement *ctxKey agreement instance.
OH_CryptoPrivKey *privkeyPrivate key.
OH_CryptoPubKey *pubkeyPublic key.
Crypto_DataBlob *secretSecret value.

Returns

TypeDescription
OH_Crypto_ErrCodeCRYPTO_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

NameDescription
OH_CryptoKeyAgreement *ctxKey agreement instance.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-cryptosymkeyapi-oh-cryptosymkey

openharmony 鸿蒙 capi-cryptoasymkeyapi-oh-cryptoasymkeygeneratorwithspec

openharmony 鸿蒙 capi-cryptoasymcipherapi-oh-cryptoasymcipher

openharmony 鸿蒙 capi-cryptokdfapi-oh-cryptokdfparams

openharmony 鸿蒙 capi-cryptomacapi

openharmony 鸿蒙 capi-cryptodigestapi-oh-cryptodigest

openharmony 鸿蒙 capi-cryptomacapi-oh-cryptomac

openharmony 鸿蒙 capi-cryptosignatureapi-oh-cryptoeccsignaturespec

openharmony 鸿蒙 capi-cryptocommonapi-crypto-datablob

openharmony 鸿蒙 capi-cryptoasymcipherapi-oh-cryptosm2ciphertextspec

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/JvKXZpll