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};
use crate::sym_key::OH_CryptoSymKey;

/// Defines the MAC structure.
///
///
/// Available since API-level: 20
#[cfg(feature = "api-20")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
#[repr(C)]
pub struct OH_CryptoMac {
    _unused: [u8; 0],
}
#[cfg(feature = "api-20")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
impl CryptoMac_ParamType {
    /// Indicates the algorithm name of the message digest function for HMAC. e.g. "SHA256".
    pub const CRYPTO_MAC_DIGEST_NAME_STR: CryptoMac_ParamType = CryptoMac_ParamType(0);
    /// Indicates the algorithm name of the symmetric cipher function for CMAC. e.g. "AES256".
    pub const CRYPTO_MAC_CIPHER_NAME_STR: CryptoMac_ParamType = CryptoMac_ParamType(1);
}
#[repr(transparent)]
/// Defines the MAC algorithm parameter 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 CryptoMac_ParamType(pub ::core::ffi::c_uint);
extern "C" {
    /// Creates a MAC context according to the given algorithm name.
    ///
    /// # Arguments
    ///
    /// * `algoName` - Indicates the algorithm name for generating the MAC context. e.g. "HMAC", "CMAC".
    ///
    /// * `ctx` - Indicates the pointer to the MAC 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_CryptoMac_Create(
        algoName: *const ::core::ffi::c_char,
        ctx: *mut *mut OH_CryptoMac,
    ) -> CryptoResult;
    /// Sets the specified parameter to the MAC context.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the MAC context.
    ///
    /// * `type` - Indicates the MAC parameter type.
    ///
    /// * `value` - Indicates the 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_CryptoMac_SetParam(
        ctx: *mut OH_CryptoMac,
        type_: CryptoMac_ParamType,
        value: *const Crypto_DataBlob,
    ) -> CryptoResult;
    /// Initializes the MAC context with a symmetric key.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the MAC context.
    ///
    /// * `key` - Indicates the symmetric 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.
    /// [`OH_CryptoMac_Update`] [`OH_CryptoMac_Final`]
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_CryptoMac_Init(ctx: *mut OH_CryptoMac, key: *const OH_CryptoSymKey) -> CryptoResult;
    /// Updates the MAC context with data.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the MAC context.
    ///
    /// * `in` - Indicates the data to update.
    ///
    /// # 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.
    /// [`OH_CryptoMac_Init`] [`OH_CryptoMac_Final`]
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_CryptoMac_Update(ctx: *mut OH_CryptoMac, in_: *const Crypto_DataBlob)
        -> CryptoResult;
    /// Finalizes the MAC operation.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the MAC context.
    ///
    /// * `out` - Indicates the MAC result.
    ///
    /// # 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.
    /// [`OH_CryptoMac_Init`] [`OH_CryptoMac_Update`]
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_CryptoMac_Final(ctx: *mut OH_CryptoMac, out: *mut Crypto_DataBlob) -> CryptoResult;
    /// Gets the length of the MAC.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the MAC context.
    ///
    /// * `length` - Indicates the MAC length.
    ///
    /// # 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_CryptoMac_GetLength(ctx: *mut OH_CryptoMac, length: *mut u32) -> CryptoResult;
    /// Destroys the MAC context.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the MAC context.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_CryptoMac_Destroy(ctx: *mut OH_CryptoMac);
}