OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/browser/importer/nss_decryptor.h" | 5 #include "chrome/browser/importer/nss_decryptor.h" |
6 | 6 |
7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "chrome/common/sqlite_utils.h" | 9 #include "chrome/common/sqlite_utils.h" |
10 | 10 |
11 #if defined(OS_LINUX) | 11 #if defined(USE_NSS) |
12 #include <pk11pub.h> | 12 #include <pk11pub.h> |
13 #include <pk11sdr.h> | 13 #include <pk11sdr.h> |
14 #endif // defined(OS_LINUX) | 14 #endif // defined(USE_NSS) |
15 | 15 |
16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
17 #include "net/base/base64.h" | 17 #include "net/base/base64.h" |
18 #include "webkit/glue/password_form.h" | 18 #include "webkit/glue/password_form.h" |
19 | 19 |
20 using webkit_glue::PasswordForm; | 20 using webkit_glue::PasswordForm; |
21 | 21 |
22 // This method is based on some Firefox code in | 22 // This method is based on some Firefox code in |
23 // security/manager/ssl/src/nsSDR.cpp | 23 // security/manager/ssl/src/nsSDR.cpp |
24 // The license block is: | 24 // The license block is: |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 return std::wstring(); | 77 return std::wstring(); |
78 } | 78 } |
79 | 79 |
80 SECItem request; | 80 SECItem request; |
81 request.data = reinterpret_cast<unsigned char*>( | 81 request.data = reinterpret_cast<unsigned char*>( |
82 const_cast<char*>(decoded_data.data())); | 82 const_cast<char*>(decoded_data.data())); |
83 request.len = static_cast<unsigned int>(decoded_data.size()); | 83 request.len = static_cast<unsigned int>(decoded_data.size()); |
84 SECItem reply; | 84 SECItem reply; |
85 reply.data = NULL; | 85 reply.data = NULL; |
86 reply.len = 0; | 86 reply.len = 0; |
87 #if defined(OS_LINUX) | 87 #if defined(USE_NSS) |
88 result = PK11SDR_DecryptWithSlot(slot, &request, &reply, NULL); | 88 result = PK11SDR_DecryptWithSlot(slot, &request, &reply, NULL); |
89 #else | 89 #else |
90 result = PK11SDR_Decrypt(&request, &reply, NULL); | 90 result = PK11SDR_Decrypt(&request, &reply, NULL); |
91 #endif // defined(OS_LINUX) | 91 #endif // defined(USE_NSS) |
92 if (result == SECSuccess) | 92 if (result == SECSuccess) |
93 plain.assign(reinterpret_cast<char*>(reply.data), reply.len); | 93 plain.assign(reinterpret_cast<char*>(reply.data), reply.len); |
94 | 94 |
95 SECITEM_FreeItem(&reply, PR_FALSE); | 95 SECITEM_FreeItem(&reply, PR_FALSE); |
96 FreeSlot(slot); | 96 FreeSlot(slot); |
97 } else { | 97 } else { |
98 // Deletes the leading '~' before decoding. | 98 // Deletes the leading '~' before decoding. |
99 net::Base64Decode(crypt.substr(1), &plain); | 99 net::Base64Decode(crypt.substr(1), &plain); |
100 } | 100 } |
101 | 101 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 // The user name, password and action. | 288 // The user name, password and action. |
289 form.username_element = UTF8ToWide(s2.column_string(3)); | 289 form.username_element = UTF8ToWide(s2.column_string(3)); |
290 form.username_value = Decrypt(s2.column_string(5)); | 290 form.username_value = Decrypt(s2.column_string(5)); |
291 form.password_element = UTF8ToWide(s2.column_string(4)); | 291 form.password_element = UTF8ToWide(s2.column_string(4)); |
292 form.password_value = Decrypt(s2.column_string(6)); | 292 form.password_value = Decrypt(s2.column_string(6)); |
293 form.action = GURL(s2.column_string(2)).ReplaceComponents(rep); | 293 form.action = GURL(s2.column_string(2)).ReplaceComponents(rep); |
294 forms->push_back(form); | 294 forms->push_back(form); |
295 } | 295 } |
296 return true; | 296 return true; |
297 } | 297 } |
OLD | NEW |