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 USERIAM_CONTEXT_MANAGER_H 17 #define USERIAM_CONTEXT_MANAGER_H 18 19 #include "coauth.h" 20 #include "executor_message.h" 21 #include "linked_list.h" 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 #define AUTH_MAX_SCHEDULING_NUM 5 28 29 typedef struct UserAuthContext { 30 uint64_t contextId; 31 int32_t userId; 32 uint8_t challenge[CHALLENGE_LEN]; 33 uint32_t authType; 34 uint32_t authTrustLevel; 35 uint32_t collectorSensorHint; 36 LinkedList *scheduleList; 37 } UserAuthContext; 38 39 typedef struct { 40 uint64_t contextId; 41 int32_t userId; 42 uint8_t challenge[CHALLENGE_LEN]; 43 uint32_t authType; 44 uint32_t authTrustLevel; 45 uint32_t executorSensorHint; 46 } AuthSolutionHal; 47 48 typedef struct IdentifyParam { 49 uint64_t contextId; 50 uint8_t challenge[CHALLENGE_LEN]; 51 uint32_t authType; 52 uint32_t executorSensorHint; 53 } IdentifyParam; 54 55 ResultCode InitUserAuthContextList(void); 56 void DestoryUserAuthContextList(void); 57 ResultCode GenerateAuthContext(AuthSolutionHal params, UserAuthContext **context); 58 UserAuthContext *GenerateIdentifyContext(IdentifyParam params); 59 60 UserAuthContext *GetContext(uint64_t contextId); 61 ResultCode ScheduleOnceFinish(UserAuthContext *context, uint64_t scheduleId); 62 void DestoryContext(UserAuthContext *context); 63 ResultCode DestoryContextbyId(uint64_t contextId); 64 ResultCode CopySchedules(UserAuthContext *context, LinkedList **schedules); 65 ResultCode FillInContext(UserAuthContext *context, uint64_t *credentialId, ExecutorResultInfo *info, 66 uint32_t authMode); 67 68 #ifdef __cplusplus 69 } 70 #endif 71 72 #endif // USERIAM_CONTEXT_MANAGER_H