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 PINAUTH_SECRET_H 17 #define PINAUTH_SECRET_H 18 19 #include <cstdint> 20 #include <openssl/evp.h> 21 #include <vector> 22 #include "nocopyable.h" 23 24 namespace OHOS { 25 namespace UserIam { 26 namespace PinAuth { 27 enum AlgoVersion : uint32_t { 28 PIN_ALGO_VERSION_V0 = 0, 29 PIN_ALGO_VERSION_V1 = 1, 30 PIN_ALGO_VERSION_V2 = 2, 31 PIN_ALGO_VERSION_V3 = 3, 32 RECOVERY_KEY_ALGO_VERSION_V0 = 0, 33 }; 34 35 class Scrypt : public NoCopyable { 36 public: Scrypt(std::vector<uint8_t> algoParameter)37 explicit Scrypt(std::vector<uint8_t> algoParameter) : algoParameter_(std::move(algoParameter)) {} 38 ~Scrypt() override = default; 39 std::vector<uint8_t> GetScrypt(const std::vector<uint8_t> &data, uint32_t algoVersion); 40 41 private: 42 bool DoScrypt(const std::vector<uint8_t> &data, uint32_t algoVersion, EVP_PKEY_CTX *pctx); 43 std::vector<uint8_t> algoParameter_ = {}; 44 }; 45 } // namespace PinAuth 46 } // namespace UserIam 47 } // namespace OHOS 48 49 #endif // PINAUTH_SECRET_H