1 /*
2 * Copyright (c) 2024-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 #include "framework_scrypt_scrypt_test.h"
17 #include "scrypt.h"
18 #include "mock_inputer_set_data.h"
19
20 #include <openssl/sha.h>
21
22 namespace OHOS {
23 namespace UserIam {
24 namespace PinAuth {
25 using namespace testing;
26 using namespace testing::ext;
27
SetUpTestCase()28 void FrameworkScryptScryptTest::SetUpTestCase()
29 {
30 }
31
TearDownTestCase()32 void FrameworkScryptScryptTest::TearDownTestCase()
33 {
34 }
35
SetUp()36 void FrameworkScryptScryptTest::SetUp()
37 {
38 }
39
TearDown()40 void FrameworkScryptScryptTest::TearDown()
41 {
42 }
43
44 HWTEST_F(FrameworkScryptScryptTest, GetScryptTest001, TestSize.Level0)
45 {
46 std::vector<uint8_t> algoParameter = {1, 2, 3, 4, 5};
47 Scrypt scrypt(algoParameter);
48 std::vector<uint8_t> data = {1, 2, 3, 4, 5};
49 uint32_t algoVersion = 1;
50 std::vector<uint8_t> result = scrypt.GetScrypt(data, algoVersion);
51 EXPECT_EQ(result.size(), 64);
52 }
53
54 HWTEST_F(FrameworkScryptScryptTest, GetScryptTest002, TestSize.Level0)
55 {
56 std::vector<uint8_t> algoParameter = {1, 2, 3, 4, 5};
57 Scrypt scrypt(algoParameter);
58 std::vector<uint8_t> data = {1, 2, 3, 4, 5};
59 uint32_t algoVersion = 100;
60 std::vector<uint8_t> result = scrypt.GetScrypt(data, algoVersion);
61 EXPECT_EQ(result.size(), 0);
62 }
63 } // namespace PinAuth
64 } // namespace UserIam
65 } // namespace OHOS
66