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 USERAUTH_INFO_H 17 #define USERAUTH_INFO_H 18 19 #include <map> 20 #include "parcel.h" 21 22 namespace OHOS { 23 namespace UserIAM { 24 namespace UserAuth { 25 enum AuthType : uint32_t { 26 PIN = 1, 27 FACE = 2, 28 }; 29 30 enum class UserAuthType { 31 FACE = 2, 32 FINGERPRINT = 4, 33 }; 34 35 enum AuthSubType : uint64_t { 36 PIN_SIX = 10000, 37 PIN_NUMBER = 10001, 38 PIN_MIXED = 10002, 39 FACE_2D = 20000, 40 FACE_3D = 20001 41 }; 42 43 enum AuthTurstLevel : uint32_t { 44 ATL1 = 10000, 45 ATL2 = 20000, 46 ATL3 = 30000, 47 ATL4 = 40000 48 }; 49 50 enum GetPropertyType : uint32_t { 51 AUTH_SUB_TYPE = 1, 52 REMAIN_TIMES = 2, 53 FREEZING_TIME = 3, 54 }; 55 56 struct GetPropertyRequest { 57 AuthType authType {0}; 58 std::vector<uint32_t> keys {}; 59 }; 60 61 struct ExecutorProperty { 62 int32_t result; 63 AuthSubType authSubType; 64 uint32_t remainTimes; 65 uint32_t freezingTime; 66 }; 67 68 enum AuthPropertyMode : uint32_t { 69 PROPERMODE_DELETE = 0, 70 PROPERMODE_GET = 1, 71 PROPERMODE_SET = 2, 72 PROPERMODE_FREEZE = 3, 73 PROPERMODE_UNFREEZE = 4, 74 PROPERMODE_INIT_ALGORITHM = 5, 75 PROPERMODE_RELEASE_ALGORITHM = 6, 76 }; 77 78 enum SetPropertyType : uint32_t { 79 INIT_ALGORITHM = 1, 80 FREEZE_TEMPLATE = 2, 81 THAW_TEMPLATE = 3, 82 }; 83 84 struct SetPropertyRequest { 85 AuthType authType {0}; 86 SetPropertyType key {0}; 87 std::vector<uint8_t> setInfo {}; 88 }; 89 90 struct AuthResult { 91 std::vector<uint8_t> token {}; 92 uint32_t remainTimes {0}; 93 uint32_t freezingTime {0}; 94 }; 95 96 struct CoAuthInfo { 97 AuthType authType {0}; 98 uint64_t callerID {0}; 99 uint64_t contextID {0}; 100 int32_t userID {0}; 101 std::string pkgName; 102 std::vector<uint64_t> sessionIds; 103 }; 104 105 struct FreezInfo { 106 uint64_t callerID; 107 std::string pkgName; 108 int32_t resultCode; 109 AuthType authType; 110 }; 111 112 struct CallerInfo { 113 uint64_t callerUID; 114 int32_t userID {0}; 115 std::string pkgName; 116 }; 117 118 enum ResultCode : int32_t { 119 SUCCESS = 0, 120 FAIL = 1, 121 GENERAL_ERROR = 2, 122 CANCELED = 3, 123 TIMEOUT = 4, 124 TYPE_NOT_SUPPORT = 5, 125 TRUST_LEVEL_NOT_SUPPORT = 6, 126 BUSY = 7, 127 INVALID_PARAMETERS = 8, 128 LOCKED = 9, 129 NOT_ENROLLED = 10, 130 IPC_ERROR = 11, 131 INVALID_CONTEXTID = 12, 132 E_WRITE_PARCEL_ERROR = 13, 133 E_READ_PARCEL_ERROR = 14, 134 E_GET_POWER_SERVICE_FAILED = 15, 135 E_RET_UNDONE = 16, 136 E_RET_NOSERVER = 17, 137 E_CHECK_PERMISSION_FAILED = 18, 138 ERRORCODE_MAX = 19 139 }; 140 141 // For API6 142 enum class AuthenticationResult { 143 NO_SUPPORT = -1, 144 SUCCESS = 0, 145 COMPARE_FAILURE = 1, 146 CANCELED = 2, 147 TIMEOUT = 3, 148 CAMERA_FAIL = 4, 149 BUSY = 5, 150 INVALID_PARAMETERS = 6, 151 LOCKED = 7, 152 NOT_ENROLLED = 8, 153 GENERAL_ERROR = 100, 154 }; 155 156 const std::map<int32_t, AuthenticationResult> result2ExecuteResult = { 157 {ResultCode::SUCCESS, AuthenticationResult::SUCCESS}, 158 {ResultCode::FAIL, AuthenticationResult::COMPARE_FAILURE}, 159 {ResultCode::GENERAL_ERROR, AuthenticationResult::GENERAL_ERROR}, 160 {ResultCode::CANCELED, AuthenticationResult::CANCELED}, 161 {ResultCode::TIMEOUT, AuthenticationResult::TIMEOUT}, 162 {ResultCode::TYPE_NOT_SUPPORT, AuthenticationResult::NO_SUPPORT}, 163 {ResultCode::TRUST_LEVEL_NOT_SUPPORT, AuthenticationResult::NO_SUPPORT}, 164 {ResultCode::BUSY, AuthenticationResult::BUSY}, 165 {ResultCode::INVALID_PARAMETERS, AuthenticationResult::INVALID_PARAMETERS}, 166 {ResultCode::LOCKED, AuthenticationResult::LOCKED}, 167 {ResultCode::NOT_ENROLLED, AuthenticationResult::NOT_ENROLLED}, 168 {ResultCode::IPC_ERROR, AuthenticationResult::GENERAL_ERROR}, 169 {ResultCode::INVALID_CONTEXTID, AuthenticationResult::GENERAL_ERROR}, 170 {ResultCode::E_WRITE_PARCEL_ERROR, AuthenticationResult::GENERAL_ERROR}, 171 {ResultCode::E_READ_PARCEL_ERROR, AuthenticationResult::GENERAL_ERROR}, 172 {ResultCode::E_GET_POWER_SERVICE_FAILED, AuthenticationResult::GENERAL_ERROR}, 173 {ResultCode::E_RET_UNDONE, AuthenticationResult::GENERAL_ERROR}, 174 {ResultCode::E_RET_NOSERVER, AuthenticationResult::GENERAL_ERROR}, 175 {ResultCode::E_CHECK_PERMISSION_FAILED, AuthenticationResult::GENERAL_ERROR}, 176 }; 177 } // namespace UserAuth 178 } // namespace UserIAM 179 } // namespace OHOS 180 #endif // USERAUTH_INFO_H 181