1 /*
2  * Copyright (c) 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 HUKS_ACCESS_H
17 #define HUKS_ACCESS_H
18 
19 #include "hks_param.h"
20 #include "hks_type_inner.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 int32_t HuksAccessModuleInit(void);
27 
28 int32_t HuksAccessModuleDestroy(void);
29 
30 int32_t HuksAccessRefresh(void);
31 
32 int32_t HuksAccessGenerateKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSetIn,
33     const struct HksBlob *keyIn, struct HksBlob *keyOut);
34 
35 int32_t HuksAccessImportKey(const struct HksBlob *keyAlias, const struct HksBlob *key,
36     const struct HksParamSet *paramSet, struct HksBlob *keyOut);
37 
38 int32_t HuksAccessImportWrappedKey(const struct HksBlob *wrappingKeyAlias, const struct HksBlob *key,
39     const struct HksBlob *wrappedKeyData, const struct HksParamSet *paramSet, struct HksBlob *keyOut);
40 
41 int32_t HuksAccessExportPublicKey(const struct HksBlob *key, const struct HksParamSet *paramSet,
42     struct HksBlob *keyOut);
43 
44 int32_t HuksAccessInit(const struct  HksBlob *key, const struct HksParamSet *paramSet, struct HksBlob *handle,
45     struct HksBlob *token);
46 
47 int32_t HuksAccessUpdate(const struct HksBlob *handle, const struct HksParamSet *paramSet,
48     const struct HksBlob *inData, struct HksBlob *outData);
49 
50 int32_t HuksAccessFinish(const struct HksBlob *handle, const struct HksParamSet *paramSet,
51     const struct HksBlob *inData, struct HksBlob *outData);
52 
53 int32_t HuksAccessAbort(const struct HksBlob *handle, const struct HksParamSet *paramSet);
54 
55 int32_t HuksAccessGetKeyProperties(const struct HksParamSet *paramSet, const struct HksBlob *key);
56 
57 int32_t HuksAccessGetAbility(int funcType);
58 
59 int32_t HuksAccessGetHardwareInfo(void);
60 
61 int32_t HuksAccessCalcMacHeader(const struct HksParamSet *paramSet, const struct HksBlob *salt,
62     const struct HksBlob *srcData, struct HksBlob *mac);
63 
64 int32_t HuksAccessUpgradeKeyInfo(const struct HksBlob *keyAlias, const struct HksBlob *keyInfo,
65     struct HksBlob *keyOut);
66 
67 int32_t HuksAccessGenerateRandom(const struct HksParamSet *paramSet, struct HksBlob *random);
68 
69 int32_t HuksAccessCalcHeaderMac(const struct HksParamSet *paramSet, const struct HksBlob *salt,
70     const struct HksBlob *srcData, struct HksBlob *mac);
71 
72 int32_t HuksAccessAttestKey(const struct HksBlob *key, const struct HksParamSet *paramSet, struct HksBlob *certChain);
73 
74 int32_t HuksAccessSign(const struct HksBlob *key, const struct HksParamSet *paramSet,
75     const struct HksBlob *srcData, struct HksBlob *signature);
76 
77 int32_t HuksAccessVerify(const struct HksBlob *key, const struct HksParamSet *paramSet,
78     const struct HksBlob *srcData, const struct HksBlob *signature);
79 
80 int32_t HuksAccessEncrypt(const struct HksBlob *key, const struct HksParamSet *paramSet,
81     const struct HksBlob *plainText, struct HksBlob *cipherText);
82 
83 int32_t HuksAccessDecrypt(const struct HksBlob *key, const struct HksParamSet *paramSet,
84     const struct HksBlob *cipherText, struct HksBlob *plainText);
85 
86 int32_t HuksAccessAgreeKey(const struct HksParamSet *paramSet, const struct HksBlob *privateKey,
87     const struct HksBlob *peerPublicKey, struct HksBlob *agreedKey);
88 
89 int32_t HuksAccessDeriveKey(const struct HksParamSet *paramSet, const struct HksBlob *kdfKey,
90     struct HksBlob *derivedKey);
91 
92 int32_t HuksAccessMac(const struct HksBlob *key, const struct HksParamSet *paramSet,
93     const struct HksBlob *srcData, struct HksBlob *mac);
94 
95 int32_t HuksAccessUpgradeKey(const struct HksBlob *oldKey, const struct HksParamSet *paramSet, struct HksBlob *newKey);
96 
97 int32_t HuksAccessExportChipsetPlatformPublicKey(const struct HksBlob *salt,
98     enum HksChipsetPlatformDecryptScene scene, struct HksBlob *publicKey);
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif /* HUKS_ACCESS_H */
105