ohos_crypto_sys/sym_key/sym_key_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};
7
8/// Define the symmetric key structure.
9///
10///
11/// Available since API-level: 12
12#[cfg(feature = "api-12")]
13#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
14#[repr(C)]
15pub struct OH_CryptoSymKey {
16 _unused: [u8; 0],
17}
18/// Define the symmetric key generator structure.
19///
20///
21/// Available since API-level: 12
22#[cfg(feature = "api-12")]
23#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
24#[repr(C)]
25pub struct OH_CryptoSymKeyGenerator {
26 _unused: [u8; 0],
27}
28extern "C" {
29 /// Create a symmetric key generator according to the given algorithm name. Example AES256.
30 ///
31 /// # Arguments
32 ///
33 /// * `algoName` - Indicates the algorithm name for generating the generator.
34 ///
35 /// * `ctx` - Indicates the pointer to the symmetric key generator context.
36 ///
37 /// # Returns
38 ///
39 /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
40 /// [`OH_Crypto_ErrCode#CRYPTO_INVALID_PARAMS`] 401 - If parameter is invalid.
41 /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
42 /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
43 /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto opertion failed.
44 ///
45 /// Available since API-level: 12
46 #[cfg(feature = "api-12")]
47 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
48 pub fn OH_CryptoSymKeyGenerator_Create(
49 algoName: *const ::core::ffi::c_char,
50 ctx: *mut *mut OH_CryptoSymKeyGenerator,
51 ) -> CryptoResult;
52 /// Generate a symmetric key.
53 ///
54 /// # Arguments
55 ///
56 /// * `ctx` - Indicates the Symmetric key generator context.
57 ///
58 /// * `keyCtx` - Indicates the pointer to the symmetric key context.
59 ///
60 /// # Returns
61 ///
62 /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
63 /// [`OH_Crypto_ErrCode#CRYPTO_INVALID_PARAMS`] 401 - If parameter is invalid.
64 /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
65 /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
66 /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto opertion failed.
67 ///
68 /// Available since API-level: 12
69 #[cfg(feature = "api-12")]
70 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
71 pub fn OH_CryptoSymKeyGenerator_Generate(
72 ctx: *mut OH_CryptoSymKeyGenerator,
73 keyCtx: *mut *mut OH_CryptoSymKey,
74 ) -> CryptoResult;
75 /// Convert the symmetric key data to a key.
76 ///
77 /// # Arguments
78 ///
79 /// * `ctx` - Indicates the symmetric key generator context.
80 ///
81 /// * `keyData` - Indicates the data to generate the Symkey.
82 ///
83 /// * `keyCtx` - Indicates the pointer to the symmetric key context.
84 ///
85 /// # Returns
86 ///
87 /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
88 /// [`OH_Crypto_ErrCode#CRYPTO_INVALID_PARAMS`] 401 - If parameter is invalid.
89 /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
90 /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
91 /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto opertion failed.
92 ///
93 /// Available since API-level: 12
94 #[cfg(feature = "api-12")]
95 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
96 pub fn OH_CryptoSymKeyGenerator_Convert(
97 ctx: *mut OH_CryptoSymKeyGenerator,
98 keyData: *const Crypto_DataBlob,
99 keyCtx: *mut *mut OH_CryptoSymKey,
100 ) -> CryptoResult;
101 /// Get the algorithm name of the symmetric key generator.
102 ///
103 /// # Arguments
104 ///
105 /// * `ctx` - Indicates the symmetric key generator context.
106 ///
107 /// # Returns
108 ///
109 /// * Return symmetric key algorithm name.
110 ///
111 /// Available since API-level: 12
112 #[cfg(feature = "api-12")]
113 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
114 pub fn OH_CryptoSymKeyGenerator_GetAlgoName(
115 ctx: *mut OH_CryptoSymKeyGenerator,
116 ) -> *const ::core::ffi::c_char;
117 /// Destroy the symmetric key generator.
118 ///
119 /// # Arguments
120 ///
121 /// * `ctx` - Indicates the symmetric key generator context.
122 ///
123 /// Available since API-level: 12
124 #[cfg(feature = "api-12")]
125 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
126 pub fn OH_CryptoSymKeyGenerator_Destroy(ctx: *mut OH_CryptoSymKeyGenerator);
127 /// Get the symmetric key algorithm name from a symmetric key.
128 ///
129 /// # Arguments
130 ///
131 /// * `keyCtx` - Indicates the symmetric key context.
132 ///
133 /// # Returns
134 ///
135 /// * Return algorithm name.
136 ///
137 /// Available since API-level: 12
138 #[cfg(feature = "api-12")]
139 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
140 pub fn OH_CryptoSymKey_GetAlgoName(keyCtx: *mut OH_CryptoSymKey) -> *const ::core::ffi::c_char;
141 /// Get the symmetric key data from a symmetric key.
142 ///
143 /// # Arguments
144 ///
145 /// * `keyCtx` - Indicates the symmetric key context.
146 ///
147 /// * `out` - Indicate to obtain the result.
148 ///
149 /// # Returns
150 ///
151 /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
152 /// [`OH_Crypto_ErrCode#CRYPTO_INVALID_PARAMS`] 401 - If parameter is invalid.
153 /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
154 /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
155 /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto opertion failed.
156 ///
157 /// Available since API-level: 12
158 #[cfg(feature = "api-12")]
159 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
160 pub fn OH_CryptoSymKey_GetKeyData(
161 keyCtx: *mut OH_CryptoSymKey,
162 out: *mut Crypto_DataBlob,
163 ) -> CryptoResult;
164 /// Destroy the symmetric key.
165 ///
166 /// # Arguments
167 ///
168 /// * `keyCtx` - Indicates the symmetric key context.
169 ///
170 /// Available since API-level: 12
171 #[cfg(feature = "api-12")]
172 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
173 pub fn OH_CryptoSymKey_Destroy(keyCtx: *mut OH_CryptoSymKey);
174}