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 random number generator structure.
///
///
/// Available since API-level: 20
#[cfg(feature = "api-20")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
#[repr(C)]
pub struct OH_CryptoRand {
    _unused: [u8; 0],
}
extern "C" {
    /// Creates a random number generator context.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the random number generator 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_CryptoRand_Create(ctx: *mut *mut OH_CryptoRand) -> CryptoResult;
    /// Generates random numbers.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the random number generator context.
    ///
    /// * `len` - Indicates the byte length of the random number.
    ///
    /// * `out` - Indicates the output data.
    ///
    /// # 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_CryptoRand_GenerateRandom(
        ctx: *mut OH_CryptoRand,
        len: ::core::ffi::c_int,
        out: *mut Crypto_DataBlob,
    ) -> CryptoResult;
    /// Gets the algorithm name of the random number generator context.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the pointer to the random number generator context.
    ///
    /// # Returns
    ///
    /// * Return the algorithm name of the random number generator context.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_CryptoRand_GetAlgoName(ctx: *mut OH_CryptoRand) -> *const ::core::ffi::c_char;
    /// Sets the seed to the random number generator context.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the random number generator context.
    ///
    /// * `seed` - Indicates the seed.
    ///
    /// # 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_CryptoRand_SetSeed(
        ctx: *mut OH_CryptoRand,
        seed: *mut Crypto_DataBlob,
    ) -> CryptoResult;
    /// Enables the hardware entropy source.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the random number generator 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: 21
    #[cfg(feature = "api-21")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-21")))]
    pub fn OH_CryptoRand_EnableHardwareEntropy(ctx: *mut OH_CryptoRand) -> CryptoResult;
    /// Destroys the random number generator context.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the random number generator context.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_CryptoRand_Destroy(ctx: *mut OH_CryptoRand);
}