openharmony 鸿蒙 capi-crypto-kdf-h

2026-08-25 浏览 (1)

crypto_kdf.h

Overview

Defines key derivation function (KDF) APIs.

Header file: <CryptoArchitectureKit/crypto_kdf.h>

Library: libohcrypto.so

System capability: SystemCapability.Security.CryptoFramework

Since: 20

Related module: CryptoKdfApi

Summary

Structs

Nametypedef KeywordDescription
OH_CryptoKdfOH_CryptoKdfDefines a KDF.
OH_CryptoKdfParamsOH_CryptoKdfParamsDefines KDF parameters.

Enums

Nametypedef KeywordDescription
CryptoKdf_ParamTypeCryptoKdf_ParamTypeDefines KDF parameter types.

Functions

NameDescription
OH_Crypto_ErrCode OH_CryptoKdfParams_Create(const char *algoName, OH_CryptoKdfParams **params)Creates KDF parameters.
Note: The created resource must be destroyed by calling OH_CryptoKdfParams_Destroy.
OH_Crypto_ErrCode OH_CryptoKdfParams_SetParam(OH_CryptoKdfParams *params, CryptoKdf_ParamType type, Crypto_DataBlob *value)Sets KDF parameters.
void OH_CryptoKdfParams_Destroy(OH_CryptoKdfParams *params)Destroys KDF parameters.
OH_Crypto_ErrCode OH_CryptoKdf_Create(const char *algoName, OH_CryptoKdf **ctx)Creates a KDF instance.
Note: The created resource must be destroyed by calling OH_CryptoKdf_Destroy.
OH_Crypto_ErrCode OH_CryptoKdf_Derive(OH_CryptoKdf *ctx, const OH_CryptoKdfParams *params, int keyLen, Crypto_DataBlob *key)Derives a key.
Note: After the use is complete, the memory for storing the key parameter must be released by calling OH_Crypto_FreeDataBlob.
void OH_CryptoKdf_Destroy(OH_CryptoKdf *ctx)Destroys a KDF instance.

Enum Description

CryptoKdf_ParamType

enum CryptoKdf_ParamType

Description

Defines KDF parameter types.

Since: 20

Enum ItemDescription
CRYPTO_KDF_KEY_DATABLOB = 0Key or password of the KDF.
CRYPTO_KDF_SALT_DATABLOB = 1Salt value of the KDF.
CRYPTO_KDF_INFO_DATABLOB = 2Information of the KDF.
CRYPTO_KDF_ITER_COUNT_INT = 3Iteration count of PBKDF2.
CRYPTO_KDF_SCRYPT_N_UINT64 = 4Parameter n of the SCRYPT KDF.
CRYPTO_KDF_SCRYPT_R_UINT64 = 5Parameter r of the SCRYPT KDF.
CRYPTO_KDF_SCRYPT_P_UINT64 = 6Parameter p of the SCRYPT KDF.
CRYPTO_KDF_SCRYPT_MAX_MEM_UINT64 = 7Maximum memory usage of the SCRYPT KDF.

Function Description

OH_CryptoKdfParams_Create()

OH_Crypto_ErrCode OH_CryptoKdfParams_Create(const char *algoName, OH_CryptoKdfParams **params)

Description

Creates KDF parameters.
Note: The created resource must be destroyed by calling OH_CryptoKdfParams_Destroy.

Since: 20

Parameters

NameDescription
const char *algoNameKDF algorithm name.
For example, HKDF|SHA384|EXTRACT_AND_EXPAND or PBKDF2|SHA384.
OH_CryptoKdfParams **paramsKDF parameters.

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_CryptoKdfParams_SetParam()

OH_Crypto_ErrCode OH_CryptoKdfParams_SetParam(OH_CryptoKdfParams *params, CryptoKdf_ParamType type, Crypto_DataBlob *value)

Description

Sets KDF parameters.

Since: 20

Parameters

NameDescription
OH_CryptoKdfParams *paramsKDF parameters.
CryptoKdf_ParamType typeKDF parameter type.
Crypto_DataBlob *valueKDF parameter values.

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_CryptoKdfParams_Destroy()

void OH_CryptoKdfParams_Destroy(OH_CryptoKdfParams *params)

Description

Destroys KDF parameters.

Since: 20

Parameters

NameDescription
OH_CryptoKdfParams *paramsKDF parameters.

OH_CryptoKdf_Create()

OH_Crypto_ErrCode OH_CryptoKdf_Create(const char *algoName, OH_CryptoKdf **ctx)

Description

Creates a KDF instance.
Note: The created resource must be destroyed by calling OH_CryptoKdf_Destroy.

Since: 20

Parameters

NameDescription
const char *algoNameKDF algorithm name.
OH_CryptoKdf **ctxKDF 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_CryptoKdf_Derive()

OH_Crypto_ErrCode OH_CryptoKdf_Derive(OH_CryptoKdf *ctx, const OH_CryptoKdfParams *params, int keyLen, Crypto_DataBlob *key)

Description

Derives a key.
Note: After the use is complete, the memory for storing the key parameter must be released by calling OH_Crypto_FreeDataBlob.

Since: 20

Parameters

NameDescription
OH_CryptoKdf *ctxKDF instance.
const OH_CryptoKdfParams *paramsKDF parameters.
int keyLenLength of the derived key.
Crypto_DataBlob *keyDerived key.

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_CryptoKdf_Destroy()

void OH_CryptoKdf_Destroy(OH_CryptoKdf *ctx)

Description

Destroys a KDF instance.

Since: 20

Parameters

NameDescription
OH_CryptoKdf *ctxKDF 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/cC8NqhEU