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};

/// Define the digest structure.
///
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
#[repr(C)]
pub struct OH_CryptoDigest {
    _unused: [u8; 0],
}
extern "C" {
    /// Create a digest context according to the given algorithm name.
    ///
    /// # Arguments
    ///
    /// * `algoName` - Indicates the algorithm name for generating the digest context. Example SHA256.
    ///
    /// * `ctx` - Indicates the pointer to the md context.
    ///
    /// # Returns
    ///
    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
    /// [`OH_Crypto_ErrCode#CRYPTO_INVALID_PARAMS`] 401 - If parameter is invalid.
    /// [`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_OPERTION_ERROR`] 17630001 - If crypto opertion failed.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_CryptoDigest_Create(
        algoName: *const ::core::ffi::c_char,
        ctx: *mut *mut OH_CryptoDigest,
    ) -> CryptoResult;
    /// Update digest with dataBlob.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the digest context.
    ///
    /// * `in` - Indicates the dataBlob.
    ///
    /// # Returns
    ///
    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
    /// [`OH_Crypto_ErrCode#CRYPTO_INVALID_PARAMS`] 401 - If parameter is invalid.
    /// [`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_OPERTION_ERROR`] 17630001 - If crypto opertion failed.
    /// [`OH_CryptoDigest_Final`]
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_CryptoDigest_Update(
        ctx: *mut OH_CryptoDigest,
        in_: *mut Crypto_DataBlob,
    ) -> CryptoResult;
    /// Final digest with dataBlob.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the digest context.
    ///
    /// * `out` - Indicates the result as dataBlob.
    ///
    /// # Returns
    ///
    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
    /// [`OH_Crypto_ErrCode#CRYPTO_INVALID_PARAMS`] 401 - If parameter is invalid.
    /// [`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_OPERTION_ERROR`] 17630001 - If crypto opertion failed.
    /// [`OH_CryptoDigest_Update`]
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_CryptoDigest_Final(
        ctx: *mut OH_CryptoDigest,
        out: *mut Crypto_DataBlob,
    ) -> CryptoResult;
    /// Get the digest length of the digest context.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the digest context.
    ///
    /// # Returns
    ///
    /// * Return the digest length.
    /// If the input parameter ctx is NULL, 401 is returned, in other failure scenarios, 0 is returned.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_CryptoDigest_GetLength(ctx: *mut OH_CryptoDigest) -> u32;
    /// Get the algorithm name of the digest context.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the digest context.
    ///
    /// # Returns
    ///
    /// * Return md algorithm name.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_CryptoDigest_GetAlgoName(ctx: *mut OH_CryptoDigest) -> *const ::core::ffi::c_char;
    /// Destroy the digest context.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the digest context.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_DigestCrypto_Destroy(ctx: *mut OH_CryptoDigest);
}