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

Side by Side Diff: chrome/browser/chromeos/login/owner_manager.h

Issue 6538098: [Chrome OS] Owner keys are generated outside Chrome now; handle appropriately (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_CHROMEOS_LOGIN_OWNER_MANAGER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_MANAGER_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/crypto/rsa_private_key.h" 12 #include "base/crypto/rsa_private_key.h"
13 #include "base/ref_counted.h" 13 #include "base/ref_counted.h"
14 #include "chrome/browser/browser_thread.h" 14 #include "chrome/browser/browser_thread.h"
15 #include "chrome/browser/chromeos/cros/login_library.h"
16 #include "chrome/browser/chromeos/login/owner_key_utils.h" 15 #include "chrome/browser/chromeos/login/owner_key_utils.h"
17 16
18 class FilePath; 17 class FilePath;
19 class NotificationDetails; 18 class NotificationDetails;
20 class NotificationType; 19 class NotificationType;
21 20
22 namespace chromeos { 21 namespace chromeos {
23 22
24 // This class allows the registration of an Owner of a Chromium OS device. 23 // This class allows the registration of an Owner of a Chromium OS device.
25 // It handles generating the appropriate keys and storing them in the 24 // It handles generating the appropriate keys and storing them in the
26 // appropriate locations. 25 // appropriate locations.
27 class OwnerManager : public base::RefCountedThreadSafe<OwnerManager>, 26 class OwnerManager : public base::RefCountedThreadSafe<OwnerManager> {
28 public LoginLibrary::Delegate {
29 public: 27 public:
30 // Return codes for public/private key operations. 28 // Return codes for public/private key operations.
31 enum KeyOpCode { 29 enum KeyOpCode {
32 SUCCESS, 30 SUCCESS,
33 KEY_UNAVAILABLE, // The necessary key isn't available yet. 31 KEY_UNAVAILABLE, // The necessary key isn't available yet.
34 OPERATION_FAILED // The crypto operation failed. 32 OPERATION_FAILED // The crypto operation failed.
35 }; 33 };
36 34
37 class Delegate { 35 class Delegate {
38 public: 36 public:
39 // Upon completion of a key operation, this method will be called. 37 // Upon completion of a key operation, this method will be called.
40 // |return_code| indicates what happened, |payload| will be used to pass 38 // |return_code| indicates what happened, |payload| will be used to pass
41 // back any artifacts of the operation. For example, if the operation 39 // back any artifacts of the operation. For example, if the operation
42 // was a signature attempt, the signature blob would come back in |payload|. 40 // was a signature attempt, the signature blob would come back in |payload|.
43 virtual void OnKeyOpComplete(const KeyOpCode return_code, 41 virtual void OnKeyOpComplete(const KeyOpCode return_code,
44 const std::vector<uint8>& payload) = 0; 42 const std::vector<uint8>& payload) = 0;
45 }; 43 };
46 44
47 OwnerManager(); 45 OwnerManager();
48 virtual ~OwnerManager(); 46 virtual ~OwnerManager();
49 47
50 // Pulls the owner's public key off disk and into memory. 48 // Pulls the owner's public key off disk and into memory.
51 // 49 //
52 // Call this on the FILE thread. 50 // Call this on the FILE thread.
53 void LoadOwnerKey(); 51 void LoadOwnerKey();
54 52
55 // Generates the owner's keys in the default NSS token. Also stores
56 // them in |public_key_| and |private_key_|. When done, causes the
57 // public key to get exported via DBus.
58 //
59 // Call this on the FILE thread.
60 void GenerateKeysAndExportPublic();
61
62 // Exports |public_key_| via DBus.
63 //
64 // Call this on the UI thread (because of DBus usage).
65 void ExportKey();
66
67 // Overridden from LoginLibrary::Delegate
68 void OnComplete(bool value);
69
70 bool EnsurePublicKey(); 53 bool EnsurePublicKey();
71 bool EnsurePrivateKey(); 54 bool EnsurePrivateKey();
72 55
73 // Do the actual work of signing |data| with |private_key_|. First, 56 // Do the actual work of signing |data| with |private_key_|. First,
74 // ensures that we have the keys we need. Then, computes the signature. 57 // ensures that we have the keys we need. Then, computes the signature.
75 // 58 //
76 // On success, calls d->OnKeyOpComplete() on |thread_id| with a 59 // On success, calls d->OnKeyOpComplete() on |thread_id| with a
77 // successful return code, passing the signaure blob in |payload|. 60 // successful return code, passing the signaure blob in |payload|.
78 // On failure, calls d->OnKeyOpComplete() on |thread_id| with an appropriate 61 // On failure, calls d->OnKeyOpComplete() on |thread_id| with an appropriate
79 // error and passes an empty string for |payload|. 62 // error and passes an empty string for |payload|.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 scoped_refptr<OwnerKeyUtils> utils_; 95 scoped_refptr<OwnerKeyUtils> utils_;
113 96
114 friend class OwnerManagerTest; 97 friend class OwnerManagerTest;
115 98
116 DISALLOW_COPY_AND_ASSIGN(OwnerManager); 99 DISALLOW_COPY_AND_ASSIGN(OwnerManager);
117 }; 100 };
118 101
119 } // namespace chromeos 102 } // namespace chromeos
120 103
121 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_MANAGER_H_ 104 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/owner_key_utils_unittest.cc ('k') | chrome/browser/chromeos/login/owner_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698