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::asym_key::OH_CryptoKeyPair;
use crate::common::{CryptoResult, Crypto_CipherMode, Crypto_DataBlob};

/// Defines the asymmetric cipher structure.
///
///
/// Available since API-level: 20
#[cfg(feature = "api-20")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
#[repr(C)]
pub struct OH_CryptoAsymCipher {
    _unused: [u8; 0],
}
/// Defines the SM2 ciphertext spec structure.
///
///
/// Available since API-level: 20
#[cfg(feature = "api-20")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
#[repr(C)]
pub struct OH_CryptoSm2CiphertextSpec {
    _unused: [u8; 0],
}
#[cfg(feature = "api-20")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
impl CryptoSm2CiphertextSpec_item {
    /// Public key x, also known as C1x.
    pub const CRYPTO_SM2_CIPHERTEXT_C1_X: CryptoSm2CiphertextSpec_item =
        CryptoSm2CiphertextSpec_item(0);
    /// Public key y, also known as C1y.
    pub const CRYPTO_SM2_CIPHERTEXT_C1_Y: CryptoSm2CiphertextSpec_item =
        CryptoSm2CiphertextSpec_item(1);
    /// Hash, also known as C2.
    pub const CRYPTO_SM2_CIPHERTEXT_C2: CryptoSm2CiphertextSpec_item =
        CryptoSm2CiphertextSpec_item(2);
    /// Ciphertext data, also known as C3.
    pub const CRYPTO_SM2_CIPHERTEXT_C3: CryptoSm2CiphertextSpec_item =
        CryptoSm2CiphertextSpec_item(3);
}
#[repr(transparent)]
/// Defines the SM2 ciphertext spec item 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 CryptoSm2CiphertextSpec_item(pub ::core::ffi::c_uint);
extern "C" {
    /// Creates an asymmetric cipher context according to the given algorithm name.
    ///
    /// # Arguments
    ///
    /// * `algoName` - Indicates the algorithm name used to generate the asymmetric cipher context. e.g. "RSA|PKCS1",
    /// "RSA|PKCS1_OAEP|SHA384|MGF1_SHA384", "SM2|SM3".
    ///
    /// * `ctx` - Indicates the pointer to the asymmetric cipher 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_CryptoAsymCipher_Create(
        algoName: *const ::core::ffi::c_char,
        ctx: *mut *mut OH_CryptoAsymCipher,
    ) -> CryptoResult;
    /// Initializes the asymmetric cipher context with the given crypto mode, key and parameters.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the asymmetric cipher context.
    ///
    /// * `mode` - Indicates the crypto mode is encryption or decryption.
    ///
    /// * `key` - Indicates the asymmetric 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_CryptoAsymCipher_Final`]
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_CryptoAsymCipher_Init(
        ctx: *mut OH_CryptoAsymCipher,
        mode: Crypto_CipherMode,
        key: *mut OH_CryptoKeyPair,
    ) -> CryptoResult;
    /// Finalizes the encryption or decryption operation.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the asymmetric cipher context.
    ///
    /// * `in` - Indicates the input data to be encrypted or decrypted.
    ///
    /// * `out` - Indicates the result of encryption or decryption.
    ///
    /// # 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_CryptoAsymCipher_Init`]
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_CryptoAsymCipher_Final(
        ctx: *mut OH_CryptoAsymCipher,
        in_: *const Crypto_DataBlob,
        out: *mut Crypto_DataBlob,
    ) -> CryptoResult;
    /// Destroys the asymmetric cipher context.
    ///
    /// # Arguments
    ///
    /// * `ctx` - Indicates the asymmetric cipher context.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_CryptoAsymCipher_Destroy(ctx: *mut OH_CryptoAsymCipher);
    /// Creates a SM2 ciphertext spec.
    ///
    /// # Arguments
    ///
    /// * `sm2Ciphertext` - Indicates the SM2 ciphertext in DER format, if sm2Ciphertext param is NULL,
    /// an empty SM2 ciphertext spec will be created.
    ///
    /// * `spec` - Indicates the output SM2 ciphertext spec.
    ///
    /// # 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_CryptoSm2CiphertextSpec_Create(
        sm2Ciphertext: *mut Crypto_DataBlob,
        spec: *mut *mut OH_CryptoSm2CiphertextSpec,
    ) -> CryptoResult;
    /// Gets the specified item of the SM2 ciphertext.
    ///
    /// # Arguments
    ///
    /// * `spec` - Indicates the SM2 ciphertext spec.
    ///
    /// * `item` - Indicates the SM2 ciphertext spec item.
    ///
    /// * `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_CryptoSm2CiphertextSpec_GetItem(
        spec: *mut OH_CryptoSm2CiphertextSpec,
        item: CryptoSm2CiphertextSpec_item,
        out: *mut Crypto_DataBlob,
    ) -> CryptoResult;
    /// Sets the specified item to the SM2 ciphertext spec.
    ///
    /// # Arguments
    ///
    /// * `spec` - Indicates the SM2 ciphertext spec.
    ///
    /// * `item` - Indicates the SM2 ciphertext spec item.
    ///
    /// * `in` - Indicates the input 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_CryptoSm2CiphertextSpec_SetItem(
        spec: *mut OH_CryptoSm2CiphertextSpec,
        item: CryptoSm2CiphertextSpec_item,
        in_: *mut Crypto_DataBlob,
    ) -> CryptoResult;
    /// Encodes the SM2 ciphertext spec to ciphertext in DER format.
    ///
    /// # Arguments
    ///
    /// * `spec` - Indicates the SM2 ciphertext spec.
    ///
    /// * `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_CryptoSm2CiphertextSpec_Encode(
        spec: *mut OH_CryptoSm2CiphertextSpec,
        out: *mut Crypto_DataBlob,
    ) -> CryptoResult;
    /// Destroys the SM2 ciphertext spec.
    ///
    /// # Arguments
    ///
    /// * `spec` - Indicates the SM2 ciphertext spec.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_CryptoSm2CiphertextSpec_Destroy(spec: *mut OH_CryptoSm2CiphertextSpec);
}