1 /* 2 * Copyright (C) 2022-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 COMMON_DEFINES_H 17 #define COMMON_DEFINES_H 18 19 #include <stdint.h> 20 21 #include "adaptor_log.h" 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 enum InnerKitResultCode { 28 INNER_RESULT_SUCCESS = 0, 29 INNER_RESULT_FAIL = 1, 30 INNER_RESULT_GENERAL_ERROR = 2, 31 INNER_RESULT_CANCELED = 3, 32 INNER_RESULT_TIMEOUT = 4, 33 INNER_RESULT_TYPE_NOT_SUPPORT = 5, 34 INNER_RESULT_TRUST_LEVEL_NOT_SUPPORT = 6, 35 INNER_RESULT_BUSY = 7, 36 INNER_RESULT_INVALID_PARAMETERS = 8, 37 INNER_RESULT_LOCKED = 9, 38 INNER_RESULT_NOT_ENROLLED = 10, 39 INNER_RESULT_HARDWARE_NOT_SUPPORTED = 11, 40 INNER_RESULT_SYSTEM_ERROR_CODE_BEGIN = 1000, // error code for system 41 INNER_RESULT_IPC_ERROR = 1001, 42 INNER_RESULT_INVALID_CONTEXT_ID = 1002, 43 INNER_RESULT_READ_PARCEL_ERROR = 1003, 44 INNER_RESULT_WRITE_PARCEL_ERROR = 1004, 45 INNER_RESULT_CHECK_PERMISSION_FAILED = 1005, 46 INNER_RESULT_INVALID_HDI_INTERFACE = 1006, 47 INNER_RESULT_VENDOR_ERROR_CODE_BEGIN = 10000, // error code for vendor 48 }; 49 50 typedef enum ResultCode { 51 RESULT_SUCCESS = INNER_RESULT_SUCCESS, 52 RESULT_GENERAL_ERROR = INNER_RESULT_GENERAL_ERROR, 53 RESULT_BAD_PARAM = INNER_RESULT_INVALID_PARAMETERS, 54 RESULT_NOT_ENROLLED = INNER_RESULT_NOT_ENROLLED, 55 RESULT_TYPE_NOT_SUPPORT = INNER_RESULT_TYPE_NOT_SUPPORT, 56 RESULT_TRUST_LEVEL_NOT_SUPPORT = INNER_RESULT_TRUST_LEVEL_NOT_SUPPORT, 57 RESULT_BAD_COPY = INNER_RESULT_VENDOR_ERROR_CODE_BEGIN + 0x3, 58 RESULT_NO_MEMORY = INNER_RESULT_VENDOR_ERROR_CODE_BEGIN + 0x4, 59 RESULT_NEED_INIT = INNER_RESULT_VENDOR_ERROR_CODE_BEGIN + 0x5, 60 RESULT_NOT_FOUND = INNER_RESULT_VENDOR_ERROR_CODE_BEGIN + 0x6, 61 RESULT_REACH_LIMIT = INNER_RESULT_VENDOR_ERROR_CODE_BEGIN + 0x7, 62 RESULT_DUPLICATE_CHECK_FAILED = INNER_RESULT_VENDOR_ERROR_CODE_BEGIN + 0x8, 63 RESULT_BAD_READ = INNER_RESULT_VENDOR_ERROR_CODE_BEGIN + 0x9, 64 RESULT_BAD_WRITE = INNER_RESULT_VENDOR_ERROR_CODE_BEGIN + 0xA, 65 RESULT_BAD_DEL = INNER_RESULT_VENDOR_ERROR_CODE_BEGIN + 0xB, 66 RESULT_UNKNOWN = INNER_RESULT_VENDOR_ERROR_CODE_BEGIN + 0xC, 67 RESULT_BAD_MATCH = INNER_RESULT_VENDOR_ERROR_CODE_BEGIN + 0xD, 68 RESULT_BAD_SIGN = INNER_RESULT_VENDOR_ERROR_CODE_BEGIN + 0xE, 69 RESULT_BUSY = INNER_RESULT_BUSY, 70 RESULT_TOKEN_TIMEOUT = INNER_RESULT_VENDOR_ERROR_CODE_BEGIN + 0x10, 71 RESULT_VERIFY_TOKEN_FAIL = INNER_RESULT_VENDOR_ERROR_CODE_BEGIN + 0x11, 72 RESULT_EXCEED_LIMIT = INNER_RESULT_VENDOR_ERROR_CODE_BEGIN + 0x12, 73 RESULT_IDM_SESSION_TIMEOUT = INNER_RESULT_VENDOR_ERROR_CODE_BEGIN + 0x13, 74 75 RESULT_AUTH_NOT_COMPELETED = INNER_RESULT_VENDOR_ERROR_CODE_BEGIN + 0x10001, 76 } ResultCode; 77 78 typedef enum AuthType { 79 DEFAULT_AUTH_TYPE = 0, 80 PIN_AUTH = 1, 81 FACE_AUTH = 2, 82 FINGER_AUTH = 4, 83 } AuthType; 84 85 typedef enum ScheduleMode { 86 SCHEDULE_MODE_ENROLL = 0, 87 SCHEDULE_MODE_AUTH = 1, 88 SCHEDULE_MODE_IDENTIFY = 2, 89 } ScheduleMode; 90 91 typedef enum AuthSubType { 92 DEFAULT_TYPE = 0, 93 } AuthSubType; 94 95 typedef enum AuthPropertyMode { 96 PROPERTY_INIT_ALGORITHM = 1, 97 PROPERTY_MODE_DEL = 2, 98 PROPERTY_MODE_GET = 3, 99 PROPERTY_MODE_SET = 4, 100 PROPERTY_MODE_FREEZE = 5, 101 PROPERTY_MODE_UNFREEZE = 6, 102 PROPERTY_MODE_SET_CACHED_TEMPLATES = 7, 103 } AuthPropertyMode; 104 105 typedef enum Asl { 106 ASL0 = 0, 107 ASL1 = 1, 108 ASL2 = 2, 109 ASL3 = 3, 110 MAX_ASL = 4, 111 } Asl; 112 113 typedef enum Acl { 114 ACL0 = 0, 115 ACL1 = 1, 116 ACL2 = 2, 117 ACL3 = 3, 118 } Acl; 119 120 typedef enum Atl { 121 ATL0 = 0, 122 ATL1 = 10000, 123 ATL2 = 20000, 124 ATL3 = 30000, 125 ATL4 = 40000, 126 } Atl; 127 128 #define IF_TRUE_LOGE_AND_RETURN_VAL(cond, retVal) \ 129 do { \ 130 if (cond) { \ 131 LOG_ERROR("(" #cond ") check fail, return"); \ 132 return (retVal); \ 133 } \ 134 } while (0) 135 136 #define IF_TRUE_LOGE_AND_RETURN(cond) \ 137 do { \ 138 if (cond) { \ 139 LOG_ERROR("(" #cond ") check fail, return"); \ 140 return; \ 141 } \ 142 } while (0) 143 144 #define MAX_DUPLICATE_CHECK 100 145 #define INVALID_SENSOR_HINT 0 146 #define MAX_TEMPLATE_OF_SCHEDULE 10 147 #define CHALLENGE_LEN 32 148 #define MAX_CREDENTIAL_OUTPUT 10 149 150 #ifdef __cplusplus 151 } 152 #endif 153 154 #endif 155