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

Side by Side Diff: chrome/browser/chromeos/system/drm_settings.cc

Issue 14179007: Move cryptohome_library to src/chromeos (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 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 | Annotate | Revision Log
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/browser/chromeos/system/drm_settings.h" 5 #include "chrome/browser/chromeos/system/drm_settings.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/chromeos/chromeos_version.h" 8 #include "base/chromeos/chromeos_version.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "chrome/browser/chromeos/cros/cros_library.h"
16 #include "chrome/browser/chromeos/cros/cryptohome_library.h"
17 #include "chrome/browser/chromeos/login/user_manager.h" 15 #include "chrome/browser/chromeos/login/user_manager.h"
18 #include "chrome/common/chrome_paths.h" 16 #include "chrome/common/chrome_paths.h"
19 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
20 #include "chromeos/chromeos_switches.h" 18 #include "chromeos/chromeos_switches.h"
19 #include "chromeos/cryptohome/cryptohome_library.h"
21 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
22 #include "crypto/encryptor.h" 21 #include "crypto/encryptor.h"
23 #include "crypto/sha2.h" 22 #include "crypto/sha2.h"
24 23
25 using content::BrowserThread; 24 using content::BrowserThread;
26 25
27 namespace { 26 namespace {
28 27
29 // This constant is mirrored in 28 // This constant is mirrored in
30 // content/browser/renderer_host/pepper_message_filter.cc 29 // content/browser/renderer_host/pepper_message_filter.cc
(...skipping 24 matching lines...) Expand all
55 54
56 // The file will be regenerated or deleted at toggle-time. 55 // The file will be regenerated or deleted at toggle-time.
57 file_util::Delete(drm_id_file, false); 56 file_util::Delete(drm_id_file, false);
58 57
59 // If DRM support is disabled, then do nothing else. 58 // If DRM support is disabled, then do nothing else.
60 if (!enable) 59 if (!enable)
61 return; 60 return;
62 61
63 // Build the identifier as follows: 62 // Build the identifier as follows:
64 // SHA256(system-salt||service||SHA256(system-salt||service||email)) 63 // SHA256(system-salt||service||SHA256(system-salt||service||email))
65 chromeos::CryptohomeLibrary* c_home = 64 chromeos::CryptohomeLibrary* c_home = chromeos::CryptohomeLibrary::Get();
66 chromeos::CrosLibrary::Get()->GetCryptohomeLibrary();
67 std::string salt = c_home->GetSystemSalt(); 65 std::string salt = c_home->GetSystemSalt();
68 char id_buf[256 / 8]; // 256-bits for SHA256 66 char id_buf[256 / 8]; // 256-bits for SHA256
69 std::string input = salt; 67 std::string input = salt;
70 input.append(kDRMIdentifierFile); 68 input.append(kDRMIdentifierFile);
71 input.append(email); 69 input.append(email);
72 crypto::SHA256HashString(input, &id_buf, sizeof(id_buf)); 70 crypto::SHA256HashString(input, &id_buf, sizeof(id_buf));
73 std::string id = StringToLowerASCII(base::HexEncode( 71 std::string id = StringToLowerASCII(base::HexEncode(
74 reinterpret_cast<const void*>(id_buf), 72 reinterpret_cast<const void*>(id_buf),
75 sizeof(id_buf))); 73 sizeof(id_buf)));
76 input = salt; 74 input = salt;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // by privileged pepper plugins specifically for deriving 123 // by privileged pepper plugins specifically for deriving
126 // per-content-provider identifiers. The user must be able to clear it, 124 // per-content-provider identifiers. The user must be able to clear it,
127 // reset it, and deny its use. 125 // reset it, and deny its use.
128 BrowserThread::PostTask( 126 BrowserThread::PostTask(
129 BrowserThread::FILE, FROM_HERE, 127 BrowserThread::FILE, FROM_HERE,
130 base::Bind(&ManageDrmIdentifierOnFileThread, enable, email)); 128 base::Bind(&ManageDrmIdentifierOnFileThread, enable, email));
131 } 129 }
132 130
133 } // namespace system 131 } // namespace system
134 } // namespace chromeos 132 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698