Skip to main content

ohos_crypto_sys/common/
common_ffi.rs

1// automatically generated by rust-bindgen 0.71.1
2
3#![allow(non_upper_case_globals)]
4#![allow(non_camel_case_types)]
5#![allow(non_snake_case)]
6
7/// Crypto data struct.
8///
9///
10/// Available since API-level: 12
11#[cfg(feature = "api-12")]
12#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
13#[repr(C)]
14pub struct Crypto_DataBlob {
15    /// Data buffer.
16    pub data: *mut u8,
17    /// Data length.
18    pub len: usize,
19}
20pub type CryptoResult = Result<(), CryptoErrorCode>;
21#[cfg(feature = "api-12")]
22#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
23impl CryptoErrorCode {
24    /// Indicates that input parameters is invalid.
25    pub const INVALID_PARAMS: CryptoErrorCode =
26        CryptoErrorCode(const { core::num::NonZero::new(401).unwrap() });
27    /// Indicates that function or algorithm is not supported.
28    pub const NOT_SUPPORTED: CryptoErrorCode =
29        CryptoErrorCode(const { core::num::NonZero::new(801).unwrap() });
30    /// Indicates the memory error.
31    pub const MEMORY_ERROR: CryptoErrorCode =
32        CryptoErrorCode(const { core::num::NonZero::new(17620001).unwrap() });
33    /// Indicates that parameter check failed.
34    ///
35    /// Available since API-level: 20
36    #[cfg(feature = "api-20")]
37    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
38    pub const PARAMETER_CHECK_FAILED: CryptoErrorCode =
39        CryptoErrorCode(const { core::num::NonZero::new(17620003).unwrap() });
40    /// Indicates that crypto operation error.
41    pub const OPERTION_ERROR: CryptoErrorCode =
42        CryptoErrorCode(const { core::num::NonZero::new(17630001).unwrap() });
43}
44#[repr(transparent)]
45/// Enumerates the error codes.
46///
47///
48/// Available since API-level: 12
49#[cfg(feature = "api-12")]
50#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
51#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
52pub struct CryptoErrorCode(pub core::num::NonZero<::core::ffi::c_uint>);
53#[cfg(feature = "api-12")]
54#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
55impl Crypto_CipherMode {
56    /// Indicates encryption operation.
57    pub const CRYPTO_ENCRYPT_MODE: Crypto_CipherMode = Crypto_CipherMode(0);
58    /// Indicates decryption operation.
59    pub const CRYPTO_DECRYPT_MODE: Crypto_CipherMode = Crypto_CipherMode(1);
60}
61#[repr(transparent)]
62/// Define crypto cipher mode.
63///
64///
65/// Available since API-level: 12
66#[cfg(feature = "api-12")]
67#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
68#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
69pub struct Crypto_CipherMode(pub ::core::ffi::c_uint);
70extern "C" {
71    /// Free the data of dataBlob.
72    ///
73    /// # Arguments
74    ///
75    /// * `dataBlob` - Indicates the data blob.
76    ///
77    /// Available since API-level: 12
78    #[cfg(feature = "api-12")]
79    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
80    pub fn OH_Crypto_FreeDataBlob(dataBlob: *mut Crypto_DataBlob);
81}