• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# crypto_key_agreement.h
2
3<!--Kit: Crypto Architecture Kit-->
4<!--Subsystem: Security-->
5<!--Owner: @zxz--3-->
6<!--Designer: @lanming-->
7<!--Tester: @PAFT-->
8<!--Adviser: @zengyawen-->
9
10## 概述
11
12定义密钥协商接口。
13
14**引用文件:** <CryptoArchitectureKit/crypto_key_agreement.h>
15
16**库:** libohcrypto.so
17
18**系统能力:** SystemCapability.Security.CryptoFramework
19
20**起始版本:** 20
21
22**相关模块:** [CryptoKeyAgreementApi](capi-cryptokeyagreementapi.md)
23
24## 汇总
25
26### 结构体
27
28| 名称 | typedef关键字 | 描述 |
29| -- | -- | -- |
30| [OH_CryptoKeyAgreement](capi-cryptokeyagreementapi-oh-cryptokeyagreement.md) | OH_CryptoKeyAgreement | 定义密钥协商结构。 |
31
32### 函数
33
34| 名称 | 描述 |
35| -- | -- |
36| [OH_Crypto_ErrCode OH_CryptoKeyAgreement_Create(const char *algoName, OH_CryptoKeyAgreement **ctx)](#oh_cryptokeyagreement_create) | 根据给定的算法名称创建密钥协商实例。 |
37| [OH_Crypto_ErrCode OH_CryptoKeyAgreement_GenerateSecret(OH_CryptoKeyAgreement *ctx, OH_CryptoPrivKey *privkey, OH_CryptoPubKey *pubkey, Crypto_DataBlob *secret)](#oh_cryptokeyagreement_generatesecret) | 生成密钥协商的秘密值。 |
38| [void OH_CryptoKeyAgreement_Destroy(OH_CryptoKeyAgreement *ctx)](#oh_cryptokeyagreement_destroy) | 销毁密钥协商实例。 |
39
40## 函数说明
41
42### OH_CryptoKeyAgreement_Create()
43
44```
45OH_Crypto_ErrCode OH_CryptoKeyAgreement_Create(const char *algoName, OH_CryptoKeyAgreement **ctx)
46```
47
48**描述**
49
50根据给定的算法名称创建密钥协商实例。
51
52**起始版本:** 20
53
54
55**参数:**
56
57| 参数项 | 描述 |
58| -- | -- |
59| const char *algoName | 用于生成密钥协商实例的算法名称。<br> 例如"ECC"、"X25519"。 |
60| [OH_CryptoKeyAgreement](capi-cryptokeyagreementapi-oh-cryptokeyagreement.md) **ctx | 密钥协商实例。 |
61
62**返回:**
63
64| 类型 | 说明 |
65| -- | -- |
66| [OH_Crypto_ErrCode](capi-crypto-common-h.md#oh_crypto_errcode) | CRYPTO_SUCCESS:操作成功。<br>         CRYPTO_NOT_SUPPORTED:操作不支持。<br>         CRYPTO_MEMORY_ERROR:内存错误。<br>         CRYPTO_PARAMETER_CHECK_FAILED:参数检查失败。<br>         CRYPTO_OPERTION_ERROR:调用三方算法库API出错。 |
67
68### OH_CryptoKeyAgreement_GenerateSecret()
69
70```
71OH_Crypto_ErrCode OH_CryptoKeyAgreement_GenerateSecret(OH_CryptoKeyAgreement *ctx, OH_CryptoPrivKey *privkey,OH_CryptoPubKey *pubkey, Crypto_DataBlob *secret)
72```
73
74**描述**
75
76生成密钥协商的秘密值。
77
78**起始版本:** 20
79
80
81**参数:**
82
83| 参数项 | 描述 |
84| -- | -- |
85| [OH_CryptoKeyAgreement](capi-cryptokeyagreementapi-oh-cryptokeyagreement.md) *ctx | 密钥协商实例。 |
86| [OH_CryptoPrivKey](capi-cryptoasymkeyapi-oh-cryptoprivkey.md) *privkey | 私钥。 |
87| [OH_CryptoPubKey](capi-cryptoasymkeyapi-oh-cryptopubkey.md) *pubkey | 公钥。 |
88| [Crypto_DataBlob](capi-cryptocommonapi-crypto-datablob.md) *secret | 秘密值。 |
89
90**返回:**
91
92| 类型 | 说明 |
93| -- | -- |
94| [OH_Crypto_ErrCode](capi-crypto-common-h.md#oh_crypto_errcode) | CRYPTO_SUCCESS:操作成功。<br>         CRYPTO_NOT_SUPPORTED:操作不支持。<br>         CRYPTO_MEMORY_ERROR:内存错误。<br>         CRYPTO_PARAMETER_CHECK_FAILED:参数检查失败。<br>         CRYPTO_OPERTION_ERROR:调用三方算法库API出错。 |
95
96### OH_CryptoKeyAgreement_Destroy()
97
98```
99void OH_CryptoKeyAgreement_Destroy(OH_CryptoKeyAgreement *ctx)
100```
101
102**描述**
103
104销毁密钥协商实例。
105
106**起始版本:** 20
107
108
109**参数:**
110
111| 参数项 | 描述 |
112| -- | -- |
113| [OH_CryptoKeyAgreement](capi-cryptokeyagreementapi-oh-cryptokeyagreement.md) *ctx | 密钥协商实例。 |
114
115
116