1 /* 2 * Copyright (c) 2022-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 INPUTER_DATA_IMPL_H 17 #define INPUTER_DATA_IMPL_H 18 19 #include <cstdint> 20 #include <memory> 21 #include <mutex> 22 #include <vector> 23 24 #include "refbase.h" 25 26 #include "iam_common_defines.h" 27 #include "i_inputer_data.h" 28 #include "inputer_get_data.h" 29 #include "inputer_set_data.h" 30 31 namespace OHOS { 32 namespace UserIam { 33 namespace PinAuth { 34 class InputerDataImpl : public IInputerData { 35 public: 36 InputerDataImpl(const InputerGetDataParam ¶m); 37 ~InputerDataImpl() override = default; 38 void OnSetData(int32_t authSubType, std::vector<uint8_t> data) override; 39 40 private: 41 bool GetSha256(const std::vector<uint8_t> &data, std::vector<uint8_t> &out); 42 void GetPinData( 43 int32_t authSubType, const std::vector<uint8_t> &dataIn, std::vector<uint8_t> &dataOut, int32_t &errorCode); 44 void GetPrivatePinData( 45 int32_t authSubType, const std::vector<uint8_t> &dataIn, std::vector<uint8_t> &dataOut, int32_t &errorCode); 46 void OnSetDataInner(int32_t authSubType, std::vector<uint8_t> &setData, int32_t errorCode); 47 int32_t CheckPinComplexity(int32_t authSubType, const std::vector<uint8_t> &data); 48 bool CheckEdmPinComplexity(int32_t authSubType, std::vector<uint8_t> &input); 49 bool CheckSpecialPinComplexity(std::vector<uint8_t> &input, int32_t authSubType); 50 bool CheckPinSizeBySubType(int32_t authSubType, size_t size); 51 bool CheckPinComplexityByReg(std::vector<uint8_t> &input, const std::string &complexityReg); 52 53 GetDataMode mode_ = GET_DATA_MODE_NONE; 54 uint32_t algoVersion_ = 0; 55 std::vector<uint8_t> algoParameter_; 56 sptr<InputerSetData> inputerSetData_; 57 std::string complexityReg_; 58 int32_t userId_; 59 int32_t authIntent_; 60 }; 61 } // namespace PinAuth 62 } // namespace UserIam 63 } // namespace OHOS 64 #endif // INPUTER_DATA_IMPL_H 65