• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *    http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef HKS_API_H
17 #define HKS_API_H
18 
19 #include "hks_type.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 HKS_API_EXPORT int32_t HksGetSdkVersion(struct HksBlob *sdkVersion);
26 
27 HKS_API_EXPORT int32_t HksInitialize(void);
28 
29 HKS_API_EXPORT int32_t HksRefreshKeyInfo(void);
30 
31 HKS_API_EXPORT int32_t HksGenerateKey(const struct HksBlob *keyAlias,
32     const struct HksParamSet *paramSetIn, struct HksParamSet *paramSetOut);
33 
34 HKS_API_EXPORT int32_t HksImportKey(const struct HksBlob *keyAlias,
35     const struct HksParamSet *paramSet, const struct HksBlob *key);
36 
37 HKS_API_EXPORT int32_t HksImportWrappedKey(const struct HksBlob *keyAlias, const struct HksBlob *wrappingKeyAlias,
38     const struct HksParamSet *paramSet, const struct HksBlob *wrappedKeyData);
39 
40 HKS_API_EXPORT int32_t HksExportPublicKey(const struct HksBlob *keyAlias,
41     const struct HksParamSet *paramSet, struct HksBlob *key);
42 
43 HKS_API_EXPORT int32_t HksDeleteKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet);
44 
45 HKS_API_EXPORT int32_t HksGetKeyParamSet(const struct HksBlob *keyAlias,
46     const struct HksParamSet *paramSetIn, struct HksParamSet *paramSetOut);
47 
48 HKS_API_EXPORT int32_t HksKeyExist(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet);
49 
50 HKS_API_EXPORT int32_t HksGenerateRandom(const struct HksParamSet *paramSet, struct HksBlob *random);
51 
52 HKS_API_EXPORT int32_t HksSign(const struct HksBlob *key, const struct HksParamSet *paramSet,
53     const struct HksBlob *srcData, struct HksBlob *signature);
54 
55 HKS_API_EXPORT int32_t HksVerify(const struct HksBlob *key, const struct HksParamSet *paramSet,
56     const struct HksBlob *srcData, const struct HksBlob *signature);
57 
58 HKS_API_EXPORT int32_t HksEncrypt(const struct HksBlob *key, const struct HksParamSet *paramSet,
59     const struct HksBlob *plainText, struct HksBlob *cipherText);
60 
61 HKS_API_EXPORT int32_t HksDecrypt(const struct HksBlob *key, const struct HksParamSet *paramSet,
62     const struct HksBlob *cipherText, struct HksBlob *plainText);
63 
64 HKS_API_EXPORT int32_t HksAgreeKey(const struct HksParamSet *paramSet, const struct HksBlob *privateKey,
65     const struct HksBlob *peerPublicKey, struct HksBlob *agreedKey);
66 
67 HKS_API_EXPORT int32_t HksDeriveKey(const struct HksParamSet *paramSet, const struct HksBlob *mainKey,
68     struct HksBlob *derivedKey);
69 
70 HKS_API_EXPORT int32_t HksMac(const struct HksBlob *key, const struct HksParamSet *paramSet,
71     const struct HksBlob *srcData, struct HksBlob *mac);
72 
73 HKS_API_EXPORT int32_t HksHash(const struct HksParamSet *paramSet,
74     const struct HksBlob *srcData, struct HksBlob *hash);
75 
76 HKS_API_EXPORT int32_t HksGetKeyInfoList(const struct HksParamSet *paramSet,
77     struct HksKeyInfo *keyInfoList, uint32_t *listCount);
78 
79 HKS_API_EXPORT int32_t HksAttestKey(const struct HksBlob *keyAlias,
80     const struct HksParamSet *paramSet, struct HksCertChain *certChain);
81 
82 HKS_API_EXPORT int32_t HksGetCertificateChain(const struct HksBlob *keyAlias,
83     const struct HksParamSet *paramSet, struct HksCertChain *certChain);
84 
85 HKS_API_EXPORT int32_t HksWrapKey(const struct HksBlob *keyAlias, const struct HksBlob *targetKeyAlias,
86     const struct HksParamSet *paramSet, struct HksBlob *wrappedData);
87 
88 HKS_API_EXPORT int32_t HksUnwrapKey(const struct HksBlob *keyAlias, const struct HksBlob *targetKeyAlias,
89     const struct HksBlob *wrappedData, const struct HksParamSet *paramSet);
90 
91 HKS_API_EXPORT int32_t HksBnExpMod(struct HksBlob *x, const struct HksBlob *a,
92     const struct HksBlob *e, const struct HksBlob *n);
93 
94 HKS_API_EXPORT int32_t HcmIsDeviceKeyExist(const struct HksParamSet *paramSet);
95 
96 HKS_API_EXPORT int32_t HksValidateCertChain(const struct HksCertChain *certChain, struct HksParamSet *paramSetOut);
97 
98 HKS_API_EXPORT int32_t HksInit(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet,
99     struct HksBlob *handle, struct HksBlob *token);
100 
101 HKS_API_EXPORT int32_t HksUpdate(const struct HksBlob *handle, const struct HksParamSet *paramSet,
102     const struct HksBlob *inData, struct HksBlob *outData);
103 
104 HKS_API_EXPORT int32_t HksFinish(const struct HksBlob *handle, const struct HksParamSet *paramSet,
105     const struct HksBlob *inData, struct HksBlob *outData);
106 
107 HKS_API_EXPORT int32_t HksAbort(const struct HksBlob *handle, const struct HksParamSet *paramSet);
108 
109 #ifdef __cplusplus
110 }
111 #endif
112 
113 #endif /* HKS_API_H */
114