ohos-crypto-sys 0.1.0

Raw bindings to the CryptoArchitectureKit NDK of OpenHarmony
Documentation
// automatically generated by rust-bindgen 0.71.1

#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use crate::common::{CryptoResult, Crypto_DataBlob};

/// Defines the KDF structure.
///
///
/// Available since API-level: 20
#[cfg(feature = "api-20")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
#[repr(C)]
pub struct OH_CryptoKdf {
    _unused: [u8; 0],
}
/// Defines the KDF params structure.
///
///
/// Available since API-level: 20
#[cfg(feature = "api-20")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
#[repr(C)]
pub struct OH_CryptoKdfParams {
    _unused: [u8; 0],
}
#[cfg(feature = "api-20")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
impl CryptoKdf_ParamType {
    /// Indicates the key or password for KDF.
    pub const CRYPTO_KDF_KEY_DATABLOB: CryptoKdf_ParamType = CryptoKdf_ParamType(0);
    /// Indicates the salt for KDF.
    pub const CRYPTO_KDF_SALT_DATABLOB: CryptoKdf_ParamType = CryptoKdf_ParamType(1);
    /// Indicates the info for KDF.
    pub const CRYPTO_KDF_INFO_DATABLOB: CryptoKdf_ParamType = CryptoKdf_ParamType(2);
    /// Indicates the iteration count for PBKDF2.
    pub const CRYPTO_KDF_ITER_COUNT_INT: CryptoKdf_ParamType = CryptoKdf_ParamType(3);
    /// Indicates the n for SCRYPT KDF.
    pub const CRYPTO_KDF_SCRYPT_N_UINT64: CryptoKdf_ParamType = CryptoKdf_ParamType(4);
    /// Indicates the r for SCRYPT KDF.
    pub const CRYPTO_KDF_SCRYPT_R_UINT64: CryptoKdf_ParamType = CryptoKdf_ParamType(5);
    /// Indicates the p for SCRYPT KDF.
    pub const CRYPTO_KDF_SCRYPT_P_UINT64: CryptoKdf_ParamType = CryptoKdf_ParamType(6);
    /// Indicates the max memory for SCRYPT KDF.
    pub const CRYPTO_KDF_SCRYPT_MAX_MEM_UINT64: CryptoKdf_ParamType = CryptoKdf_ParamType(7);
}
#[repr(transparent)]
/// Defines the KDF param type.
///
///
/// Available since API-level: 20
#[cfg(feature = "api-20")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct CryptoKdf_ParamType(pub ::core::ffi::c_uint);
extern "C" {
    /// Creates KDF params.
    ///
    /// # Arguments
    ///
    /// * `algoName` - Indicates the KDF algorithm name. e.g. "HKDF", "PBKDF2", "SCRYPT".
    ///
    /// * `params` - Indicates the KDF params.
    ///
    /// # Returns
    ///
    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_CryptoKdfParams_Create(
        algoName: *const ::core::ffi::c_char,
        params: *mut *mut OH_CryptoKdfParams,
    ) -> CryptoResult;
    /// Sets a parameter to the KDF parameters.
    ///
    /// # Arguments
    ///
    /// * `params` - Indicates the KDF parameters.
    ///
    /// * `type` - Indicates the KDF parameter type.
    ///
    /// * `value` - Indicates the KDF parameter value.
    ///
    /// # Returns
    ///
    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_CryptoKdfParams_SetParam(
        params: *mut OH_CryptoKdfParams,
        type_: CryptoKdf_ParamType,
        value: *mut Crypto_DataBlob,
    ) -> CryptoResult;
    /// Destroys the KDF params.
    ///
    /// # Arguments
    ///
    /// * `params` - Indicates the KDF parameters.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_CryptoKdfParams_Destroy(params: *mut OH_CryptoKdfParams);
    /// Creates a KDF context.
    ///
    /// # Arguments
    ///
    /// * `algoName` - Indicates the KDF algorithm name. e.g. "HKDF|SHA384|EXTRACT_AND_EXPAND", "PBKDF2|SHA384", "SCRYPT".
    ///
    /// * `ctx` - Indicates the KDF context.
    ///
    /// # Returns
    ///
    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_CryptoKdf_Create(
        algoName: *const ::core::ffi::c_char,
        ctx: *mut *mut OH_CryptoKdf,
    ) -> CryptoResult;
    /// Derives a key.
    ///
    /// # Arguments
    ///
    /// * `ctx` - The KDF context.
    ///
    /// * `params` - Indicates the KDF parameters.
    ///
    /// * `keyLen` - Indicates the key derivation length.
    ///
    /// * `key` - Indicates the derived key.
    ///
    /// # Returns
    ///
    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_CryptoKdf_Derive(
        ctx: *mut OH_CryptoKdf,
        params: *const OH_CryptoKdfParams,
        keyLen: ::core::ffi::c_int,
        key: *mut Crypto_DataBlob,
    ) -> CryptoResult;
    /// Destroys the KDF context.
    ///
    /// # Arguments
    ///
    /// * `ctx` - The KDF context.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_CryptoKdf_Destroy(ctx: *mut OH_CryptoKdf);
}