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 symmetric key structure.
///
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
#[repr(C)]
pub struct OH_CryptoSymKey {
    _unused: [u8; 0],
}
/// Define the symmetric key generator structure.
///
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
#[repr(C)]
pub struct OH_CryptoSymKeyGenerator {
    _unused: [u8; 0],
}
extern "C" {
    /// Create a symmetric key generator according to the given algorithm name. Example AES256.
    ///
    /// # Arguments
    ///
    /// * `algoName` - Indicates the algorithm name for generating the generator.
    ///
    /// * `ctx` - Indicates the pointer to the symmetric key generator 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_CryptoSymKeyGenerator_Create(
        algoName: *const ::core::ffi::c_char,
        ctx: *mut *mut OH_CryptoSymKeyGenerator,
    ) -> CryptoResult;
    /// Generate a symmetric key.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the Symmetric key generator context.
    ///
    /// * `keyCtx` - Indicates the pointer to the symmetric key 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_CryptoSymKeyGenerator_Generate(
        ctx: *mut OH_CryptoSymKeyGenerator,
        keyCtx: *mut *mut OH_CryptoSymKey,
    ) -> CryptoResult;
    /// Convert the symmetric key data to a key.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the symmetric key generator context.
    ///
    /// * `keyData` - Indicates the data to generate the Symkey.
    ///
    /// * `keyCtx` - Indicates the pointer to the symmetric key 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_CryptoSymKeyGenerator_Convert(
        ctx: *mut OH_CryptoSymKeyGenerator,
        keyData: *const Crypto_DataBlob,
        keyCtx: *mut *mut OH_CryptoSymKey,
    ) -> CryptoResult;
    /// Get the algorithm name of the symmetric key generator.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the symmetric key generator context.
    ///
    /// # Returns
    ///
    /// * Return symmetric key algorithm name.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_CryptoSymKeyGenerator_GetAlgoName(
        ctx: *mut OH_CryptoSymKeyGenerator,
    ) -> *const ::core::ffi::c_char;
    /// Destroy the symmetric key generator.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the symmetric key generator context.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_CryptoSymKeyGenerator_Destroy(ctx: *mut OH_CryptoSymKeyGenerator);
    /// Get the symmetric key algorithm name from a symmetric key.
    ///
    /// # Arguments
    ///
    /// * `keyCtx` - Indicates the symmetric key context.
    ///
    /// # Returns
    ///
    /// * Return algorithm name.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_CryptoSymKey_GetAlgoName(keyCtx: *mut OH_CryptoSymKey) -> *const ::core::ffi::c_char;
    /// Get the symmetric key data from a symmetric key.
    ///
    /// # Arguments
    ///
    /// * `keyCtx` - Indicates the symmetric key context.
    ///
    /// * `out` - Indicate to obtain the result.
    ///
    /// # 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_CryptoSymKey_GetKeyData(
        keyCtx: *mut OH_CryptoSymKey,
        out: *mut Crypto_DataBlob,
    ) -> CryptoResult;
    /// Destroy the symmetric key.
    ///
    /// # Arguments
    ///
    /// * `keyCtx` - Indicates the symmetric key context.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_CryptoSymKey_Destroy(keyCtx: *mut OH_CryptoSymKey);
}