Skip to main content

ohos_crypto_sys/asym_key/
asym_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 key pair 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_CryptoKeyPair {
16    _unused: [u8; 0],
17}
18/// Define the public key 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_CryptoPubKey {
26    _unused: [u8; 0],
27}
28/// Defines the private key structure.
29///
30///
31/// Available since API-level: 20
32#[cfg(feature = "api-20")]
33#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
34#[repr(C)]
35pub struct OH_CryptoPrivKey {
36    _unused: [u8; 0],
37}
38#[cfg(feature = "api-12")]
39#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
40impl CryptoAsymKey_ParamType {
41    /// Indicates the DSA prime p.
42    pub const CRYPTO_DSA_P_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(101);
43    /// Indicates the DSA sub-prime q.
44    pub const CRYPTO_DSA_Q_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(102);
45    /// Indicates the DSA base g.
46    pub const CRYPTO_DSA_G_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(103);
47    /// Indicates the DSA private key.
48    pub const CRYPTO_DSA_SK_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(104);
49    /// Indicates the DSA public key.
50    pub const CRYPTO_DSA_PK_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(105);
51    /// Indicates the prime p of an elliptic curve (EC) prime finite field.
52    pub const CRYPTO_ECC_FP_P_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(201);
53    /// Indicates the first coefficient a of this elliptic curve.
54    pub const CRYPTO_ECC_A_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(202);
55    /// Indicates the second coefficient b of this elliptic curve.
56    pub const CRYPTO_ECC_B_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(203);
57    /// Indicates the affine x-coordinate of base point g.
58    pub const CRYPTO_ECC_G_X_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(204);
59    /// Indicates the affine y-coordinate of base point g.
60    pub const CRYPTO_ECC_G_Y_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(205);
61    /// Indicates the order of the base point g.
62    pub const CRYPTO_ECC_N_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(206);
63    /// Indicates the cofactor of the elliptic curve.
64    pub const CRYPTO_ECC_H_INT: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(207);
65    /// Indicates the private value of the ECC private key.
66    pub const CRYPTO_ECC_SK_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(208);
67    /// Indicates the affine x-coordinate of a point, which is the public point of an ECC public key.
68    pub const CRYPTO_ECC_PK_X_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(209);
69    /// Indicates the affine y-coordinate of a point, which is the public point of an ECC public key.
70    pub const CRYPTO_ECC_PK_Y_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(210);
71    /// Indicates an elliptic curve finite field type.
72    pub const CRYPTO_ECC_FIELD_TYPE_STR: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(211);
73    /// Indicates the field size in bits.
74    pub const CRYPTO_ECC_FIELD_SIZE_INT: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(212);
75    /// Indicates the curve name according to SECG (Standards for Efficient Cryptography Group).
76    pub const CRYPTO_ECC_CURVE_NAME_STR: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(213);
77    /// Indicates the modulus n of RSA algorithm.
78    pub const CRYPTO_RSA_N_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(301);
79    /// Indicates the private exponent d of RSA algorithm.
80    pub const CRYPTO_RSA_D_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(302);
81    /// Indicates the public exponent e of RSA algorithm.
82    pub const CRYPTO_RSA_E_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(303);
83    /// Indicates the prime p of DH algorithm.
84    pub const CRYPTO_DH_P_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(401);
85    /// Indicates the generator g of DH algorithm.
86    pub const CRYPTO_DH_G_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(402);
87    /// Indicates the number of bits of the private key length used in the DH algorithm.
88    pub const CRYPTO_DH_L_INT: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(403);
89    /// Indicates the private value of the DH private key.
90    pub const CRYPTO_DH_SK_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(404);
91    /// Indicates the public value of the DH public key.
92    pub const CRYPTO_DH_PK_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(405);
93    /// Indicates the private value of the ED25519 private key.
94    pub const CRYPTO_ED25519_SK_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(501);
95    /// Indicates the public value of the ED25519 public key.
96    pub const CRYPTO_ED25519_PK_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(502);
97    /// Indicates the private value of the X25519 private key.
98    pub const CRYPTO_X25519_SK_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(601);
99    /// Indicates the public value of the X25519 public key.
100    pub const CRYPTO_X25519_PK_DATABLOB: CryptoAsymKey_ParamType = CryptoAsymKey_ParamType(602);
101}
102#[repr(transparent)]
103/// Define the asymmetric key parameter types.
104///
105///
106/// Available since API-level: 12
107#[cfg(feature = "api-12")]
108#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
109#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
110pub struct CryptoAsymKey_ParamType(pub ::core::ffi::c_uint);
111#[cfg(feature = "api-12")]
112#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
113impl Crypto_EncodingType {
114    /// PEM format
115    pub const CRYPTO_PEM: Crypto_EncodingType = Crypto_EncodingType(0);
116    /// DER format
117    pub const CRYPTO_DER: Crypto_EncodingType = Crypto_EncodingType(1);
118}
119#[repr(transparent)]
120/// Define the encoding type.
121///
122///
123/// Available since API-level: 12
124#[cfg(feature = "api-12")]
125#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
126#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
127pub struct Crypto_EncodingType(pub ::core::ffi::c_uint);
128/// Define the asymmetric key generator structure.
129///
130///
131/// Available since API-level: 12
132#[cfg(feature = "api-12")]
133#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
134#[repr(C)]
135pub struct OH_CryptoAsymKeyGenerator {
136    _unused: [u8; 0],
137}
138/// Defines the private key encoding params structure.
139///
140///
141/// Available since API-level: 20
142#[cfg(feature = "api-20")]
143#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
144#[repr(C)]
145pub struct OH_CryptoPrivKeyEncodingParams {
146    _unused: [u8; 0],
147}
148#[cfg(feature = "api-20")]
149#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
150impl CryptoPrivKeyEncoding_ParamType {
151    /// Indicates the password string.
152    pub const CRYPTO_PRIVATE_KEY_ENCODING_PASSWORD_STR: CryptoPrivKeyEncoding_ParamType =
153        CryptoPrivKeyEncoding_ParamType(0);
154    /// Indicates the symmetric cipher string.
155    pub const CRYPTO_PRIVATE_KEY_ENCODING_SYMMETRIC_CIPHER_STR: CryptoPrivKeyEncoding_ParamType =
156        CryptoPrivKeyEncoding_ParamType(1);
157}
158#[repr(transparent)]
159/// Defines the private key encoding param type.
160///
161///
162/// Available since API-level: 20
163#[cfg(feature = "api-20")]
164#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
165#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
166pub struct CryptoPrivKeyEncoding_ParamType(pub ::core::ffi::c_uint);
167/// Defines the asymmetric key spec structure.
168///
169///
170/// Available since API-level: 20
171#[cfg(feature = "api-20")]
172#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
173#[repr(C)]
174pub struct OH_CryptoAsymKeySpec {
175    _unused: [u8; 0],
176}
177#[cfg(feature = "api-20")]
178#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
179impl CryptoAsymKeySpec_Type {
180    /// Common parameters spec.
181    pub const CRYPTO_ASYM_KEY_COMMON_PARAMS_SPEC: CryptoAsymKeySpec_Type =
182        CryptoAsymKeySpec_Type(0);
183    /// Private key spec.
184    pub const CRYPTO_ASYM_KEY_PRIVATE_KEY_SPEC: CryptoAsymKeySpec_Type = CryptoAsymKeySpec_Type(1);
185    /// Public key spec.
186    pub const CRYPTO_ASYM_KEY_PUBLIC_KEY_SPEC: CryptoAsymKeySpec_Type = CryptoAsymKeySpec_Type(2);
187    /// Key pair spec.
188    pub const CRYPTO_ASYM_KEY_KEY_PAIR_SPEC: CryptoAsymKeySpec_Type = CryptoAsymKeySpec_Type(3);
189}
190#[repr(transparent)]
191/// Defines the asymmetric key spec type.
192///
193///
194/// Available since API-level: 20
195#[cfg(feature = "api-20")]
196#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
197#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
198pub struct CryptoAsymKeySpec_Type(pub ::core::ffi::c_uint);
199/// Defines the asymmetric key generator with spec.
200///
201///
202/// Available since API-level: 20
203#[cfg(feature = "api-20")]
204#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
205#[repr(C)]
206pub struct OH_CryptoAsymKeyGeneratorWithSpec {
207    _unused: [u8; 0],
208}
209/// Defines the EC point structure.
210///
211///
212/// Available since API-level: 20
213#[cfg(feature = "api-20")]
214#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
215#[repr(C)]
216pub struct OH_CryptoEcPoint {
217    _unused: [u8; 0],
218}
219extern "C" {
220    /// Create an asymmetric key generator according to the given algorithm name.
221    ///
222    /// # Arguments
223    ///
224    /// * `algoName` - Indicates the algorithm name for generating the generator. Example RSA1024|PRIMES_2.
225    ///
226    /// * `ctx` - Indicates the pointer to asymmetric key generator context.
227    ///
228    /// # Returns
229    ///
230    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
231    /// [`OH_Crypto_ErrCode#CRYPTO_INVALID_PARAMS`] 401 - If parameter is invalid.
232    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
233    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
234    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto opertion failed.
235    ///
236    /// Available since API-level: 12
237    #[cfg(feature = "api-12")]
238    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
239    pub fn OH_CryptoAsymKeyGenerator_Create(
240        algoName: *const ::core::ffi::c_char,
241        ctx: *mut *mut OH_CryptoAsymKeyGenerator,
242    ) -> CryptoResult;
243    /// Generate an asymmetric key(a key pair).
244    ///
245    /// # Arguments
246    ///
247    /// * `ctx` - Indicates the asymmetric key generator context.
248    ///
249    /// * `keyCtx` - Indicates the pointer to the asyKey context.
250    ///
251    /// # Returns
252    ///
253    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
254    /// [`OH_Crypto_ErrCode#CRYPTO_INVALID_PARAMS`] 401 - If parameter is invalid.
255    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
256    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
257    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto opertion failed.
258    ///
259    /// Available since API-level: 12
260    #[cfg(feature = "api-12")]
261    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
262    pub fn OH_CryptoAsymKeyGenerator_Generate(
263        ctx: *mut OH_CryptoAsymKeyGenerator,
264        keyCtx: *mut *mut OH_CryptoKeyPair,
265    ) -> CryptoResult;
266    /// Convert the asymmetric key data to a key pair.
267    ///
268    /// # Arguments
269    ///
270    /// * `ctx` - Indicates the asymmetric key generator context.
271    ///
272    /// * `type` - Indicates the encryption encoding type.
273    ///
274    /// * `pubKeyData` - Indicates the public key data.
275    ///
276    /// * `priKeyData` - Indicates the private key data.
277    ///
278    /// * `keyCtx` - Indicates the pointer to the keyPair instance.
279    ///
280    /// # Returns
281    ///
282    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
283    /// [`OH_Crypto_ErrCode#CRYPTO_INVALID_PARAMS`] 401 - If parameter is invalid.
284    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
285    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
286    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto opertion failed.
287    ///
288    /// Available since API-level: 12
289    #[cfg(feature = "api-12")]
290    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
291    pub fn OH_CryptoAsymKeyGenerator_Convert(
292        ctx: *mut OH_CryptoAsymKeyGenerator,
293        type_: Crypto_EncodingType,
294        pubKeyData: *mut Crypto_DataBlob,
295        priKeyData: *mut Crypto_DataBlob,
296        keyCtx: *mut *mut OH_CryptoKeyPair,
297    ) -> CryptoResult;
298    /// Get the algorithm name of the asymmetric key generator.
299    ///
300    /// # Arguments
301    ///
302    /// * `ctx` - Indicates the asymmetric key generator context.
303    ///
304    /// # Returns
305    ///
306    /// * Returns the asymmetric key algorithm name.
307    ///
308    /// Available since API-level: 12
309    #[cfg(feature = "api-12")]
310    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
311    pub fn OH_CryptoAsymKeyGenerator_GetAlgoName(
312        ctx: *mut OH_CryptoAsymKeyGenerator,
313    ) -> *const ::core::ffi::c_char;
314    /// Destroy the asymmetric key generator.
315    ///
316    /// # Arguments
317    ///
318    /// * `ctx` - Indicates the asymmetric key generator context.
319    ///
320    /// Available since API-level: 12
321    #[cfg(feature = "api-12")]
322    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
323    pub fn OH_CryptoAsymKeyGenerator_Destroy(ctx: *mut OH_CryptoAsymKeyGenerator);
324    /// Destroy the key pair.
325    ///
326    /// # Arguments
327    ///
328    /// * `keyCtx` - Indicates the keyPair context.
329    ///
330    /// Available since API-level: 12
331    #[cfg(feature = "api-12")]
332    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
333    pub fn OH_CryptoKeyPair_Destroy(keyCtx: *mut OH_CryptoKeyPair);
334    /// Get the public key of the key pair.
335    ///
336    /// # Arguments
337    ///
338    /// * `keyCtx` - Indicates the keyPair context.
339    ///
340    /// # Returns
341    ///
342    /// * Return the public key context from the key pair.
343    ///
344    /// Available since API-level: 12
345    #[cfg(feature = "api-12")]
346    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
347    pub fn OH_CryptoKeyPair_GetPubKey(keyCtx: *mut OH_CryptoKeyPair) -> *mut OH_CryptoPubKey;
348    /// Gets the private key of the key pair.
349    ///
350    /// # Arguments
351    ///
352    /// * `keyCtx` - Indicates the keyPair context.
353    ///
354    /// # Returns
355    ///
356    /// * Return the private key context from the key pair.
357    ///
358    /// Available since API-level: 20
359    #[cfg(feature = "api-20")]
360    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
361    pub fn OH_CryptoKeyPair_GetPrivKey(keyCtx: *mut OH_CryptoKeyPair) -> *mut OH_CryptoPrivKey;
362    /// Encode the public key.
363    ///
364    /// # Arguments
365    ///
366    /// * `key` - Indicates the public key.
367    ///
368    /// * `type` - Indicates the pubkey type.
369    ///
370    /// * `encodingStandard` - Indicates the encoding standard.
371    ///
372    /// * `out` - Indicates the encoded result.
373    ///
374    /// # Returns
375    ///
376    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
377    /// [`OH_Crypto_ErrCode#CRYPTO_INVALID_PARAMS`] 401 - If parameter is invalid.
378    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
379    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
380    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto opertion failed.
381    ///
382    /// Available since API-level: 12
383    #[cfg(feature = "api-12")]
384    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
385    pub fn OH_CryptoPubKey_Encode(
386        key: *mut OH_CryptoPubKey,
387        type_: Crypto_EncodingType,
388        encodingStandard: *const ::core::ffi::c_char,
389        out: *mut Crypto_DataBlob,
390    ) -> CryptoResult;
391    /// Get the specified param of the public key.
392    ///
393    /// # Arguments
394    ///
395    /// * `key` - Indicates the public key.
396    ///
397    /// * `item` - Indicates the asymmetric key param type.
398    ///
399    /// * `value` - Indicates the output data.
400    ///
401    /// # Returns
402    ///
403    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
404    /// [`OH_Crypto_ErrCode#CRYPTO_INVALID_PARAMS`] 401 - If parameter is invalid.
405    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
406    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
407    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto opertion failed.
408    ///
409    /// Available since API-level: 12
410    #[cfg(feature = "api-12")]
411    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
412    pub fn OH_CryptoPubKey_GetParam(
413        key: *mut OH_CryptoPubKey,
414        item: CryptoAsymKey_ParamType,
415        value: *mut Crypto_DataBlob,
416    ) -> CryptoResult;
417    /// Sets the password to the asymmetric key generator context.
418    ///
419    /// Call this method to set the password if you need to convert encrypted private key data to a key pair using
420    /// [`OH_CryptoAsymKeyGenerator_Convert`].
421    ///
422    ///
423    /// # Arguments
424    ///
425    /// * `ctx` - Indicates the asymmetric key generator context.
426    ///
427    /// * `password` - Indicates the password.
428    ///
429    /// * `passwordLen` - Indicates the password length.
430    ///
431    /// # Returns
432    ///
433    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
434    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
435    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
436    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
437    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
438    ///
439    /// Available since API-level: 20
440    #[cfg(feature = "api-20")]
441    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
442    pub fn OH_CryptoAsymKeyGenerator_SetPassword(
443        ctx: *mut OH_CryptoAsymKeyGenerator,
444        password: *const ::core::ffi::c_uchar,
445        passwordLen: u32,
446    ) -> CryptoResult;
447    /// Creates private key encoding params.
448    ///
449    /// # Arguments
450    ///
451    /// * `ctx` - Indicates the private key encoding params.
452    ///
453    /// # Returns
454    ///
455    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
456    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
457    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
458    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
459    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
460    ///
461    /// Available since API-level: 20
462    #[cfg(feature = "api-20")]
463    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
464    pub fn OH_CryptoPrivKeyEncodingParams_Create(
465        ctx: *mut *mut OH_CryptoPrivKeyEncodingParams,
466    ) -> CryptoResult;
467    /// Sets the private key encoding params.
468    ///
469    /// # Arguments
470    ///
471    /// * `ctx` - Indicates the private key encoding params.
472    ///
473    /// * `type` - Indicates the private key encoding param type.
474    ///
475    /// * `value` - Indicates the private key encoding params value.
476    ///
477    /// # Returns
478    ///
479    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
480    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
481    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
482    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
483    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
484    ///
485    /// Available since API-level: 20
486    #[cfg(feature = "api-20")]
487    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
488    pub fn OH_CryptoPrivKeyEncodingParams_SetParam(
489        ctx: *mut OH_CryptoPrivKeyEncodingParams,
490        type_: CryptoPrivKeyEncoding_ParamType,
491        value: *mut Crypto_DataBlob,
492    ) -> CryptoResult;
493    /// Destroys the private key encoding params.
494    ///
495    /// # Arguments
496    ///
497    /// * `ctx` - Indicates the private key encoding params.
498    ///
499    /// Available since API-level: 20
500    #[cfg(feature = "api-20")]
501    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
502    pub fn OH_CryptoPrivKeyEncodingParams_Destroy(ctx: *mut OH_CryptoPrivKeyEncodingParams);
503    /// Encodes the private key.
504    ///
505    /// # Arguments
506    ///
507    /// * `key` - Indicates the private key.
508    ///
509    /// * `type` - Indicates the private encoding type.
510    ///
511    /// * `encodingStandard` - Indicates the encoding standard, such as "PKCS8".
512    ///
513    /// * `params` - Indicates the private key encoding params, it can be NULL, and if you want encypt the private key,
514    /// you should set this param.
515    ///
516    /// * `out` - Indicates the encoded result.
517    ///
518    /// # Returns
519    ///
520    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
521    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
522    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
523    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
524    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
525    ///
526    /// Available since API-level: 20
527    #[cfg(feature = "api-20")]
528    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
529    pub fn OH_CryptoPrivKey_Encode(
530        key: *mut OH_CryptoPrivKey,
531        type_: Crypto_EncodingType,
532        encodingStandard: *const ::core::ffi::c_char,
533        params: *mut OH_CryptoPrivKeyEncodingParams,
534        out: *mut Crypto_DataBlob,
535    ) -> CryptoResult;
536    /// Gets the specified param of the private key.
537    ///
538    /// # Arguments
539    ///
540    /// * `key` - Indicates the private key.
541    ///
542    /// * `item` - Indicates the asymmetric key param type.
543    ///
544    /// * `value` - Indicates the output data.
545    ///
546    /// # Returns
547    ///
548    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
549    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
550    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
551    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
552    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
553    ///
554    /// Available since API-level: 20
555    #[cfg(feature = "api-20")]
556    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
557    pub fn OH_CryptoPrivKey_GetParam(
558        key: *mut OH_CryptoPrivKey,
559        item: CryptoAsymKey_ParamType,
560        value: *mut Crypto_DataBlob,
561    ) -> CryptoResult;
562    /// Generates an EC common parameters spec.
563    ///
564    /// # Arguments
565    ///
566    /// * `curveName` - Indicates the ECC curve name.
567    ///
568    /// * `spec` - Indicates the pointer to the EC common parameters spec.
569    ///
570    /// # Returns
571    ///
572    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
573    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
574    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
575    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
576    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
577    ///
578    /// Available since API-level: 20
579    #[cfg(feature = "api-20")]
580    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
581    pub fn OH_CryptoAsymKeySpec_GenEcCommonParamsSpec(
582        curveName: *const ::core::ffi::c_char,
583        spec: *mut *mut OH_CryptoAsymKeySpec,
584    ) -> CryptoResult;
585    /// Generates a DH common parameters spec.
586    ///
587    /// # Arguments
588    ///
589    /// * `pLen` - Indicates the byte length of the prime p.
590    ///
591    /// * `skLen` - Indicates the byte length of the private key.
592    ///
593    /// * `spec` - Indicates the pointer to the DH common parameters spec.
594    ///
595    /// # Returns
596    ///
597    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
598    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
599    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
600    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
601    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
602    ///
603    /// Available since API-level: 20
604    #[cfg(feature = "api-20")]
605    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
606    pub fn OH_CryptoAsymKeySpec_GenDhCommonParamsSpec(
607        pLen: ::core::ffi::c_int,
608        skLen: ::core::ffi::c_int,
609        spec: *mut *mut OH_CryptoAsymKeySpec,
610    ) -> CryptoResult;
611    /// Creates an asymmetric key spec according to the given algorithm name and spec type.
612    ///
613    /// # Arguments
614    ///
615    /// * `algoName` - Indicates the algorithm name for generating the spec. Example RSA.
616    ///
617    /// * `type` - Indicates the asymmetric key spec type.
618    ///
619    /// * `spec` - Indicates the pointer to the asymmetric key spec.
620    ///
621    /// # Returns
622    ///
623    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
624    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
625    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
626    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
627    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
628    ///
629    /// Available since API-level: 20
630    #[cfg(feature = "api-20")]
631    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
632    pub fn OH_CryptoAsymKeySpec_Create(
633        algoName: *const ::core::ffi::c_char,
634        type_: CryptoAsymKeySpec_Type,
635        spec: *mut *mut OH_CryptoAsymKeySpec,
636    ) -> CryptoResult;
637    /// Sets the specified parameter to the asymmetric key spec.
638    ///
639    /// # Arguments
640    ///
641    /// * `spec` - Indicates the asymmetric key spec.
642    ///
643    /// * `type` - Indicates the asymmetric key param type.
644    ///
645    /// * `value` - Indicates the input data.
646    ///
647    /// # Returns
648    ///
649    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
650    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
651    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
652    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
653    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
654    ///
655    /// Available since API-level: 20
656    #[cfg(feature = "api-20")]
657    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
658    pub fn OH_CryptoAsymKeySpec_SetParam(
659        spec: *mut OH_CryptoAsymKeySpec,
660        type_: CryptoAsymKey_ParamType,
661        value: *mut Crypto_DataBlob,
662    ) -> CryptoResult;
663    /// Sets the common parameters spec to the asymmetric key spec.
664    ///
665    /// # Arguments
666    ///
667    /// * `spec` - Indicates the asymmetric key spec.
668    ///
669    /// * `commonParamsSpec` - Indicates the common parameters spec.
670    ///
671    /// # Returns
672    ///
673    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
674    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
675    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
676    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
677    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
678    ///
679    /// Available since API-level: 20
680    #[cfg(feature = "api-20")]
681    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
682    pub fn OH_CryptoAsymKeySpec_SetCommonParamsSpec(
683        spec: *mut OH_CryptoAsymKeySpec,
684        commonParamsSpec: *mut OH_CryptoAsymKeySpec,
685    ) -> CryptoResult;
686    /// Gets the specified parameter from the asymmetric key spec.
687    ///
688    /// # Arguments
689    ///
690    /// * `spec` - Indicates the asymmetric key spec.
691    ///
692    /// * `type` - Indicates the asymmetric key param type.
693    ///
694    /// * `value` - Indicates the output data.
695    ///
696    /// # Returns
697    ///
698    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
699    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
700    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
701    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
702    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
703    ///
704    /// Available since API-level: 20
705    #[cfg(feature = "api-20")]
706    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
707    pub fn OH_CryptoAsymKeySpec_GetParam(
708        spec: *mut OH_CryptoAsymKeySpec,
709        type_: CryptoAsymKey_ParamType,
710        value: *mut Crypto_DataBlob,
711    ) -> CryptoResult;
712    /// Destroys the asymmetric key spec.
713    ///
714    /// # Arguments
715    ///
716    /// * `spec` - Indicates the asymmetric key spec.
717    ///
718    /// Available since API-level: 20
719    #[cfg(feature = "api-20")]
720    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
721    pub fn OH_CryptoAsymKeySpec_Destroy(spec: *mut OH_CryptoAsymKeySpec);
722    /// Creates an asymmetric key generator with spec.
723    ///
724    /// # Arguments
725    ///
726    /// * `keySpec` - Indicates the asymmetric key spec.
727    ///
728    /// * `generator` - Indicates the asymmetric key generator with spec.
729    ///
730    /// # Returns
731    ///
732    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
733    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
734    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
735    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
736    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
737    ///
738    /// Available since API-level: 20
739    #[cfg(feature = "api-20")]
740    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
741    pub fn OH_CryptoAsymKeyGeneratorWithSpec_Create(
742        keySpec: *mut OH_CryptoAsymKeySpec,
743        generator: *mut *mut OH_CryptoAsymKeyGeneratorWithSpec,
744    ) -> CryptoResult;
745    /// Generates a key pair according to the asymmetric key spec.
746    ///
747    /// # Arguments
748    ///
749    /// * `generator` - Indicates the asymmetric key generator with spec.
750    ///
751    /// * `keyPair` - Indicates the pointer to the key pair.
752    ///
753    /// # Returns
754    ///
755    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
756    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
757    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
758    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
759    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
760    ///
761    /// Available since API-level: 20
762    #[cfg(feature = "api-20")]
763    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
764    pub fn OH_CryptoAsymKeyGeneratorWithSpec_GenKeyPair(
765        generator: *mut OH_CryptoAsymKeyGeneratorWithSpec,
766        keyPair: *mut *mut OH_CryptoKeyPair,
767    ) -> CryptoResult;
768    /// Destroys the asymmetric key generator with spec.
769    ///
770    /// # Arguments
771    ///
772    /// * `generator` - Indicates the asymmetric key generator with spec.
773    ///
774    /// Available since API-level: 20
775    #[cfg(feature = "api-20")]
776    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
777    pub fn OH_CryptoAsymKeyGeneratorWithSpec_Destroy(
778        generator: *mut OH_CryptoAsymKeyGeneratorWithSpec,
779    );
780    /// Creates an EC point.
781    ///
782    /// # Arguments
783    ///
784    /// * `curveName` - Indicates the curve name.
785    ///
786    /// * `ecKeyData` - Indicates the EC point data, supports "04 || x || y", "02 || x" or "03 || x" format.
787    /// If ecKeyData param is NULL, an empty EC point spec will be created.
788    ///
789    /// * `point` - Indicates the pointer to the EC point.
790    ///
791    /// # Returns
792    ///
793    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
794    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
795    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
796    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
797    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
798    ///
799    /// Available since API-level: 20
800    #[cfg(feature = "api-20")]
801    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
802    pub fn OH_CryptoEcPoint_Create(
803        curveName: *const ::core::ffi::c_char,
804        ecKeyData: *mut Crypto_DataBlob,
805        point: *mut *mut OH_CryptoEcPoint,
806    ) -> CryptoResult;
807    /// Gets the x and y coordinate of the EC point.
808    ///
809    /// # Arguments
810    ///
811    /// * `point` - Indicates the EC point.
812    ///
813    /// * `x` - Indicates the x coordinate of the EC point, it can be NULL.
814    ///
815    /// * `y` - Indicates the y coordinate of the EC point, it can be NULL.
816    ///
817    /// # Returns
818    ///
819    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
820    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
821    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
822    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
823    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
824    ///
825    /// Available since API-level: 20
826    #[cfg(feature = "api-20")]
827    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
828    pub fn OH_CryptoEcPoint_GetCoordinate(
829        point: *mut OH_CryptoEcPoint,
830        x: *mut Crypto_DataBlob,
831        y: *mut Crypto_DataBlob,
832    ) -> CryptoResult;
833    /// Sets the x and y coordinate to the EC point.
834    ///
835    /// # Arguments
836    ///
837    /// * `point` - Indicates the EC point.
838    ///
839    /// * `x` - Indicates the x coordinate of the EC point.
840    ///
841    /// * `y` - Indicates the y coordinate of the EC point.
842    ///
843    /// # Returns
844    ///
845    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
846    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
847    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
848    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
849    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
850    ///
851    /// Available since API-level: 20
852    #[cfg(feature = "api-20")]
853    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
854    pub fn OH_CryptoEcPoint_SetCoordinate(
855        point: *mut OH_CryptoEcPoint,
856        x: *mut Crypto_DataBlob,
857        y: *mut Crypto_DataBlob,
858    ) -> CryptoResult;
859    /// Encodes the EC point to the specified format.
860    ///
861    /// # Arguments
862    ///
863    /// * `point` - Indicates the EC point.
864    ///
865    /// * `format` - Indicates the encoding format, supports "UNCOMPRESSED" and "COMPRESSED".
866    ///
867    /// * `out` - Indicates the encoded ec point data.
868    ///
869    /// # Returns
870    ///
871    /// * [`OH_Crypto_ErrCode#CRYPTO_SUCCESS`] 0 - If the operation is successful.
872    /// [`OH_Crypto_ErrCode#CRYPTO_NOT_SUPPORTED`] 801 - If the operation is not supported.
873    /// [`OH_Crypto_ErrCode#CRYPTO_MEMORY_ERROR`] 17620001 - If memory operation failed.
874    /// [`OH_Crypto_ErrCode#CRYPTO_PARAMETER_CHECK_FAILED`] 17620003 - If parameter check failed.
875    /// [`OH_Crypto_ErrCode#CRYPTO_OPERTION_ERROR`] 17630001 - If crypto operation failed.
876    ///
877    /// Available since API-level: 20
878    #[cfg(feature = "api-20")]
879    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
880    pub fn OH_CryptoEcPoint_Encode(
881        point: *mut OH_CryptoEcPoint,
882        format: *const ::core::ffi::c_char,
883        out: *mut Crypto_DataBlob,
884    ) -> CryptoResult;
885    /// Destroys the EC point.
886    ///
887    /// # Arguments
888    ///
889    /// * `point` - Indicates the EC point.
890    ///
891    /// Available since API-level: 20
892    #[cfg(feature = "api-20")]
893    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
894    pub fn OH_CryptoEcPoint_Destroy(point: *mut OH_CryptoEcPoint);
895}