1 /* 2 * Copyright (c) 2021 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_TEEC_H 17 #define HKS_TEEC_H 18 19 #include <tee_client_type.h> 20 #include "hks_type_inner.h" 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 int32_t HksTeeOpen(void); 27 28 int32_t HksTeeGenerateKey(const struct HksBlob *keyBlob, const struct HksParamSet *paramSetIn, 29 struct HksBlob *keyOut); 30 31 int32_t HksTeeProcessInit(uint32_t cmdId, const struct HksBlob *key, const struct HksParamSet *paramSet, 32 uint64_t *operationHandle); 33 34 int32_t HksTeeProcessMultiUpdate(uint32_t cmdId, uint64_t operationHandle, const struct HksBlob *inData, 35 struct HksBlob *outData); 36 37 int32_t HksTeeSign(const struct HksBlob *keyBlob, const struct HksParamSet *paramSet, 38 const struct HksBlob *srcData, struct HksBlob *signature); 39 40 int32_t HksTeeVerify(const struct HksBlob *keyBlob, const struct HksParamSet *paramSet, 41 const struct HksBlob *srcData, const struct HksBlob *signature); 42 43 int32_t HksTeeEncrypt(const struct HksBlob *keyBlob, const struct HksParamSet *paramSet, 44 const struct HksBlob *plainText, struct HksBlob *cipherText); 45 46 int32_t HksTeeDecrypt(const struct HksBlob *keyBlob, const struct HksParamSet *paramSet, 47 const struct HksBlob *cipherText, struct HksBlob *plainText); 48 49 int32_t HksTeeCheckKeyLegality(const struct HksParamSet *paramSet, const struct HksBlob *key); 50 51 int32_t HksTeeGenerateRandom(const struct HksParamSet *paramSet, struct HksBlob *random); 52 53 int32_t HksTeeImportKey(const struct HksBlob *key, const struct HksParamSet *paramSet, struct HksBlob *keyOut); 54 55 int32_t HksTeeExportPublicKey(const struct HksBlob *key, const struct HksParamSet *paramSet, struct HksBlob *keyOut); 56 57 int32_t HksTeeAgreeKey(const struct HksParamSet *paramSet, const struct HksBlob *privateKey, 58 const struct HksBlob *peerPublicKey, struct HksBlob *agreedKey); 59 60 int32_t HksTeeDeriveKey(const struct HksParamSet *paramSet, const struct HksBlob *kdfKey, struct HksBlob *derivedKey); 61 62 int32_t HksTeeMac(const struct HksBlob *keyBlob, const struct HksParamSet *paramSet, 63 const struct HksBlob *srcData, struct HksBlob *mac); 64 65 int32_t HksTeeAttestKey(const struct HksBlob *key, const struct HksParamSet *paramSet, struct HksBlob *certChain); 66 67 int32_t ProvisionVerify(TEEC_Operation *operation, const struct HksBlob *challengeIn, uint32_t certCount, 68 const struct HksBlob *verify, bool isVerify); 69 70 int32_t HksTeeExportTrustCerts(struct HksBlob *certChain); 71 72 int32_t HksTeeImportTrustCerts(const struct HksBlob *certChain); 73 74 int32_t HcmTeeIsDeviceKeyExist(void); 75 76 int32_t HksTeeProvision(const struct HksBlob *keybox, struct HksBlob *challenge, 77 const struct HksBlob *challengeIn, struct HksBlob *signature, struct HksBlob *certData); 78 79 int32_t HksTeeProvisionVerify(const struct HksBlob *verify, struct HksBlob *challenge, 80 const struct HksBlob *challengeIn, struct HksBlob *signature); 81 82 #ifdef __cplusplus 83 } 84 #endif 85 86 #endif