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_HDI_H 17 #define HUKS_HDI_H 18 19 #include "hks_param.h" 20 #include "hks_type.h" 21 22 struct HuksHdi { 23 int32_t (*HuksHdiModuleInit)(void); 24 25 int32_t (*HuksHdiRefresh)(void); 26 27 int32_t (*HuksHdiGenerateKey)(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet, 28 const struct HksBlob *keyIn, struct HksBlob *keyOut); 29 30 int32_t (*HuksHdiImportKey)(const struct HksBlob *keyAlias, const struct HksBlob *key, 31 const struct HksParamSet *paramSet, struct HksBlob *keyOut); 32 33 int32_t (*HuksHdiImportWrappedKey)(const struct HksBlob *wrappingKeyAlias, const struct HksBlob *key, 34 const struct HksBlob *wrappedKeyData, const struct HksParamSet *paramSet, struct HksBlob *keyOut); 35 36 int32_t (*HuksHdiExportPublicKey)(const struct HksBlob *key, const struct HksParamSet *paramSet, 37 struct HksBlob *keyOut); 38 39 int32_t (*HuksHdiInit)(const struct HksBlob *key, const struct HksParamSet *paramSet, struct HksBlob *handle, 40 struct HksBlob *token); 41 42 int32_t (*HuksHdiUpdate)(const struct HksBlob *handle, const struct HksParamSet *paramSet, 43 const struct HksBlob *inData, struct HksBlob *outData); 44 45 int32_t (*HuksHdiFinish)(const struct HksBlob *handle, const struct HksParamSet *paramSet, 46 const struct HksBlob *inData, struct HksBlob *outData); 47 48 int32_t (*HuksHdiAbort)(const struct HksBlob *handle, const struct HksParamSet *paramSet); 49 50 int32_t (*HuksHdiGetKeyProperties)(const struct HksParamSet *paramSet, const struct HksBlob *key); 51 52 int32_t (*HuksHdiAttestKey)(const struct HksBlob *key, const struct HksParamSet *paramSet, 53 struct HksBlob *certChain); 54 55 int32_t (*HuksHdiGetAbility)(int32_t funcType); 56 57 int32_t (*HuksHdiGetHardwareInfo)(void); 58 59 int32_t (*HuksHdiCalcMacHeader)(const struct HksParamSet *paramSet, const struct HksBlob *salt, 60 const struct HksBlob *srcData, struct HksBlob *mac); 61 62 int32_t (*HuksHdiUpgradeKeyInfo)(const struct HksBlob *keyAlias, const struct HksBlob *keyInfo, 63 struct HksBlob *keyOut); 64 65 int32_t (*HuksHdiGenerateRandom)(const struct HksParamSet *paramSet, struct HksBlob *random); 66 67 int32_t (*HuksHdiSign)(const struct HksBlob *key, const struct HksParamSet *paramSet, 68 const struct HksBlob *srcData, struct HksBlob *signature); 69 70 int32_t (*HuksHdiVerify)(const struct HksBlob *key, const struct HksParamSet *paramSet, 71 const struct HksBlob *srcData, const struct HksBlob *signature); 72 73 int32_t (*HuksHdiEncrypt)(const struct HksBlob *key, const struct HksParamSet *paramSet, 74 const struct HksBlob *plainText, struct HksBlob *cipherText); 75 76 int32_t (*HuksHdiDecrypt)(const struct HksBlob *key, const struct HksParamSet *paramSet, 77 const struct HksBlob *cipherText, struct HksBlob *plainText); 78 79 int32_t (*HuksHdiAgreeKey)(const struct HksParamSet *paramSet, const struct HksBlob *privateKey, 80 const struct HksBlob *peerPublicKey, struct HksBlob *agreedKey); 81 82 int32_t (*HuksHdiDeriveKey)(const struct HksParamSet *paramSet, const struct HksBlob *kdfKey, 83 struct HksBlob *derivedKey); 84 85 int32_t (*HuksHdiMac)(const struct HksBlob *key, const struct HksParamSet *paramSet, 86 const struct HksBlob *srcData, struct HksBlob *mac); 87 }; 88 89 #endif /* HUKS_HDI_H */ 90