1e41f4b71Sopenharmony_ci# CryptoAsymKeyApi
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ci## Overview
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ciProvides APIs for asymmetric keys.
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ci**Since**: 12
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci## Summary
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci### Files
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci| Name | Description |
17e41f4b71Sopenharmony_ci| -------- | -------- |
18e41f4b71Sopenharmony_ci| [crypto_asym_key.h](crypto__asym__key_8h.md) | Defines APIs for asymmetric keys. |
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci### Types
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci| Name | Description |
24e41f4b71Sopenharmony_ci| -------- | -------- |
25e41f4b71Sopenharmony_ci| typedef struct [OH_CryptoKeyPair](#oh_cryptokeypair) [OH_CryptoKeyPair](#oh_cryptokeypair) | Defines a struct for an asymmetric key pair. |
26e41f4b71Sopenharmony_ci| typedef struct [OH_CryptoPubKey](#oh_cryptopubkey) [OH_CryptoPubKey](#oh_cryptopubkey) | Defines a struct for the public key in an asymmetric key pair. |
27e41f4b71Sopenharmony_ci| typedef struct [OH_CryptoAsymKeyGenerator](#oh_cryptoasymkeygenerator) [OH_CryptoAsymKeyGenerator](#oh_cryptoasymkeygenerator) | Defines a struct for an asymmetric key generator. |
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci### Enums
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci| Name | Description |
33e41f4b71Sopenharmony_ci| -------- | -------- |
34e41f4b71Sopenharmony_ci| [CryptoAsymKey_ParamType](#cryptoasymkey_paramtype) {<br>CRYPTO_DSA_P_DATABLOB = 101, CRYPTO_DSA_Q_DATABLOB = 102,<br>CRYPTO_DSA_G_DATABLOB = 103, CRYPTO_DSA_SK_DATABLOB = 104,<br>CRYPTO_DSA_PK_DATABLOB = 105, CRYPTO_ECC_FP_P_DATABLOB = 201,<br>CRYPTO_ECC_A_DATABLOB = 202, CRYPTO_ECC_B_DATABLOB = 203,<br>CRYPTO_ECC_G_X_DATABLOB = 204, CRYPTO_ECC_G_Y_DATABLOB = 205,<br>CRYPTO_ECC_N_DATABLOB = 206, CRYPTO_ECC_H_INT = 207,<br>CRYPTO_ECC_SK_DATABLOB = 208, CRYPTO_ECC_PK_X_DATABLOB = 209,<br>CRYPTO_ECC_PK_Y_DATABLOB = 210, CRYPTO_ECC_FIELD_TYPE_STR = 211,<br>CRYPTO_ECC_FIELD_SIZE_INT = 212, CRYPTO_ECC_CURVE_NAME_STR = 213,<br>CRYPTO_RSA_N_DATABLOB = 301, CRYPTO_RSA_D_DATABLOB = 302,<br>CRYPTO_RSA_E_DATABLOB = 303, CRYPTO_DH_P_DATABLOB = 401,<br>CRYPTO_DH_G_DATABLOB = 402, CRYPTO_DH_L_NUM = 403,<br>CRYPTO_DH_SK_DATABLOB = 404, CRYPTO_DH_PK_DATABLOB = 405,<br>CRYPTO_ED25519_SK_DATABLOB = 501, CRYPTO_ED25519_PK_DATABLOB = 502,<br>CRYPTO_X25519_SK_DATABLOB = 601, CRYPTO_X25519_PK_DATABLOB = 602<br>} | Enumerates the types of the asymmetric key parameters. |
35e41f4b71Sopenharmony_ci| [Crypto_EncodingType](#crypto_encodingtype) { CRYPTO_PEM = 0, CRYPTO_DER = 1 } | Enumerates the encoding types. |
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci### Functions
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci| Name | Description |
41e41f4b71Sopenharmony_ci| -------- | -------- |
42e41f4b71Sopenharmony_ci| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoAsymKeyGenerator_Create](#oh_cryptoasymkeygenerator_create) (const char \*algoName, [OH_CryptoAsymKeyGenerator](#oh_cryptoasymkeygenerator) \*\*ctx) | Creates an asymmetric key generator instance based on the specified algorithm. |
43e41f4b71Sopenharmony_ci| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoAsymKeyGenerator_Generate](#oh_cryptoasymkeygenerator_generate) ([OH_CryptoAsymKeyGenerator](#oh_cryptoasymkeygenerator) \*ctx, [OH_CryptoKeyPair](#oh_cryptokeypair) \*\*keyCtx) | Randomly generates an asymmetric key pair. |
44e41f4b71Sopenharmony_ci| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoAsymKeyGenerator_Convert](#oh_cryptoasymkeygenerator_convert) ([OH_CryptoAsymKeyGenerator](#oh_cryptoasymkeygenerator) \*ctx, [Crypto_EncodingType](#crypto_encodingtype) type, [Crypto_DataBlob](_crypto___data_blob.md) \*pubKeyData, [Crypto_DataBlob](_crypto___data_blob.md) \*priKeyData, [OH_CryptoKeyPair](#oh_cryptokeypair) \*\*keyCtx) | Converts asymmetric key data into a key pair. |
45e41f4b71Sopenharmony_ci| const char \* [OH_CryptoAsymKeyGenerator_GetAlgoName](#oh_cryptoasymkeygenerator_getalgoname) ([OH_CryptoAsymKeyGenerator](#oh_cryptoasymkeygenerator) \*ctx) | Obtains the asymmetric key algorithm. |
46e41f4b71Sopenharmony_ci| void [OH_CryptoAsymKeyGenerator_Destroy](#oh_cryptoasymkeygenerator_destroy) ([OH_CryptoAsymKeyGenerator](#oh_cryptoasymkeygenerator) \*ctx) | Destroys an asymmetric key generator instance. |
47e41f4b71Sopenharmony_ci| void [OH_CryptoKeyPair_Destroy](#oh_cryptokeypair_destroy) ([OH_CryptoKeyPair](#oh_cryptokeypair) \*keyCtx) | Destroys an asymmetric key pair instance. |
48e41f4b71Sopenharmony_ci| [OH_CryptoPubKey](#oh_cryptopubkey) \* [OH_CryptoKeyPair_GetPubKey](#oh_cryptokeypair_getpubkey) ([OH_CryptoKeyPair](#oh_cryptokeypair) \*keyCtx) | Obtains the public key instance from a key pair. |
49e41f4b71Sopenharmony_ci| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoPubKey_Encode](#oh_cryptopubkey_encode) ([OH_CryptoPubKey](#oh_cryptopubkey) \*key, [Crypto_EncodingType](#crypto_encodingtype) type, const char \*encodingStandard, [Crypto_DataBlob](_crypto___data_blob.md) \*out) | Encodes the public key data in the specified format. |
50e41f4b71Sopenharmony_ci| [OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode) [OH_CryptoPubKey_GetParam](#oh_cryptopubkey_getparam) ([OH_CryptoPubKey](#oh_cryptopubkey) \*key, [CryptoAsymKey_ParamType](#cryptoasymkey_paramtype) item, [Crypto_DataBlob](_crypto___data_blob.md) \*value) | Obtains the specified parameter from a public key instance. |
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci## Type Description
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci### OH_CryptoAsymKeyGenerator
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci```
59e41f4b71Sopenharmony_citypedef struct OH_CryptoAsymKeyGenerator OH_CryptoAsymKeyGenerator
60e41f4b71Sopenharmony_ci```
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci**Description**
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ciDefines a struct for an asymmetric key generator.
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ci**Since**: 12
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci### OH_CryptoKeyPair
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci```
72e41f4b71Sopenharmony_citypedef struct OH_CryptoKeyPair OH_CryptoKeyPair
73e41f4b71Sopenharmony_ci```
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ci**Description**
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ciDefines a struct for an asymmetric key pair.
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci**Since**: 12
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci### OH_CryptoPubKey
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci```
85e41f4b71Sopenharmony_citypedef struct OH_CryptoPubKey OH_CryptoPubKey
86e41f4b71Sopenharmony_ci```
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci**Description**
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ciDefines a struct for the public key in an asymmetric key pair.
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci**Since**: 12
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_ci## Enum Description
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ci### Crypto_EncodingType
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci```
101e41f4b71Sopenharmony_cienum Crypto_EncodingType
102e41f4b71Sopenharmony_ci```
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_ci**Description**
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_ciEnumerates the encoding types.
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ci**Since**: 12
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci| Enum | Description |
111e41f4b71Sopenharmony_ci| -------- | -------- |
112e41f4b71Sopenharmony_ci| CRYPTO_PEM | PEM. |
113e41f4b71Sopenharmony_ci| CRYPTO_DER | DER. |
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ci### CryptoAsymKey_ParamType
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ci```
119e41f4b71Sopenharmony_cienum CryptoAsymKey_ParamType
120e41f4b71Sopenharmony_ci```
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ci**Description**
123e41f4b71Sopenharmony_ci
124e41f4b71Sopenharmony_ciEnumerates the types of the asymmetric key parameters.
125e41f4b71Sopenharmony_ci
126e41f4b71Sopenharmony_ci**Since**: 12
127e41f4b71Sopenharmony_ci
128e41f4b71Sopenharmony_ci| Enum | Description |
129e41f4b71Sopenharmony_ci| -------- | -------- |
130e41f4b71Sopenharmony_ci| CRYPTO_DSA_P_DATABLOB | Prime modulus **p** in the DSA algorithm. |
131e41f4b71Sopenharmony_ci| CRYPTO_DSA_Q_DATABLOB | Parameter **q**, prime factor of (p – 1) in the DSA algorithm. |
132e41f4b71Sopenharmony_ci| CRYPTO_DSA_G_DATABLOB | Parameter **g** in the DSA algorithm. |
133e41f4b71Sopenharmony_ci| CRYPTO_DSA_SK_DATABLOB | Private key **sk** in the DSA algorithm. |
134e41f4b71Sopenharmony_ci| CRYPTO_DSA_PK_DATABLOB | Public key **pk** in the DSA algorithm. |
135e41f4b71Sopenharmony_ci| CRYPTO_ECC_FP_P_DATABLOB | Prime number **p** in the **Fp** field of the elliptic curve in the ECC algorithm. |
136e41f4b71Sopenharmony_ci| CRYPTO_ECC_A_DATABLOB | First coefficient **a** of the elliptic curve in the ECC algorithm. |
137e41f4b71Sopenharmony_ci| CRYPTO_ECC_B_DATABLOB | Second coefficient **b** of the elliptic curve in the ECC algorithm. |
138e41f4b71Sopenharmony_ci| CRYPTO_ECC_G_X_DATABLOB | X coordinate of the base point **g** in the ECC algorithm. |
139e41f4b71Sopenharmony_ci| CRYPTO_ECC_G_Y_DATABLOB | Y coordinate of the base point **g** in the ECC algorithm. |
140e41f4b71Sopenharmony_ci| CRYPTO_ECC_N_DATABLOB | Order **n** of the base point **g** in the ECC algorithm. |
141e41f4b71Sopenharmony_ci| CRYPTO_ECC_H_INT | Cofactor **h** in the ECC algorithm. |
142e41f4b71Sopenharmony_ci| CRYPTO_ECC_SK_DATABLOB | Private key **sk** in the ECC algorithm. |
143e41f4b71Sopenharmony_ci| CRYPTO_ECC_PK_X_DATABLOB | X coordinate of the public key **pk** (a point on the elliptic curve) in the ECC algorithm. |
144e41f4b71Sopenharmony_ci| CRYPTO_ECC_PK_Y_DATABLOB | Y coordinate of the public key **pk** (a point on the elliptic curve) in the ECC algorithm. |
145e41f4b71Sopenharmony_ci| CRYPTO_ECC_FIELD_TYPE_STR | Elliptic curve field type in the ECC algorithm. Currently, only the **Fp** field is supported. |
146e41f4b71Sopenharmony_ci| CRYPTO_ECC_FIELD_SIZE_INT | Size of the field in the ECC algorithm, in bits.<br>**NOTE**: The size of the **Fp** field is the length of the prime **p**, in bits. |
147e41f4b71Sopenharmony_ci| CRYPTO_ECC_CURVE_NAME_STR | Standards for Efficient Cryptography Group (SECG) curve name in the ECC algorithm. |
148e41f4b71Sopenharmony_ci| CRYPTO_RSA_N_DATABLOB | Modulus **n** in the RSA algorithm. |
149e41f4b71Sopenharmony_ci| CRYPTO_RSA_D_DATABLOB | Private key **sk** (private key exponent **d**) in the RSA algorithm. |
150e41f4b71Sopenharmony_ci| CRYPTO_RSA_E_DATABLOB | Public key **pk** (public key exponent **e**) in the RSA algorithm. |
151e41f4b71Sopenharmony_ci| CRYPTO_DH_P_DATABLOB | Prime **p** in the DH algorithm. |
152e41f4b71Sopenharmony_ci| CRYPTO_DH_G_DATABLOB | Parameter **g** in the DH algorithm. |
153e41f4b71Sopenharmony_ci| CRYPTO_DH_L_NUM | Length of the private key in the DH algorithm, in bits. |
154e41f4b71Sopenharmony_ci| CRYPTO_DH_SK_DATABLOB | Private key **sk** in the DH algorithm. |
155e41f4b71Sopenharmony_ci| CRYPTO_DH_PK_DATABLOB | Public key **pk** in the DH algorithm. |
156e41f4b71Sopenharmony_ci| CRYPTO_ED25519_SK_DATABLOB | Private key **sk** in the Ed25519 algorithm. |
157e41f4b71Sopenharmony_ci| CRYPTO_ED25519_PK_DATABLOB | Public key **pk** in the Ed25519 algorithm. |
158e41f4b71Sopenharmony_ci| CRYPTO_X25519_SK_DATABLOB | Private key **sk** in the X25519 algorithm. |
159e41f4b71Sopenharmony_ci| CRYPTO_X25519_PK_DATABLOB | Public key **pk** in the X25519 algorithm. |
160e41f4b71Sopenharmony_ci
161e41f4b71Sopenharmony_ci
162e41f4b71Sopenharmony_ci## Function Description
163e41f4b71Sopenharmony_ci
164e41f4b71Sopenharmony_ci
165e41f4b71Sopenharmony_ci### OH_CryptoAsymKeyGenerator_Convert()
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_ci```
168e41f4b71Sopenharmony_ciOH_Crypto_ErrCode OH_CryptoAsymKeyGenerator_Convert (OH_CryptoAsymKeyGenerator *ctx, Crypto_EncodingType type, Crypto_DataBlob *pubKeyData, Crypto_DataBlob *priKeyData, OH_CryptoKeyPair **keyCtx )
169e41f4b71Sopenharmony_ci```
170e41f4b71Sopenharmony_ci
171e41f4b71Sopenharmony_ci**Description**
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_ciConverts binary data into an asymmetric key pair.
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ci**Since**: 12
176e41f4b71Sopenharmony_ci
177e41f4b71Sopenharmony_ci**Parameters**
178e41f4b71Sopenharmony_ci
179e41f4b71Sopenharmony_ci| Name | Description |
180e41f4b71Sopenharmony_ci| -------- | -------- |
181e41f4b71Sopenharmony_ci| ctx | Pointer to the asymmetric key generator instance. |
182e41f4b71Sopenharmony_ci| type | Encoding type. |
183e41f4b71Sopenharmony_ci| pubKeyData | Pointer to the public key data to convert. |
184e41f4b71Sopenharmony_ci| priKeyData | Pointer to the private key data to convert. |
185e41f4b71Sopenharmony_ci| keyCtx | Pointer to the asymmetric key pair instance. |
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci**Returns**
188e41f4b71Sopenharmony_ci
189e41f4b71Sopenharmony_ci[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode):
190e41f4b71Sopenharmony_ci
191e41f4b71Sopenharmony_ci**0**: The operation is successful.
192e41f4b71Sopenharmony_ci
193e41f4b71Sopenharmony_ci**401**: Invalid parameters are detected.
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ci**801**: The operation is not supported.
196e41f4b71Sopenharmony_ci
197e41f4b71Sopenharmony_ci**17620001**: A memory error occurred.
198e41f4b71Sopenharmony_ci
199e41f4b71Sopenharmony_ci**17630001**: Failed to call an API of a third-party algorithm library.
200e41f4b71Sopenharmony_ci
201e41f4b71Sopenharmony_ci
202e41f4b71Sopenharmony_ci### OH_CryptoAsymKeyGenerator_Create()
203e41f4b71Sopenharmony_ci
204e41f4b71Sopenharmony_ci```
205e41f4b71Sopenharmony_ciOH_Crypto_ErrCode OH_CryptoAsymKeyGenerator_Create (const char *algoName, OH_CryptoAsymKeyGenerator **ctx )
206e41f4b71Sopenharmony_ci```
207e41f4b71Sopenharmony_ci
208e41f4b71Sopenharmony_ci**Description**
209e41f4b71Sopenharmony_ci
210e41f4b71Sopenharmony_ciCreates an asymmetric key generator instance based on the specified algorithm.
211e41f4b71Sopenharmony_ci
212e41f4b71Sopenharmony_ci**Since**: 12
213e41f4b71Sopenharmony_ci
214e41f4b71Sopenharmony_ci**Parameters**
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci| Name | Description |
217e41f4b71Sopenharmony_ci| -------- | -------- |
218e41f4b71Sopenharmony_ci| algoName | Pointer to the algorithm used to create the asymmetric key generator instance. For example, **'RSA1024\|PRIMES_2'**. |
219e41f4b71Sopenharmony_ci| ctx | Pointer to the asymmetric key generator instance created. |
220e41f4b71Sopenharmony_ci
221e41f4b71Sopenharmony_ci**Returns**
222e41f4b71Sopenharmony_ci
223e41f4b71Sopenharmony_ci[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode):
224e41f4b71Sopenharmony_ci
225e41f4b71Sopenharmony_ci**0**: The operation is successful.
226e41f4b71Sopenharmony_ci
227e41f4b71Sopenharmony_ci**401**: Invalid parameters are detected.
228e41f4b71Sopenharmony_ci
229e41f4b71Sopenharmony_ci**801**: The operation is not supported.
230e41f4b71Sopenharmony_ci
231e41f4b71Sopenharmony_ci**17620001**: A memory error occurred.
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ci**17630001**: Failed to call an API of a third-party algorithm library.
234e41f4b71Sopenharmony_ci
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ci### OH_CryptoAsymKeyGenerator_Destroy()
237e41f4b71Sopenharmony_ci
238e41f4b71Sopenharmony_ci```
239e41f4b71Sopenharmony_civoid OH_CryptoAsymKeyGenerator_Destroy (OH_CryptoAsymKeyGenerator *ctx)
240e41f4b71Sopenharmony_ci```
241e41f4b71Sopenharmony_ci
242e41f4b71Sopenharmony_ci**Description**
243e41f4b71Sopenharmony_ci
244e41f4b71Sopenharmony_ciDestroys an asymmetric key generator instance.
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_ci**Since**: 12
247e41f4b71Sopenharmony_ci
248e41f4b71Sopenharmony_ci**Parameters**
249e41f4b71Sopenharmony_ci
250e41f4b71Sopenharmony_ci| Name | Description |
251e41f4b71Sopenharmony_ci| -------- | -------- |
252e41f4b71Sopenharmony_ci| ctx | Pointer to the asymmetric key generator instance to destroy. |
253e41f4b71Sopenharmony_ci
254e41f4b71Sopenharmony_ci
255e41f4b71Sopenharmony_ci### OH_CryptoAsymKeyGenerator_Generate()
256e41f4b71Sopenharmony_ci
257e41f4b71Sopenharmony_ci```
258e41f4b71Sopenharmony_ciOH_Crypto_ErrCode OH_CryptoAsymKeyGenerator_Generate (OH_CryptoAsymKeyGenerator *ctx, OH_CryptoKeyPair **keyCtx )
259e41f4b71Sopenharmony_ci```
260e41f4b71Sopenharmony_ci
261e41f4b71Sopenharmony_ci**Description**
262e41f4b71Sopenharmony_ci
263e41f4b71Sopenharmony_ciRandomly generates an asymmetric key pair.
264e41f4b71Sopenharmony_ci
265e41f4b71Sopenharmony_ci**Since**: 12
266e41f4b71Sopenharmony_ci
267e41f4b71Sopenharmony_ci**Parameters**
268e41f4b71Sopenharmony_ci
269e41f4b71Sopenharmony_ci| Name | Description |
270e41f4b71Sopenharmony_ci| -------- | -------- |
271e41f4b71Sopenharmony_ci| ctx | Pointer to the asymmetric key generator instance. |
272e41f4b71Sopenharmony_ci| keyCtx | Pointer to the asymmetric key pair instance created. |
273e41f4b71Sopenharmony_ci
274e41f4b71Sopenharmony_ci**Returns**
275e41f4b71Sopenharmony_ci
276e41f4b71Sopenharmony_ci[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode):
277e41f4b71Sopenharmony_ci
278e41f4b71Sopenharmony_ci**0**: The operation is successful.
279e41f4b71Sopenharmony_ci
280e41f4b71Sopenharmony_ci**401**: Invalid parameters are detected.
281e41f4b71Sopenharmony_ci
282e41f4b71Sopenharmony_ci**801**: The operation is not supported.
283e41f4b71Sopenharmony_ci
284e41f4b71Sopenharmony_ci**17620001**: A memory error occurred.
285e41f4b71Sopenharmony_ci
286e41f4b71Sopenharmony_ci**17630001**: Failed to call an API of a third-party algorithm library.
287e41f4b71Sopenharmony_ci
288e41f4b71Sopenharmony_ci
289e41f4b71Sopenharmony_ci### OH_CryptoAsymKeyGenerator_GetAlgoName()
290e41f4b71Sopenharmony_ci
291e41f4b71Sopenharmony_ci```
292e41f4b71Sopenharmony_ciconst char* OH_CryptoAsymKeyGenerator_GetAlgoName (OH_CryptoAsymKeyGenerator *ctx)
293e41f4b71Sopenharmony_ci```
294e41f4b71Sopenharmony_ci
295e41f4b71Sopenharmony_ci**Description**
296e41f4b71Sopenharmony_ci
297e41f4b71Sopenharmony_ciObtains the asymmetric key algorithm.
298e41f4b71Sopenharmony_ci
299e41f4b71Sopenharmony_ci**Since**: 12
300e41f4b71Sopenharmony_ci
301e41f4b71Sopenharmony_ci**Parameters**
302e41f4b71Sopenharmony_ci
303e41f4b71Sopenharmony_ci| Name | Description |
304e41f4b71Sopenharmony_ci| -------- | -------- |
305e41f4b71Sopenharmony_ci| ctx | Pointer to the asymmetric key generator instance. |
306e41f4b71Sopenharmony_ci
307e41f4b71Sopenharmony_ci**Returns**
308e41f4b71Sopenharmony_ci
309e41f4b71Sopenharmony_ciName of the asymmetric key algorithm obtained.
310e41f4b71Sopenharmony_ci
311e41f4b71Sopenharmony_ci
312e41f4b71Sopenharmony_ci### OH_CryptoKeyPair_Destroy()
313e41f4b71Sopenharmony_ci
314e41f4b71Sopenharmony_ci```
315e41f4b71Sopenharmony_civoid OH_CryptoKeyPair_Destroy (OH_CryptoKeyPair *keyCtx)
316e41f4b71Sopenharmony_ci```
317e41f4b71Sopenharmony_ci
318e41f4b71Sopenharmony_ci**Description**
319e41f4b71Sopenharmony_ci
320e41f4b71Sopenharmony_ciDestroys an asymmetric key pair instance.
321e41f4b71Sopenharmony_ci
322e41f4b71Sopenharmony_ci**Since**: 12
323e41f4b71Sopenharmony_ci
324e41f4b71Sopenharmony_ci**Parameters**
325e41f4b71Sopenharmony_ci
326e41f4b71Sopenharmony_ci| Name | Description |
327e41f4b71Sopenharmony_ci| -------- | -------- |
328e41f4b71Sopenharmony_ci| keyCtx | Pointer to the asymmetric key pair instance to destroy. |
329e41f4b71Sopenharmony_ci
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_ci### OH_CryptoKeyPair_GetPubKey()
332e41f4b71Sopenharmony_ci
333e41f4b71Sopenharmony_ci```
334e41f4b71Sopenharmony_ciOH_CryptoPubKey* OH_CryptoKeyPair_GetPubKey (OH_CryptoKeyPair *keyCtx)
335e41f4b71Sopenharmony_ci```
336e41f4b71Sopenharmony_ci
337e41f4b71Sopenharmony_ci**Description**
338e41f4b71Sopenharmony_ci
339e41f4b71Sopenharmony_ciObtains the public key from a key pair.
340e41f4b71Sopenharmony_ci
341e41f4b71Sopenharmony_ci**Since**: 12
342e41f4b71Sopenharmony_ci
343e41f4b71Sopenharmony_ci**Parameters**
344e41f4b71Sopenharmony_ci
345e41f4b71Sopenharmony_ci| Name | Description |
346e41f4b71Sopenharmony_ci| -------- | -------- |
347e41f4b71Sopenharmony_ci| keyCtx | Pointer to the key pair instance. |
348e41f4b71Sopenharmony_ci
349e41f4b71Sopenharmony_ci**Returns**
350e41f4b71Sopenharmony_ci
351e41f4b71Sopenharmony_ciPublic key obtained.
352e41f4b71Sopenharmony_ci
353e41f4b71Sopenharmony_ci
354e41f4b71Sopenharmony_ci### OH_CryptoPubKey_Encode()
355e41f4b71Sopenharmony_ci
356e41f4b71Sopenharmony_ci```
357e41f4b71Sopenharmony_ciOH_Crypto_ErrCode OH_CryptoPubKey_Encode (OH_CryptoPubKey *key, Crypto_EncodingType type, const char *encodingStandard, Crypto_DataBlob *out )
358e41f4b71Sopenharmony_ci```
359e41f4b71Sopenharmony_ci
360e41f4b71Sopenharmony_ci**Description**
361e41f4b71Sopenharmony_ci
362e41f4b71Sopenharmony_ciEncodes the public key data in the specified format.
363e41f4b71Sopenharmony_ci
364e41f4b71Sopenharmony_ci**Since**: 12
365e41f4b71Sopenharmony_ci
366e41f4b71Sopenharmony_ci**Parameters**
367e41f4b71Sopenharmony_ci
368e41f4b71Sopenharmony_ci| Name | Description |
369e41f4b71Sopenharmony_ci| -------- | -------- |
370e41f4b71Sopenharmony_ci| key | Ponter to the public key data. |
371e41f4b71Sopenharmony_ci| type | Encoding type. |
372e41f4b71Sopenharmony_ci| encodingStandard | Encoding format. |
373e41f4b71Sopenharmony_ci| out | Pointer to the public key encoded in the specified format. |
374e41f4b71Sopenharmony_ci
375e41f4b71Sopenharmony_ci**Returns**
376e41f4b71Sopenharmony_ci
377e41f4b71Sopenharmony_ci[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode):
378e41f4b71Sopenharmony_ci
379e41f4b71Sopenharmony_ci**0**: The operation is successful.
380e41f4b71Sopenharmony_ci
381e41f4b71Sopenharmony_ci**401**: Invalid parameters are detected.
382e41f4b71Sopenharmony_ci
383e41f4b71Sopenharmony_ci**801**: The operation is not supported.
384e41f4b71Sopenharmony_ci
385e41f4b71Sopenharmony_ci**17620001**: A memory error occurred.
386e41f4b71Sopenharmony_ci
387e41f4b71Sopenharmony_ci**17630001**: Failed to call an API of a third-party algorithm library.
388e41f4b71Sopenharmony_ci
389e41f4b71Sopenharmony_ci
390e41f4b71Sopenharmony_ci### OH_CryptoPubKey_GetParam()
391e41f4b71Sopenharmony_ci
392e41f4b71Sopenharmony_ci```
393e41f4b71Sopenharmony_ciOH_Crypto_ErrCode OH_CryptoPubKey_GetParam (OH_CryptoPubKey *key, CryptoAsymKey_ParamType item, Crypto_DataBlob *value )
394e41f4b71Sopenharmony_ci```
395e41f4b71Sopenharmony_ci
396e41f4b71Sopenharmony_ci**Description**
397e41f4b71Sopenharmony_ci
398e41f4b71Sopenharmony_ciObtains the specified parameter from a public key instance.
399e41f4b71Sopenharmony_ci
400e41f4b71Sopenharmony_ci**Since**: 12
401e41f4b71Sopenharmony_ci
402e41f4b71Sopenharmony_ci**Parameters**
403e41f4b71Sopenharmony_ci
404e41f4b71Sopenharmony_ci| Name | Description |
405e41f4b71Sopenharmony_ci| -------- | -------- |
406e41f4b71Sopenharmony_ci| key | Ponter to the public key data. |
407e41f4b71Sopenharmony_ci| item | Type of the asymmetric key parameter to obtain. |
408e41f4b71Sopenharmony_ci| value | Pointer to the parameter value obtained. |
409e41f4b71Sopenharmony_ci
410e41f4b71Sopenharmony_ci**Returns**
411e41f4b71Sopenharmony_ci
412e41f4b71Sopenharmony_ci[OH_Crypto_ErrCode](_crypto_common_api.md#oh_crypto_errcode): 
413e41f4b71Sopenharmony_ci
414e41f4b71Sopenharmony_ci**0**: The operation is successful.
415e41f4b71Sopenharmony_ci
416e41f4b71Sopenharmony_ci**401**: Invalid parameters are detected.
417e41f4b71Sopenharmony_ci
418e41f4b71Sopenharmony_ci**801**: The operation is not supported.
419e41f4b71Sopenharmony_ci
420e41f4b71Sopenharmony_ci**17620001**: A memory error occurred.
421e41f4b71Sopenharmony_ci
422e41f4b71Sopenharmony_ci**17630001**: Failed to call an API of a third-party algorithm library.
423