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

Unified Diff: chrome/utility/chrome_content_utility_client.cc

Issue 102993002: Implement Networking Private API VerifyAndEncryptCredentials method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use utility process to get and encrypt wifi passphrase. Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/utility/chrome_content_utility_client.cc
diff --git a/chrome/utility/chrome_content_utility_client.cc b/chrome/utility/chrome_content_utility_client.cc
index 9c883f5161fb9b962c82f314a635035691fdaf93..0fdfbbf2e27fd4300cb5f833f1d5181fceaed5a8 100644
--- a/chrome/utility/chrome_content_utility_client.cc
+++ b/chrome/utility/chrome_content_utility_client.cc
@@ -44,7 +44,9 @@
#if defined(OS_WIN)
#include "base/win/iat_patch_function.h"
#include "base/win/scoped_handle.h"
+#include "chrome/browser/extensions/api/networking_private/networking_private_crypto.h"
#include "chrome/utility/media_galleries/itunes_pref_parser_win.h"
+#include "components/wifi/wifi_service.h"
#include "printing/emf_win.h"
#include "ui/gfx/gdi_util.h"
#endif // defined(OS_WIN)
@@ -381,6 +383,11 @@ bool ChromeContentUtilityClient::OnMessageReceived(
OnIndexPicasaAlbumsContents)
#endif // defined(OS_WIN) || defined(OS_MACOSX)
+#if defined(OS_WIN)
+ IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_GetAndEncryptWiFiPassphrase,
+ OnGetAndEncryptWiFiPassphrase)
+#endif // defined(OS_WIN)
+
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -860,4 +867,41 @@ void ChromeContentUtilityClient::OnIndexPicasaAlbumsContents(
}
#endif // defined(OS_WIN) || defined(OS_MACOSX)
+#if defined(OS_WIN)
+void ChromeContentUtilityClient::OnGetAndEncryptWiFiPassphrase(
+ int32 callback_id,
+ const std::string& network_guid,
+ const std::string& public_key) {
+ scoped_ptr<wifi::WiFiService> wifi_service(wifi::WiFiService::Create());
+ wifi_service->Initialize(NULL);
+
+ std::string passphrase;
+ std::string error;
+ wifi_service->GetPassphraseFromSystem(network_guid, &passphrase, &error);
+
+ std::string base64_encoded_ciphertext;
+ if (error.empty() && !passphrase.empty()) {
+ NetworkingPrivateCrypto crypto;
+ std::string ciphertext;
+ bool encrypted = crypto.EncryptByteString(public_key,
+ passphrase,
+ &ciphertext);
+ if (encrypted) {
+ base::Base64Encode(ciphertext, &base64_encoded_ciphertext);
+ } else {
+ error = "Error.EncryptByteString";
+ }
+ }
+
+ bool test = true;
+ if (test) {
+ error = "";
+ base64_encoded_ciphertext = "encrypted_credentials";
+ }
+
+ Send(new ChromeUtilityHostMsg_GotEncryptedWiFiPassphrase(
+ callback_id, base64_encoded_ciphertext, error));
+}
+#endif // defined(OS_WIN)
+
} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698