Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: chrome/utility/importer/nss_decryptor.cc

Issue 1082123003: Rename USE_NSS to USE_NSS_CERTS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@use-nss-certs
Patch Set: rebase Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/utility/importer/nss_decryptor.h" 5 #include "chrome/utility/importer/nss_decryptor.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string_split.h" 12 #include "base/strings/string_split.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "components/autofill/core/common/password_form.h" 15 #include "components/autofill/core/common/password_form.h"
16 #include "sql/connection.h" 16 #include "sql/connection.h"
17 #include "sql/statement.h" 17 #include "sql/statement.h"
18 18
19 #if defined(USE_NSS) 19 #if defined(USE_NSS_CERTS)
20 #include <pk11pub.h> 20 #include <pk11pub.h>
21 #include <pk11sdr.h> 21 #include <pk11sdr.h>
22 #endif // defined(USE_NSS) 22 #endif // defined(USE_NSS_CERTS)
23 23
24 // This method is based on some Firefox code in 24 // This method is based on some Firefox code in
25 // security/manager/ssl/src/nsSDR.cpp 25 // security/manager/ssl/src/nsSDR.cpp
26 // The license block is: 26 // The license block is:
27 27
28 /* ***** BEGIN LICENSE BLOCK ***** 28 /* ***** BEGIN LICENSE BLOCK *****
29 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 29 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
30 * 30 *
31 * The contents of this file are subject to the Mozilla Public License Version 31 * The contents of this file are subject to the Mozilla Public License Version
32 * 1.1 (the "License"); you may not use this file except in compliance with 32 * 1.1 (the "License"); you may not use this file except in compliance with
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 return base::string16(); 83 return base::string16();
84 } 84 }
85 85
86 SECItem request; 86 SECItem request;
87 request.data = reinterpret_cast<unsigned char*>( 87 request.data = reinterpret_cast<unsigned char*>(
88 const_cast<char*>(decoded_data.data())); 88 const_cast<char*>(decoded_data.data()));
89 request.len = static_cast<unsigned int>(decoded_data.size()); 89 request.len = static_cast<unsigned int>(decoded_data.size());
90 SECItem reply; 90 SECItem reply;
91 reply.data = NULL; 91 reply.data = NULL;
92 reply.len = 0; 92 reply.len = 0;
93 #if defined(USE_NSS) 93 #if defined(USE_NSS_CERTS)
94 result = PK11SDR_DecryptWithSlot(slot, &request, &reply, NULL); 94 result = PK11SDR_DecryptWithSlot(slot, &request, &reply, NULL);
95 #else 95 #else
96 result = PK11SDR_Decrypt(&request, &reply, NULL); 96 result = PK11SDR_Decrypt(&request, &reply, NULL);
97 #endif // defined(USE_NSS) 97 #endif // defined(USE_NSS_CERTS)
98 if (result == SECSuccess) 98 if (result == SECSuccess)
99 plain.assign(reinterpret_cast<char*>(reply.data), reply.len); 99 plain.assign(reinterpret_cast<char*>(reply.data), reply.len);
100 100
101 SECITEM_FreeItem(&reply, PR_FALSE); 101 SECITEM_FreeItem(&reply, PR_FALSE);
102 FreeSlot(slot); 102 FreeSlot(slot);
103 } else { 103 } else {
104 // Deletes the leading '~' before decoding. 104 // Deletes the leading '~' before decoding.
105 if (!base::Base64Decode(crypt.substr(1), &plain)) 105 if (!base::Base64Decode(crypt.substr(1), &plain))
106 return base::string16(); 106 return base::string16();
107 } 107 }
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 // The user name, password and action. 300 // The user name, password and action.
301 form.username_element = s2.ColumnString16(3); 301 form.username_element = s2.ColumnString16(3);
302 form.username_value = Decrypt(s2.ColumnString(5)); 302 form.username_value = Decrypt(s2.ColumnString(5));
303 form.password_element = s2.ColumnString16(4); 303 form.password_element = s2.ColumnString16(4);
304 form.password_value = Decrypt(s2.ColumnString(6)); 304 form.password_value = Decrypt(s2.ColumnString(6));
305 form.action = GURL(s2.ColumnString(2)).ReplaceComponents(rep); 305 form.action = GURL(s2.ColumnString(2)).ReplaceComponents(rep);
306 forms->push_back(form); 306 forms->push_back(form);
307 } 307 }
308 return true; 308 return true;
309 } 309 }
OLDNEW
« no previous file with comments | « chrome/utility/importer/nss_decryptor.h ('k') | chromecast/browser/url_request_context_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698