1 /* 2 * Copyright (c) 2023-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 HKS_DCM_CALLBACK_HANDLER_H 17 #define HKS_DCM_CALLBACK_HANDLER_H 18 19 #ifdef __cplusplus 20 #include <cstdint> 21 #include <mutex> 22 #endif 23 24 typedef enum { 25 DCM_SUCCESS = 0 26 } DcmErrorCode; 27 28 struct DcmBlob { 29 uint32_t size; 30 uint8_t *data; 31 }; 32 33 struct DcmCertChain { 34 DcmBlob *certs; 35 uint32_t certsCount; 36 }; 37 38 typedef struct { 39 DcmBlob blob; 40 uint64_t requestId; 41 } DcmAnonymousRequest; 42 43 typedef struct { 44 uint64_t requestId; 45 uint32_t errCode; 46 DcmBlob errInfo; 47 DcmCertChain *certChain; 48 } DcmAnonymousResponse; 49 50 typedef void (*DcmCallback)(DcmAnonymousResponse *response); 51 typedef int32_t (*AttestFunction)(DcmAnonymousRequest *requset, DcmCallback callback); 52 53 #ifdef __cplusplus 54 extern "C" { 55 #endif 56 57 void HksDcmCallback(DcmAnonymousResponse *response); 58 59 int32_t HksDcmCallbackHandlerSetRequestIdWithoutLock(const uint8_t *remoteObject, uint64_t requestId); 60 61 AttestFunction HksOpenDcmFunction(void); 62 63 void HksCloseDcmFunction(void); 64 65 #ifdef __cplusplus 66 } // extern "C" 67 #endif 68 69 #ifdef __cplusplus 70 std::mutex &HksDcmCallbackHandlerGetMapMutex(void); 71 #endif 72 73 #endif // HKS_DCM_CALLBACK_HANDLER_H