openharmony 鸿蒙 capi-oh-rdb-crypto-param-h

2026-08-25 浏览 (2)

oh_rdb_crypto_param.h

Overview

Defines functions and enums related to encryption parameters of the RDB store.

File to include: <database/rdb/oh_rdb_crypto_param.h>

Library: libnative_rdb_ndk.z.so

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Since: 20

Related module: RDB

Summary

Structs

Nametypedef KeywordDescription
OH_Rdb_CryptoParamOH_Rdb_CryptoParamDefines the encryption parameters used to open an encrypted database.

Enums

Nametypedef KeywordDescription
Rdb_EncryptionAlgoRdb_EncryptionAlgoEnumerates database encryption algorithms.
Rdb_HmacAlgoRdb_HmacAlgoEnumerates HMAC algorithms.
Rdb_KdfAlgoRdb_KdfAlgoEnumerates KDF algorithms.

Functions

NameDescription
OH_Rdb_CryptoParam *OH_Rdb_CreateCryptoParam(void)Creates an OH_Rdb_CryptoParam instance.
int OH_Rdb_DestroyCryptoParam(OH_Rdb_CryptoParam *param)Destroys an OH_Rdb_CryptoParam instance.
int OH_Crypto_SetEncryptionKey(OH_Rdb_CryptoParam *param, const uint8_t *key, int32_t length)Sets the key data of an OH_Rdb_CryptoParam instance.
int OH_Crypto_SetIteration(OH_Rdb_CryptoParam *param, int64_t iteration)Sets the number of iterations of the KDF algorithm used when opening an encrypted database.
int OH_Crypto_SetEncryptionAlgo(OH_Rdb_CryptoParam *param, int32_t algo)Sets the encryption algorithm used when opening an encrypted database.
int OH_Crypto_SetHmacAlgo(OH_Rdb_CryptoParam *param, int32_t algo)Sets the HMAC algorithm used when opening an encrypted database.
int OH_Crypto_SetKdfAlgo(OH_Rdb_CryptoParam *param, int32_t algo)Sets the KDF algorithm used when opening an encrypted database.
int OH_Crypto_SetCryptoPageSize(OH_Rdb_CryptoParam *param, int64_t size)Sets the page size used when opening an encrypted database.

Enum Description

Rdb_EncryptionAlgo

enum Rdb_EncryptionAlgo

Description

Enumerates database encryption algorithms.

Since: 20

Enum ItemDescription
RDB_AES_256_GCM = 0RDB_AES_256_GCM.
RDB_AES_256_CBCRDB_AES_256_CBC.
RDB_PLAIN_TEXTNo encryption is required.
Since: 22

Rdb_HmacAlgo

enum Rdb_HmacAlgo

Description

Enumerates HMAC algorithms.

Since: 20

Enum ItemDescription
RDB_HMAC_SHA1 = 0RDB_HMAC_SHA1.
RDB_HMAC_SHA256RDB_HMAC_SHA256.
RDB_HMAC_SHA512RDB_HMAC_SHA512.

Rdb_KdfAlgo

enum Rdb_KdfAlgo

Description

Enumerates KDF algorithms.

Since: 20

Enum ItemDescription
RDB_KDF_SHA1 = 0RDB_KDF_SHA1.
RDB_KDF_SHA256RDB_KDF_SHA256.
RDB_KDF_SHA512RDB_KDF_SHA512.

Function Description

OH_Rdb_CreateCryptoParam()

OH_Rdb_CryptoParam *OH_Rdb_CreateCryptoParam(void)

Description

Creates an OH_Rdb_CryptoParam instance.

Since: 20

Returns

TypeDescription
OH_Rdb_CryptoParamReturns a pointer to the OH_Rdb_CryptoParam instance if the operation is successful; returns nullptr otherwise. Use OH_Rdb_DestroyCryptoParam to release the memory in time.

OH_Rdb_DestroyCryptoParam()

int OH_Rdb_DestroyCryptoParam(OH_Rdb_CryptoParam *param)

Description

Destroys an OH_Rdb_CryptoParam instance.

Since: 20

Parameters

NameDescription
OH_Rdb_CryptoParam *paramPointer to the OH_Rdb_CryptoParam instance.

Returns

TypeDescription
intReturns an execution result.
RDB_OK indicates that the execution is successful.
RDB_E_INVALID_ARGS indicates that invalid parameters are specified.

