1 /* 2 * Copyright (c) 2021-2024 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_CLIENT_IPC_H 17 #define HKS_CLIENT_IPC_H 18 19 #include "hks_type_inner.h" 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 int32_t HksClientInitialize(void); 26 27 int32_t HksClientRefreshKeyInfo(void); 28 29 int32_t HksClientGenerateKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSetIn, 30 struct HksParamSet *paramSetOut); 31 32 int32_t HksClientImportKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet, 33 const struct HksBlob *key); 34 35 int32_t HksClientExportPublicKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet, 36 struct HksBlob *key); 37 38 int32_t HksClientImportWrappedKey(const struct HksBlob *keyAlias, const struct HksBlob *wrappingKeyAlias, 39 const struct HksParamSet *paramSet, const struct HksBlob *wrappedKeyData); 40 41 int32_t HksClientDeleteKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet); 42 43 int32_t HksClientGetKeyParamSet(const struct HksBlob *keyAlias, const struct HksParamSet *paramSetIn, 44 struct HksParamSet *paramSetOut); 45 46 int32_t HksClientKeyExist(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet); 47 48 int32_t HksClientGenerateRandom(struct HksBlob *random, const struct HksParamSet *paramSet); 49 50 int32_t HksClientSign(const struct HksBlob *key, const struct HksParamSet *paramSet, 51 const struct HksBlob *srcData, struct HksBlob *signature); 52 53 int32_t HksClientVerify(const struct HksBlob *key, const struct HksParamSet *paramSet, 54 const struct HksBlob *srcData, const struct HksBlob *signature); 55 56 int32_t HksClientEncrypt(const struct HksBlob *key, const struct HksParamSet *paramSet, 57 const struct HksBlob *plainText, struct HksBlob *cipherText); 58 59 int32_t HksClientDecrypt(const struct HksBlob *key, const struct HksParamSet *paramSet, 60 const struct HksBlob *cipherText, struct HksBlob *plainText); 61 62 int32_t HksClientAgreeKey(const struct HksParamSet *paramSet, const struct HksBlob *privateKey, 63 const struct HksBlob *peerPublicKey, struct HksBlob *agreedKey); 64 65 int32_t HksClientDeriveKey(const struct HksParamSet *paramSet, const struct HksBlob *mainKey, 66 struct HksBlob *derivedKey); 67 68 int32_t HksClientMac(const struct HksBlob *key, const struct HksParamSet *paramSet, const struct HksBlob *srcData, 69 struct HksBlob *mac); 70 71 int32_t HksClientGetKeyInfoList(const struct HksParamSet *paramSet, struct HksKeyInfo *keyInfoList, 72 uint32_t *listCount); 73 74 int32_t HksClientAttestKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet, 75 struct HksCertChain *certChain, bool needAnonCertChain); 76 77 int32_t HksClientInit(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet, struct HksBlob *handle, 78 struct HksBlob *token); 79 80 int32_t HksClientUpdate(const struct HksBlob *handle, const struct HksParamSet *paramSet, const struct HksBlob *inData, 81 struct HksBlob *outData); 82 83 int32_t HksClientFinish(const struct HksBlob *handle, const struct HksParamSet *paramSet, const struct HksBlob *inData, 84 struct HksBlob *outData); 85 86 int32_t HksClientAbort(const struct HksBlob *handle, const struct HksParamSet *paramSet); 87 88 int32_t HksClientExportChipsetPlatformPublicKey(const struct HksBlob *salt, 89 enum HksChipsetPlatformDecryptScene scene, struct HksBlob *publicKey); 90 91 int32_t HksClientListAliases(const struct HksParamSet *paramSet, struct HksKeyAliasSet **outData); 92 93 int32_t HksClientRenameKeyAlias(const struct HksBlob *oldKeyAlias, const struct HksParamSet *paramSet, 94 const struct HksBlob *newKeyAlias); 95 96 int32_t HksClientChangeStorageLevel(const struct HksBlob *keyAlias, const struct HksParamSet *srcParamSet, 97 const struct HksParamSet *destParamSet); 98 99 #ifdef __cplusplus 100 } 101 #endif 102 103 #endif /* HKS_CLIENT_IPC_H */ 104