1 /* 2 * Copyright (c) 2023 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_HDI_PASSTHROUGH_ADAPTER_H 17 #define HUKS_HDI_PASSTHROUGH_ADAPTER_H 18 19 #include "huks_hdi_template.h" 20 #include "huks_sa_type.h" 21 #include "huks_sa_hdi_struct.h" 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 int32_t HuksHdiAdapterGenerateKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSetIn, 28 const struct HksBlob *keyIn, struct HksBlob *keyOut); 29 30 int32_t HuksHdiAdapterSign(const struct HksBlob *key, const struct HksParamSet *paramSet, const struct HksBlob *srcData, 31 struct HksBlob *signature); 32 33 int32_t HuksHdiAdapterVerify(const struct HksBlob *key, const struct HksParamSet *paramSet, 34 const struct HksBlob *srcData, const struct HksBlob *signature); 35 36 int32_t HuksHdiAdapterEncrypt(const struct HksBlob *key, const struct HksParamSet *paramSet, 37 const struct HksBlob *plainText, struct HksBlob *cipherText); 38 39 int32_t HuksHdiAdapterDecrypt(const struct HksBlob *key, const struct HksParamSet *paramSet, 40 const struct HksBlob *cipherText, struct HksBlob *plainText); 41 42 int32_t HuksHdiAdapterGenerateRandom(const struct HksParamSet *paramSet, struct HksBlob *random); 43 44 int32_t HuksHdiAdapterImportKey(const struct HksBlob *keyAlias, const struct HksBlob *key, 45 const struct HksParamSet *paramSet, struct HksBlob *keyOut); 46 47 int32_t HuksHdiAdapterExportPublicKey(const struct HksBlob *key, const struct HksParamSet *paramSet, 48 struct HksBlob *keyOut); 49 50 int32_t HuksHdiAdapterAgreeKey(const struct HksParamSet *paramSet, const struct HksBlob *privateKey, 51 const struct HksBlob *peerPublicKey, struct HksBlob *agreedKey); 52 53 int32_t HuksHdiAdapterDeriveKey(const struct HksParamSet *paramSet, const struct HksBlob *kdfKey, 54 struct HksBlob *derivedKey); 55 56 int32_t HuksHdiAdapterMac(const struct HksBlob *key, const struct HksParamSet *paramSet, const struct HksBlob *srcData, 57 struct HksBlob *mac); 58 59 int32_t HuksHdiAdapterModuleInit(void); 60 61 int32_t HuksHdiAdapterModuleDestroy(void); 62 63 int32_t HuksHdiAdapterImportWrappedKey(const struct HksBlob *wrappingKeyAlias, const struct HksBlob *wrappingKey, 64 const struct HksBlob *wrappedKeyData, const struct HksParamSet *paramSet, struct HksBlob *keyOut); 65 66 int32_t HuksHdiAdapterInit(const struct HksBlob *key, const struct HksParamSet *paramSet, struct HksBlob *handle, 67 struct HksBlob *token); 68 69 int32_t HuksHdiAdapterUpdate(const struct HksBlob *handle, const struct HksParamSet *paramSet, 70 const struct HksBlob *inData, struct HksBlob *outData); 71 72 int32_t HuksHdiAdapterFinish(const struct HksBlob *handle, const struct HksParamSet *paramSet, 73 const struct HksBlob *inData, struct HksBlob *outData); 74 75 int32_t HuksHdiAdapterAbort(const struct HksBlob *handle, const struct HksParamSet *paramSet); 76 77 int32_t HuksHdiAdapterGetKeyProperties(const struct HksParamSet *paramSet, const struct HksBlob *key); 78 79 int32_t HuksHdiAdapterAttestKey(const struct HksBlob *key, const struct HksParamSet *paramSet, 80 struct HksBlob *certChain); 81 82 int32_t HuksHdiAdapterUpgradeKey(const struct HksBlob *oldKey, const struct HksParamSet *paramSet, 83 struct HksBlob *newKey); 84 85 int32_t HuksHdiAdapterExportChipsetPlatformPublicKey(const struct HksBlob *salt, 86 enum HksChipsetPlatformDecryptScene scene, struct HksBlob *publicKey); 87 88 int32_t HuksInitHuksCoreEngine(void); 89 90 int32_t HuksReleaseCoreEngine(void); 91 92 struct HuksHdi *HuksGetCoreEngine(void); 93 94 #ifdef __cplusplus 95 } 96 #endif 97 98 #endif