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

#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
impl CryptoSymCipher_ParamsType {
    /// Indicates the parameters such as iv.
    pub const CRYPTO_IV_DATABLOB: CryptoSymCipher_ParamsType = CryptoSymCipher_ParamsType(100);
    /// Indicates the additional Authenticated Data in GCM mode.
    pub const CRYPTO_AAD_DATABLOB: CryptoSymCipher_ParamsType = CryptoSymCipher_ParamsType(101);
    /// Indicates the output tag from the encryption operation. The tag is used for integrity check.
    pub const CRYPTO_TAG_DATABLOB: CryptoSymCipher_ParamsType = CryptoSymCipher_ParamsType(102);
}
#[repr(transparent)]
/// Define the cipher param type.
///
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct CryptoSymCipher_ParamsType(pub ::core::ffi::c_uint);
/// Define the symmetric key cipher structure.
///
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
#[repr(C)]
pub struct OH_CryptoSymCipher {
    _unused: [u8; 0],
}
/// Define the symmetric key cipher params structure.
///
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
#[repr(C)]
pub struct OH_CryptoSymCipherParams {
    _unused: [u8; 0],
}
extern "C" {
    /// Create a symmetric key cipher params.
    ///
    /// # Arguments
    ///
    /// * `params` - Indicates the pointer to the cipher params 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_CryptoSymCipherParams_Create(
        params: *mut *mut OH_CryptoSymCipherParams,
    ) -> CryptoResult;
    /// Set a parameter to the cipher params context.
    ///
    /// # Arguments
    ///
    /// * `params` - Indicates the parameters context.
    ///
    /// * `paramsType` - Set cipher parameters.
    ///
    /// * `value` - Indicates the setParam 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_CryptoSymCipherParams_SetParam(
        params: *mut OH_CryptoSymCipherParams,
        paramsType: CryptoSymCipher_ParamsType,
        value: *mut Crypto_DataBlob,
    ) -> CryptoResult;
    /// Destroy the cipher params context.
    ///
    /// # Arguments
    ///
    /// * `params` - Indicates the parameters context.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_CryptoSymCipherParams_Destroy(params: *mut OH_CryptoSymCipherParams);
    /// Create a symmetric key cipher context according to the given algorithm name.
    ///
    /// # Arguments
    ///
    /// * `algoName` - Indicates the algorithm name used to generate the symmetric key cipher context.
    /// Example AES128|GCM|PKCS7.
    ///
    /// * `ctx` - Indicates the pointer to the symmetric key cipher 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_CryptoSymCipher_Create(
        algoName: *const ::core::ffi::c_char,
        ctx: *mut *mut OH_CryptoSymCipher,
    ) -> CryptoResult;
    /// Init the crypto operation with the given crypto mode, key and parameters.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the symmetric key cipher context.
    ///
    /// * `mod` - Indicates the crypto mode is encryption or decryption.
    ///
    /// * `key` - Indicates the symmetric key or the asymmetric key.
    ///
    /// * `params` - Indicates the algorithm parameters such as IV.
    ///
    /// # 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_CryptoSymCipher_Update`] [`OH_CryptoSymCipher_Final`]
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_CryptoSymCipher_Init(
        ctx: *mut OH_CryptoSymCipher,
        mod_: Crypto_CipherMode,
        key: *mut OH_CryptoSymKey,
        params: *mut OH_CryptoSymCipherParams,
    ) -> CryptoResult;
    /// Update the crypto operation with the input data, and feed back the encrypted or decrypted data.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the symmetric key cipher context.
    ///
    /// * `in` - Indicates the data to be encrypted or decrypted.
    ///
    /// * `out` - Indicates the data to be update encrypted or decrypted.
    ///
    /// # 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_CryptoSymCipher_Init`] [`OH_CryptoSymCipher_Final`]
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_CryptoSymCipher_Update(
        ctx: *mut OH_CryptoSymCipher,
        in_: *mut Crypto_DataBlob,
        out: *mut Crypto_DataBlob,
    ) -> CryptoResult;
    /// Finish the crypto operation, encrypt or decrypt the input data, and then feed back the output data.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the symmetric key cipher context.
    ///
    /// * `in` - Indicates the data to be encrypted or decrypted.
    ///
    /// * `out` - Indicates the data to be finally encrypted or decrypted.
    ///
    /// # 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_CryptoSymCipher_Init`] [`OH_CryptoSymCipher_Update`]
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_CryptoSymCipher_Final(
        ctx: *mut OH_CryptoSymCipher,
        in_: *mut Crypto_DataBlob,
        out: *mut Crypto_DataBlob,
    ) -> CryptoResult;
    /// Get the algorithm name of the symmetric key cipher context.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the symmetric key context.
    ///
    /// # Returns
    ///
    /// * Return symmetric key cipher algorithm name.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_CryptoSymCipher_GetAlgoName(
        ctx: *mut OH_CryptoSymCipher,
    ) -> *const ::core::ffi::c_char;
    /// Destroy the symmetric key cipher context.
    ///
    /// # Arguments
    ///
    /// * `ctx` - 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_CryptoSymCipher_Destroy(ctx: *mut OH_CryptoSymCipher);
}