1 /* 2 * Copyright (c) 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 CJ_HUKS_FFI_H 17 #define CJ_HUKS_FFI_H 18 19 #include "hks_param.h" 20 #include "hks_errcode_adapter.h" 21 22 #define FFI_EXPORT __attribute__((visibility("default"))) 23 24 FFI_EXPORT int32_t FfiOHOSGetSdkVersion(struct HksBlob *sdkVersion); 25 26 FFI_EXPORT int32_t FfiOHOSInitSession(const char *keyAlias, const struct HksParamSet *paramSet, 27 struct HksBlob *handle, struct HksBlob *token); 28 29 FFI_EXPORT int32_t FfiOHOSUpdateSession(const struct HksBlob *handle, const struct HksParamSet *paramSet, 30 const struct HksBlob *inData, struct HksBlob *outData); 31 32 FFI_EXPORT int32_t FfiOHOSFinishSession(const struct HksBlob *handle, const struct HksParamSet *paramSet, 33 const struct HksBlob *inData, struct HksBlob *outData); 34 35 FFI_EXPORT int32_t FfiOHOSAbortSession(const struct HksBlob *handle, const struct HksParamSet *paramSet); 36 37 FFI_EXPORT int32_t FfiOHOSIsKeyExist(const char *keyAlias, const struct HksParamSet *paramSet); 38 39 FFI_EXPORT int32_t FfiOHOSGetKeyItemProperties(const char *keyAlias, 40 const struct HksParamSet *paramSetIn, struct HksParamSet *paramSetOut); 41 42 FFI_EXPORT int32_t FfiOHOSHAttestKey(const char *keyAlias, const struct HksParamSet *paramSet, 43 struct HksCertChain *certChain); 44 45 FFI_EXPORT int32_t FfiOHOSHAnonAttestKey(const char *keyAlias, const struct HksParamSet *paramSet, 46 struct HksCertChain *certChain); 47 48 FFI_EXPORT int32_t FfiOHOSExportKey(const char *keyAlias, const struct HksParamSet *paramSet, struct HksBlob *key); 49 50 FFI_EXPORT int32_t FfiOHOSImportWrappedKey(const char *keyAlias, const char *wrappingKeyAlias, 51 const struct HksParamSet *paramSet, const struct HksBlob *wrappedKeyData); 52 53 FFI_EXPORT int32_t FfiOHOSGenerateKey(const char *keyAlias, const struct HksParamSet *paramSetIn, 54 struct HksParamSet *paramSetOut); 55 56 FFI_EXPORT int32_t FfiOHOSDeleteKey(const char *keyAlias, const struct HksParamSet *paramSet); 57 58 FFI_EXPORT int32_t FfiOHOSImportKey(const char *keyAlias, const struct HksParamSet *paramSet, struct HksBlob *key); 59 60 FFI_EXPORT void FfiOHOSConvertErrCode(int32_t hksCode, struct HksResult *ret); 61 62 #endif