ohos_crypto_sys/mac/mac_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)]
6use crate::common::{CryptoResult, Crypto_DataBlob};
7use crate::sym_key::OH_CryptoSymKey;
8
9/// Defines the MAC structure.
10///
11///
12/// Available since API-level: 20
13#[cfg(feature = "api-20")]
14#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
15#[repr(C)]
16pub struct OH_CryptoMac {
17 _unused: [u8; 0],
18}
19#[cfg(feature = "api-20")]
20#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
21impl CryptoMac_ParamType {
22 /// Indicates the algorithm name of the message digest function for HMAC. e.g. "SHA256".
23 pub const CRYPTO_MAC_DIGEST_NAME_STR: CryptoMac_ParamType = CryptoMac_ParamType(0);
24 /// Indicates the algorithm name of the symmetric cipher function for CMAC. e.g. "AES256".
25 pub const CRYPTO_MAC_CIPHER_NAME_STR: CryptoMac_ParamType = CryptoMac_ParamType(1);
26}
27#[repr(transparent)]
28/// Defines the MAC algorithm parameter type.
29///
30///
31/// Available since API-level: 20
32#[cfg(feature = "api-20")]
33#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
34#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
35pub struct CryptoMac_ParamType(pub ::core::ffi::c_uint);
36extern "C" {
37 /// Creates a MAC context according to the given algorithm name.
38 ///
39 /// # Arguments
40 ///
41 /// * `algoName` - Indicates the algorithm name for generating the MAC context. e.g. "HMAC", "CMAC".
42 ///
43 /// * `ctx` - Indicates the pointer to the MAC context.
44 ///
45 /// # Returns
46 ///
47 /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
48 /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
49 /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
50 /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
51 /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
52 ///
53 /// Available since API-level: 20
54 #[cfg(feature = "api-20")]
55 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
56 pub fn OH_CryptoMac_Create(
57 algoName: *const ::core::ffi::c_char,
58 ctx: *mut *mut OH_CryptoMac,
59 ) -> CryptoResult;
60 /// Sets the specified parameter to the MAC context.
61 ///
62 /// # Arguments
63 ///
64 /// * `ctx` - Indicates the MAC context.
65 ///
66 /// * `type` - Indicates the MAC parameter type.
67 ///
68 /// * `value` - Indicates the parameter value.
69 ///
70 /// # Returns
71 ///
72 /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
73 /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
74 /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
75 /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
76 /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
77 ///
78 /// Available since API-level: 20
79 #[cfg(feature = "api-20")]
80 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
81 pub fn OH_CryptoMac_SetParam(
82 ctx: *mut OH_CryptoMac,
83 type_: CryptoMac_ParamType,
84 value: *const Crypto_DataBlob,
85 ) -> CryptoResult;
86 /// Initializes the MAC context with a symmetric key.
87 ///
88 /// # Arguments
89 ///
90 /// * `ctx` - Indicates the MAC context.
91 ///
92 /// * `key` - Indicates the symmetric key.
93 ///
94 /// # Returns
95 ///
96 /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
97 /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
98 /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
99 /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
100 /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
101 /// [`OH_CryptoMac_Update`] [`OH_CryptoMac_Final`]
102 /// Available since API-level: 20
103 #[cfg(feature = "api-20")]
104 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
105 pub fn OH_CryptoMac_Init(ctx: *mut OH_CryptoMac, key: *const OH_CryptoSymKey) -> CryptoResult;
106 /// Updates the MAC context with data.
107 ///
108 /// # Arguments
109 ///
110 /// * `ctx` - Indicates the MAC context.
111 ///
112 /// * `in` - Indicates the data to update.
113 ///
114 /// # Returns
115 ///
116 /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
117 /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
118 /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
119 /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
120 /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
121 /// [`OH_CryptoMac_Init`] [`OH_CryptoMac_Final`]
122 /// Available since API-level: 20
123 #[cfg(feature = "api-20")]
124 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
125 pub fn OH_CryptoMac_Update(ctx: *mut OH_CryptoMac, in_: *const Crypto_DataBlob)
126 -> CryptoResult;
127 /// Finalizes the MAC operation.
128 ///
129 /// # Arguments
130 ///
131 /// * `ctx` - Indicates the MAC context.
132 ///
133 /// * `out` - Indicates the MAC result.
134 ///
135 /// # Returns
136 ///
137 /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
138 /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
139 /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
140 /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
141 /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
142 /// [`OH_CryptoMac_Init`] [`OH_CryptoMac_Update`]
143 /// Available since API-level: 20
144 #[cfg(feature = "api-20")]
145 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
146 pub fn OH_CryptoMac_Final(ctx: *mut OH_CryptoMac, out: *mut Crypto_DataBlob) -> CryptoResult;
147 /// Gets the length of the MAC.
148 ///
149 /// # Arguments
150 ///
151 /// * `ctx` - Indicates the MAC context.
152 ///
153 /// * `length` - Indicates the MAC length.
154 ///
155 /// # Returns
156 ///
157 /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
158 /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
159 /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
160 /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
161 /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
162 ///
163 /// Available since API-level: 20
164 #[cfg(feature = "api-20")]
165 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
166 pub fn OH_CryptoMac_GetLength(ctx: *mut OH_CryptoMac, length: *mut u32) -> CryptoResult;
167 /// Destroys the MAC context.
168 ///
169 /// # Arguments
170 ///
171 /// * `ctx` - Indicates the MAC context.
172 ///
173 /// Available since API-level: 20
174 #[cfg(feature = "api-20")]
175 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
176 pub fn OH_CryptoMac_Destroy(ctx: *mut OH_CryptoMac);
177}