OH_Crypto_SetEncryptionKey()

int OH_Crypto_SetEncryptionKey(OH_Rdb_CryptoParam *param, const uint8_t *key, int32_t length)

Description

Sets the key data of an OH_Rdb_CryptoParam instance.

Since: 20

Parameters

NameDescription
OH_Rdb_CryptoParam *paramPointer to the OH_Rdb_CryptoParam instance.
const uint8_t *keyPointer to the array data.
int32_t lengthSize of the key array.

Returns

TypeDescription
intReturns an execution result.
RDB_OK indicates that the execution is successful.
RDB_E_INVALID_ARGS indicates that invalid parameters are specified.

OH_Crypto_SetIteration()

int OH_Crypto_SetIteration(OH_Rdb_CryptoParam *param, int64_t iteration)

Description

Sets the number of iterations of the KDF algorithm used when opening an encrypted database.

Since: 20

Parameters

NameDescription
OH_Rdb_CryptoParam *paramPointer to the OH_Rdb_CryptoParam instance.
int64_t iterationNumber of iterations.

Returns

TypeDescription
intReturns an execution result.
RDB_OK indicates that the execution is successful.
RDB_E_INVALID_ARGS indicates that invalid parameters are specified.

OH_Crypto_SetEncryptionAlgo()

int OH_Crypto_SetEncryptionAlgo(OH_Rdb_CryptoParam *param, int32_t algo)

Description

Sets the encryption algorithm used when opening an encrypted database.

Since: 20

Parameters

NameDescription
OH_Rdb_CryptoParam *paramPointer to the OH_Rdb_CryptoParam instance.
int32_t algoEncryption algorithm.

Returns

TypeDescription
intReturns an execution result.
RDB_OK indicates that the execution is successful.
RDB_E_INVALID_ARGS indicates that invalid parameters are specified.

OH_Crypto_SetHmacAlgo()

int OH_Crypto_SetHmacAlgo(OH_Rdb_CryptoParam *param, int32_t algo)

Description

Sets the HMAC algorithm used when opening an encrypted database.

Since: 20

Parameters

NameDescription
OH_Rdb_CryptoParam *paramPointer to the OH_Rdb_CryptoParam instance.
int32_t algoHMAC algorithm.

Returns

TypeDescription
intReturns an execution result.
RDB_OK indicates that the execution is successful.
RDB_E_INVALID_ARGS indicates that invalid parameters are specified.

OH_Crypto_SetKdfAlgo()

int OH_Crypto_SetKdfAlgo(OH_Rdb_CryptoParam *param, int32_t algo)

Description

Sets the KDF algorithm used when opening an encrypted database.

Since: 20

Parameters

NameDescription
OH_Rdb_CryptoParam *paramPointer to the OH_Rdb_CryptoParam instance.
int32_t algoKDF algorithm.

Returns

TypeDescription
intReturns an execution result.
RDB_OK indicates that the execution is successful.
RDB_E_INVALID_ARGS indicates that invalid parameters are specified.

OH_Crypto_SetCryptoPageSize()

int OH_Crypto_SetCryptoPageSize(OH_Rdb_CryptoParam *param, int64_t size)

Description

Sets the page size used when opening an encrypted database.

Since: 20

Parameters

NameDescription
OH_Rdb_CryptoParam *paramPointer to the OH_Rdb_CryptoParam instance.
int64_t sizePage size, in bytes. The value must be a power of 2 and ranges from 1024 to 65536.

Returns

TypeDescription
intReturns an execution result.
RDB_OK indicates that the execution is successful.
RDB_E_INVALID_ARGS indicates that invalid parameters are specified.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 js-apis-distributedKVStore-sys

openharmony 鸿蒙 capi-oh-preferences-h

openharmony 鸿蒙 capi-udmf-oh-udshyperlink

openharmony 鸿蒙 js-apis-data-dataSharePredicates

openharmony 鸿蒙 capi-udmf-oh-udsappitem

openharmony 鸿蒙 capi-rdb-oh-data-vbuckets

openharmony 鸿蒙 capi-rdb-oh-predicates

openharmony 鸿蒙 capi-rdb-oh-data-value

openharmony 鸿蒙 capi-preferences-oh-preferencespair

openharmony 鸿蒙 errorcode-datashare

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