| OLD | NEW |
| 1 // Copyright (c) 2011 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 #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 <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 const std::vector<uint8>& payload) = 0; | 44 const std::vector<uint8>& payload) = 0; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 class KeyUpdateDelegate { | 47 class KeyUpdateDelegate { |
| 48 public: | 48 public: |
| 49 // Called upon completion of a key update operation. | 49 // Called upon completion of a key update operation. |
| 50 virtual void OnKeyUpdated() = 0; | 50 virtual void OnKeyUpdated() = 0; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 OwnerManager(); | 53 OwnerManager(); |
| 54 virtual ~OwnerManager(); | |
| 55 | 54 |
| 56 // Sets a new owner key from a provided memory buffer. | 55 // Sets a new owner key from a provided memory buffer. |
| 57 void UpdateOwnerKey(const content::BrowserThread::ID thread_id, | 56 void UpdateOwnerKey(const content::BrowserThread::ID thread_id, |
| 58 const std::vector<uint8>& key, | 57 const std::vector<uint8>& key, |
| 59 KeyUpdateDelegate* d); | 58 KeyUpdateDelegate* d); |
| 60 | 59 |
| 61 // Pulls the owner's public key off disk and into memory. | 60 // Pulls the owner's public key off disk and into memory. |
| 62 // | 61 // |
| 63 // Call this on the FILE thread. | 62 // Call this on the FILE thread. |
| 64 void LoadOwnerKey(); | 63 void LoadOwnerKey(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 83 // | 82 // |
| 84 // On success, calls d->OnKeyOpComplete() on |thread_id| with a | 83 // On success, calls d->OnKeyOpComplete() on |thread_id| with a |
| 85 // successful return code, passing an empty string for |payload|. | 84 // successful return code, passing an empty string for |payload|. |
| 86 // On failure, calls d->OnKeyOpComplete() on |thread_id| with an appropriate | 85 // On failure, calls d->OnKeyOpComplete() on |thread_id| with an appropriate |
| 87 // error code, passing an empty string for |payload|. | 86 // error code, passing an empty string for |payload|. |
| 88 void Verify(const content::BrowserThread::ID thread_id, | 87 void Verify(const content::BrowserThread::ID thread_id, |
| 89 const std::string& data, | 88 const std::string& data, |
| 90 const std::vector<uint8>& signature, | 89 const std::vector<uint8>& signature, |
| 91 Delegate* d); | 90 Delegate* d); |
| 92 | 91 |
| 92 protected: |
| 93 virtual ~OwnerManager(); |
| 94 |
| 93 private: | 95 private: |
| 96 friend class base::RefCountedThreadSafe<OwnerManager>; |
| 97 |
| 94 // A helper method to send a notification on another thread. | 98 // A helper method to send a notification on another thread. |
| 95 void SendNotification(int type, | 99 void SendNotification(int type, |
| 96 const content::NotificationDetails& details); | 100 const content::NotificationDetails& details); |
| 97 | 101 |
| 98 // Calls back a key update delegate on a given thread. | 102 // Calls back a key update delegate on a given thread. |
| 99 void CallKeyUpdateDelegate(KeyUpdateDelegate* d) { | 103 void CallKeyUpdateDelegate(KeyUpdateDelegate* d) { |
| 100 d->OnKeyUpdated(); | 104 d->OnKeyUpdated(); |
| 101 } | 105 } |
| 102 | 106 |
| 103 // A helper method to call back a delegte on another thread. | 107 // A helper method to call back a delegte on another thread. |
| 104 void CallDelegate(Delegate* d, | 108 void CallDelegate(Delegate* d, |
| 105 const KeyOpCode return_code, | 109 const KeyOpCode return_code, |
| 106 const std::vector<uint8>& payload) { | 110 const std::vector<uint8>& payload) { |
| 107 d->OnKeyOpComplete(return_code, payload); | 111 d->OnKeyOpComplete(return_code, payload); |
| 108 } | 112 } |
| 109 | 113 |
| 110 scoped_ptr<crypto::RSAPrivateKey> private_key_; | 114 scoped_ptr<crypto::RSAPrivateKey> private_key_; |
| 111 std::vector<uint8> public_key_; | 115 std::vector<uint8> public_key_; |
| 112 | 116 |
| 113 scoped_refptr<OwnerKeyUtils> utils_; | 117 scoped_refptr<OwnerKeyUtils> utils_; |
| 114 | 118 |
| 115 friend class OwnerManagerTest; | 119 friend class OwnerManagerTest; |
| 116 | 120 |
| 117 DISALLOW_COPY_AND_ASSIGN(OwnerManager); | 121 DISALLOW_COPY_AND_ASSIGN(OwnerManager); |
| 118 }; | 122 }; |
| 119 | 123 |
| 120 } // namespace chromeos | 124 } // namespace chromeos |
| 121 | 125 |
| 122 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_MANAGER_H_ | 126 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_MANAGER_H_ |
| OLD | NEW |