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 PINAUTH_IINPUTERDATA_IMPL_H 17 #define PINAUTH_IINPUTERDATA_IMPL_H 18 19 #include <cstdint> 20 #include <memory> 21 #include <mutex> 22 #include <vector> 23 #include "i_inputer_data.h" 24 #include "iremote_inputer_data.h" 25 #include "nocopyable.h" 26 #include "refbase.h" 27 28 namespace OHOS { 29 namespace UserIAM { 30 namespace PinAuth { 31 const int32_t OUT_LENGTH = 64; 32 const int32_t SCRYPT_N = 32768; 33 const int32_t SCRYPT_R = 3; 34 const int32_t SCRYPT_P = 1; 35 36 class InputerDataImpl : public IInputerData { 37 public: 38 DISALLOW_COPY_AND_MOVE(InputerDataImpl); 39 explicit InputerDataImpl(std::vector<uint8_t> salt, sptr<IRemoteInputerData> remoteInputerData); 40 ~InputerDataImpl() override; 41 void OnSetData(int32_t authSubType, std::vector<uint8_t> data) override; 42 43 private: 44 std::vector<uint8_t> salt_; 45 sptr<IRemoteInputerData> remoteInputerData_; 46 private: 47 void getScrypt(std::vector<uint8_t> data, std::vector<uint8_t> &scrypt); 48 }; 49 } // namespace PinAuth 50 } // namespace UserIAM 51 } // namespace OHOS 52 53 #endif // PINAUTH_IINPUTERDATA_H 54