OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "testing/gtest/include/gtest/gtest.h" | |
6 | |
7 #include <windows.h> | |
8 | |
9 #include <vector> | |
10 | |
11 #include "base/strings/string16.h" | |
12 #include "components/webdata/encryptor/ie7_password.h" | |
13 | |
14 TEST(IEImporterTest, IE7Importer) { | |
15 // This is the unencrypted values of my keys under Storage2. | |
16 // The passwords have been manually changed to abcdef... but the size remains | |
17 // the same. | |
18 unsigned char data1[] = "\x0c\x00\x00\x00\x38\x00\x00\x00\x2c\x00\x00\x00" | |
19 "\x57\x49\x43\x4b\x18\x00\x00\x00\x02\x00\x00\x00" | |
20 "\x67\x00\x72\x00\x01\x00\x00\x00\x00\x00\x00\x00" | |
21 "\x00\x00\x00\x00\x4e\xfa\x67\x76\x22\x94\xc8\x01" | |
22 "\x08\x00\x00\x00\x12\x00\x00\x00\x4e\xfa\x67\x76" | |
23 "\x22\x94\xc8\x01\x0c\x00\x00\x00\x61\x00\x62\x00" | |
24 "\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00" | |
25 "\x00\x00\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00" | |
26 "\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00" | |
27 "\x6c\x00\x00\x00"; | |
28 | |
29 unsigned char data2[] = "\x0c\x00\x00\x00\x38\x00\x00\x00\x24\x00\x00\x00" | |
30 "\x57\x49\x43\x4b\x18\x00\x00\x00\x02\x00\x00\x00" | |
31 "\x67\x00\x72\x00\x01\x00\x00\x00\x00\x00\x00\x00" | |
32 "\x00\x00\x00\x00\xa8\xea\xf4\xe5\x9f\x9a\xc8\x01" | |
33 "\x09\x00\x00\x00\x14\x00\x00\x00\xa8\xea\xf4\xe5" | |
34 "\x9f\x9a\xc8\x01\x07\x00\x00\x00\x61\x00\x62\x00" | |
35 "\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00" | |
36 "\x69\x00\x00\x00\x61\x00\x62\x00\x63\x00\x64\x00" | |
37 "\x65\x00\x66\x00\x67\x00\x00\x00"; | |
38 | |
39 | |
40 | |
41 std::vector<unsigned char> decrypted_data1; | |
42 decrypted_data1.resize(arraysize(data1)); | |
43 memcpy(&decrypted_data1.front(), data1, sizeof(data1)); | |
44 | |
45 std::vector<unsigned char> decrypted_data2; | |
46 decrypted_data2.resize(arraysize(data2)); | |
47 memcpy(&decrypted_data2.front(), data2, sizeof(data2)); | |
48 | |
49 string16 password; | |
50 string16 username; | |
51 ASSERT_TRUE(ie7_password::GetUserPassFromData(decrypted_data1, &username, | |
52 &password)); | |
53 EXPECT_EQ(L"abcdefgh", username); | |
54 EXPECT_EQ(L"abcdefghijkl", password); | |
55 | |
56 ASSERT_TRUE(ie7_password::GetUserPassFromData(decrypted_data2, &username, | |
57 &password)); | |
58 EXPECT_EQ(L"abcdefghi", username); | |
59 EXPECT_EQ(L"abcdefg", password); | |
60 } | |
OLD | NEW |