| 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 CHROME_BROWSER_AUTOFILL_CRYPTO_RC4_DECRYPTOR_H_ | 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_CRYPTO_RC4_DECRYPTOR_H_ |
| 6 #define CHROME_BROWSER_AUTOFILL_CRYPTO_RC4_DECRYPTOR_H_ | 6 #define COMPONENTS_AUTOFILL_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 // This is modified RC4 decryption used for import of Toolbar autofill data | 12 // This is modified RC4 decryption used for import of Toolbar autofill data |
| 13 // only. The difference from the Crypto Api implementation is twofold: | 13 // only. The difference from the Crypto Api implementation is twofold: |
| 14 // First, it uses a non-standard key size (160 bit), not supported by Microsoft | 14 // First, it uses a non-standard key size (160 bit), not supported by Microsoft |
| 15 // (it supports only 40 and 128 bit for RC4). Second, it codes 128 words with | 15 // (it supports only 40 and 128 bit for RC4). Second, it codes 128 words with |
| 16 // value 0x0020 at the beginning of the code to enhance security. | 16 // value 0x0020 at the beginning of the code to enhance security. |
| 17 // This class used in chrome/browser/autofill/autofill_ie_toolbar_import_win.cc. | 17 // This class used in components/autofill/browser/autofill_ie_toolbar_import_win
.cc. |
| 18 // This class should not be used anywhere else!!! | 18 // This class should not be used anywhere else!!! |
| 19 class RC4Decryptor { | 19 class RC4Decryptor { |
| 20 public: | 20 public: |
| 21 explicit RC4Decryptor(wchar_t const* password) { | 21 explicit RC4Decryptor(wchar_t const* password) { |
| 22 PrepareKey(reinterpret_cast<const uint8 *>(password), | 22 PrepareKey(reinterpret_cast<const uint8 *>(password), |
| 23 wcslen(password) * sizeof(wchar_t)); | 23 wcslen(password) * sizeof(wchar_t)); |
| 24 std::wstring data; | 24 std::wstring data; |
| 25 // First 128 bytes should be spaces. | 25 // First 128 bytes should be spaces. |
| 26 data.resize(128, L' '); | 26 data.resize(128, L' '); |
| 27 Run(data.c_str()); | 27 Run(data.c_str()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 xor_index = (state[x] + state[y]) % kKeyDataSize; | 93 xor_index = (state[x] + state[y]) % kKeyDataSize; |
| 94 buffer[counter] ^= state[xor_index]; | 94 buffer[counter] ^= state[xor_index]; |
| 95 } | 95 } |
| 96 key_.x = x; | 96 key_.x = x; |
| 97 key_.y = y; | 97 key_.y = y; |
| 98 } | 98 } |
| 99 | 99 |
| 100 Rc4Key key_; | 100 Rc4Key key_; |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 #endif // CHROME_BROWSER_AUTOFILL_CRYPTO_RC4_DECRYPTOR_H_ | 103 #endif // COMPONENTS_AUTOFILL_BROWSER_CRYPTO_RC4_DECRYPTOR_H_ |
| OLD | NEW |