OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_AUTOFILL_BROWSER_CRYPTO_RC4_DECRYPTOR_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_CRYPTO_RC4_DECRYPTOR_H_ |
6 #define COMPONENTS_AUTOFILL_BROWSER_CRYPTO_RC4_DECRYPTOR_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_CRYPTO_RC4_DECRYPTOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 | 11 |
12 namespace autofill { | 12 namespace autofill { |
13 | 13 |
14 // This is modified RC4 decryption used for import of Toolbar autofill data | 14 // This is modified RC4 decryption used for import of Toolbar autofill data |
15 // only. The difference from the Crypto Api implementation is twofold: | 15 // only. The difference from the Crypto Api implementation is twofold: |
16 // First, it uses a non-standard key size (160 bit), not supported by Microsoft | 16 // First, it uses a non-standard key size (160 bit), not supported by Microsoft |
17 // (it supports only 40 and 128 bit for RC4). Second, it codes 128 words with | 17 // (it supports only 40 and 128 bit for RC4). Second, it codes 128 words with |
18 // value 0x0020 at the beginning of the code to enhance security. | 18 // value 0x0020 at the beginning of the code to enhance security. |
19 // | 19 // |
20 // This class used in | 20 // This class used in |
21 // components/autofill/browser/autofill_ie_toolbar_import_win.cc. | 21 // components/autofill/core/browser/autofill_ie_toolbar_import_win.cc. |
22 // | 22 // |
23 // This class should not be used anywhere else!!! | 23 // This class should not be used anywhere else!!! |
24 class RC4Decryptor { | 24 class RC4Decryptor { |
25 public: | 25 public: |
26 explicit RC4Decryptor(wchar_t const* password) { | 26 explicit RC4Decryptor(wchar_t const* password) { |
27 PrepareKey(reinterpret_cast<const uint8 *>(password), | 27 PrepareKey(reinterpret_cast<const uint8 *>(password), |
28 wcslen(password) * sizeof(wchar_t)); | 28 wcslen(password) * sizeof(wchar_t)); |
29 std::wstring data; | 29 std::wstring data; |
30 // First 128 bytes should be spaces. | 30 // First 128 bytes should be spaces. |
31 data.resize(128, L' '); | 31 data.resize(128, L' '); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 } | 100 } |
101 key_.x = x; | 101 key_.x = x; |
102 key_.y = y; | 102 key_.y = y; |
103 } | 103 } |
104 | 104 |
105 Rc4Key key_; | 105 Rc4Key key_; |
106 }; | 106 }; |
107 | 107 |
108 } // namespace autofill | 108 } // namespace autofill |
109 | 109 |
110 #endif // COMPONENTS_AUTOFILL_BROWSER_CRYPTO_RC4_DECRYPTOR_H_ | 110 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_CRYPTO_RC4_DECRYPTOR_H_ |
OLD | NEW |