Skip to main content

ohos_crypto_sys/kdf/
kdf_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/// Defines the KDF structure.
9///
10///
11/// Available since API-level: 20
12#[cfg(feature = "api-20")]
13#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
14#[repr(C)]
15pub struct OH_CryptoKdf {
16    _unused: [u8; 0],
17}
18/// Defines the KDF params structure.
19///
20///
21/// Available since API-level: 20
22#[cfg(feature = "api-20")]
23#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
24#[repr(C)]
25pub struct OH_CryptoKdfParams {
26    _unused: [u8; 0],
27}
28#[cfg(feature = "api-20")]
29#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
30impl CryptoKdf_ParamType {
31    /// Indicates the key or password for KDF.
32    pub const CRYPTO_KDF_KEY_DATABLOB: CryptoKdf_ParamType = CryptoKdf_ParamType(0);
33    /// Indicates the salt for KDF.
34    pub const CRYPTO_KDF_SALT_DATABLOB: CryptoKdf_ParamType = CryptoKdf_ParamType(1);
35    /// Indicates the info for KDF.
36    pub const CRYPTO_KDF_INFO_DATABLOB: CryptoKdf_ParamType = CryptoKdf_ParamType(2);
37    /// Indicates the iteration count for PBKDF2.
38    pub const CRYPTO_KDF_ITER_COUNT_INT: CryptoKdf_ParamType = CryptoKdf_ParamType(3);
39    /// Indicates the n for SCRYPT KDF.
40    pub const CRYPTO_KDF_SCRYPT_N_UINT64: CryptoKdf_ParamType = CryptoKdf_ParamType(4);
41    /// Indicates the r for SCRYPT KDF.
42    pub const CRYPTO_KDF_SCRYPT_R_UINT64: CryptoKdf_ParamType = CryptoKdf_ParamType(5);
43    /// Indicates the p for SCRYPT KDF.
44    pub const CRYPTO_KDF_SCRYPT_P_UINT64: CryptoKdf_ParamType = CryptoKdf_ParamType(6);
45    /// Indicates the max memory for SCRYPT KDF.
46    pub const CRYPTO_KDF_SCRYPT_MAX_MEM_UINT64: CryptoKdf_ParamType = CryptoKdf_ParamType(7);
47}
48#[repr(transparent)]
49/// Defines the KDF param type.
50///
51///
52/// Available since API-level: 20
53#[cfg(feature = "api-20")]
54#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
55#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
56pub struct CryptoKdf_ParamType(pub ::core::ffi::c_uint);
57extern "C" {
58    /// Creates KDF params.
59    ///
60    /// # Arguments
61    ///
62    /// * `algoName` - Indicates the KDF algorithm name. e.g. "HKDF", "PBKDF2", "SCRYPT".
63    ///
64    /// * `params` - Indicates the KDF params.
65    ///
66    /// # Returns
67    ///
68    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
69    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
70    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
71    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
72    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
73    ///
74    /// Available since API-level: 20
75    #[cfg(feature = "api-20")]
76    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
77    pub fn OH_CryptoKdfParams_Create(
78        algoName: *const ::core::ffi::c_char,
79        params: *mut *mut OH_CryptoKdfParams,
80    ) -> CryptoResult;
81    /// Sets a parameter to the KDF parameters.
82    ///
83    /// # Arguments
84    ///
85    /// * `params` - Indicates the KDF parameters.
86    ///
87    /// * `type` - Indicates the KDF parameter type.
88    ///
89    /// * `value` - Indicates the KDF parameter value.
90    ///
91    /// # Returns
92    ///
93    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
94    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
95    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
96    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
97    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
98    ///
99    /// Available since API-level: 20
100    #[cfg(feature = "api-20")]
101    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
102    pub fn OH_CryptoKdfParams_SetParam(
103        params: *mut OH_CryptoKdfParams,
104        type_: CryptoKdf_ParamType,
105        value: *mut Crypto_DataBlob,
106    ) -> CryptoResult;
107    /// Destroys the KDF params.
108    ///
109    /// # Arguments
110    ///
111    /// * `params` - Indicates the KDF parameters.
112    ///
113    /// Available since API-level: 20
114    #[cfg(feature = "api-20")]
115    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
116    pub fn OH_CryptoKdfParams_Destroy(params: *mut OH_CryptoKdfParams);
117    /// Creates a KDF context.
118    ///
119    /// # Arguments
120    ///
121    /// * `algoName` - Indicates the KDF algorithm name. e.g. "HKDF|SHA384|EXTRACT_AND_EXPAND", "PBKDF2|SHA384", "SCRYPT".
122    ///
123    /// * `ctx` - Indicates the KDF context.
124    ///
125    /// # Returns
126    ///
127    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
128    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
129    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
130    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
131    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
132    ///
133    /// Available since API-level: 20
134    #[cfg(feature = "api-20")]
135    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
136    pub fn OH_CryptoKdf_Create(
137        algoName: *const ::core::ffi::c_char,
138        ctx: *mut *mut OH_CryptoKdf,
139    ) -> CryptoResult;
140    /// Derives a key.
141    ///
142    /// # Arguments
143    ///
144    /// * `ctx` - The KDF context.
145    ///
146    /// * `params` - Indicates the KDF parameters.
147    ///
148    /// * `keyLen` - Indicates the key derivation length.
149    ///
150    /// * `key` - Indicates the derived key.
151    ///
152    /// # Returns
153    ///
154    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
155    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
156    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
157    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
158    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
159    ///
160    /// Available since API-level: 20
161    #[cfg(feature = "api-20")]
162    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
163    pub fn OH_CryptoKdf_Derive(
164        ctx: *mut OH_CryptoKdf,
165        params: *const OH_CryptoKdfParams,
166        keyLen: ::core::ffi::c_int,
167        key: *mut Crypto_DataBlob,
168    ) -> CryptoResult;
169    /// Destroys the KDF context.
170    ///
171    /// # Arguments
172    ///
173    /// * `ctx` - The KDF context.
174    ///
175    /// Available since API-level: 20
176    #[cfg(feature = "api-20")]
177    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
178    pub fn OH_CryptoKdf_Destroy(ctx: *mut OH_CryptoKdf);
179}